bundle.min.js 936 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/source-map')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/source-map'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
  5. }(this, (function (exports, sourceMap) { 'use strict';
  6. /***********************************************************************
  7. A JavaScript tokenizer / parser / beautifier / compressor.
  8. https://github.com/mishoo/UglifyJS2
  9. -------------------------------- (C) ---------------------------------
  10. Author: Mihai Bazon
  11. <mihai.bazon@gmail.com>
  12. http://mihai.bazon.net/blog
  13. Distributed under the BSD license:
  14. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15. Redistribution and use in source and binary forms, with or without
  16. modification, are permitted provided that the following conditions
  17. are met:
  18. * Redistributions of source code must retain the above
  19. copyright notice, this list of conditions and the following
  20. disclaimer.
  21. * Redistributions in binary form must reproduce the above
  22. copyright notice, this list of conditions and the following
  23. disclaimer in the documentation and/or other materials
  24. provided with the distribution.
  25. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  26. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  28. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  31. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  32. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  35. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. SUCH DAMAGE.
  37. ***********************************************************************/
  38. function characters(str) {
  39. return str.split("");
  40. }
  41. function member(name, array) {
  42. return array.includes(name);
  43. }
  44. class DefaultsError extends Error {
  45. constructor(msg, defs) {
  46. super();
  47. this.name = "DefaultsError";
  48. this.message = msg;
  49. this.defs = defs;
  50. }
  51. }
  52. function defaults(args, defs, croak) {
  53. if (args === true) {
  54. args = {};
  55. } else if (args != null && typeof args === "object") {
  56. args = {...args};
  57. }
  58. const ret = args || {};
  59. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  60. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  61. }
  62. for (const i in defs) if (HOP(defs, i)) {
  63. if (!args || !HOP(args, i)) {
  64. ret[i] = defs[i];
  65. } else if (i === "ecma") {
  66. let ecma = args[i] | 0;
  67. if (ecma > 5 && ecma < 2015) ecma += 2009;
  68. ret[i] = ecma;
  69. } else {
  70. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  71. }
  72. }
  73. return ret;
  74. }
  75. function noop() {}
  76. function return_false() { return false; }
  77. function return_true() { return true; }
  78. function return_this() { return this; }
  79. function return_null() { return null; }
  80. var MAP = (function() {
  81. function MAP(a, f, backwards) {
  82. var ret = [], top = [], i;
  83. function doit() {
  84. var val = f(a[i], i);
  85. var is_last = val instanceof Last;
  86. if (is_last) val = val.v;
  87. if (val instanceof AtTop) {
  88. val = val.v;
  89. if (val instanceof Splice) {
  90. top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
  91. } else {
  92. top.push(val);
  93. }
  94. } else if (val !== skip) {
  95. if (val instanceof Splice) {
  96. ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
  97. } else {
  98. ret.push(val);
  99. }
  100. }
  101. return is_last;
  102. }
  103. if (Array.isArray(a)) {
  104. if (backwards) {
  105. for (i = a.length; --i >= 0;) if (doit()) break;
  106. ret.reverse();
  107. top.reverse();
  108. } else {
  109. for (i = 0; i < a.length; ++i) if (doit()) break;
  110. }
  111. } else {
  112. for (i in a) if (HOP(a, i)) if (doit()) break;
  113. }
  114. return top.concat(ret);
  115. }
  116. MAP.at_top = function(val) { return new AtTop(val); };
  117. MAP.splice = function(val) { return new Splice(val); };
  118. MAP.last = function(val) { return new Last(val); };
  119. var skip = MAP.skip = {};
  120. function AtTop(val) { this.v = val; }
  121. function Splice(val) { this.v = val; }
  122. function Last(val) { this.v = val; }
  123. return MAP;
  124. })();
  125. function make_node(ctor, orig, props) {
  126. if (!props) props = {};
  127. if (orig) {
  128. if (!props.start) props.start = orig.start;
  129. if (!props.end) props.end = orig.end;
  130. }
  131. return new ctor(props);
  132. }
  133. function push_uniq(array, el) {
  134. if (!array.includes(el))
  135. array.push(el);
  136. }
  137. function string_template(text, props) {
  138. return text.replace(/{(.+?)}/g, function(str, p) {
  139. return props && props[p];
  140. });
  141. }
  142. function remove(array, el) {
  143. for (var i = array.length; --i >= 0;) {
  144. if (array[i] === el) array.splice(i, 1);
  145. }
  146. }
  147. function mergeSort(array, cmp) {
  148. if (array.length < 2) return array.slice();
  149. function merge(a, b) {
  150. var r = [], ai = 0, bi = 0, i = 0;
  151. while (ai < a.length && bi < b.length) {
  152. cmp(a[ai], b[bi]) <= 0
  153. ? r[i++] = a[ai++]
  154. : r[i++] = b[bi++];
  155. }
  156. if (ai < a.length) r.push.apply(r, a.slice(ai));
  157. if (bi < b.length) r.push.apply(r, b.slice(bi));
  158. return r;
  159. }
  160. function _ms(a) {
  161. if (a.length <= 1)
  162. return a;
  163. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  164. left = _ms(left);
  165. right = _ms(right);
  166. return merge(left, right);
  167. }
  168. return _ms(array);
  169. }
  170. function makePredicate(words) {
  171. if (!Array.isArray(words)) words = words.split(" ");
  172. return new Set(words.sort());
  173. }
  174. function map_add(map, key, value) {
  175. if (map.has(key)) {
  176. map.get(key).push(value);
  177. } else {
  178. map.set(key, [ value ]);
  179. }
  180. }
  181. function map_from_object(obj) {
  182. var map = new Map();
  183. for (var key in obj) {
  184. if (HOP(obj, key) && key.charAt(0) === "$") {
  185. map.set(key.substr(1), obj[key]);
  186. }
  187. }
  188. return map;
  189. }
  190. function map_to_object(map) {
  191. var obj = Object.create(null);
  192. map.forEach(function (value, key) {
  193. obj["$" + key] = value;
  194. });
  195. return obj;
  196. }
  197. function HOP(obj, prop) {
  198. return Object.prototype.hasOwnProperty.call(obj, prop);
  199. }
  200. function keep_name(keep_setting, name) {
  201. return keep_setting === true
  202. || (keep_setting instanceof RegExp && keep_setting.test(name));
  203. }
  204. var lineTerminatorEscape = {
  205. "\0": "0",
  206. "\n": "n",
  207. "\r": "r",
  208. "\u2028": "u2028",
  209. "\u2029": "u2029",
  210. };
  211. function regexp_source_fix(source) {
  212. // V8 does not escape line terminators in regexp patterns in node 12
  213. // We'll also remove literal \0
  214. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  215. var escaped = source[offset - 1] == "\\"
  216. && (source[offset - 2] != "\\"
  217. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  218. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  219. });
  220. }
  221. // Subset of regexps that is not going to cause regexp based DDOS
  222. // https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
  223. const re_safe_regexp = /^[\\/|\0\s\w^$.[\]()]*$/;
  224. /** Check if the regexp is safe for Terser to create without risking a RegExp DOS */
  225. const regexp_is_safe = (source) => re_safe_regexp.test(source);
  226. const all_flags = "dgimsuy";
  227. function sort_regexp_flags(flags) {
  228. const existing_flags = new Set(flags.split(""));
  229. let out = "";
  230. for (const flag of all_flags) {
  231. if (existing_flags.has(flag)) {
  232. out += flag;
  233. existing_flags.delete(flag);
  234. }
  235. }
  236. if (existing_flags.size) {
  237. // Flags Terser doesn't know about
  238. existing_flags.forEach(flag => { out += flag; });
  239. }
  240. return out;
  241. }
  242. function has_annotation(node, annotation) {
  243. return node._annotations & annotation;
  244. }
  245. function set_annotation(node, annotation) {
  246. node._annotations |= annotation;
  247. }
  248. /***********************************************************************
  249. A JavaScript tokenizer / parser / beautifier / compressor.
  250. https://github.com/mishoo/UglifyJS2
  251. -------------------------------- (C) ---------------------------------
  252. Author: Mihai Bazon
  253. <mihai.bazon@gmail.com>
  254. http://mihai.bazon.net/blog
  255. Distributed under the BSD license:
  256. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  257. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  258. Redistribution and use in source and binary forms, with or without
  259. modification, are permitted provided that the following conditions
  260. are met:
  261. * Redistributions of source code must retain the above
  262. copyright notice, this list of conditions and the following
  263. disclaimer.
  264. * Redistributions in binary form must reproduce the above
  265. copyright notice, this list of conditions and the following
  266. disclaimer in the documentation and/or other materials
  267. provided with the distribution.
  268. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  269. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  270. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  271. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  272. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  273. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  274. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  275. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  276. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  277. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  278. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  279. SUCH DAMAGE.
  280. ***********************************************************************/
  281. var LATEST_RAW = ""; // Only used for numbers and template strings
  282. var TEMPLATE_RAWS = new Map(); // Raw template strings
  283. 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";
  284. var KEYWORDS_ATOM = "false null true";
  285. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  286. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  287. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  288. KEYWORDS = makePredicate(KEYWORDS);
  289. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  290. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  291. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  292. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  293. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  294. var RE_NUM_LITERAL = /[0-9a-f]/i;
  295. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  296. var RE_OCT_NUMBER = /^0[0-7]+$/;
  297. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  298. var RE_BIN_NUMBER = /^0b[01]+$/i;
  299. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  300. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  301. var OPERATORS = makePredicate([
  302. "in",
  303. "instanceof",
  304. "typeof",
  305. "new",
  306. "void",
  307. "delete",
  308. "++",
  309. "--",
  310. "+",
  311. "-",
  312. "!",
  313. "~",
  314. "&",
  315. "|",
  316. "^",
  317. "*",
  318. "**",
  319. "/",
  320. "%",
  321. ">>",
  322. "<<",
  323. ">>>",
  324. "<",
  325. ">",
  326. "<=",
  327. ">=",
  328. "==",
  329. "===",
  330. "!=",
  331. "!==",
  332. "?",
  333. "=",
  334. "+=",
  335. "-=",
  336. "||=",
  337. "&&=",
  338. "??=",
  339. "/=",
  340. "*=",
  341. "**=",
  342. "%=",
  343. ">>=",
  344. "<<=",
  345. ">>>=",
  346. "|=",
  347. "^=",
  348. "&=",
  349. "&&",
  350. "??",
  351. "||",
  352. ]);
  353. 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"));
  354. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  355. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  356. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  357. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  358. /* -----[ Tokenizer ]----- */
  359. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  360. var UNICODE = {
  361. 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]/,
  362. 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])+/,
  363. };
  364. function get_full_char(str, pos) {
  365. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  366. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  367. return str.charAt(pos) + str.charAt(pos + 1);
  368. }
  369. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  370. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  371. return str.charAt(pos - 1) + str.charAt(pos);
  372. }
  373. }
  374. return str.charAt(pos);
  375. }
  376. function get_full_char_code(str, pos) {
  377. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  378. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  379. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  380. }
  381. return str.charCodeAt(pos);
  382. }
  383. function get_full_char_length(str) {
  384. var surrogates = 0;
  385. for (var i = 0; i < str.length; i++) {
  386. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  387. surrogates++;
  388. i++;
  389. }
  390. }
  391. return str.length - surrogates;
  392. }
  393. function from_char_code(code) {
  394. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  395. if (code > 0xFFFF) {
  396. code -= 0x10000;
  397. return (String.fromCharCode((code >> 10) + 0xD800) +
  398. String.fromCharCode((code % 0x400) + 0xDC00));
  399. }
  400. return String.fromCharCode(code);
  401. }
  402. function is_surrogate_pair_head(code) {
  403. return code >= 0xd800 && code <= 0xdbff;
  404. }
  405. function is_surrogate_pair_tail(code) {
  406. return code >= 0xdc00 && code <= 0xdfff;
  407. }
  408. function is_digit(code) {
  409. return code >= 48 && code <= 57;
  410. }
  411. function is_identifier_start(ch) {
  412. return UNICODE.ID_Start.test(ch);
  413. }
  414. function is_identifier_char(ch) {
  415. return UNICODE.ID_Continue.test(ch);
  416. }
  417. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  418. function is_basic_identifier_string(str) {
  419. return BASIC_IDENT.test(str);
  420. }
  421. function is_identifier_string(str, allow_surrogates) {
  422. if (BASIC_IDENT.test(str)) {
  423. return true;
  424. }
  425. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  426. return false;
  427. }
  428. var match = UNICODE.ID_Start.exec(str);
  429. if (!match || match.index !== 0) {
  430. return false;
  431. }
  432. str = str.slice(match[0].length);
  433. if (!str) {
  434. return true;
  435. }
  436. match = UNICODE.ID_Continue.exec(str);
  437. return !!match && match[0].length === str.length;
  438. }
  439. function parse_js_number(num, allow_e = true) {
  440. if (!allow_e && num.includes("e")) {
  441. return NaN;
  442. }
  443. if (RE_HEX_NUMBER.test(num)) {
  444. return parseInt(num.substr(2), 16);
  445. } else if (RE_OCT_NUMBER.test(num)) {
  446. return parseInt(num.substr(1), 8);
  447. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  448. return parseInt(num.substr(2), 8);
  449. } else if (RE_BIN_NUMBER.test(num)) {
  450. return parseInt(num.substr(2), 2);
  451. } else if (RE_DEC_NUMBER.test(num)) {
  452. return parseFloat(num);
  453. } else {
  454. var val = parseFloat(num);
  455. if (val == num) return val;
  456. }
  457. }
  458. class JS_Parse_Error extends Error {
  459. constructor(message, filename, line, col, pos) {
  460. super();
  461. this.name = "SyntaxError";
  462. this.message = message;
  463. this.filename = filename;
  464. this.line = line;
  465. this.col = col;
  466. this.pos = pos;
  467. }
  468. }
  469. function js_error(message, filename, line, col, pos) {
  470. throw new JS_Parse_Error(message, filename, line, col, pos);
  471. }
  472. function is_token(token, type, val) {
  473. return token.type == type && (val == null || token.value == val);
  474. }
  475. var EX_EOF = {};
  476. function tokenizer($TEXT, filename, html5_comments, shebang) {
  477. var S = {
  478. text : $TEXT,
  479. filename : filename,
  480. pos : 0,
  481. tokpos : 0,
  482. line : 1,
  483. tokline : 0,
  484. col : 0,
  485. tokcol : 0,
  486. newline_before : false,
  487. regex_allowed : false,
  488. brace_counter : 0,
  489. template_braces : [],
  490. comments_before : [],
  491. directives : {},
  492. directive_stack : []
  493. };
  494. function peek() { return get_full_char(S.text, S.pos); }
  495. // Used because parsing ?. involves a lookahead for a digit
  496. function is_option_chain_op() {
  497. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  498. if (!must_be_dot) return false;
  499. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  500. return cannot_be_digit < 48 || cannot_be_digit > 57;
  501. }
  502. function next(signal_eof, in_string) {
  503. var ch = get_full_char(S.text, S.pos++);
  504. if (signal_eof && !ch)
  505. throw EX_EOF;
  506. if (NEWLINE_CHARS.has(ch)) {
  507. S.newline_before = S.newline_before || !in_string;
  508. ++S.line;
  509. S.col = 0;
  510. if (ch == "\r" && peek() == "\n") {
  511. // treat a \r\n sequence as a single \n
  512. ++S.pos;
  513. ch = "\n";
  514. }
  515. } else {
  516. if (ch.length > 1) {
  517. ++S.pos;
  518. ++S.col;
  519. }
  520. ++S.col;
  521. }
  522. return ch;
  523. }
  524. function forward(i) {
  525. while (i--) next();
  526. }
  527. function looking_at(str) {
  528. return S.text.substr(S.pos, str.length) == str;
  529. }
  530. function find_eol() {
  531. var text = S.text;
  532. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  533. var ch = text[i];
  534. if (NEWLINE_CHARS.has(ch))
  535. return i;
  536. }
  537. return -1;
  538. }
  539. function find(what, signal_eof) {
  540. var pos = S.text.indexOf(what, S.pos);
  541. if (signal_eof && pos == -1) throw EX_EOF;
  542. return pos;
  543. }
  544. function start_token() {
  545. S.tokline = S.line;
  546. S.tokcol = S.col;
  547. S.tokpos = S.pos;
  548. }
  549. var prev_was_dot = false;
  550. var previous_token = null;
  551. function token(type, value, is_comment) {
  552. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  553. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  554. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  555. (type == "arrow");
  556. if (type == "punc" && (value == "." || value == "?.")) {
  557. prev_was_dot = true;
  558. } else if (!is_comment) {
  559. prev_was_dot = false;
  560. }
  561. const line = S.tokline;
  562. const col = S.tokcol;
  563. const pos = S.tokpos;
  564. const nlb = S.newline_before;
  565. const file = filename;
  566. let comments_before = [];
  567. let comments_after = [];
  568. if (!is_comment) {
  569. comments_before = S.comments_before;
  570. comments_after = S.comments_before = [];
  571. }
  572. S.newline_before = false;
  573. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  574. if (!is_comment) previous_token = tok;
  575. return tok;
  576. }
  577. function skip_whitespace() {
  578. while (WHITESPACE_CHARS.has(peek()))
  579. next();
  580. }
  581. function read_while(pred) {
  582. var ret = "", ch, i = 0;
  583. while ((ch = peek()) && pred(ch, i++))
  584. ret += next();
  585. return ret;
  586. }
  587. function parse_error(err) {
  588. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  589. }
  590. function read_num(prefix) {
  591. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  592. var num = read_while(function(ch, i) {
  593. if (is_big_int) return false;
  594. var code = ch.charCodeAt(0);
  595. switch (code) {
  596. case 95: // _
  597. return (numeric_separator = true);
  598. case 98: case 66: // bB
  599. return (has_x = true); // Can occur in hex sequence, don't return false yet
  600. case 111: case 79: // oO
  601. case 120: case 88: // xX
  602. return has_x ? false : (has_x = true);
  603. case 101: case 69: // eE
  604. return has_x ? true : has_e ? false : (has_e = after_e = true);
  605. case 45: // -
  606. return after_e || (i == 0 && !prefix);
  607. case 43: // +
  608. return after_e;
  609. case (after_e = false, 46): // .
  610. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  611. }
  612. if (ch === "n") {
  613. is_big_int = true;
  614. return true;
  615. }
  616. return RE_NUM_LITERAL.test(ch);
  617. });
  618. if (prefix) num = prefix + num;
  619. LATEST_RAW = num;
  620. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  621. parse_error("Legacy octal literals are not allowed in strict mode");
  622. }
  623. if (numeric_separator) {
  624. if (num.endsWith("_")) {
  625. parse_error("Numeric separators are not allowed at the end of numeric literals");
  626. } else if (num.includes("__")) {
  627. parse_error("Only one underscore is allowed as numeric separator");
  628. }
  629. num = num.replace(/_/g, "");
  630. }
  631. if (num.endsWith("n")) {
  632. const without_n = num.slice(0, -1);
  633. const allow_e = RE_HEX_NUMBER.test(without_n);
  634. const valid = parse_js_number(without_n, allow_e);
  635. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  636. return token("big_int", without_n);
  637. parse_error("Invalid or unexpected token");
  638. }
  639. var valid = parse_js_number(num);
  640. if (!isNaN(valid)) {
  641. return token("num", valid);
  642. } else {
  643. parse_error("Invalid syntax: " + num);
  644. }
  645. }
  646. function is_octal(ch) {
  647. return ch >= "0" && ch <= "7";
  648. }
  649. function read_escaped_char(in_string, strict_hex, template_string) {
  650. var ch = next(true, in_string);
  651. switch (ch.charCodeAt(0)) {
  652. case 110 : return "\n";
  653. case 114 : return "\r";
  654. case 116 : return "\t";
  655. case 98 : return "\b";
  656. case 118 : return "\u000b"; // \v
  657. case 102 : return "\f";
  658. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  659. case 117 : // \u
  660. if (peek() == "{") {
  661. next(true);
  662. if (peek() === "}")
  663. parse_error("Expecting hex-character between {}");
  664. while (peek() == "0") next(true); // No significance
  665. var result, length = find("}", true) - S.pos;
  666. // Avoid 32 bit integer overflow (1 << 32 === 1)
  667. // We know first character isn't 0 and thus out of range anyway
  668. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  669. parse_error("Unicode reference out of bounds");
  670. }
  671. next(true);
  672. return from_char_code(result);
  673. }
  674. return String.fromCharCode(hex_bytes(4, strict_hex));
  675. case 10 : return ""; // newline
  676. case 13 : // \r
  677. if (peek() == "\n") { // DOS newline
  678. next(true, in_string);
  679. return "";
  680. }
  681. }
  682. if (is_octal(ch)) {
  683. if (template_string && strict_hex) {
  684. const represents_null_character = ch === "0" && !is_octal(peek());
  685. if (!represents_null_character) {
  686. parse_error("Octal escape sequences are not allowed in template strings");
  687. }
  688. }
  689. return read_octal_escape_sequence(ch, strict_hex);
  690. }
  691. return ch;
  692. }
  693. function read_octal_escape_sequence(ch, strict_octal) {
  694. // Read
  695. var p = peek();
  696. if (p >= "0" && p <= "7") {
  697. ch += next(true);
  698. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  699. ch += next(true);
  700. }
  701. // Parse
  702. if (ch === "0") return "\0";
  703. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  704. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  705. return String.fromCharCode(parseInt(ch, 8));
  706. }
  707. function hex_bytes(n, strict_hex) {
  708. var num = 0;
  709. for (; n > 0; --n) {
  710. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  711. return parseInt(num, 16) || "";
  712. }
  713. var digit = next(true);
  714. if (isNaN(parseInt(digit, 16)))
  715. parse_error("Invalid hex-character pattern in string");
  716. num += digit;
  717. }
  718. return parseInt(num, 16);
  719. }
  720. var read_string = with_eof_error("Unterminated string constant", function() {
  721. const start_pos = S.pos;
  722. var quote = next(), ret = [];
  723. for (;;) {
  724. var ch = next(true, true);
  725. if (ch == "\\") ch = read_escaped_char(true, true);
  726. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  727. else if (ch == quote) break;
  728. ret.push(ch);
  729. }
  730. var tok = token("string", ret.join(""));
  731. LATEST_RAW = S.text.slice(start_pos, S.pos);
  732. tok.quote = quote;
  733. return tok;
  734. });
  735. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  736. if (begin) {
  737. S.template_braces.push(S.brace_counter);
  738. }
  739. var content = "", raw = "", ch, tok;
  740. next(true, true);
  741. while ((ch = next(true, true)) != "`") {
  742. if (ch == "\r") {
  743. if (peek() == "\n") ++S.pos;
  744. ch = "\n";
  745. } else if (ch == "$" && peek() == "{") {
  746. next(true, true);
  747. S.brace_counter++;
  748. tok = token(begin ? "template_head" : "template_substitution", content);
  749. TEMPLATE_RAWS.set(tok, raw);
  750. tok.template_end = false;
  751. return tok;
  752. }
  753. raw += ch;
  754. if (ch == "\\") {
  755. var tmp = S.pos;
  756. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  757. ch = read_escaped_char(true, !prev_is_tag, true);
  758. raw += S.text.substr(tmp, S.pos - tmp);
  759. }
  760. content += ch;
  761. }
  762. S.template_braces.pop();
  763. tok = token(begin ? "template_head" : "template_substitution", content);
  764. TEMPLATE_RAWS.set(tok, raw);
  765. tok.template_end = true;
  766. return tok;
  767. });
  768. function skip_line_comment(type) {
  769. var regex_allowed = S.regex_allowed;
  770. var i = find_eol(), ret;
  771. if (i == -1) {
  772. ret = S.text.substr(S.pos);
  773. S.pos = S.text.length;
  774. } else {
  775. ret = S.text.substring(S.pos, i);
  776. S.pos = i;
  777. }
  778. S.col = S.tokcol + (S.pos - S.tokpos);
  779. S.comments_before.push(token(type, ret, true));
  780. S.regex_allowed = regex_allowed;
  781. return next_token;
  782. }
  783. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  784. var regex_allowed = S.regex_allowed;
  785. var i = find("*/", true);
  786. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  787. // update stream position
  788. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  789. S.comments_before.push(token("comment2", text, true));
  790. S.newline_before = S.newline_before || text.includes("\n");
  791. S.regex_allowed = regex_allowed;
  792. return next_token;
  793. });
  794. var read_name = with_eof_error("Unterminated identifier name", function() {
  795. var name = [], ch, escaped = false;
  796. var read_escaped_identifier_char = function() {
  797. escaped = true;
  798. next();
  799. if (peek() !== "u") {
  800. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  801. }
  802. return read_escaped_char(false, true);
  803. };
  804. // Read first character (ID_Start)
  805. if ((ch = peek()) === "\\") {
  806. ch = read_escaped_identifier_char();
  807. if (!is_identifier_start(ch)) {
  808. parse_error("First identifier char is an invalid identifier char");
  809. }
  810. } else if (is_identifier_start(ch)) {
  811. next();
  812. } else {
  813. return "";
  814. }
  815. name.push(ch);
  816. // Read ID_Continue
  817. while ((ch = peek()) != null) {
  818. if ((ch = peek()) === "\\") {
  819. ch = read_escaped_identifier_char();
  820. if (!is_identifier_char(ch)) {
  821. parse_error("Invalid escaped identifier char");
  822. }
  823. } else {
  824. if (!is_identifier_char(ch)) {
  825. break;
  826. }
  827. next();
  828. }
  829. name.push(ch);
  830. }
  831. const name_str = name.join("");
  832. if (RESERVED_WORDS.has(name_str) && escaped) {
  833. parse_error("Escaped characters are not allowed in keywords");
  834. }
  835. return name_str;
  836. });
  837. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  838. var prev_backslash = false, ch, in_class = false;
  839. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  840. parse_error("Unexpected line terminator");
  841. } else if (prev_backslash) {
  842. source += "\\" + ch;
  843. prev_backslash = false;
  844. } else if (ch == "[") {
  845. in_class = true;
  846. source += ch;
  847. } else if (ch == "]" && in_class) {
  848. in_class = false;
  849. source += ch;
  850. } else if (ch == "/" && !in_class) {
  851. break;
  852. } else if (ch == "\\") {
  853. prev_backslash = true;
  854. } else {
  855. source += ch;
  856. }
  857. const flags = read_name();
  858. return token("regexp", "/" + source + "/" + flags);
  859. });
  860. function read_operator(prefix) {
  861. function grow(op) {
  862. if (!peek()) return op;
  863. var bigger = op + peek();
  864. if (OPERATORS.has(bigger)) {
  865. next();
  866. return grow(bigger);
  867. } else {
  868. return op;
  869. }
  870. }
  871. return token("operator", grow(prefix || next()));
  872. }
  873. function handle_slash() {
  874. next();
  875. switch (peek()) {
  876. case "/":
  877. next();
  878. return skip_line_comment("comment1");
  879. case "*":
  880. next();
  881. return skip_multiline_comment();
  882. }
  883. return S.regex_allowed ? read_regexp("") : read_operator("/");
  884. }
  885. function handle_eq_sign() {
  886. next();
  887. if (peek() === ">") {
  888. next();
  889. return token("arrow", "=>");
  890. } else {
  891. return read_operator("=");
  892. }
  893. }
  894. function handle_dot() {
  895. next();
  896. if (is_digit(peek().charCodeAt(0))) {
  897. return read_num(".");
  898. }
  899. if (peek() === ".") {
  900. next(); // Consume second dot
  901. next(); // Consume third dot
  902. return token("expand", "...");
  903. }
  904. return token("punc", ".");
  905. }
  906. function read_word() {
  907. var word = read_name();
  908. if (prev_was_dot) return token("name", word);
  909. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  910. : !KEYWORDS.has(word) ? token("name", word)
  911. : OPERATORS.has(word) ? token("operator", word)
  912. : token("keyword", word);
  913. }
  914. function read_private_word() {
  915. next();
  916. return token("privatename", read_name());
  917. }
  918. function with_eof_error(eof_error, cont) {
  919. return function(x) {
  920. try {
  921. return cont(x);
  922. } catch(ex) {
  923. if (ex === EX_EOF) parse_error(eof_error);
  924. else throw ex;
  925. }
  926. };
  927. }
  928. function next_token(force_regexp) {
  929. if (force_regexp != null)
  930. return read_regexp(force_regexp);
  931. if (shebang && S.pos == 0 && looking_at("#!")) {
  932. start_token();
  933. forward(2);
  934. skip_line_comment("comment5");
  935. }
  936. for (;;) {
  937. skip_whitespace();
  938. start_token();
  939. if (html5_comments) {
  940. if (looking_at("<!--")) {
  941. forward(4);
  942. skip_line_comment("comment3");
  943. continue;
  944. }
  945. if (looking_at("-->") && S.newline_before) {
  946. forward(3);
  947. skip_line_comment("comment4");
  948. continue;
  949. }
  950. }
  951. var ch = peek();
  952. if (!ch) return token("eof");
  953. var code = ch.charCodeAt(0);
  954. switch (code) {
  955. case 34: case 39: return read_string();
  956. case 46: return handle_dot();
  957. case 47: {
  958. var tok = handle_slash();
  959. if (tok === next_token) continue;
  960. return tok;
  961. }
  962. case 61: return handle_eq_sign();
  963. case 63: {
  964. if (!is_option_chain_op()) break; // Handled below
  965. next(); // ?
  966. next(); // .
  967. return token("punc", "?.");
  968. }
  969. case 96: return read_template_characters(true);
  970. case 123:
  971. S.brace_counter++;
  972. break;
  973. case 125:
  974. S.brace_counter--;
  975. if (S.template_braces.length > 0
  976. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  977. return read_template_characters(false);
  978. break;
  979. }
  980. if (is_digit(code)) return read_num();
  981. if (PUNC_CHARS.has(ch)) return token("punc", next());
  982. if (OPERATOR_CHARS.has(ch)) return read_operator();
  983. if (code == 92 || is_identifier_start(ch)) return read_word();
  984. if (code == 35) return read_private_word();
  985. break;
  986. }
  987. parse_error("Unexpected character '" + ch + "'");
  988. }
  989. next_token.next = next;
  990. next_token.peek = peek;
  991. next_token.context = function(nc) {
  992. if (nc) S = nc;
  993. return S;
  994. };
  995. next_token.add_directive = function(directive) {
  996. S.directive_stack[S.directive_stack.length - 1].push(directive);
  997. if (S.directives[directive] === undefined) {
  998. S.directives[directive] = 1;
  999. } else {
  1000. S.directives[directive]++;
  1001. }
  1002. };
  1003. next_token.push_directives_stack = function() {
  1004. S.directive_stack.push([]);
  1005. };
  1006. next_token.pop_directives_stack = function() {
  1007. var directives = S.directive_stack[S.directive_stack.length - 1];
  1008. for (var i = 0; i < directives.length; i++) {
  1009. S.directives[directives[i]]--;
  1010. }
  1011. S.directive_stack.pop();
  1012. };
  1013. next_token.has_directive = function(directive) {
  1014. return S.directives[directive] > 0;
  1015. };
  1016. return next_token;
  1017. }
  1018. /* -----[ Parser (constants) ]----- */
  1019. var UNARY_PREFIX = makePredicate([
  1020. "typeof",
  1021. "void",
  1022. "delete",
  1023. "--",
  1024. "++",
  1025. "!",
  1026. "~",
  1027. "-",
  1028. "+"
  1029. ]);
  1030. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  1031. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  1032. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  1033. var PRECEDENCE = (function(a, ret) {
  1034. for (var i = 0; i < a.length; ++i) {
  1035. var b = a[i];
  1036. for (var j = 0; j < b.length; ++j) {
  1037. ret[b[j]] = i + 1;
  1038. }
  1039. }
  1040. return ret;
  1041. })(
  1042. [
  1043. ["||"],
  1044. ["??"],
  1045. ["&&"],
  1046. ["|"],
  1047. ["^"],
  1048. ["&"],
  1049. ["==", "===", "!=", "!=="],
  1050. ["<", ">", "<=", ">=", "in", "instanceof"],
  1051. [">>", "<<", ">>>"],
  1052. ["+", "-"],
  1053. ["*", "/", "%"],
  1054. ["**"]
  1055. ],
  1056. {}
  1057. );
  1058. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name" ]);
  1059. /* -----[ Parser ]----- */
  1060. function parse($TEXT, options) {
  1061. // maps start tokens to count of comments found outside of their parens
  1062. // Example: /* I count */ ( /* I don't */ foo() )
  1063. // Useful because comments_before property of call with parens outside
  1064. // contains both comments inside and outside these parens. Used to find the
  1065. const outer_comments_before_counts = new WeakMap();
  1066. options = defaults(options, {
  1067. bare_returns : false,
  1068. ecma : null, // Legacy
  1069. expression : false,
  1070. filename : null,
  1071. html5_comments : true,
  1072. module : false,
  1073. shebang : true,
  1074. strict : false,
  1075. toplevel : null,
  1076. }, true);
  1077. var S = {
  1078. input : (typeof $TEXT == "string"
  1079. ? tokenizer($TEXT, options.filename,
  1080. options.html5_comments, options.shebang)
  1081. : $TEXT),
  1082. token : null,
  1083. prev : null,
  1084. peeked : null,
  1085. in_function : 0,
  1086. in_async : -1,
  1087. in_generator : -1,
  1088. in_directives : true,
  1089. in_loop : 0,
  1090. labels : []
  1091. };
  1092. S.token = next();
  1093. function is(type, value) {
  1094. return is_token(S.token, type, value);
  1095. }
  1096. function peek() { return S.peeked || (S.peeked = S.input()); }
  1097. function next() {
  1098. S.prev = S.token;
  1099. if (!S.peeked) peek();
  1100. S.token = S.peeked;
  1101. S.peeked = null;
  1102. S.in_directives = S.in_directives && (
  1103. S.token.type == "string" || is("punc", ";")
  1104. );
  1105. return S.token;
  1106. }
  1107. function prev() {
  1108. return S.prev;
  1109. }
  1110. function croak(msg, line, col, pos) {
  1111. var ctx = S.input.context();
  1112. js_error(msg,
  1113. ctx.filename,
  1114. line != null ? line : ctx.tokline,
  1115. col != null ? col : ctx.tokcol,
  1116. pos != null ? pos : ctx.tokpos);
  1117. }
  1118. function token_error(token, msg) {
  1119. croak(msg, token.line, token.col);
  1120. }
  1121. function unexpected(token) {
  1122. if (token == null)
  1123. token = S.token;
  1124. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  1125. }
  1126. function expect_token(type, val) {
  1127. if (is(type, val)) {
  1128. return next();
  1129. }
  1130. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  1131. }
  1132. function expect(punc) { return expect_token("punc", punc); }
  1133. function has_newline_before(token) {
  1134. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  1135. }
  1136. function can_insert_semicolon() {
  1137. return !options.strict
  1138. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  1139. }
  1140. function is_in_generator() {
  1141. return S.in_generator === S.in_function;
  1142. }
  1143. function is_in_async() {
  1144. return S.in_async === S.in_function;
  1145. }
  1146. function can_await() {
  1147. return (
  1148. S.in_async === S.in_function
  1149. || S.in_function === 0 && S.input.has_directive("use strict")
  1150. );
  1151. }
  1152. function semicolon(optional) {
  1153. if (is("punc", ";")) next();
  1154. else if (!optional && !can_insert_semicolon()) unexpected();
  1155. }
  1156. function parenthesised() {
  1157. expect("(");
  1158. var exp = expression(true);
  1159. expect(")");
  1160. return exp;
  1161. }
  1162. function embed_tokens(parser) {
  1163. return function _embed_tokens_wrapper(...args) {
  1164. const start = S.token;
  1165. const expr = parser(...args);
  1166. expr.start = start;
  1167. expr.end = prev();
  1168. return expr;
  1169. };
  1170. }
  1171. function handle_regexp() {
  1172. if (is("operator", "/") || is("operator", "/=")) {
  1173. S.peeked = null;
  1174. S.token = S.input(S.token.value.substr(1)); // force regexp
  1175. }
  1176. }
  1177. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  1178. handle_regexp();
  1179. switch (S.token.type) {
  1180. case "string":
  1181. if (S.in_directives) {
  1182. var token = peek();
  1183. if (!LATEST_RAW.includes("\\")
  1184. && (is_token(token, "punc", ";")
  1185. || is_token(token, "punc", "}")
  1186. || has_newline_before(token)
  1187. || is_token(token, "eof"))) {
  1188. S.input.add_directive(S.token.value);
  1189. } else {
  1190. S.in_directives = false;
  1191. }
  1192. }
  1193. var dir = S.in_directives, stat = simple_statement();
  1194. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  1195. case "template_head":
  1196. case "num":
  1197. case "big_int":
  1198. case "regexp":
  1199. case "operator":
  1200. case "atom":
  1201. return simple_statement();
  1202. case "name":
  1203. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  1204. next();
  1205. next();
  1206. if (is_for_body) {
  1207. croak("functions are not allowed as the body of a loop");
  1208. }
  1209. return function_(AST_Defun, false, true, is_export_default);
  1210. }
  1211. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  1212. next();
  1213. var node = import_statement();
  1214. semicolon();
  1215. return node;
  1216. }
  1217. return is_token(peek(), "punc", ":")
  1218. ? labeled_statement()
  1219. : simple_statement();
  1220. case "punc":
  1221. switch (S.token.value) {
  1222. case "{":
  1223. return new AST_BlockStatement({
  1224. start : S.token,
  1225. body : block_(),
  1226. end : prev()
  1227. });
  1228. case "[":
  1229. case "(":
  1230. return simple_statement();
  1231. case ";":
  1232. S.in_directives = false;
  1233. next();
  1234. return new AST_EmptyStatement();
  1235. default:
  1236. unexpected();
  1237. }
  1238. case "keyword":
  1239. switch (S.token.value) {
  1240. case "break":
  1241. next();
  1242. return break_cont(AST_Break);
  1243. case "continue":
  1244. next();
  1245. return break_cont(AST_Continue);
  1246. case "debugger":
  1247. next();
  1248. semicolon();
  1249. return new AST_Debugger();
  1250. case "do":
  1251. next();
  1252. var body = in_loop(statement);
  1253. expect_token("keyword", "while");
  1254. var condition = parenthesised();
  1255. semicolon(true);
  1256. return new AST_Do({
  1257. body : body,
  1258. condition : condition
  1259. });
  1260. case "while":
  1261. next();
  1262. return new AST_While({
  1263. condition : parenthesised(),
  1264. body : in_loop(function() { return statement(false, true); })
  1265. });
  1266. case "for":
  1267. next();
  1268. return for_();
  1269. case "class":
  1270. next();
  1271. if (is_for_body) {
  1272. croak("classes are not allowed as the body of a loop");
  1273. }
  1274. if (is_if_body) {
  1275. croak("classes are not allowed as the body of an if");
  1276. }
  1277. return class_(AST_DefClass, is_export_default);
  1278. case "function":
  1279. next();
  1280. if (is_for_body) {
  1281. croak("functions are not allowed as the body of a loop");
  1282. }
  1283. return function_(AST_Defun, false, false, is_export_default);
  1284. case "if":
  1285. next();
  1286. return if_();
  1287. case "return":
  1288. if (S.in_function == 0 && !options.bare_returns)
  1289. croak("'return' outside of function");
  1290. next();
  1291. var value = null;
  1292. if (is("punc", ";")) {
  1293. next();
  1294. } else if (!can_insert_semicolon()) {
  1295. value = expression(true);
  1296. semicolon();
  1297. }
  1298. return new AST_Return({
  1299. value: value
  1300. });
  1301. case "switch":
  1302. next();
  1303. return new AST_Switch({
  1304. expression : parenthesised(),
  1305. body : in_loop(switch_body_)
  1306. });
  1307. case "throw":
  1308. next();
  1309. if (has_newline_before(S.token))
  1310. croak("Illegal newline after 'throw'");
  1311. var value = expression(true);
  1312. semicolon();
  1313. return new AST_Throw({
  1314. value: value
  1315. });
  1316. case "try":
  1317. next();
  1318. return try_();
  1319. case "var":
  1320. next();
  1321. var node = var_();
  1322. semicolon();
  1323. return node;
  1324. case "let":
  1325. next();
  1326. var node = let_();
  1327. semicolon();
  1328. return node;
  1329. case "const":
  1330. next();
  1331. var node = const_();
  1332. semicolon();
  1333. return node;
  1334. case "with":
  1335. if (S.input.has_directive("use strict")) {
  1336. croak("Strict mode may not include a with statement");
  1337. }
  1338. next();
  1339. return new AST_With({
  1340. expression : parenthesised(),
  1341. body : statement()
  1342. });
  1343. case "export":
  1344. if (!is_token(peek(), "punc", "(")) {
  1345. next();
  1346. var node = export_statement();
  1347. if (is("punc", ";")) semicolon();
  1348. return node;
  1349. }
  1350. }
  1351. }
  1352. unexpected();
  1353. });
  1354. function labeled_statement() {
  1355. var label = as_symbol(AST_Label);
  1356. if (label.name === "await" && is_in_async()) {
  1357. token_error(S.prev, "await cannot be used as label inside async function");
  1358. }
  1359. if (S.labels.some((l) => l.name === label.name)) {
  1360. // ECMA-262, 12.12: An ECMAScript program is considered
  1361. // syntactically incorrect if it contains a
  1362. // LabelledStatement that is enclosed by a
  1363. // LabelledStatement with the same Identifier as label.
  1364. croak("Label " + label.name + " defined twice");
  1365. }
  1366. expect(":");
  1367. S.labels.push(label);
  1368. var stat = statement();
  1369. S.labels.pop();
  1370. if (!(stat instanceof AST_IterationStatement)) {
  1371. // check for `continue` that refers to this label.
  1372. // those should be reported as syntax errors.
  1373. // https://github.com/mishoo/UglifyJS2/issues/287
  1374. label.references.forEach(function(ref) {
  1375. if (ref instanceof AST_Continue) {
  1376. ref = ref.label.start;
  1377. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  1378. ref.line, ref.col, ref.pos);
  1379. }
  1380. });
  1381. }
  1382. return new AST_LabeledStatement({ body: stat, label: label });
  1383. }
  1384. function simple_statement(tmp) {
  1385. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  1386. }
  1387. function break_cont(type) {
  1388. var label = null, ldef;
  1389. if (!can_insert_semicolon()) {
  1390. label = as_symbol(AST_LabelRef, true);
  1391. }
  1392. if (label != null) {
  1393. ldef = S.labels.find((l) => l.name === label.name);
  1394. if (!ldef)
  1395. croak("Undefined label " + label.name);
  1396. label.thedef = ldef;
  1397. } else if (S.in_loop == 0)
  1398. croak(type.TYPE + " not inside a loop or switch");
  1399. semicolon();
  1400. var stat = new type({ label: label });
  1401. if (ldef) ldef.references.push(stat);
  1402. return stat;
  1403. }
  1404. function for_() {
  1405. var for_await_error = "`for await` invalid in this context";
  1406. var await_tok = S.token;
  1407. if (await_tok.type == "name" && await_tok.value == "await") {
  1408. if (!can_await()) {
  1409. token_error(await_tok, for_await_error);
  1410. }
  1411. next();
  1412. } else {
  1413. await_tok = false;
  1414. }
  1415. expect("(");
  1416. var init = null;
  1417. if (!is("punc", ";")) {
  1418. init =
  1419. is("keyword", "var") ? (next(), var_(true)) :
  1420. is("keyword", "let") ? (next(), let_(true)) :
  1421. is("keyword", "const") ? (next(), const_(true)) :
  1422. expression(true, true);
  1423. var is_in = is("operator", "in");
  1424. var is_of = is("name", "of");
  1425. if (await_tok && !is_of) {
  1426. token_error(await_tok, for_await_error);
  1427. }
  1428. if (is_in || is_of) {
  1429. if (init instanceof AST_Definitions) {
  1430. if (init.definitions.length > 1)
  1431. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  1432. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  1433. token_error(init.start, "Invalid left-hand side in for..in loop");
  1434. }
  1435. next();
  1436. if (is_in) {
  1437. return for_in(init);
  1438. } else {
  1439. return for_of(init, !!await_tok);
  1440. }
  1441. }
  1442. } else if (await_tok) {
  1443. token_error(await_tok, for_await_error);
  1444. }
  1445. return regular_for(init);
  1446. }
  1447. function regular_for(init) {
  1448. expect(";");
  1449. var test = is("punc", ";") ? null : expression(true);
  1450. expect(";");
  1451. var step = is("punc", ")") ? null : expression(true);
  1452. expect(")");
  1453. return new AST_For({
  1454. init : init,
  1455. condition : test,
  1456. step : step,
  1457. body : in_loop(function() { return statement(false, true); })
  1458. });
  1459. }
  1460. function for_of(init, is_await) {
  1461. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  1462. var obj = expression(true);
  1463. expect(")");
  1464. return new AST_ForOf({
  1465. await : is_await,
  1466. init : init,
  1467. name : lhs,
  1468. object : obj,
  1469. body : in_loop(function() { return statement(false, true); })
  1470. });
  1471. }
  1472. function for_in(init) {
  1473. var obj = expression(true);
  1474. expect(")");
  1475. return new AST_ForIn({
  1476. init : init,
  1477. object : obj,
  1478. body : in_loop(function() { return statement(false, true); })
  1479. });
  1480. }
  1481. var arrow_function = function(start, argnames, is_async) {
  1482. if (has_newline_before(S.token)) {
  1483. croak("Unexpected newline before arrow (=>)");
  1484. }
  1485. expect_token("arrow", "=>");
  1486. var body = _function_body(is("punc", "{"), false, is_async);
  1487. var end =
  1488. body instanceof Array && body.length ? body[body.length - 1].end :
  1489. body instanceof Array ? start :
  1490. body.end;
  1491. return new AST_Arrow({
  1492. start : start,
  1493. end : end,
  1494. async : is_async,
  1495. argnames : argnames,
  1496. body : body
  1497. });
  1498. };
  1499. var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
  1500. var in_statement = ctor === AST_Defun;
  1501. var is_generator = is("operator", "*");
  1502. if (is_generator) {
  1503. next();
  1504. }
  1505. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  1506. if (in_statement && !name) {
  1507. if (is_export_default) {
  1508. ctor = AST_Function;
  1509. } else {
  1510. unexpected();
  1511. }
  1512. }
  1513. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  1514. unexpected(prev());
  1515. var args = [];
  1516. var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
  1517. return new ctor({
  1518. start : args.start,
  1519. end : body.end,
  1520. is_generator: is_generator,
  1521. async : is_async,
  1522. name : name,
  1523. argnames: args,
  1524. body : body
  1525. });
  1526. };
  1527. class UsedParametersTracker {
  1528. constructor(is_parameter, strict, duplicates_ok = false) {
  1529. this.is_parameter = is_parameter;
  1530. this.duplicates_ok = duplicates_ok;
  1531. this.parameters = new Set();
  1532. this.duplicate = null;
  1533. this.default_assignment = false;
  1534. this.spread = false;
  1535. this.strict_mode = !!strict;
  1536. }
  1537. add_parameter(token) {
  1538. if (this.parameters.has(token.value)) {
  1539. if (this.duplicate === null) {
  1540. this.duplicate = token;
  1541. }
  1542. this.check_strict();
  1543. } else {
  1544. this.parameters.add(token.value);
  1545. if (this.is_parameter) {
  1546. switch (token.value) {
  1547. case "arguments":
  1548. case "eval":
  1549. case "yield":
  1550. if (this.strict_mode) {
  1551. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1552. }
  1553. break;
  1554. default:
  1555. if (RESERVED_WORDS.has(token.value)) {
  1556. unexpected();
  1557. }
  1558. }
  1559. }
  1560. }
  1561. }
  1562. mark_default_assignment(token) {
  1563. if (this.default_assignment === false) {
  1564. this.default_assignment = token;
  1565. }
  1566. }
  1567. mark_spread(token) {
  1568. if (this.spread === false) {
  1569. this.spread = token;
  1570. }
  1571. }
  1572. mark_strict_mode() {
  1573. this.strict_mode = true;
  1574. }
  1575. is_strict() {
  1576. return this.default_assignment !== false || this.spread !== false || this.strict_mode;
  1577. }
  1578. check_strict() {
  1579. if (this.is_strict() && this.duplicate !== null && !this.duplicates_ok) {
  1580. token_error(this.duplicate, "Parameter " + this.duplicate.value + " was used already");
  1581. }
  1582. }
  1583. }
  1584. function parameters(params) {
  1585. var used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1586. expect("(");
  1587. while (!is("punc", ")")) {
  1588. var param = parameter(used_parameters);
  1589. params.push(param);
  1590. if (!is("punc", ")")) {
  1591. expect(",");
  1592. }
  1593. if (param instanceof AST_Expansion) {
  1594. break;
  1595. }
  1596. }
  1597. next();
  1598. }
  1599. function parameter(used_parameters, symbol_type) {
  1600. var param;
  1601. var expand = false;
  1602. if (used_parameters === undefined) {
  1603. used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1604. }
  1605. if (is("expand", "...")) {
  1606. expand = S.token;
  1607. used_parameters.mark_spread(S.token);
  1608. next();
  1609. }
  1610. param = binding_element(used_parameters, symbol_type);
  1611. if (is("operator", "=") && expand === false) {
  1612. used_parameters.mark_default_assignment(S.token);
  1613. next();
  1614. param = new AST_DefaultAssign({
  1615. start: param.start,
  1616. left: param,
  1617. operator: "=",
  1618. right: expression(false),
  1619. end: S.token
  1620. });
  1621. }
  1622. if (expand !== false) {
  1623. if (!is("punc", ")")) {
  1624. unexpected();
  1625. }
  1626. param = new AST_Expansion({
  1627. start: expand,
  1628. expression: param,
  1629. end: expand
  1630. });
  1631. }
  1632. used_parameters.check_strict();
  1633. return param;
  1634. }
  1635. function binding_element(used_parameters, symbol_type) {
  1636. var elements = [];
  1637. var first = true;
  1638. var is_expand = false;
  1639. var expand_token;
  1640. var first_token = S.token;
  1641. if (used_parameters === undefined) {
  1642. const strict = S.input.has_directive("use strict");
  1643. const duplicates_ok = symbol_type === AST_SymbolVar;
  1644. used_parameters = new UsedParametersTracker(false, strict, duplicates_ok);
  1645. }
  1646. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1647. if (is("punc", "[")) {
  1648. next();
  1649. while (!is("punc", "]")) {
  1650. if (first) {
  1651. first = false;
  1652. } else {
  1653. expect(",");
  1654. }
  1655. if (is("expand", "...")) {
  1656. is_expand = true;
  1657. expand_token = S.token;
  1658. used_parameters.mark_spread(S.token);
  1659. next();
  1660. }
  1661. if (is("punc")) {
  1662. switch (S.token.value) {
  1663. case ",":
  1664. elements.push(new AST_Hole({
  1665. start: S.token,
  1666. end: S.token
  1667. }));
  1668. continue;
  1669. case "]": // Trailing comma after last element
  1670. break;
  1671. case "[":
  1672. case "{":
  1673. elements.push(binding_element(used_parameters, symbol_type));
  1674. break;
  1675. default:
  1676. unexpected();
  1677. }
  1678. } else if (is("name")) {
  1679. used_parameters.add_parameter(S.token);
  1680. elements.push(as_symbol(symbol_type));
  1681. } else {
  1682. croak("Invalid function parameter");
  1683. }
  1684. if (is("operator", "=") && is_expand === false) {
  1685. used_parameters.mark_default_assignment(S.token);
  1686. next();
  1687. elements[elements.length - 1] = new AST_DefaultAssign({
  1688. start: elements[elements.length - 1].start,
  1689. left: elements[elements.length - 1],
  1690. operator: "=",
  1691. right: expression(false),
  1692. end: S.token
  1693. });
  1694. }
  1695. if (is_expand) {
  1696. if (!is("punc", "]")) {
  1697. croak("Rest element must be last element");
  1698. }
  1699. elements[elements.length - 1] = new AST_Expansion({
  1700. start: expand_token,
  1701. expression: elements[elements.length - 1],
  1702. end: expand_token
  1703. });
  1704. }
  1705. }
  1706. expect("]");
  1707. used_parameters.check_strict();
  1708. return new AST_Destructuring({
  1709. start: first_token,
  1710. names: elements,
  1711. is_array: true,
  1712. end: prev()
  1713. });
  1714. } else if (is("punc", "{")) {
  1715. next();
  1716. while (!is("punc", "}")) {
  1717. if (first) {
  1718. first = false;
  1719. } else {
  1720. expect(",");
  1721. }
  1722. if (is("expand", "...")) {
  1723. is_expand = true;
  1724. expand_token = S.token;
  1725. used_parameters.mark_spread(S.token);
  1726. next();
  1727. }
  1728. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1729. used_parameters.add_parameter(S.token);
  1730. var start = prev();
  1731. var value = as_symbol(symbol_type);
  1732. if (is_expand) {
  1733. elements.push(new AST_Expansion({
  1734. start: expand_token,
  1735. expression: value,
  1736. end: value.end,
  1737. }));
  1738. } else {
  1739. elements.push(new AST_ObjectKeyVal({
  1740. start: start,
  1741. key: value.name,
  1742. value: value,
  1743. end: value.end,
  1744. }));
  1745. }
  1746. } else if (is("punc", "}")) {
  1747. continue; // Allow trailing hole
  1748. } else {
  1749. var property_token = S.token;
  1750. var property = as_property_name();
  1751. if (property === null) {
  1752. unexpected(prev());
  1753. } else if (prev().type === "name" && !is("punc", ":")) {
  1754. elements.push(new AST_ObjectKeyVal({
  1755. start: prev(),
  1756. key: property,
  1757. value: new symbol_type({
  1758. start: prev(),
  1759. name: property,
  1760. end: prev()
  1761. }),
  1762. end: prev()
  1763. }));
  1764. } else {
  1765. expect(":");
  1766. elements.push(new AST_ObjectKeyVal({
  1767. start: property_token,
  1768. quote: property_token.quote,
  1769. key: property,
  1770. value: binding_element(used_parameters, symbol_type),
  1771. end: prev()
  1772. }));
  1773. }
  1774. }
  1775. if (is_expand) {
  1776. if (!is("punc", "}")) {
  1777. croak("Rest element must be last element");
  1778. }
  1779. } else if (is("operator", "=")) {
  1780. used_parameters.mark_default_assignment(S.token);
  1781. next();
  1782. elements[elements.length - 1].value = new AST_DefaultAssign({
  1783. start: elements[elements.length - 1].value.start,
  1784. left: elements[elements.length - 1].value,
  1785. operator: "=",
  1786. right: expression(false),
  1787. end: S.token
  1788. });
  1789. }
  1790. }
  1791. expect("}");
  1792. used_parameters.check_strict();
  1793. return new AST_Destructuring({
  1794. start: first_token,
  1795. names: elements,
  1796. is_array: false,
  1797. end: prev()
  1798. });
  1799. } else if (is("name")) {
  1800. used_parameters.add_parameter(S.token);
  1801. return as_symbol(symbol_type);
  1802. } else {
  1803. croak("Invalid function parameter");
  1804. }
  1805. }
  1806. function params_or_seq_(allow_arrows, maybe_sequence) {
  1807. var spread_token;
  1808. var invalid_sequence;
  1809. var trailing_comma;
  1810. var a = [];
  1811. expect("(");
  1812. while (!is("punc", ")")) {
  1813. if (spread_token) unexpected(spread_token);
  1814. if (is("expand", "...")) {
  1815. spread_token = S.token;
  1816. if (maybe_sequence) invalid_sequence = S.token;
  1817. next();
  1818. a.push(new AST_Expansion({
  1819. start: prev(),
  1820. expression: expression(),
  1821. end: S.token,
  1822. }));
  1823. } else {
  1824. a.push(expression());
  1825. }
  1826. if (!is("punc", ")")) {
  1827. expect(",");
  1828. if (is("punc", ")")) {
  1829. trailing_comma = prev();
  1830. if (maybe_sequence) invalid_sequence = trailing_comma;
  1831. }
  1832. }
  1833. }
  1834. expect(")");
  1835. if (allow_arrows && is("arrow", "=>")) {
  1836. if (spread_token && trailing_comma) unexpected(trailing_comma);
  1837. } else if (invalid_sequence) {
  1838. unexpected(invalid_sequence);
  1839. }
  1840. return a;
  1841. }
  1842. function _function_body(block, generator, is_async, name, args) {
  1843. var loop = S.in_loop;
  1844. var labels = S.labels;
  1845. var current_generator = S.in_generator;
  1846. var current_async = S.in_async;
  1847. ++S.in_function;
  1848. if (generator)
  1849. S.in_generator = S.in_function;
  1850. if (is_async)
  1851. S.in_async = S.in_function;
  1852. if (args) parameters(args);
  1853. if (block)
  1854. S.in_directives = true;
  1855. S.in_loop = 0;
  1856. S.labels = [];
  1857. if (block) {
  1858. S.input.push_directives_stack();
  1859. var a = block_();
  1860. if (name) _verify_symbol(name);
  1861. if (args) args.forEach(_verify_symbol);
  1862. S.input.pop_directives_stack();
  1863. } else {
  1864. var a = [new AST_Return({
  1865. start: S.token,
  1866. value: expression(false),
  1867. end: S.token
  1868. })];
  1869. }
  1870. --S.in_function;
  1871. S.in_loop = loop;
  1872. S.labels = labels;
  1873. S.in_generator = current_generator;
  1874. S.in_async = current_async;
  1875. return a;
  1876. }
  1877. function _await_expression() {
  1878. // Previous token must be "await" and not be interpreted as an identifier
  1879. if (!can_await()) {
  1880. croak("Unexpected await expression outside async function",
  1881. S.prev.line, S.prev.col, S.prev.pos);
  1882. }
  1883. // the await expression is parsed as a unary expression in Babel
  1884. return new AST_Await({
  1885. start: prev(),
  1886. end: S.token,
  1887. expression : maybe_unary(true),
  1888. });
  1889. }
  1890. function _yield_expression() {
  1891. // Previous token must be keyword yield and not be interpret as an identifier
  1892. if (!is_in_generator()) {
  1893. croak("Unexpected yield expression outside generator function",
  1894. S.prev.line, S.prev.col, S.prev.pos);
  1895. }
  1896. var start = S.token;
  1897. var star = false;
  1898. var has_expression = true;
  1899. // Attempt to get expression or star (and then the mandatory expression)
  1900. // behind yield on the same line.
  1901. //
  1902. // If nothing follows on the same line of the yieldExpression,
  1903. // it should default to the value `undefined` for yield to return.
  1904. // In that case, the `undefined` stored as `null` in ast.
  1905. //
  1906. // Note 1: It isn't allowed for yield* to close without an expression
  1907. // Note 2: If there is a nlb between yield and star, it is interpret as
  1908. // yield <explicit undefined> <inserted automatic semicolon> *
  1909. if (can_insert_semicolon() ||
  1910. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  1911. has_expression = false;
  1912. } else if (is("operator", "*")) {
  1913. star = true;
  1914. next();
  1915. }
  1916. return new AST_Yield({
  1917. start : start,
  1918. is_star : star,
  1919. expression : has_expression ? expression() : null,
  1920. end : prev()
  1921. });
  1922. }
  1923. function if_() {
  1924. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  1925. if (is("keyword", "else")) {
  1926. next();
  1927. belse = statement(false, false, true);
  1928. }
  1929. return new AST_If({
  1930. condition : cond,
  1931. body : body,
  1932. alternative : belse
  1933. });
  1934. }
  1935. function block_() {
  1936. expect("{");
  1937. var a = [];
  1938. while (!is("punc", "}")) {
  1939. if (is("eof")) unexpected();
  1940. a.push(statement());
  1941. }
  1942. next();
  1943. return a;
  1944. }
  1945. function switch_body_() {
  1946. expect("{");
  1947. var a = [], cur = null, branch = null, tmp;
  1948. while (!is("punc", "}")) {
  1949. if (is("eof")) unexpected();
  1950. if (is("keyword", "case")) {
  1951. if (branch) branch.end = prev();
  1952. cur = [];
  1953. branch = new AST_Case({
  1954. start : (tmp = S.token, next(), tmp),
  1955. expression : expression(true),
  1956. body : cur
  1957. });
  1958. a.push(branch);
  1959. expect(":");
  1960. } else if (is("keyword", "default")) {
  1961. if (branch) branch.end = prev();
  1962. cur = [];
  1963. branch = new AST_Default({
  1964. start : (tmp = S.token, next(), expect(":"), tmp),
  1965. body : cur
  1966. });
  1967. a.push(branch);
  1968. } else {
  1969. if (!cur) unexpected();
  1970. cur.push(statement());
  1971. }
  1972. }
  1973. if (branch) branch.end = prev();
  1974. next();
  1975. return a;
  1976. }
  1977. function try_() {
  1978. var body = block_(), bcatch = null, bfinally = null;
  1979. if (is("keyword", "catch")) {
  1980. var start = S.token;
  1981. next();
  1982. if (is("punc", "{")) {
  1983. var name = null;
  1984. } else {
  1985. expect("(");
  1986. var name = parameter(undefined, AST_SymbolCatch);
  1987. expect(")");
  1988. }
  1989. bcatch = new AST_Catch({
  1990. start : start,
  1991. argname : name,
  1992. body : block_(),
  1993. end : prev()
  1994. });
  1995. }
  1996. if (is("keyword", "finally")) {
  1997. var start = S.token;
  1998. next();
  1999. bfinally = new AST_Finally({
  2000. start : start,
  2001. body : block_(),
  2002. end : prev()
  2003. });
  2004. }
  2005. if (!bcatch && !bfinally)
  2006. croak("Missing catch/finally blocks");
  2007. return new AST_Try({
  2008. body : body,
  2009. bcatch : bcatch,
  2010. bfinally : bfinally
  2011. });
  2012. }
  2013. function vardefs(no_in, kind) {
  2014. var a = [];
  2015. var def;
  2016. for (;;) {
  2017. var sym_type =
  2018. kind === "var" ? AST_SymbolVar :
  2019. kind === "const" ? AST_SymbolConst :
  2020. kind === "let" ? AST_SymbolLet : null;
  2021. if (is("punc", "{") || is("punc", "[")) {
  2022. def = new AST_VarDef({
  2023. start: S.token,
  2024. name: binding_element(undefined, sym_type),
  2025. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  2026. end: prev()
  2027. });
  2028. } else {
  2029. def = new AST_VarDef({
  2030. start : S.token,
  2031. name : as_symbol(sym_type),
  2032. value : is("operator", "=")
  2033. ? (next(), expression(false, no_in))
  2034. : !no_in && kind === "const"
  2035. ? croak("Missing initializer in const declaration") : null,
  2036. end : prev()
  2037. });
  2038. if (def.name.name == "import") croak("Unexpected token: import");
  2039. }
  2040. a.push(def);
  2041. if (!is("punc", ","))
  2042. break;
  2043. next();
  2044. }
  2045. return a;
  2046. }
  2047. var var_ = function(no_in) {
  2048. return new AST_Var({
  2049. start : prev(),
  2050. definitions : vardefs(no_in, "var"),
  2051. end : prev()
  2052. });
  2053. };
  2054. var let_ = function(no_in) {
  2055. return new AST_Let({
  2056. start : prev(),
  2057. definitions : vardefs(no_in, "let"),
  2058. end : prev()
  2059. });
  2060. };
  2061. var const_ = function(no_in) {
  2062. return new AST_Const({
  2063. start : prev(),
  2064. definitions : vardefs(no_in, "const"),
  2065. end : prev()
  2066. });
  2067. };
  2068. var new_ = function(allow_calls) {
  2069. var start = S.token;
  2070. expect_token("operator", "new");
  2071. if (is("punc", ".")) {
  2072. next();
  2073. expect_token("name", "target");
  2074. return subscripts(new AST_NewTarget({
  2075. start : start,
  2076. end : prev()
  2077. }), allow_calls);
  2078. }
  2079. var newexp = expr_atom(false), args;
  2080. if (is("punc", "(")) {
  2081. next();
  2082. args = expr_list(")", true);
  2083. } else {
  2084. args = [];
  2085. }
  2086. var call = new AST_New({
  2087. start : start,
  2088. expression : newexp,
  2089. args : args,
  2090. end : prev()
  2091. });
  2092. annotate(call);
  2093. return subscripts(call, allow_calls);
  2094. };
  2095. function as_atom_node() {
  2096. var tok = S.token, ret;
  2097. switch (tok.type) {
  2098. case "name":
  2099. ret = _make_symbol(AST_SymbolRef);
  2100. break;
  2101. case "num":
  2102. ret = new AST_Number({
  2103. start: tok,
  2104. end: tok,
  2105. value: tok.value,
  2106. raw: LATEST_RAW
  2107. });
  2108. break;
  2109. case "big_int":
  2110. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  2111. break;
  2112. case "string":
  2113. ret = new AST_String({
  2114. start : tok,
  2115. end : tok,
  2116. value : tok.value,
  2117. quote : tok.quote
  2118. });
  2119. break;
  2120. case "regexp":
  2121. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  2122. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  2123. break;
  2124. case "atom":
  2125. switch (tok.value) {
  2126. case "false":
  2127. ret = new AST_False({ start: tok, end: tok });
  2128. break;
  2129. case "true":
  2130. ret = new AST_True({ start: tok, end: tok });
  2131. break;
  2132. case "null":
  2133. ret = new AST_Null({ start: tok, end: tok });
  2134. break;
  2135. }
  2136. break;
  2137. }
  2138. next();
  2139. return ret;
  2140. }
  2141. function to_fun_args(ex, default_seen_above) {
  2142. var insert_default = function(ex, default_value) {
  2143. if (default_value) {
  2144. return new AST_DefaultAssign({
  2145. start: ex.start,
  2146. left: ex,
  2147. operator: "=",
  2148. right: default_value,
  2149. end: default_value.end
  2150. });
  2151. }
  2152. return ex;
  2153. };
  2154. if (ex instanceof AST_Object) {
  2155. return insert_default(new AST_Destructuring({
  2156. start: ex.start,
  2157. end: ex.end,
  2158. is_array: false,
  2159. names: ex.properties.map(prop => to_fun_args(prop))
  2160. }), default_seen_above);
  2161. } else if (ex instanceof AST_ObjectKeyVal) {
  2162. ex.value = to_fun_args(ex.value);
  2163. return insert_default(ex, default_seen_above);
  2164. } else if (ex instanceof AST_Hole) {
  2165. return ex;
  2166. } else if (ex instanceof AST_Destructuring) {
  2167. ex.names = ex.names.map(name => to_fun_args(name));
  2168. return insert_default(ex, default_seen_above);
  2169. } else if (ex instanceof AST_SymbolRef) {
  2170. return insert_default(new AST_SymbolFunarg({
  2171. name: ex.name,
  2172. start: ex.start,
  2173. end: ex.end
  2174. }), default_seen_above);
  2175. } else if (ex instanceof AST_Expansion) {
  2176. ex.expression = to_fun_args(ex.expression);
  2177. return insert_default(ex, default_seen_above);
  2178. } else if (ex instanceof AST_Array) {
  2179. return insert_default(new AST_Destructuring({
  2180. start: ex.start,
  2181. end: ex.end,
  2182. is_array: true,
  2183. names: ex.elements.map(elm => to_fun_args(elm))
  2184. }), default_seen_above);
  2185. } else if (ex instanceof AST_Assign) {
  2186. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2187. } else if (ex instanceof AST_DefaultAssign) {
  2188. ex.left = to_fun_args(ex.left);
  2189. return ex;
  2190. } else {
  2191. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2192. }
  2193. }
  2194. var expr_atom = function(allow_calls, allow_arrows) {
  2195. if (is("operator", "new")) {
  2196. return new_(allow_calls);
  2197. }
  2198. if (is("operator", "import")) {
  2199. return import_meta();
  2200. }
  2201. var start = S.token;
  2202. var peeked;
  2203. var async = is("name", "async")
  2204. && (peeked = peek()).value != "["
  2205. && peeked.type != "arrow"
  2206. && as_atom_node();
  2207. if (is("punc")) {
  2208. switch (S.token.value) {
  2209. case "(":
  2210. if (async && !allow_calls) break;
  2211. var exprs = params_or_seq_(allow_arrows, !async);
  2212. if (allow_arrows && is("arrow", "=>")) {
  2213. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2214. }
  2215. var ex = async ? new AST_Call({
  2216. expression: async,
  2217. args: exprs
  2218. }) : exprs.length == 1 ? exprs[0] : new AST_Sequence({
  2219. expressions: exprs
  2220. });
  2221. if (ex.start) {
  2222. const outer_comments_before = start.comments_before.length;
  2223. outer_comments_before_counts.set(start, outer_comments_before);
  2224. ex.start.comments_before.unshift(...start.comments_before);
  2225. start.comments_before = ex.start.comments_before;
  2226. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2227. var comment = start.comments_before[0];
  2228. if (!comment.nlb) {
  2229. comment.nlb = start.nlb;
  2230. start.nlb = false;
  2231. }
  2232. }
  2233. start.comments_after = ex.start.comments_after;
  2234. }
  2235. ex.start = start;
  2236. var end = prev();
  2237. if (ex.end) {
  2238. end.comments_before = ex.end.comments_before;
  2239. ex.end.comments_after.push(...end.comments_after);
  2240. end.comments_after = ex.end.comments_after;
  2241. }
  2242. ex.end = end;
  2243. if (ex instanceof AST_Call) annotate(ex);
  2244. return subscripts(ex, allow_calls);
  2245. case "[":
  2246. return subscripts(array_(), allow_calls);
  2247. case "{":
  2248. return subscripts(object_or_destructuring_(), allow_calls);
  2249. }
  2250. if (!async) unexpected();
  2251. }
  2252. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2253. var param = new AST_SymbolFunarg({
  2254. name: S.token.value,
  2255. start: start,
  2256. end: start,
  2257. });
  2258. next();
  2259. return arrow_function(start, [param], !!async);
  2260. }
  2261. if (is("keyword", "function")) {
  2262. next();
  2263. var func = function_(AST_Function, false, !!async);
  2264. func.start = start;
  2265. func.end = prev();
  2266. return subscripts(func, allow_calls);
  2267. }
  2268. if (async) return subscripts(async, allow_calls);
  2269. if (is("keyword", "class")) {
  2270. next();
  2271. var cls = class_(AST_ClassExpression);
  2272. cls.start = start;
  2273. cls.end = prev();
  2274. return subscripts(cls, allow_calls);
  2275. }
  2276. if (is("template_head")) {
  2277. return subscripts(template_string(), allow_calls);
  2278. }
  2279. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2280. return subscripts(as_atom_node(), allow_calls);
  2281. }
  2282. unexpected();
  2283. };
  2284. function template_string() {
  2285. var segments = [], start = S.token;
  2286. segments.push(new AST_TemplateSegment({
  2287. start: S.token,
  2288. raw: TEMPLATE_RAWS.get(S.token),
  2289. value: S.token.value,
  2290. end: S.token
  2291. }));
  2292. while (!S.token.template_end) {
  2293. next();
  2294. handle_regexp();
  2295. segments.push(expression(true));
  2296. segments.push(new AST_TemplateSegment({
  2297. start: S.token,
  2298. raw: TEMPLATE_RAWS.get(S.token),
  2299. value: S.token.value,
  2300. end: S.token
  2301. }));
  2302. }
  2303. next();
  2304. return new AST_TemplateString({
  2305. start: start,
  2306. segments: segments,
  2307. end: S.token
  2308. });
  2309. }
  2310. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2311. var first = true, a = [];
  2312. while (!is("punc", closing)) {
  2313. if (first) first = false; else expect(",");
  2314. if (allow_trailing_comma && is("punc", closing)) break;
  2315. if (is("punc", ",") && allow_empty) {
  2316. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2317. } else if (is("expand", "...")) {
  2318. next();
  2319. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2320. } else {
  2321. a.push(expression(false));
  2322. }
  2323. }
  2324. next();
  2325. return a;
  2326. }
  2327. var array_ = embed_tokens(function() {
  2328. expect("[");
  2329. return new AST_Array({
  2330. elements: expr_list("]", !options.strict, true)
  2331. });
  2332. });
  2333. var create_accessor = embed_tokens((is_generator, is_async) => {
  2334. return function_(AST_Accessor, is_generator, is_async);
  2335. });
  2336. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2337. var start = S.token, first = true, a = [];
  2338. expect("{");
  2339. while (!is("punc", "}")) {
  2340. if (first) first = false; else expect(",");
  2341. if (!options.strict && is("punc", "}"))
  2342. // allow trailing comma
  2343. break;
  2344. start = S.token;
  2345. if (start.type == "expand") {
  2346. next();
  2347. a.push(new AST_Expansion({
  2348. start: start,
  2349. expression: expression(false),
  2350. end: prev(),
  2351. }));
  2352. continue;
  2353. }
  2354. var name = as_property_name();
  2355. var value;
  2356. // Check property and fetch value
  2357. if (!is("punc", ":")) {
  2358. var concise = concise_method_or_getset(name, start);
  2359. if (concise) {
  2360. a.push(concise);
  2361. continue;
  2362. }
  2363. value = new AST_SymbolRef({
  2364. start: prev(),
  2365. name: name,
  2366. end: prev()
  2367. });
  2368. } else if (name === null) {
  2369. unexpected(prev());
  2370. } else {
  2371. next(); // `:` - see first condition
  2372. value = expression(false);
  2373. }
  2374. // Check for default value and alter value accordingly if necessary
  2375. if (is("operator", "=")) {
  2376. next();
  2377. value = new AST_Assign({
  2378. start: start,
  2379. left: value,
  2380. operator: "=",
  2381. right: expression(false),
  2382. logical: false,
  2383. end: prev()
  2384. });
  2385. }
  2386. // Create property
  2387. a.push(new AST_ObjectKeyVal({
  2388. start: start,
  2389. quote: start.quote,
  2390. key: name instanceof AST_Node ? name : "" + name,
  2391. value: value,
  2392. end: prev()
  2393. }));
  2394. }
  2395. next();
  2396. return new AST_Object({ properties: a });
  2397. });
  2398. function class_(KindOfClass, is_export_default) {
  2399. var start, method, class_name, extends_, a = [];
  2400. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2401. S.input.add_directive("use strict");
  2402. if (S.token.type == "name" && S.token.value != "extends") {
  2403. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2404. }
  2405. if (KindOfClass === AST_DefClass && !class_name) {
  2406. if (is_export_default) {
  2407. KindOfClass = AST_ClassExpression;
  2408. } else {
  2409. unexpected();
  2410. }
  2411. }
  2412. if (S.token.value == "extends") {
  2413. next();
  2414. extends_ = expression(true);
  2415. }
  2416. expect("{");
  2417. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2418. while (!is("punc", "}")) {
  2419. start = S.token;
  2420. method = concise_method_or_getset(as_property_name(), start, true);
  2421. if (!method) { unexpected(); }
  2422. a.push(method);
  2423. while (is("punc", ";")) { next(); }
  2424. }
  2425. S.input.pop_directives_stack();
  2426. next();
  2427. return new KindOfClass({
  2428. start: start,
  2429. name: class_name,
  2430. extends: extends_,
  2431. properties: a,
  2432. end: prev(),
  2433. });
  2434. }
  2435. function concise_method_or_getset(name, start, is_class) {
  2436. const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
  2437. if (typeof name === "string" || typeof name === "number") {
  2438. return new SymbolClass({
  2439. start,
  2440. name: "" + name,
  2441. end: prev()
  2442. });
  2443. } else if (name === null) {
  2444. unexpected();
  2445. }
  2446. return name;
  2447. };
  2448. const is_not_method_start = () =>
  2449. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=");
  2450. var is_async = false;
  2451. var is_static = false;
  2452. var is_generator = false;
  2453. var is_private = false;
  2454. var accessor_type = null;
  2455. if (is_class && name === "static" && is_not_method_start()) {
  2456. const static_block = class_static_block();
  2457. if (static_block != null) {
  2458. return static_block;
  2459. }
  2460. is_static = true;
  2461. name = as_property_name();
  2462. }
  2463. if (name === "async" && is_not_method_start()) {
  2464. is_async = true;
  2465. name = as_property_name();
  2466. }
  2467. if (prev().type === "operator" && prev().value === "*") {
  2468. is_generator = true;
  2469. name = as_property_name();
  2470. }
  2471. if ((name === "get" || name === "set") && is_not_method_start()) {
  2472. accessor_type = name;
  2473. name = as_property_name();
  2474. }
  2475. if (prev().type === "privatename") {
  2476. is_private = true;
  2477. }
  2478. const property_token = prev();
  2479. if (accessor_type != null) {
  2480. if (!is_private) {
  2481. const AccessorClass = accessor_type === "get"
  2482. ? AST_ObjectGetter
  2483. : AST_ObjectSetter;
  2484. name = get_symbol_ast(name);
  2485. return new AccessorClass({
  2486. start,
  2487. static: is_static,
  2488. key: name,
  2489. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  2490. value: create_accessor(),
  2491. end: prev()
  2492. });
  2493. } else {
  2494. const AccessorClass = accessor_type === "get"
  2495. ? AST_PrivateGetter
  2496. : AST_PrivateSetter;
  2497. return new AccessorClass({
  2498. start,
  2499. static: is_static,
  2500. key: get_symbol_ast(name),
  2501. value: create_accessor(),
  2502. end: prev(),
  2503. });
  2504. }
  2505. }
  2506. if (is("punc", "(")) {
  2507. name = get_symbol_ast(name);
  2508. const AST_MethodVariant = is_private
  2509. ? AST_PrivateMethod
  2510. : AST_ConciseMethod;
  2511. var node = new AST_MethodVariant({
  2512. start : start,
  2513. static : is_static,
  2514. is_generator: is_generator,
  2515. async : is_async,
  2516. key : name,
  2517. quote : name instanceof AST_SymbolMethod ?
  2518. property_token.quote : undefined,
  2519. value : create_accessor(is_generator, is_async),
  2520. end : prev()
  2521. });
  2522. return node;
  2523. }
  2524. if (is_class) {
  2525. const key = get_symbol_ast(name, AST_SymbolClassProperty);
  2526. const quote = key instanceof AST_SymbolClassProperty
  2527. ? property_token.quote
  2528. : undefined;
  2529. const AST_ClassPropertyVariant = is_private
  2530. ? AST_ClassPrivateProperty
  2531. : AST_ClassProperty;
  2532. if (is("operator", "=")) {
  2533. next();
  2534. return new AST_ClassPropertyVariant({
  2535. start,
  2536. static: is_static,
  2537. quote,
  2538. key,
  2539. value: expression(false),
  2540. end: prev()
  2541. });
  2542. } else if (
  2543. is("name")
  2544. || is("privatename")
  2545. || is("operator", "*")
  2546. || is("punc", ";")
  2547. || is("punc", "}")
  2548. ) {
  2549. return new AST_ClassPropertyVariant({
  2550. start,
  2551. static: is_static,
  2552. quote,
  2553. key,
  2554. end: prev()
  2555. });
  2556. }
  2557. }
  2558. }
  2559. function class_static_block() {
  2560. if (!is("punc", "{")) {
  2561. return null;
  2562. }
  2563. const start = S.token;
  2564. const body = [];
  2565. next();
  2566. while (!is("punc", "}")) {
  2567. body.push(statement());
  2568. }
  2569. next();
  2570. return new AST_ClassStaticBlock({ start, body, end: prev() });
  2571. }
  2572. function maybe_import_assertion() {
  2573. if (is("name", "assert") && !has_newline_before(S.token)) {
  2574. next();
  2575. return object_or_destructuring_();
  2576. }
  2577. return null;
  2578. }
  2579. function import_statement() {
  2580. var start = prev();
  2581. var imported_name;
  2582. var imported_names;
  2583. if (is("name")) {
  2584. imported_name = as_symbol(AST_SymbolImport);
  2585. }
  2586. if (is("punc", ",")) {
  2587. next();
  2588. }
  2589. imported_names = map_names(true);
  2590. if (imported_names || imported_name) {
  2591. expect_token("name", "from");
  2592. }
  2593. var mod_str = S.token;
  2594. if (mod_str.type !== "string") {
  2595. unexpected();
  2596. }
  2597. next();
  2598. const assert_clause = maybe_import_assertion();
  2599. return new AST_Import({
  2600. start,
  2601. imported_name,
  2602. imported_names,
  2603. module_name: new AST_String({
  2604. start: mod_str,
  2605. value: mod_str.value,
  2606. quote: mod_str.quote,
  2607. end: mod_str,
  2608. }),
  2609. assert_clause,
  2610. end: S.token,
  2611. });
  2612. }
  2613. function import_meta() {
  2614. var start = S.token;
  2615. expect_token("operator", "import");
  2616. expect_token("punc", ".");
  2617. expect_token("name", "meta");
  2618. return subscripts(new AST_ImportMeta({
  2619. start: start,
  2620. end: prev()
  2621. }), false);
  2622. }
  2623. function map_name(is_import) {
  2624. function make_symbol(type) {
  2625. return new type({
  2626. name: as_property_name(),
  2627. start: prev(),
  2628. end: prev()
  2629. });
  2630. }
  2631. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2632. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2633. var start = S.token;
  2634. var foreign_name;
  2635. var name;
  2636. if (is_import) {
  2637. foreign_name = make_symbol(foreign_type);
  2638. } else {
  2639. name = make_symbol(type);
  2640. }
  2641. if (is("name", "as")) {
  2642. next(); // The "as" word
  2643. if (is_import) {
  2644. name = make_symbol(type);
  2645. } else {
  2646. foreign_name = make_symbol(foreign_type);
  2647. }
  2648. } else if (is_import) {
  2649. name = new type(foreign_name);
  2650. } else {
  2651. foreign_name = new foreign_type(name);
  2652. }
  2653. return new AST_NameMapping({
  2654. start: start,
  2655. foreign_name: foreign_name,
  2656. name: name,
  2657. end: prev(),
  2658. });
  2659. }
  2660. function map_nameAsterisk(is_import, name) {
  2661. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2662. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2663. var start = S.token;
  2664. var foreign_name;
  2665. var end = prev();
  2666. name = name || new type({
  2667. name: "*",
  2668. start: start,
  2669. end: end,
  2670. });
  2671. foreign_name = new foreign_type({
  2672. name: "*",
  2673. start: start,
  2674. end: end,
  2675. });
  2676. return new AST_NameMapping({
  2677. start: start,
  2678. foreign_name: foreign_name,
  2679. name: name,
  2680. end: end,
  2681. });
  2682. }
  2683. function map_names(is_import) {
  2684. var names;
  2685. if (is("punc", "{")) {
  2686. next();
  2687. names = [];
  2688. while (!is("punc", "}")) {
  2689. names.push(map_name(is_import));
  2690. if (is("punc", ",")) {
  2691. next();
  2692. }
  2693. }
  2694. next();
  2695. } else if (is("operator", "*")) {
  2696. var name;
  2697. next();
  2698. if (is_import && is("name", "as")) {
  2699. next(); // The "as" word
  2700. name = as_symbol(is_import ? AST_SymbolImport : AST_SymbolExportForeign);
  2701. }
  2702. names = [map_nameAsterisk(is_import, name)];
  2703. }
  2704. return names;
  2705. }
  2706. function export_statement() {
  2707. var start = S.token;
  2708. var is_default;
  2709. var exported_names;
  2710. if (is("keyword", "default")) {
  2711. is_default = true;
  2712. next();
  2713. } else if (exported_names = map_names(false)) {
  2714. if (is("name", "from")) {
  2715. next();
  2716. var mod_str = S.token;
  2717. if (mod_str.type !== "string") {
  2718. unexpected();
  2719. }
  2720. next();
  2721. const assert_clause = maybe_import_assertion();
  2722. return new AST_Export({
  2723. start: start,
  2724. is_default: is_default,
  2725. exported_names: exported_names,
  2726. module_name: new AST_String({
  2727. start: mod_str,
  2728. value: mod_str.value,
  2729. quote: mod_str.quote,
  2730. end: mod_str,
  2731. }),
  2732. end: prev(),
  2733. assert_clause
  2734. });
  2735. } else {
  2736. return new AST_Export({
  2737. start: start,
  2738. is_default: is_default,
  2739. exported_names: exported_names,
  2740. end: prev(),
  2741. });
  2742. }
  2743. }
  2744. var node;
  2745. var exported_value;
  2746. var exported_definition;
  2747. if (is("punc", "{")
  2748. || is_default
  2749. && (is("keyword", "class") || is("keyword", "function"))
  2750. && is_token(peek(), "punc")) {
  2751. exported_value = expression(false);
  2752. semicolon();
  2753. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2754. unexpected(node.start);
  2755. } else if (
  2756. node instanceof AST_Definitions
  2757. || node instanceof AST_Defun
  2758. || node instanceof AST_DefClass
  2759. ) {
  2760. exported_definition = node;
  2761. } else if (
  2762. node instanceof AST_ClassExpression
  2763. || node instanceof AST_Function
  2764. ) {
  2765. exported_value = node;
  2766. } else if (node instanceof AST_SimpleStatement) {
  2767. exported_value = node.body;
  2768. } else {
  2769. unexpected(node.start);
  2770. }
  2771. return new AST_Export({
  2772. start: start,
  2773. is_default: is_default,
  2774. exported_value: exported_value,
  2775. exported_definition: exported_definition,
  2776. end: prev(),
  2777. assert_clause: null
  2778. });
  2779. }
  2780. function as_property_name() {
  2781. var tmp = S.token;
  2782. switch (tmp.type) {
  2783. case "punc":
  2784. if (tmp.value === "[") {
  2785. next();
  2786. var ex = expression(false);
  2787. expect("]");
  2788. return ex;
  2789. } else unexpected(tmp);
  2790. case "operator":
  2791. if (tmp.value === "*") {
  2792. next();
  2793. return null;
  2794. }
  2795. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2796. unexpected(tmp);
  2797. }
  2798. /* falls through */
  2799. case "name":
  2800. case "privatename":
  2801. case "string":
  2802. case "num":
  2803. case "big_int":
  2804. case "keyword":
  2805. case "atom":
  2806. next();
  2807. return tmp.value;
  2808. default:
  2809. unexpected(tmp);
  2810. }
  2811. }
  2812. function as_name() {
  2813. var tmp = S.token;
  2814. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  2815. next();
  2816. return tmp.value;
  2817. }
  2818. function _make_symbol(type) {
  2819. var name = S.token.value;
  2820. return new (name == "this" ? AST_This :
  2821. name == "super" ? AST_Super :
  2822. type)({
  2823. name : String(name),
  2824. start : S.token,
  2825. end : S.token
  2826. });
  2827. }
  2828. function _verify_symbol(sym) {
  2829. var name = sym.name;
  2830. if (is_in_generator() && name == "yield") {
  2831. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2832. }
  2833. if (S.input.has_directive("use strict")) {
  2834. if (name == "yield") {
  2835. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2836. }
  2837. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2838. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2839. }
  2840. }
  2841. }
  2842. function as_symbol(type, noerror) {
  2843. if (!is("name")) {
  2844. if (!noerror) croak("Name expected");
  2845. return null;
  2846. }
  2847. var sym = _make_symbol(type);
  2848. _verify_symbol(sym);
  2849. next();
  2850. return sym;
  2851. }
  2852. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2853. function annotate(node) {
  2854. var start = node.start;
  2855. var comments = start.comments_before;
  2856. const comments_outside_parens = outer_comments_before_counts.get(start);
  2857. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2858. while (--i >= 0) {
  2859. var comment = comments[i];
  2860. if (/[@#]__/.test(comment.value)) {
  2861. if (/[@#]__PURE__/.test(comment.value)) {
  2862. set_annotation(node, _PURE);
  2863. break;
  2864. }
  2865. if (/[@#]__INLINE__/.test(comment.value)) {
  2866. set_annotation(node, _INLINE);
  2867. break;
  2868. }
  2869. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2870. set_annotation(node, _NOINLINE);
  2871. break;
  2872. }
  2873. }
  2874. }
  2875. }
  2876. var subscripts = function(expr, allow_calls, is_chain) {
  2877. var start = expr.start;
  2878. if (is("punc", ".")) {
  2879. next();
  2880. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2881. return subscripts(new AST_DotVariant({
  2882. start : start,
  2883. expression : expr,
  2884. optional : false,
  2885. property : as_name(),
  2886. end : prev()
  2887. }), allow_calls, is_chain);
  2888. }
  2889. if (is("punc", "[")) {
  2890. next();
  2891. var prop = expression(true);
  2892. expect("]");
  2893. return subscripts(new AST_Sub({
  2894. start : start,
  2895. expression : expr,
  2896. optional : false,
  2897. property : prop,
  2898. end : prev()
  2899. }), allow_calls, is_chain);
  2900. }
  2901. if (allow_calls && is("punc", "(")) {
  2902. next();
  2903. var call = new AST_Call({
  2904. start : start,
  2905. expression : expr,
  2906. optional : false,
  2907. args : call_args(),
  2908. end : prev()
  2909. });
  2910. annotate(call);
  2911. return subscripts(call, true, is_chain);
  2912. }
  2913. if (is("punc", "?.")) {
  2914. next();
  2915. let chain_contents;
  2916. if (allow_calls && is("punc", "(")) {
  2917. next();
  2918. const call = new AST_Call({
  2919. start,
  2920. optional: true,
  2921. expression: expr,
  2922. args: call_args(),
  2923. end: prev()
  2924. });
  2925. annotate(call);
  2926. chain_contents = subscripts(call, true, true);
  2927. } else if (is("name") || is("privatename")) {
  2928. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2929. chain_contents = subscripts(new AST_DotVariant({
  2930. start,
  2931. expression: expr,
  2932. optional: true,
  2933. property: as_name(),
  2934. end: prev()
  2935. }), allow_calls, true);
  2936. } else if (is("punc", "[")) {
  2937. next();
  2938. const property = expression(true);
  2939. expect("]");
  2940. chain_contents = subscripts(new AST_Sub({
  2941. start,
  2942. expression: expr,
  2943. optional: true,
  2944. property,
  2945. end: prev()
  2946. }), allow_calls, true);
  2947. }
  2948. if (!chain_contents) unexpected();
  2949. if (chain_contents instanceof AST_Chain) return chain_contents;
  2950. return new AST_Chain({
  2951. start,
  2952. expression: chain_contents,
  2953. end: prev()
  2954. });
  2955. }
  2956. if (is("template_head")) {
  2957. if (is_chain) {
  2958. // a?.b`c` is a syntax error
  2959. unexpected();
  2960. }
  2961. return subscripts(new AST_PrefixedTemplateString({
  2962. start: start,
  2963. prefix: expr,
  2964. template_string: template_string(),
  2965. end: prev()
  2966. }), allow_calls);
  2967. }
  2968. return expr;
  2969. };
  2970. function call_args() {
  2971. var args = [];
  2972. while (!is("punc", ")")) {
  2973. if (is("expand", "...")) {
  2974. next();
  2975. args.push(new AST_Expansion({
  2976. start: prev(),
  2977. expression: expression(false),
  2978. end: prev()
  2979. }));
  2980. } else {
  2981. args.push(expression(false));
  2982. }
  2983. if (!is("punc", ")")) {
  2984. expect(",");
  2985. }
  2986. }
  2987. next();
  2988. return args;
  2989. }
  2990. var maybe_unary = function(allow_calls, allow_arrows) {
  2991. var start = S.token;
  2992. if (start.type == "name" && start.value == "await" && can_await()) {
  2993. next();
  2994. return _await_expression();
  2995. }
  2996. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  2997. next();
  2998. handle_regexp();
  2999. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  3000. ex.start = start;
  3001. ex.end = prev();
  3002. return ex;
  3003. }
  3004. var val = expr_atom(allow_calls, allow_arrows);
  3005. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  3006. if (val instanceof AST_Arrow) unexpected();
  3007. val = make_unary(AST_UnaryPostfix, S.token, val);
  3008. val.start = start;
  3009. val.end = S.token;
  3010. next();
  3011. }
  3012. return val;
  3013. };
  3014. function make_unary(ctor, token, expr) {
  3015. var op = token.value;
  3016. switch (op) {
  3017. case "++":
  3018. case "--":
  3019. if (!is_assignable(expr))
  3020. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  3021. break;
  3022. case "delete":
  3023. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3024. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3025. break;
  3026. }
  3027. return new ctor({ operator: op, expression: expr });
  3028. }
  3029. var expr_op = function(left, min_prec, no_in) {
  3030. var op = is("operator") ? S.token.value : null;
  3031. if (op == "in" && no_in) op = null;
  3032. if (op == "**" && left instanceof AST_UnaryPrefix
  3033. /* unary token in front not allowed - parenthesis required */
  3034. && !is_token(left.start, "punc", "(")
  3035. && left.operator !== "--" && left.operator !== "++")
  3036. unexpected(left.start);
  3037. var prec = op != null ? PRECEDENCE[op] : null;
  3038. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3039. next();
  3040. var right = expr_op(maybe_unary(true), prec, no_in);
  3041. return expr_op(new AST_Binary({
  3042. start : left.start,
  3043. left : left,
  3044. operator : op,
  3045. right : right,
  3046. end : right.end
  3047. }), min_prec, no_in);
  3048. }
  3049. return left;
  3050. };
  3051. function expr_ops(no_in) {
  3052. return expr_op(maybe_unary(true, true), 0, no_in);
  3053. }
  3054. var maybe_conditional = function(no_in) {
  3055. var start = S.token;
  3056. var expr = expr_ops(no_in);
  3057. if (is("operator", "?")) {
  3058. next();
  3059. var yes = expression(false);
  3060. expect(":");
  3061. return new AST_Conditional({
  3062. start : start,
  3063. condition : expr,
  3064. consequent : yes,
  3065. alternative : expression(false, no_in),
  3066. end : prev()
  3067. });
  3068. }
  3069. return expr;
  3070. };
  3071. function is_assignable(expr) {
  3072. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3073. }
  3074. function to_destructuring(node) {
  3075. if (node instanceof AST_Object) {
  3076. node = new AST_Destructuring({
  3077. start: node.start,
  3078. names: node.properties.map(to_destructuring),
  3079. is_array: false,
  3080. end: node.end
  3081. });
  3082. } else if (node instanceof AST_Array) {
  3083. var names = [];
  3084. for (var i = 0; i < node.elements.length; i++) {
  3085. // Only allow expansion as last element
  3086. if (node.elements[i] instanceof AST_Expansion) {
  3087. if (i + 1 !== node.elements.length) {
  3088. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3089. }
  3090. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3091. }
  3092. names.push(to_destructuring(node.elements[i]));
  3093. }
  3094. node = new AST_Destructuring({
  3095. start: node.start,
  3096. names: names,
  3097. is_array: true,
  3098. end: node.end
  3099. });
  3100. } else if (node instanceof AST_ObjectProperty) {
  3101. node.value = to_destructuring(node.value);
  3102. } else if (node instanceof AST_Assign) {
  3103. node = new AST_DefaultAssign({
  3104. start: node.start,
  3105. left: node.left,
  3106. operator: "=",
  3107. right: node.right,
  3108. end: node.end
  3109. });
  3110. }
  3111. return node;
  3112. }
  3113. // In ES6, AssignmentExpression can also be an ArrowFunction
  3114. var maybe_assign = function(no_in) {
  3115. handle_regexp();
  3116. var start = S.token;
  3117. if (start.type == "name" && start.value == "yield") {
  3118. if (is_in_generator()) {
  3119. next();
  3120. return _yield_expression();
  3121. } else if (S.input.has_directive("use strict")) {
  3122. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3123. }
  3124. }
  3125. var left = maybe_conditional(no_in);
  3126. var val = S.token.value;
  3127. if (is("operator") && ASSIGNMENT.has(val)) {
  3128. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3129. next();
  3130. return new AST_Assign({
  3131. start : start,
  3132. left : left,
  3133. operator : val,
  3134. right : maybe_assign(no_in),
  3135. logical : LOGICAL_ASSIGNMENT.has(val),
  3136. end : prev()
  3137. });
  3138. }
  3139. croak("Invalid assignment");
  3140. }
  3141. return left;
  3142. };
  3143. var expression = function(commas, no_in) {
  3144. var start = S.token;
  3145. var exprs = [];
  3146. while (true) {
  3147. exprs.push(maybe_assign(no_in));
  3148. if (!commas || !is("punc", ",")) break;
  3149. next();
  3150. commas = true;
  3151. }
  3152. return exprs.length == 1 ? exprs[0] : new AST_Sequence({
  3153. start : start,
  3154. expressions : exprs,
  3155. end : peek()
  3156. });
  3157. };
  3158. function in_loop(cont) {
  3159. ++S.in_loop;
  3160. var ret = cont();
  3161. --S.in_loop;
  3162. return ret;
  3163. }
  3164. if (options.expression) {
  3165. return expression(true);
  3166. }
  3167. return (function parse_toplevel() {
  3168. var start = S.token;
  3169. var body = [];
  3170. S.input.push_directives_stack();
  3171. if (options.module) S.input.add_directive("use strict");
  3172. while (!is("eof")) {
  3173. body.push(statement());
  3174. }
  3175. S.input.pop_directives_stack();
  3176. var end = prev();
  3177. var toplevel = options.toplevel;
  3178. if (toplevel) {
  3179. toplevel.body = toplevel.body.concat(body);
  3180. toplevel.end = end;
  3181. } else {
  3182. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3183. }
  3184. TEMPLATE_RAWS = new Map();
  3185. return toplevel;
  3186. })();
  3187. }
  3188. /***********************************************************************
  3189. A JavaScript tokenizer / parser / beautifier / compressor.
  3190. https://github.com/mishoo/UglifyJS2
  3191. -------------------------------- (C) ---------------------------------
  3192. Author: Mihai Bazon
  3193. <mihai.bazon@gmail.com>
  3194. http://mihai.bazon.net/blog
  3195. Distributed under the BSD license:
  3196. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3197. Redistribution and use in source and binary forms, with or without
  3198. modification, are permitted provided that the following conditions
  3199. are met:
  3200. * Redistributions of source code must retain the above
  3201. copyright notice, this list of conditions and the following
  3202. disclaimer.
  3203. * Redistributions in binary form must reproduce the above
  3204. copyright notice, this list of conditions and the following
  3205. disclaimer in the documentation and/or other materials
  3206. provided with the distribution.
  3207. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3208. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3209. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3210. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3211. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3212. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3213. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3214. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3215. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3216. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3217. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3218. SUCH DAMAGE.
  3219. ***********************************************************************/
  3220. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  3221. if (!props) props = [];
  3222. else props = props.split(/\s+/);
  3223. var self_props = props;
  3224. if (base && base.PROPS)
  3225. props = props.concat(base.PROPS);
  3226. const proto = base && Object.create(base.prototype);
  3227. if (proto) {
  3228. ctor.prototype = proto;
  3229. ctor.BASE = base;
  3230. }
  3231. if (base) base.SUBCLASSES.push(ctor);
  3232. ctor.prototype.CTOR = ctor;
  3233. ctor.prototype.constructor = ctor;
  3234. ctor.PROPS = props || null;
  3235. ctor.SELF_PROPS = self_props;
  3236. ctor.SUBCLASSES = [];
  3237. if (type) {
  3238. ctor.prototype.TYPE = ctor.TYPE = type;
  3239. }
  3240. if (methods) for (let i in methods) if (HOP(methods, i)) {
  3241. if (i[0] === "$") {
  3242. ctor[i.substr(1)] = methods[i];
  3243. } else {
  3244. ctor.prototype[i] = methods[i];
  3245. }
  3246. }
  3247. ctor.DEFMETHOD = function(name, method) {
  3248. this.prototype[name] = method;
  3249. };
  3250. return ctor;
  3251. }
  3252. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  3253. const set_tok_flag = (tok, flag, truth) => {
  3254. if (truth) {
  3255. tok.flags |= flag;
  3256. } else {
  3257. tok.flags &= ~flag;
  3258. }
  3259. };
  3260. const TOK_FLAG_NLB = 0b0001;
  3261. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  3262. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  3263. const TOK_FLAG_TEMPLATE_END = 0b1000;
  3264. class AST_Token {
  3265. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  3266. this.flags = (nlb ? 1 : 0);
  3267. this.type = type;
  3268. this.value = value;
  3269. this.line = line;
  3270. this.col = col;
  3271. this.pos = pos;
  3272. this.comments_before = comments_before;
  3273. this.comments_after = comments_after;
  3274. this.file = file;
  3275. Object.seal(this);
  3276. }
  3277. get nlb() {
  3278. return has_tok_flag(this, TOK_FLAG_NLB);
  3279. }
  3280. set nlb(new_nlb) {
  3281. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  3282. }
  3283. get quote() {
  3284. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  3285. ? ""
  3286. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  3287. }
  3288. set quote(quote_type) {
  3289. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  3290. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  3291. }
  3292. get template_end() {
  3293. return has_tok_flag(this, TOK_FLAG_TEMPLATE_END);
  3294. }
  3295. set template_end(new_template_end) {
  3296. set_tok_flag(this, TOK_FLAG_TEMPLATE_END, new_template_end);
  3297. }
  3298. }
  3299. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  3300. if (props) {
  3301. this.start = props.start;
  3302. this.end = props.end;
  3303. }
  3304. this.flags = 0;
  3305. }, {
  3306. _clone: function(deep) {
  3307. if (deep) {
  3308. var self = this.clone();
  3309. return self.transform(new TreeTransformer(function(node) {
  3310. if (node !== self) {
  3311. return node.clone(true);
  3312. }
  3313. }));
  3314. }
  3315. return new this.CTOR(this);
  3316. },
  3317. clone: function(deep) {
  3318. return this._clone(deep);
  3319. },
  3320. $documentation: "Base class of all AST nodes",
  3321. $propdoc: {
  3322. start: "[AST_Token] The first token of this node",
  3323. end: "[AST_Token] The last token of this node"
  3324. },
  3325. _walk: function(visitor) {
  3326. return visitor._visit(this);
  3327. },
  3328. walk: function(visitor) {
  3329. return this._walk(visitor); // not sure the indirection will be any help
  3330. },
  3331. _children_backwards: () => {}
  3332. }, null);
  3333. /* -----[ statements ]----- */
  3334. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  3335. if (props) {
  3336. this.start = props.start;
  3337. this.end = props.end;
  3338. }
  3339. this.flags = 0;
  3340. }, {
  3341. $documentation: "Base class of all statements",
  3342. });
  3343. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  3344. if (props) {
  3345. this.start = props.start;
  3346. this.end = props.end;
  3347. }
  3348. this.flags = 0;
  3349. }, {
  3350. $documentation: "Represents a debugger statement",
  3351. }, AST_Statement);
  3352. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  3353. if (props) {
  3354. this.value = props.value;
  3355. this.quote = props.quote;
  3356. this.start = props.start;
  3357. this.end = props.end;
  3358. }
  3359. this.flags = 0;
  3360. }, {
  3361. $documentation: "Represents a directive, like \"use strict\";",
  3362. $propdoc: {
  3363. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3364. quote: "[string] the original quote character"
  3365. },
  3366. }, AST_Statement);
  3367. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  3368. if (props) {
  3369. this.body = props.body;
  3370. this.start = props.start;
  3371. this.end = props.end;
  3372. }
  3373. this.flags = 0;
  3374. }, {
  3375. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3376. $propdoc: {
  3377. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3378. },
  3379. _walk: function(visitor) {
  3380. return visitor._visit(this, function() {
  3381. this.body._walk(visitor);
  3382. });
  3383. },
  3384. _children_backwards(push) {
  3385. push(this.body);
  3386. }
  3387. }, AST_Statement);
  3388. function walk_body(node, visitor) {
  3389. const body = node.body;
  3390. for (var i = 0, len = body.length; i < len; i++) {
  3391. body[i]._walk(visitor);
  3392. }
  3393. }
  3394. function clone_block_scope(deep) {
  3395. var clone = this._clone(deep);
  3396. if (this.block_scope) {
  3397. clone.block_scope = this.block_scope.clone();
  3398. }
  3399. return clone;
  3400. }
  3401. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  3402. if (props) {
  3403. this.body = props.body;
  3404. this.block_scope = props.block_scope;
  3405. this.start = props.start;
  3406. this.end = props.end;
  3407. }
  3408. this.flags = 0;
  3409. }, {
  3410. $documentation: "A body of statements (usually braced)",
  3411. $propdoc: {
  3412. body: "[AST_Statement*] an array of statements",
  3413. block_scope: "[AST_Scope] the block scope"
  3414. },
  3415. _walk: function(visitor) {
  3416. return visitor._visit(this, function() {
  3417. walk_body(this, visitor);
  3418. });
  3419. },
  3420. _children_backwards(push) {
  3421. let i = this.body.length;
  3422. while (i--) push(this.body[i]);
  3423. },
  3424. clone: clone_block_scope
  3425. }, AST_Statement);
  3426. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  3427. if (props) {
  3428. this.body = props.body;
  3429. this.block_scope = props.block_scope;
  3430. this.start = props.start;
  3431. this.end = props.end;
  3432. }
  3433. this.flags = 0;
  3434. }, {
  3435. $documentation: "A block statement",
  3436. }, AST_Block);
  3437. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  3438. if (props) {
  3439. this.start = props.start;
  3440. this.end = props.end;
  3441. }
  3442. this.flags = 0;
  3443. }, {
  3444. $documentation: "The empty statement (empty block or simply a semicolon)"
  3445. }, AST_Statement);
  3446. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  3447. if (props) {
  3448. this.body = props.body;
  3449. this.start = props.start;
  3450. this.end = props.end;
  3451. }
  3452. this.flags = 0;
  3453. }, {
  3454. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3455. $propdoc: {
  3456. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3457. }
  3458. }, AST_Statement);
  3459. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  3460. if (props) {
  3461. this.label = props.label;
  3462. this.body = props.body;
  3463. this.start = props.start;
  3464. this.end = props.end;
  3465. }
  3466. this.flags = 0;
  3467. }, {
  3468. $documentation: "Statement with a label",
  3469. $propdoc: {
  3470. label: "[AST_Label] a label definition"
  3471. },
  3472. _walk: function(visitor) {
  3473. return visitor._visit(this, function() {
  3474. this.label._walk(visitor);
  3475. this.body._walk(visitor);
  3476. });
  3477. },
  3478. _children_backwards(push) {
  3479. push(this.body);
  3480. push(this.label);
  3481. },
  3482. clone: function(deep) {
  3483. var node = this._clone(deep);
  3484. if (deep) {
  3485. var label = node.label;
  3486. var def = this.label;
  3487. node.walk(new TreeWalker(function(node) {
  3488. if (node instanceof AST_LoopControl
  3489. && node.label && node.label.thedef === def) {
  3490. node.label.thedef = label;
  3491. label.references.push(node);
  3492. }
  3493. }));
  3494. }
  3495. return node;
  3496. }
  3497. }, AST_StatementWithBody);
  3498. var AST_IterationStatement = DEFNODE(
  3499. "IterationStatement",
  3500. "block_scope",
  3501. function AST_IterationStatement(props) {
  3502. if (props) {
  3503. this.block_scope = props.block_scope;
  3504. this.body = props.body;
  3505. this.start = props.start;
  3506. this.end = props.end;
  3507. }
  3508. this.flags = 0;
  3509. },
  3510. {
  3511. $documentation: "Internal class. All loops inherit from it.",
  3512. $propdoc: {
  3513. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3514. },
  3515. clone: clone_block_scope
  3516. },
  3517. AST_StatementWithBody
  3518. );
  3519. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  3520. if (props) {
  3521. this.condition = props.condition;
  3522. this.block_scope = props.block_scope;
  3523. this.body = props.body;
  3524. this.start = props.start;
  3525. this.end = props.end;
  3526. }
  3527. this.flags = 0;
  3528. }, {
  3529. $documentation: "Base class for do/while statements",
  3530. $propdoc: {
  3531. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3532. }
  3533. }, AST_IterationStatement);
  3534. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  3535. if (props) {
  3536. this.condition = props.condition;
  3537. this.block_scope = props.block_scope;
  3538. this.body = props.body;
  3539. this.start = props.start;
  3540. this.end = props.end;
  3541. }
  3542. this.flags = 0;
  3543. }, {
  3544. $documentation: "A `do` statement",
  3545. _walk: function(visitor) {
  3546. return visitor._visit(this, function() {
  3547. this.body._walk(visitor);
  3548. this.condition._walk(visitor);
  3549. });
  3550. },
  3551. _children_backwards(push) {
  3552. push(this.condition);
  3553. push(this.body);
  3554. }
  3555. }, AST_DWLoop);
  3556. var AST_While = DEFNODE("While", null, function AST_While(props) {
  3557. if (props) {
  3558. this.condition = props.condition;
  3559. this.block_scope = props.block_scope;
  3560. this.body = props.body;
  3561. this.start = props.start;
  3562. this.end = props.end;
  3563. }
  3564. this.flags = 0;
  3565. }, {
  3566. $documentation: "A `while` statement",
  3567. _walk: function(visitor) {
  3568. return visitor._visit(this, function() {
  3569. this.condition._walk(visitor);
  3570. this.body._walk(visitor);
  3571. });
  3572. },
  3573. _children_backwards(push) {
  3574. push(this.body);
  3575. push(this.condition);
  3576. },
  3577. }, AST_DWLoop);
  3578. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  3579. if (props) {
  3580. this.init = props.init;
  3581. this.condition = props.condition;
  3582. this.step = props.step;
  3583. this.block_scope = props.block_scope;
  3584. this.body = props.body;
  3585. this.start = props.start;
  3586. this.end = props.end;
  3587. }
  3588. this.flags = 0;
  3589. }, {
  3590. $documentation: "A `for` statement",
  3591. $propdoc: {
  3592. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3593. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3594. step: "[AST_Node?] the `for` update clause, or null if empty"
  3595. },
  3596. _walk: function(visitor) {
  3597. return visitor._visit(this, function() {
  3598. if (this.init) this.init._walk(visitor);
  3599. if (this.condition) this.condition._walk(visitor);
  3600. if (this.step) this.step._walk(visitor);
  3601. this.body._walk(visitor);
  3602. });
  3603. },
  3604. _children_backwards(push) {
  3605. push(this.body);
  3606. if (this.step) push(this.step);
  3607. if (this.condition) push(this.condition);
  3608. if (this.init) push(this.init);
  3609. },
  3610. }, AST_IterationStatement);
  3611. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  3612. if (props) {
  3613. this.init = props.init;
  3614. this.object = props.object;
  3615. this.block_scope = props.block_scope;
  3616. this.body = props.body;
  3617. this.start = props.start;
  3618. this.end = props.end;
  3619. }
  3620. this.flags = 0;
  3621. }, {
  3622. $documentation: "A `for ... in` statement",
  3623. $propdoc: {
  3624. init: "[AST_Node] the `for/in` initialization code",
  3625. object: "[AST_Node] the object that we're looping through"
  3626. },
  3627. _walk: function(visitor) {
  3628. return visitor._visit(this, function() {
  3629. this.init._walk(visitor);
  3630. this.object._walk(visitor);
  3631. this.body._walk(visitor);
  3632. });
  3633. },
  3634. _children_backwards(push) {
  3635. push(this.body);
  3636. if (this.object) push(this.object);
  3637. if (this.init) push(this.init);
  3638. },
  3639. }, AST_IterationStatement);
  3640. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  3641. if (props) {
  3642. this.await = props.await;
  3643. this.init = props.init;
  3644. this.object = props.object;
  3645. this.block_scope = props.block_scope;
  3646. this.body = props.body;
  3647. this.start = props.start;
  3648. this.end = props.end;
  3649. }
  3650. this.flags = 0;
  3651. }, {
  3652. $documentation: "A `for ... of` statement",
  3653. }, AST_ForIn);
  3654. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  3655. if (props) {
  3656. this.expression = props.expression;
  3657. this.body = props.body;
  3658. this.start = props.start;
  3659. this.end = props.end;
  3660. }
  3661. this.flags = 0;
  3662. }, {
  3663. $documentation: "A `with` statement",
  3664. $propdoc: {
  3665. expression: "[AST_Node] the `with` expression"
  3666. },
  3667. _walk: function(visitor) {
  3668. return visitor._visit(this, function() {
  3669. this.expression._walk(visitor);
  3670. this.body._walk(visitor);
  3671. });
  3672. },
  3673. _children_backwards(push) {
  3674. push(this.body);
  3675. push(this.expression);
  3676. },
  3677. }, AST_StatementWithBody);
  3678. /* -----[ scope and functions ]----- */
  3679. var AST_Scope = DEFNODE(
  3680. "Scope",
  3681. "variables uses_with uses_eval parent_scope enclosed cname",
  3682. function AST_Scope(props) {
  3683. if (props) {
  3684. this.variables = props.variables;
  3685. this.uses_with = props.uses_with;
  3686. this.uses_eval = props.uses_eval;
  3687. this.parent_scope = props.parent_scope;
  3688. this.enclosed = props.enclosed;
  3689. this.cname = props.cname;
  3690. this.body = props.body;
  3691. this.block_scope = props.block_scope;
  3692. this.start = props.start;
  3693. this.end = props.end;
  3694. }
  3695. this.flags = 0;
  3696. },
  3697. {
  3698. $documentation: "Base class for all statements introducing a lexical scope",
  3699. $propdoc: {
  3700. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3701. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3702. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3703. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3704. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3705. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3706. },
  3707. get_defun_scope: function() {
  3708. var self = this;
  3709. while (self.is_block_scope()) {
  3710. self = self.parent_scope;
  3711. }
  3712. return self;
  3713. },
  3714. clone: function(deep, toplevel) {
  3715. var node = this._clone(deep);
  3716. if (deep && this.variables && toplevel && !this._block_scope) {
  3717. node.figure_out_scope({}, {
  3718. toplevel: toplevel,
  3719. parent_scope: this.parent_scope
  3720. });
  3721. } else {
  3722. if (this.variables) node.variables = new Map(this.variables);
  3723. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3724. if (this._block_scope) node._block_scope = this._block_scope;
  3725. }
  3726. return node;
  3727. },
  3728. pinned: function() {
  3729. return this.uses_eval || this.uses_with;
  3730. }
  3731. },
  3732. AST_Block
  3733. );
  3734. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  3735. if (props) {
  3736. this.globals = props.globals;
  3737. this.variables = props.variables;
  3738. this.uses_with = props.uses_with;
  3739. this.uses_eval = props.uses_eval;
  3740. this.parent_scope = props.parent_scope;
  3741. this.enclosed = props.enclosed;
  3742. this.cname = props.cname;
  3743. this.body = props.body;
  3744. this.block_scope = props.block_scope;
  3745. this.start = props.start;
  3746. this.end = props.end;
  3747. }
  3748. this.flags = 0;
  3749. }, {
  3750. $documentation: "The toplevel scope",
  3751. $propdoc: {
  3752. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3753. },
  3754. wrap_commonjs: function(name) {
  3755. var body = this.body;
  3756. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3757. wrapped_tl = parse(wrapped_tl);
  3758. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3759. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3760. return MAP.splice(body);
  3761. }
  3762. }));
  3763. return wrapped_tl;
  3764. },
  3765. wrap_enclose: function(args_values) {
  3766. if (typeof args_values != "string") args_values = "";
  3767. var index = args_values.indexOf(":");
  3768. if (index < 0) index = args_values.length;
  3769. var body = this.body;
  3770. return parse([
  3771. "(function(",
  3772. args_values.slice(0, index),
  3773. '){"$ORIG"})(',
  3774. args_values.slice(index + 1),
  3775. ")"
  3776. ].join("")).transform(new TreeTransformer(function(node) {
  3777. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3778. return MAP.splice(body);
  3779. }
  3780. }));
  3781. }
  3782. }, AST_Scope);
  3783. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  3784. if (props) {
  3785. this.expression = props.expression;
  3786. this.start = props.start;
  3787. this.end = props.end;
  3788. }
  3789. this.flags = 0;
  3790. }, {
  3791. $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",
  3792. $propdoc: {
  3793. expression: "[AST_Node] the thing to be expanded"
  3794. },
  3795. _walk: function(visitor) {
  3796. return visitor._visit(this, function() {
  3797. this.expression.walk(visitor);
  3798. });
  3799. },
  3800. _children_backwards(push) {
  3801. push(this.expression);
  3802. },
  3803. });
  3804. var AST_Lambda = DEFNODE(
  3805. "Lambda",
  3806. "name argnames uses_arguments is_generator async",
  3807. function AST_Lambda(props) {
  3808. if (props) {
  3809. this.name = props.name;
  3810. this.argnames = props.argnames;
  3811. this.uses_arguments = props.uses_arguments;
  3812. this.is_generator = props.is_generator;
  3813. this.async = props.async;
  3814. this.variables = props.variables;
  3815. this.uses_with = props.uses_with;
  3816. this.uses_eval = props.uses_eval;
  3817. this.parent_scope = props.parent_scope;
  3818. this.enclosed = props.enclosed;
  3819. this.cname = props.cname;
  3820. this.body = props.body;
  3821. this.block_scope = props.block_scope;
  3822. this.start = props.start;
  3823. this.end = props.end;
  3824. }
  3825. this.flags = 0;
  3826. },
  3827. {
  3828. $documentation: "Base class for functions",
  3829. $propdoc: {
  3830. name: "[AST_SymbolDeclaration?] the name of this function",
  3831. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3832. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3833. is_generator: "[boolean] is this a generator method",
  3834. async: "[boolean] is this method async",
  3835. },
  3836. args_as_names: function () {
  3837. var out = [];
  3838. for (var i = 0; i < this.argnames.length; i++) {
  3839. if (this.argnames[i] instanceof AST_Destructuring) {
  3840. out.push(...this.argnames[i].all_symbols());
  3841. } else {
  3842. out.push(this.argnames[i]);
  3843. }
  3844. }
  3845. return out;
  3846. },
  3847. _walk: function(visitor) {
  3848. return visitor._visit(this, function() {
  3849. if (this.name) this.name._walk(visitor);
  3850. var argnames = this.argnames;
  3851. for (var i = 0, len = argnames.length; i < len; i++) {
  3852. argnames[i]._walk(visitor);
  3853. }
  3854. walk_body(this, visitor);
  3855. });
  3856. },
  3857. _children_backwards(push) {
  3858. let i = this.body.length;
  3859. while (i--) push(this.body[i]);
  3860. i = this.argnames.length;
  3861. while (i--) push(this.argnames[i]);
  3862. if (this.name) push(this.name);
  3863. },
  3864. is_braceless() {
  3865. return this.body[0] instanceof AST_Return && this.body[0].value;
  3866. },
  3867. // Default args and expansion don't count, so .argnames.length doesn't cut it
  3868. length_property() {
  3869. let length = 0;
  3870. for (const arg of this.argnames) {
  3871. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  3872. length++;
  3873. }
  3874. }
  3875. return length;
  3876. }
  3877. },
  3878. AST_Scope
  3879. );
  3880. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  3881. if (props) {
  3882. this.name = props.name;
  3883. this.argnames = props.argnames;
  3884. this.uses_arguments = props.uses_arguments;
  3885. this.is_generator = props.is_generator;
  3886. this.async = props.async;
  3887. this.variables = props.variables;
  3888. this.uses_with = props.uses_with;
  3889. this.uses_eval = props.uses_eval;
  3890. this.parent_scope = props.parent_scope;
  3891. this.enclosed = props.enclosed;
  3892. this.cname = props.cname;
  3893. this.body = props.body;
  3894. this.block_scope = props.block_scope;
  3895. this.start = props.start;
  3896. this.end = props.end;
  3897. }
  3898. this.flags = 0;
  3899. }, {
  3900. $documentation: "A setter/getter function. The `name` property is always null."
  3901. }, AST_Lambda);
  3902. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  3903. if (props) {
  3904. this.name = props.name;
  3905. this.argnames = props.argnames;
  3906. this.uses_arguments = props.uses_arguments;
  3907. this.is_generator = props.is_generator;
  3908. this.async = props.async;
  3909. this.variables = props.variables;
  3910. this.uses_with = props.uses_with;
  3911. this.uses_eval = props.uses_eval;
  3912. this.parent_scope = props.parent_scope;
  3913. this.enclosed = props.enclosed;
  3914. this.cname = props.cname;
  3915. this.body = props.body;
  3916. this.block_scope = props.block_scope;
  3917. this.start = props.start;
  3918. this.end = props.end;
  3919. }
  3920. this.flags = 0;
  3921. }, {
  3922. $documentation: "A function expression"
  3923. }, AST_Lambda);
  3924. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  3925. if (props) {
  3926. this.name = props.name;
  3927. this.argnames = props.argnames;
  3928. this.uses_arguments = props.uses_arguments;
  3929. this.is_generator = props.is_generator;
  3930. this.async = props.async;
  3931. this.variables = props.variables;
  3932. this.uses_with = props.uses_with;
  3933. this.uses_eval = props.uses_eval;
  3934. this.parent_scope = props.parent_scope;
  3935. this.enclosed = props.enclosed;
  3936. this.cname = props.cname;
  3937. this.body = props.body;
  3938. this.block_scope = props.block_scope;
  3939. this.start = props.start;
  3940. this.end = props.end;
  3941. }
  3942. this.flags = 0;
  3943. }, {
  3944. $documentation: "An ES6 Arrow function ((a) => b)"
  3945. }, AST_Lambda);
  3946. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  3947. if (props) {
  3948. this.name = props.name;
  3949. this.argnames = props.argnames;
  3950. this.uses_arguments = props.uses_arguments;
  3951. this.is_generator = props.is_generator;
  3952. this.async = props.async;
  3953. this.variables = props.variables;
  3954. this.uses_with = props.uses_with;
  3955. this.uses_eval = props.uses_eval;
  3956. this.parent_scope = props.parent_scope;
  3957. this.enclosed = props.enclosed;
  3958. this.cname = props.cname;
  3959. this.body = props.body;
  3960. this.block_scope = props.block_scope;
  3961. this.start = props.start;
  3962. this.end = props.end;
  3963. }
  3964. this.flags = 0;
  3965. }, {
  3966. $documentation: "A function definition"
  3967. }, AST_Lambda);
  3968. /* -----[ DESTRUCTURING ]----- */
  3969. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  3970. if (props) {
  3971. this.names = props.names;
  3972. this.is_array = props.is_array;
  3973. this.start = props.start;
  3974. this.end = props.end;
  3975. }
  3976. this.flags = 0;
  3977. }, {
  3978. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  3979. $propdoc: {
  3980. "names": "[AST_Node*] Array of properties or elements",
  3981. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  3982. },
  3983. _walk: function(visitor) {
  3984. return visitor._visit(this, function() {
  3985. this.names.forEach(function(name) {
  3986. name._walk(visitor);
  3987. });
  3988. });
  3989. },
  3990. _children_backwards(push) {
  3991. let i = this.names.length;
  3992. while (i--) push(this.names[i]);
  3993. },
  3994. all_symbols: function() {
  3995. var out = [];
  3996. this.walk(new TreeWalker(function (node) {
  3997. if (node instanceof AST_Symbol) {
  3998. out.push(node);
  3999. }
  4000. }));
  4001. return out;
  4002. }
  4003. });
  4004. var AST_PrefixedTemplateString = DEFNODE(
  4005. "PrefixedTemplateString",
  4006. "template_string prefix",
  4007. function AST_PrefixedTemplateString(props) {
  4008. if (props) {
  4009. this.template_string = props.template_string;
  4010. this.prefix = props.prefix;
  4011. this.start = props.start;
  4012. this.end = props.end;
  4013. }
  4014. this.flags = 0;
  4015. },
  4016. {
  4017. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  4018. $propdoc: {
  4019. template_string: "[AST_TemplateString] The template string",
  4020. prefix: "[AST_Node] The prefix, which will get called."
  4021. },
  4022. _walk: function(visitor) {
  4023. return visitor._visit(this, function () {
  4024. this.prefix._walk(visitor);
  4025. this.template_string._walk(visitor);
  4026. });
  4027. },
  4028. _children_backwards(push) {
  4029. push(this.template_string);
  4030. push(this.prefix);
  4031. },
  4032. }
  4033. );
  4034. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  4035. if (props) {
  4036. this.segments = props.segments;
  4037. this.start = props.start;
  4038. this.end = props.end;
  4039. }
  4040. this.flags = 0;
  4041. }, {
  4042. $documentation: "A template string literal",
  4043. $propdoc: {
  4044. 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."
  4045. },
  4046. _walk: function(visitor) {
  4047. return visitor._visit(this, function() {
  4048. this.segments.forEach(function(seg) {
  4049. seg._walk(visitor);
  4050. });
  4051. });
  4052. },
  4053. _children_backwards(push) {
  4054. let i = this.segments.length;
  4055. while (i--) push(this.segments[i]);
  4056. }
  4057. });
  4058. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  4059. if (props) {
  4060. this.value = props.value;
  4061. this.raw = props.raw;
  4062. this.start = props.start;
  4063. this.end = props.end;
  4064. }
  4065. this.flags = 0;
  4066. }, {
  4067. $documentation: "A segment of a template string literal",
  4068. $propdoc: {
  4069. value: "Content of the segment",
  4070. raw: "Raw source of the segment",
  4071. }
  4072. });
  4073. /* -----[ JUMPS ]----- */
  4074. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  4075. if (props) {
  4076. this.start = props.start;
  4077. this.end = props.end;
  4078. }
  4079. this.flags = 0;
  4080. }, {
  4081. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  4082. }, AST_Statement);
  4083. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  4084. if (props) {
  4085. this.value = props.value;
  4086. this.start = props.start;
  4087. this.end = props.end;
  4088. }
  4089. this.flags = 0;
  4090. }, {
  4091. $documentation: "Base class for “exits” (`return` and `throw`)",
  4092. $propdoc: {
  4093. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  4094. },
  4095. _walk: function(visitor) {
  4096. return visitor._visit(this, this.value && function() {
  4097. this.value._walk(visitor);
  4098. });
  4099. },
  4100. _children_backwards(push) {
  4101. if (this.value) push(this.value);
  4102. },
  4103. }, AST_Jump);
  4104. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  4105. if (props) {
  4106. this.value = props.value;
  4107. this.start = props.start;
  4108. this.end = props.end;
  4109. }
  4110. this.flags = 0;
  4111. }, {
  4112. $documentation: "A `return` statement"
  4113. }, AST_Exit);
  4114. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  4115. if (props) {
  4116. this.value = props.value;
  4117. this.start = props.start;
  4118. this.end = props.end;
  4119. }
  4120. this.flags = 0;
  4121. }, {
  4122. $documentation: "A `throw` statement"
  4123. }, AST_Exit);
  4124. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  4125. if (props) {
  4126. this.label = props.label;
  4127. this.start = props.start;
  4128. this.end = props.end;
  4129. }
  4130. this.flags = 0;
  4131. }, {
  4132. $documentation: "Base class for loop control statements (`break` and `continue`)",
  4133. $propdoc: {
  4134. label: "[AST_LabelRef?] the label, or null if none",
  4135. },
  4136. _walk: function(visitor) {
  4137. return visitor._visit(this, this.label && function() {
  4138. this.label._walk(visitor);
  4139. });
  4140. },
  4141. _children_backwards(push) {
  4142. if (this.label) push(this.label);
  4143. },
  4144. }, AST_Jump);
  4145. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  4146. if (props) {
  4147. this.label = props.label;
  4148. this.start = props.start;
  4149. this.end = props.end;
  4150. }
  4151. this.flags = 0;
  4152. }, {
  4153. $documentation: "A `break` statement"
  4154. }, AST_LoopControl);
  4155. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  4156. if (props) {
  4157. this.label = props.label;
  4158. this.start = props.start;
  4159. this.end = props.end;
  4160. }
  4161. this.flags = 0;
  4162. }, {
  4163. $documentation: "A `continue` statement"
  4164. }, AST_LoopControl);
  4165. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  4166. if (props) {
  4167. this.expression = props.expression;
  4168. this.start = props.start;
  4169. this.end = props.end;
  4170. }
  4171. this.flags = 0;
  4172. }, {
  4173. $documentation: "An `await` statement",
  4174. $propdoc: {
  4175. expression: "[AST_Node] the mandatory expression being awaited",
  4176. },
  4177. _walk: function(visitor) {
  4178. return visitor._visit(this, function() {
  4179. this.expression._walk(visitor);
  4180. });
  4181. },
  4182. _children_backwards(push) {
  4183. push(this.expression);
  4184. },
  4185. });
  4186. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  4187. if (props) {
  4188. this.expression = props.expression;
  4189. this.is_star = props.is_star;
  4190. this.start = props.start;
  4191. this.end = props.end;
  4192. }
  4193. this.flags = 0;
  4194. }, {
  4195. $documentation: "A `yield` statement",
  4196. $propdoc: {
  4197. 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",
  4198. is_star: "[Boolean] Whether this is a yield or yield* statement"
  4199. },
  4200. _walk: function(visitor) {
  4201. return visitor._visit(this, this.expression && function() {
  4202. this.expression._walk(visitor);
  4203. });
  4204. },
  4205. _children_backwards(push) {
  4206. if (this.expression) push(this.expression);
  4207. }
  4208. });
  4209. /* -----[ IF ]----- */
  4210. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  4211. if (props) {
  4212. this.condition = props.condition;
  4213. this.alternative = props.alternative;
  4214. this.body = props.body;
  4215. this.start = props.start;
  4216. this.end = props.end;
  4217. }
  4218. this.flags = 0;
  4219. }, {
  4220. $documentation: "A `if` statement",
  4221. $propdoc: {
  4222. condition: "[AST_Node] the `if` condition",
  4223. alternative: "[AST_Statement?] the `else` part, or null if not present"
  4224. },
  4225. _walk: function(visitor) {
  4226. return visitor._visit(this, function() {
  4227. this.condition._walk(visitor);
  4228. this.body._walk(visitor);
  4229. if (this.alternative) this.alternative._walk(visitor);
  4230. });
  4231. },
  4232. _children_backwards(push) {
  4233. if (this.alternative) {
  4234. push(this.alternative);
  4235. }
  4236. push(this.body);
  4237. push(this.condition);
  4238. }
  4239. }, AST_StatementWithBody);
  4240. /* -----[ SWITCH ]----- */
  4241. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  4242. if (props) {
  4243. this.expression = props.expression;
  4244. this.body = props.body;
  4245. this.block_scope = props.block_scope;
  4246. this.start = props.start;
  4247. this.end = props.end;
  4248. }
  4249. this.flags = 0;
  4250. }, {
  4251. $documentation: "A `switch` statement",
  4252. $propdoc: {
  4253. expression: "[AST_Node] the `switch` “discriminant”"
  4254. },
  4255. _walk: function(visitor) {
  4256. return visitor._visit(this, function() {
  4257. this.expression._walk(visitor);
  4258. walk_body(this, visitor);
  4259. });
  4260. },
  4261. _children_backwards(push) {
  4262. let i = this.body.length;
  4263. while (i--) push(this.body[i]);
  4264. push(this.expression);
  4265. }
  4266. }, AST_Block);
  4267. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  4268. if (props) {
  4269. this.body = props.body;
  4270. this.block_scope = props.block_scope;
  4271. this.start = props.start;
  4272. this.end = props.end;
  4273. }
  4274. this.flags = 0;
  4275. }, {
  4276. $documentation: "Base class for `switch` branches",
  4277. }, AST_Block);
  4278. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  4279. if (props) {
  4280. this.body = props.body;
  4281. this.block_scope = props.block_scope;
  4282. this.start = props.start;
  4283. this.end = props.end;
  4284. }
  4285. this.flags = 0;
  4286. }, {
  4287. $documentation: "A `default` switch branch",
  4288. }, AST_SwitchBranch);
  4289. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  4290. if (props) {
  4291. this.expression = props.expression;
  4292. this.body = props.body;
  4293. this.block_scope = props.block_scope;
  4294. this.start = props.start;
  4295. this.end = props.end;
  4296. }
  4297. this.flags = 0;
  4298. }, {
  4299. $documentation: "A `case` switch branch",
  4300. $propdoc: {
  4301. expression: "[AST_Node] the `case` expression"
  4302. },
  4303. _walk: function(visitor) {
  4304. return visitor._visit(this, function() {
  4305. this.expression._walk(visitor);
  4306. walk_body(this, visitor);
  4307. });
  4308. },
  4309. _children_backwards(push) {
  4310. let i = this.body.length;
  4311. while (i--) push(this.body[i]);
  4312. push(this.expression);
  4313. },
  4314. }, AST_SwitchBranch);
  4315. /* -----[ EXCEPTIONS ]----- */
  4316. var AST_Try = DEFNODE("Try", "bcatch bfinally", function AST_Try(props) {
  4317. if (props) {
  4318. this.bcatch = props.bcatch;
  4319. this.bfinally = props.bfinally;
  4320. this.body = props.body;
  4321. this.block_scope = props.block_scope;
  4322. this.start = props.start;
  4323. this.end = props.end;
  4324. }
  4325. this.flags = 0;
  4326. }, {
  4327. $documentation: "A `try` statement",
  4328. $propdoc: {
  4329. bcatch: "[AST_Catch?] the catch block, or null if not present",
  4330. bfinally: "[AST_Finally?] the finally block, or null if not present"
  4331. },
  4332. _walk: function(visitor) {
  4333. return visitor._visit(this, function() {
  4334. walk_body(this, visitor);
  4335. if (this.bcatch) this.bcatch._walk(visitor);
  4336. if (this.bfinally) this.bfinally._walk(visitor);
  4337. });
  4338. },
  4339. _children_backwards(push) {
  4340. if (this.bfinally) push(this.bfinally);
  4341. if (this.bcatch) push(this.bcatch);
  4342. let i = this.body.length;
  4343. while (i--) push(this.body[i]);
  4344. },
  4345. }, AST_Block);
  4346. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  4347. if (props) {
  4348. this.argname = props.argname;
  4349. this.body = props.body;
  4350. this.block_scope = props.block_scope;
  4351. this.start = props.start;
  4352. this.end = props.end;
  4353. }
  4354. this.flags = 0;
  4355. }, {
  4356. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  4357. $propdoc: {
  4358. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  4359. },
  4360. _walk: function(visitor) {
  4361. return visitor._visit(this, function() {
  4362. if (this.argname) this.argname._walk(visitor);
  4363. walk_body(this, visitor);
  4364. });
  4365. },
  4366. _children_backwards(push) {
  4367. let i = this.body.length;
  4368. while (i--) push(this.body[i]);
  4369. if (this.argname) push(this.argname);
  4370. },
  4371. }, AST_Block);
  4372. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  4373. if (props) {
  4374. this.body = props.body;
  4375. this.block_scope = props.block_scope;
  4376. this.start = props.start;
  4377. this.end = props.end;
  4378. }
  4379. this.flags = 0;
  4380. }, {
  4381. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  4382. }, AST_Block);
  4383. /* -----[ VAR/CONST ]----- */
  4384. var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
  4385. if (props) {
  4386. this.definitions = props.definitions;
  4387. this.start = props.start;
  4388. this.end = props.end;
  4389. }
  4390. this.flags = 0;
  4391. }, {
  4392. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  4393. $propdoc: {
  4394. definitions: "[AST_VarDef*] array of variable definitions"
  4395. },
  4396. _walk: function(visitor) {
  4397. return visitor._visit(this, function() {
  4398. var definitions = this.definitions;
  4399. for (var i = 0, len = definitions.length; i < len; i++) {
  4400. definitions[i]._walk(visitor);
  4401. }
  4402. });
  4403. },
  4404. _children_backwards(push) {
  4405. let i = this.definitions.length;
  4406. while (i--) push(this.definitions[i]);
  4407. },
  4408. }, AST_Statement);
  4409. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  4410. if (props) {
  4411. this.definitions = props.definitions;
  4412. this.start = props.start;
  4413. this.end = props.end;
  4414. }
  4415. this.flags = 0;
  4416. }, {
  4417. $documentation: "A `var` statement"
  4418. }, AST_Definitions);
  4419. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  4420. if (props) {
  4421. this.definitions = props.definitions;
  4422. this.start = props.start;
  4423. this.end = props.end;
  4424. }
  4425. this.flags = 0;
  4426. }, {
  4427. $documentation: "A `let` statement"
  4428. }, AST_Definitions);
  4429. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  4430. if (props) {
  4431. this.definitions = props.definitions;
  4432. this.start = props.start;
  4433. this.end = props.end;
  4434. }
  4435. this.flags = 0;
  4436. }, {
  4437. $documentation: "A `const` statement"
  4438. }, AST_Definitions);
  4439. var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
  4440. if (props) {
  4441. this.name = props.name;
  4442. this.value = props.value;
  4443. this.start = props.start;
  4444. this.end = props.end;
  4445. }
  4446. this.flags = 0;
  4447. }, {
  4448. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  4449. $propdoc: {
  4450. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  4451. value: "[AST_Node?] initializer, or null of there's no initializer"
  4452. },
  4453. _walk: function(visitor) {
  4454. return visitor._visit(this, function() {
  4455. this.name._walk(visitor);
  4456. if (this.value) this.value._walk(visitor);
  4457. });
  4458. },
  4459. _children_backwards(push) {
  4460. if (this.value) push(this.value);
  4461. push(this.name);
  4462. },
  4463. });
  4464. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  4465. if (props) {
  4466. this.foreign_name = props.foreign_name;
  4467. this.name = props.name;
  4468. this.start = props.start;
  4469. this.end = props.end;
  4470. }
  4471. this.flags = 0;
  4472. }, {
  4473. $documentation: "The part of the export/import statement that declare names from a module.",
  4474. $propdoc: {
  4475. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  4476. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  4477. },
  4478. _walk: function (visitor) {
  4479. return visitor._visit(this, function() {
  4480. this.foreign_name._walk(visitor);
  4481. this.name._walk(visitor);
  4482. });
  4483. },
  4484. _children_backwards(push) {
  4485. push(this.name);
  4486. push(this.foreign_name);
  4487. },
  4488. });
  4489. var AST_Import = DEFNODE(
  4490. "Import",
  4491. "imported_name imported_names module_name assert_clause",
  4492. function AST_Import(props) {
  4493. if (props) {
  4494. this.imported_name = props.imported_name;
  4495. this.imported_names = props.imported_names;
  4496. this.module_name = props.module_name;
  4497. this.assert_clause = props.assert_clause;
  4498. this.start = props.start;
  4499. this.end = props.end;
  4500. }
  4501. this.flags = 0;
  4502. },
  4503. {
  4504. $documentation: "An `import` statement",
  4505. $propdoc: {
  4506. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  4507. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  4508. module_name: "[AST_String] String literal describing where this module came from",
  4509. assert_clause: "[AST_Object?] The import assertion"
  4510. },
  4511. _walk: function(visitor) {
  4512. return visitor._visit(this, function() {
  4513. if (this.imported_name) {
  4514. this.imported_name._walk(visitor);
  4515. }
  4516. if (this.imported_names) {
  4517. this.imported_names.forEach(function(name_import) {
  4518. name_import._walk(visitor);
  4519. });
  4520. }
  4521. this.module_name._walk(visitor);
  4522. });
  4523. },
  4524. _children_backwards(push) {
  4525. push(this.module_name);
  4526. if (this.imported_names) {
  4527. let i = this.imported_names.length;
  4528. while (i--) push(this.imported_names[i]);
  4529. }
  4530. if (this.imported_name) push(this.imported_name);
  4531. },
  4532. }
  4533. );
  4534. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  4535. if (props) {
  4536. this.start = props.start;
  4537. this.end = props.end;
  4538. }
  4539. this.flags = 0;
  4540. }, {
  4541. $documentation: "A reference to import.meta",
  4542. });
  4543. var AST_Export = DEFNODE(
  4544. "Export",
  4545. "exported_definition exported_value is_default exported_names module_name assert_clause",
  4546. function AST_Export(props) {
  4547. if (props) {
  4548. this.exported_definition = props.exported_definition;
  4549. this.exported_value = props.exported_value;
  4550. this.is_default = props.is_default;
  4551. this.exported_names = props.exported_names;
  4552. this.module_name = props.module_name;
  4553. this.assert_clause = props.assert_clause;
  4554. this.start = props.start;
  4555. this.end = props.end;
  4556. }
  4557. this.flags = 0;
  4558. },
  4559. {
  4560. $documentation: "An `export` statement",
  4561. $propdoc: {
  4562. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  4563. exported_value: "[AST_Node?] An exported value",
  4564. exported_names: "[AST_NameMapping*?] List of exported names",
  4565. module_name: "[AST_String?] Name of the file to load exports from",
  4566. is_default: "[Boolean] Whether this is the default exported value of this module",
  4567. assert_clause: "[AST_Object?] The import assertion"
  4568. },
  4569. _walk: function (visitor) {
  4570. return visitor._visit(this, function () {
  4571. if (this.exported_definition) {
  4572. this.exported_definition._walk(visitor);
  4573. }
  4574. if (this.exported_value) {
  4575. this.exported_value._walk(visitor);
  4576. }
  4577. if (this.exported_names) {
  4578. this.exported_names.forEach(function(name_export) {
  4579. name_export._walk(visitor);
  4580. });
  4581. }
  4582. if (this.module_name) {
  4583. this.module_name._walk(visitor);
  4584. }
  4585. });
  4586. },
  4587. _children_backwards(push) {
  4588. if (this.module_name) push(this.module_name);
  4589. if (this.exported_names) {
  4590. let i = this.exported_names.length;
  4591. while (i--) push(this.exported_names[i]);
  4592. }
  4593. if (this.exported_value) push(this.exported_value);
  4594. if (this.exported_definition) push(this.exported_definition);
  4595. }
  4596. },
  4597. AST_Statement
  4598. );
  4599. /* -----[ OTHER ]----- */
  4600. var AST_Call = DEFNODE(
  4601. "Call",
  4602. "expression args optional _annotations",
  4603. function AST_Call(props) {
  4604. if (props) {
  4605. this.expression = props.expression;
  4606. this.args = props.args;
  4607. this.optional = props.optional;
  4608. this._annotations = props._annotations;
  4609. this.start = props.start;
  4610. this.end = props.end;
  4611. this.initialize();
  4612. }
  4613. this.flags = 0;
  4614. },
  4615. {
  4616. $documentation: "A function call expression",
  4617. $propdoc: {
  4618. expression: "[AST_Node] expression to invoke as function",
  4619. args: "[AST_Node*] array of arguments",
  4620. optional: "[boolean] whether this is an optional call (IE ?.() )",
  4621. _annotations: "[number] bitfield containing information about the call"
  4622. },
  4623. initialize() {
  4624. if (this._annotations == null) this._annotations = 0;
  4625. },
  4626. _walk(visitor) {
  4627. return visitor._visit(this, function() {
  4628. var args = this.args;
  4629. for (var i = 0, len = args.length; i < len; i++) {
  4630. args[i]._walk(visitor);
  4631. }
  4632. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  4633. });
  4634. },
  4635. _children_backwards(push) {
  4636. let i = this.args.length;
  4637. while (i--) push(this.args[i]);
  4638. push(this.expression);
  4639. },
  4640. }
  4641. );
  4642. var AST_New = DEFNODE("New", null, function AST_New(props) {
  4643. if (props) {
  4644. this.expression = props.expression;
  4645. this.args = props.args;
  4646. this.optional = props.optional;
  4647. this._annotations = props._annotations;
  4648. this.start = props.start;
  4649. this.end = props.end;
  4650. this.initialize();
  4651. }
  4652. this.flags = 0;
  4653. }, {
  4654. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  4655. }, AST_Call);
  4656. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  4657. if (props) {
  4658. this.expressions = props.expressions;
  4659. this.start = props.start;
  4660. this.end = props.end;
  4661. }
  4662. this.flags = 0;
  4663. }, {
  4664. $documentation: "A sequence expression (comma-separated expressions)",
  4665. $propdoc: {
  4666. expressions: "[AST_Node*] array of expressions (at least two)"
  4667. },
  4668. _walk: function(visitor) {
  4669. return visitor._visit(this, function() {
  4670. this.expressions.forEach(function(node) {
  4671. node._walk(visitor);
  4672. });
  4673. });
  4674. },
  4675. _children_backwards(push) {
  4676. let i = this.expressions.length;
  4677. while (i--) push(this.expressions[i]);
  4678. },
  4679. });
  4680. var AST_PropAccess = DEFNODE(
  4681. "PropAccess",
  4682. "expression property optional",
  4683. function AST_PropAccess(props) {
  4684. if (props) {
  4685. this.expression = props.expression;
  4686. this.property = props.property;
  4687. this.optional = props.optional;
  4688. this.start = props.start;
  4689. this.end = props.end;
  4690. }
  4691. this.flags = 0;
  4692. },
  4693. {
  4694. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  4695. $propdoc: {
  4696. expression: "[AST_Node] the “container” expression",
  4697. 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",
  4698. optional: "[boolean] whether this is an optional property access (IE ?.)"
  4699. }
  4700. }
  4701. );
  4702. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  4703. if (props) {
  4704. this.quote = props.quote;
  4705. this.expression = props.expression;
  4706. this.property = props.property;
  4707. this.optional = props.optional;
  4708. this.start = props.start;
  4709. this.end = props.end;
  4710. }
  4711. this.flags = 0;
  4712. }, {
  4713. $documentation: "A dotted property access expression",
  4714. $propdoc: {
  4715. quote: "[string] the original quote character when transformed from AST_Sub",
  4716. },
  4717. _walk: function(visitor) {
  4718. return visitor._visit(this, function() {
  4719. this.expression._walk(visitor);
  4720. });
  4721. },
  4722. _children_backwards(push) {
  4723. push(this.expression);
  4724. },
  4725. }, AST_PropAccess);
  4726. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  4727. if (props) {
  4728. this.expression = props.expression;
  4729. this.property = props.property;
  4730. this.optional = props.optional;
  4731. this.start = props.start;
  4732. this.end = props.end;
  4733. }
  4734. this.flags = 0;
  4735. }, {
  4736. $documentation: "A dotted property access to a private property",
  4737. _walk: function(visitor) {
  4738. return visitor._visit(this, function() {
  4739. this.expression._walk(visitor);
  4740. });
  4741. },
  4742. _children_backwards(push) {
  4743. push(this.expression);
  4744. },
  4745. }, AST_PropAccess);
  4746. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  4747. if (props) {
  4748. this.expression = props.expression;
  4749. this.property = props.property;
  4750. this.optional = props.optional;
  4751. this.start = props.start;
  4752. this.end = props.end;
  4753. }
  4754. this.flags = 0;
  4755. }, {
  4756. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4757. _walk: function(visitor) {
  4758. return visitor._visit(this, function() {
  4759. this.expression._walk(visitor);
  4760. this.property._walk(visitor);
  4761. });
  4762. },
  4763. _children_backwards(push) {
  4764. push(this.property);
  4765. push(this.expression);
  4766. },
  4767. }, AST_PropAccess);
  4768. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  4769. if (props) {
  4770. this.expression = props.expression;
  4771. this.start = props.start;
  4772. this.end = props.end;
  4773. }
  4774. this.flags = 0;
  4775. }, {
  4776. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4777. $propdoc: {
  4778. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  4779. },
  4780. _walk: function (visitor) {
  4781. return visitor._visit(this, function() {
  4782. this.expression._walk(visitor);
  4783. });
  4784. },
  4785. _children_backwards(push) {
  4786. push(this.expression);
  4787. },
  4788. });
  4789. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  4790. if (props) {
  4791. this.operator = props.operator;
  4792. this.expression = props.expression;
  4793. this.start = props.start;
  4794. this.end = props.end;
  4795. }
  4796. this.flags = 0;
  4797. }, {
  4798. $documentation: "Base class for unary expressions",
  4799. $propdoc: {
  4800. operator: "[string] the operator",
  4801. expression: "[AST_Node] expression that this unary operator applies to"
  4802. },
  4803. _walk: function(visitor) {
  4804. return visitor._visit(this, function() {
  4805. this.expression._walk(visitor);
  4806. });
  4807. },
  4808. _children_backwards(push) {
  4809. push(this.expression);
  4810. },
  4811. });
  4812. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  4813. if (props) {
  4814. this.operator = props.operator;
  4815. this.expression = props.expression;
  4816. this.start = props.start;
  4817. this.end = props.end;
  4818. }
  4819. this.flags = 0;
  4820. }, {
  4821. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4822. }, AST_Unary);
  4823. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  4824. if (props) {
  4825. this.operator = props.operator;
  4826. this.expression = props.expression;
  4827. this.start = props.start;
  4828. this.end = props.end;
  4829. }
  4830. this.flags = 0;
  4831. }, {
  4832. $documentation: "Unary postfix expression, i.e. `i++`"
  4833. }, AST_Unary);
  4834. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  4835. if (props) {
  4836. this.operator = props.operator;
  4837. this.left = props.left;
  4838. this.right = props.right;
  4839. this.start = props.start;
  4840. this.end = props.end;
  4841. }
  4842. this.flags = 0;
  4843. }, {
  4844. $documentation: "Binary expression, i.e. `a + b`",
  4845. $propdoc: {
  4846. left: "[AST_Node] left-hand side expression",
  4847. operator: "[string] the operator",
  4848. right: "[AST_Node] right-hand side expression"
  4849. },
  4850. _walk: function(visitor) {
  4851. return visitor._visit(this, function() {
  4852. this.left._walk(visitor);
  4853. this.right._walk(visitor);
  4854. });
  4855. },
  4856. _children_backwards(push) {
  4857. push(this.right);
  4858. push(this.left);
  4859. },
  4860. });
  4861. var AST_Conditional = DEFNODE(
  4862. "Conditional",
  4863. "condition consequent alternative",
  4864. function AST_Conditional(props) {
  4865. if (props) {
  4866. this.condition = props.condition;
  4867. this.consequent = props.consequent;
  4868. this.alternative = props.alternative;
  4869. this.start = props.start;
  4870. this.end = props.end;
  4871. }
  4872. this.flags = 0;
  4873. },
  4874. {
  4875. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  4876. $propdoc: {
  4877. condition: "[AST_Node]",
  4878. consequent: "[AST_Node]",
  4879. alternative: "[AST_Node]"
  4880. },
  4881. _walk: function(visitor) {
  4882. return visitor._visit(this, function() {
  4883. this.condition._walk(visitor);
  4884. this.consequent._walk(visitor);
  4885. this.alternative._walk(visitor);
  4886. });
  4887. },
  4888. _children_backwards(push) {
  4889. push(this.alternative);
  4890. push(this.consequent);
  4891. push(this.condition);
  4892. },
  4893. }
  4894. );
  4895. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  4896. if (props) {
  4897. this.logical = props.logical;
  4898. this.operator = props.operator;
  4899. this.left = props.left;
  4900. this.right = props.right;
  4901. this.start = props.start;
  4902. this.end = props.end;
  4903. }
  4904. this.flags = 0;
  4905. }, {
  4906. $documentation: "An assignment expression — `a = b + 5`",
  4907. $propdoc: {
  4908. logical: "Whether it's a logical assignment"
  4909. }
  4910. }, AST_Binary);
  4911. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  4912. if (props) {
  4913. this.operator = props.operator;
  4914. this.left = props.left;
  4915. this.right = props.right;
  4916. this.start = props.start;
  4917. this.end = props.end;
  4918. }
  4919. this.flags = 0;
  4920. }, {
  4921. $documentation: "A default assignment expression like in `(a = 3) => a`"
  4922. }, AST_Binary);
  4923. /* -----[ LITERALS ]----- */
  4924. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  4925. if (props) {
  4926. this.elements = props.elements;
  4927. this.start = props.start;
  4928. this.end = props.end;
  4929. }
  4930. this.flags = 0;
  4931. }, {
  4932. $documentation: "An array literal",
  4933. $propdoc: {
  4934. elements: "[AST_Node*] array of elements"
  4935. },
  4936. _walk: function(visitor) {
  4937. return visitor._visit(this, function() {
  4938. var elements = this.elements;
  4939. for (var i = 0, len = elements.length; i < len; i++) {
  4940. elements[i]._walk(visitor);
  4941. }
  4942. });
  4943. },
  4944. _children_backwards(push) {
  4945. let i = this.elements.length;
  4946. while (i--) push(this.elements[i]);
  4947. },
  4948. });
  4949. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  4950. if (props) {
  4951. this.properties = props.properties;
  4952. this.start = props.start;
  4953. this.end = props.end;
  4954. }
  4955. this.flags = 0;
  4956. }, {
  4957. $documentation: "An object literal",
  4958. $propdoc: {
  4959. properties: "[AST_ObjectProperty*] array of properties"
  4960. },
  4961. _walk: function(visitor) {
  4962. return visitor._visit(this, function() {
  4963. var properties = this.properties;
  4964. for (var i = 0, len = properties.length; i < len; i++) {
  4965. properties[i]._walk(visitor);
  4966. }
  4967. });
  4968. },
  4969. _children_backwards(push) {
  4970. let i = this.properties.length;
  4971. while (i--) push(this.properties[i]);
  4972. },
  4973. });
  4974. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  4975. if (props) {
  4976. this.key = props.key;
  4977. this.value = props.value;
  4978. this.start = props.start;
  4979. this.end = props.end;
  4980. }
  4981. this.flags = 0;
  4982. }, {
  4983. $documentation: "Base class for literal object properties",
  4984. $propdoc: {
  4985. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  4986. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  4987. },
  4988. _walk: function(visitor) {
  4989. return visitor._visit(this, function() {
  4990. if (this.key instanceof AST_Node)
  4991. this.key._walk(visitor);
  4992. this.value._walk(visitor);
  4993. });
  4994. },
  4995. _children_backwards(push) {
  4996. push(this.value);
  4997. if (this.key instanceof AST_Node) push(this.key);
  4998. }
  4999. });
  5000. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  5001. if (props) {
  5002. this.quote = props.quote;
  5003. this.key = props.key;
  5004. this.value = props.value;
  5005. this.start = props.start;
  5006. this.end = props.end;
  5007. }
  5008. this.flags = 0;
  5009. }, {
  5010. $documentation: "A key: value object property",
  5011. $propdoc: {
  5012. quote: "[string] the original quote character"
  5013. },
  5014. computed_key() {
  5015. return this.key instanceof AST_Node;
  5016. }
  5017. }, AST_ObjectProperty);
  5018. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  5019. if (props) {
  5020. this.static = props.static;
  5021. this.key = props.key;
  5022. this.value = props.value;
  5023. this.start = props.start;
  5024. this.end = props.end;
  5025. }
  5026. this.flags = 0;
  5027. }, {
  5028. $propdoc: {
  5029. static: "[boolean] whether this is a static private setter"
  5030. },
  5031. $documentation: "A private setter property",
  5032. computed_key() {
  5033. return false;
  5034. }
  5035. }, AST_ObjectProperty);
  5036. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
  5037. if (props) {
  5038. this.static = props.static;
  5039. this.key = props.key;
  5040. this.value = props.value;
  5041. this.start = props.start;
  5042. this.end = props.end;
  5043. }
  5044. this.flags = 0;
  5045. }, {
  5046. $propdoc: {
  5047. static: "[boolean] whether this is a static private getter"
  5048. },
  5049. $documentation: "A private getter property",
  5050. computed_key() {
  5051. return false;
  5052. }
  5053. }, AST_ObjectProperty);
  5054. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  5055. if (props) {
  5056. this.quote = props.quote;
  5057. this.static = props.static;
  5058. this.key = props.key;
  5059. this.value = props.value;
  5060. this.start = props.start;
  5061. this.end = props.end;
  5062. }
  5063. this.flags = 0;
  5064. }, {
  5065. $propdoc: {
  5066. quote: "[string|undefined] the original quote character, if any",
  5067. static: "[boolean] whether this is a static setter (classes only)"
  5068. },
  5069. $documentation: "An object setter property",
  5070. computed_key() {
  5071. return !(this.key instanceof AST_SymbolMethod);
  5072. }
  5073. }, AST_ObjectProperty);
  5074. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  5075. if (props) {
  5076. this.quote = props.quote;
  5077. this.static = props.static;
  5078. this.key = props.key;
  5079. this.value = props.value;
  5080. this.start = props.start;
  5081. this.end = props.end;
  5082. }
  5083. this.flags = 0;
  5084. }, {
  5085. $propdoc: {
  5086. quote: "[string|undefined] the original quote character, if any",
  5087. static: "[boolean] whether this is a static getter (classes only)"
  5088. },
  5089. $documentation: "An object getter property",
  5090. computed_key() {
  5091. return !(this.key instanceof AST_SymbolMethod);
  5092. }
  5093. }, AST_ObjectProperty);
  5094. var AST_ConciseMethod = DEFNODE(
  5095. "ConciseMethod",
  5096. "quote static is_generator async",
  5097. function AST_ConciseMethod(props) {
  5098. if (props) {
  5099. this.quote = props.quote;
  5100. this.static = props.static;
  5101. this.is_generator = props.is_generator;
  5102. this.async = props.async;
  5103. this.key = props.key;
  5104. this.value = props.value;
  5105. this.start = props.start;
  5106. this.end = props.end;
  5107. }
  5108. this.flags = 0;
  5109. },
  5110. {
  5111. $propdoc: {
  5112. quote: "[string|undefined] the original quote character, if any",
  5113. static: "[boolean] is this method static (classes only)",
  5114. is_generator: "[boolean] is this a generator method",
  5115. async: "[boolean] is this method async",
  5116. },
  5117. $documentation: "An ES6 concise method inside an object or class",
  5118. computed_key() {
  5119. return !(this.key instanceof AST_SymbolMethod);
  5120. }
  5121. },
  5122. AST_ObjectProperty
  5123. );
  5124. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
  5125. if (props) {
  5126. this.quote = props.quote;
  5127. this.static = props.static;
  5128. this.is_generator = props.is_generator;
  5129. this.async = props.async;
  5130. this.key = props.key;
  5131. this.value = props.value;
  5132. this.start = props.start;
  5133. this.end = props.end;
  5134. }
  5135. this.flags = 0;
  5136. }, {
  5137. $documentation: "A private class method inside a class",
  5138. }, AST_ConciseMethod);
  5139. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  5140. if (props) {
  5141. this.name = props.name;
  5142. this.extends = props.extends;
  5143. this.properties = props.properties;
  5144. this.variables = props.variables;
  5145. this.uses_with = props.uses_with;
  5146. this.uses_eval = props.uses_eval;
  5147. this.parent_scope = props.parent_scope;
  5148. this.enclosed = props.enclosed;
  5149. this.cname = props.cname;
  5150. this.body = props.body;
  5151. this.block_scope = props.block_scope;
  5152. this.start = props.start;
  5153. this.end = props.end;
  5154. }
  5155. this.flags = 0;
  5156. }, {
  5157. $propdoc: {
  5158. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  5159. extends: "[AST_Node]? optional parent class",
  5160. properties: "[AST_ObjectProperty*] array of properties"
  5161. },
  5162. $documentation: "An ES6 class",
  5163. _walk: function(visitor) {
  5164. return visitor._visit(this, function() {
  5165. if (this.name) {
  5166. this.name._walk(visitor);
  5167. }
  5168. if (this.extends) {
  5169. this.extends._walk(visitor);
  5170. }
  5171. this.properties.forEach((prop) => prop._walk(visitor));
  5172. });
  5173. },
  5174. _children_backwards(push) {
  5175. let i = this.properties.length;
  5176. while (i--) push(this.properties[i]);
  5177. if (this.extends) push(this.extends);
  5178. if (this.name) push(this.name);
  5179. },
  5180. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  5181. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  5182. if (props) {
  5183. this.static = props.static;
  5184. this.quote = props.quote;
  5185. this.key = props.key;
  5186. this.value = props.value;
  5187. this.start = props.start;
  5188. this.end = props.end;
  5189. }
  5190. this.flags = 0;
  5191. }, {
  5192. $documentation: "A class property",
  5193. $propdoc: {
  5194. static: "[boolean] whether this is a static key",
  5195. quote: "[string] which quote is being used"
  5196. },
  5197. _walk: function(visitor) {
  5198. return visitor._visit(this, function() {
  5199. if (this.key instanceof AST_Node)
  5200. this.key._walk(visitor);
  5201. if (this.value instanceof AST_Node)
  5202. this.value._walk(visitor);
  5203. });
  5204. },
  5205. _children_backwards(push) {
  5206. if (this.value instanceof AST_Node) push(this.value);
  5207. if (this.key instanceof AST_Node) push(this.key);
  5208. },
  5209. computed_key() {
  5210. return !(this.key instanceof AST_SymbolClassProperty);
  5211. }
  5212. }, AST_ObjectProperty);
  5213. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  5214. if (props) {
  5215. this.static = props.static;
  5216. this.quote = props.quote;
  5217. this.key = props.key;
  5218. this.value = props.value;
  5219. this.start = props.start;
  5220. this.end = props.end;
  5221. }
  5222. this.flags = 0;
  5223. }, {
  5224. $documentation: "A class property for a private property",
  5225. }, AST_ClassProperty);
  5226. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  5227. if (props) {
  5228. this.name = props.name;
  5229. this.extends = props.extends;
  5230. this.properties = props.properties;
  5231. this.variables = props.variables;
  5232. this.uses_with = props.uses_with;
  5233. this.uses_eval = props.uses_eval;
  5234. this.parent_scope = props.parent_scope;
  5235. this.enclosed = props.enclosed;
  5236. this.cname = props.cname;
  5237. this.body = props.body;
  5238. this.block_scope = props.block_scope;
  5239. this.start = props.start;
  5240. this.end = props.end;
  5241. }
  5242. this.flags = 0;
  5243. }, {
  5244. $documentation: "A class definition",
  5245. }, AST_Class);
  5246. var AST_ClassStaticBlock = DEFNODE("ClassStaticBlock", "body block_scope", function AST_ClassStaticBlock (props) {
  5247. this.body = props.body;
  5248. this.block_scope = props.block_scope;
  5249. this.start = props.start;
  5250. this.end = props.end;
  5251. }, {
  5252. $documentation: "A block containing statements to be executed in the context of the class",
  5253. $propdoc: {
  5254. body: "[AST_Statement*] an array of statements",
  5255. },
  5256. _walk: function(visitor) {
  5257. return visitor._visit(this, function() {
  5258. walk_body(this, visitor);
  5259. });
  5260. },
  5261. _children_backwards(push) {
  5262. let i = this.body.length;
  5263. while (i--) push(this.body[i]);
  5264. },
  5265. clone: clone_block_scope,
  5266. }, AST_Scope);
  5267. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  5268. if (props) {
  5269. this.name = props.name;
  5270. this.extends = props.extends;
  5271. this.properties = props.properties;
  5272. this.variables = props.variables;
  5273. this.uses_with = props.uses_with;
  5274. this.uses_eval = props.uses_eval;
  5275. this.parent_scope = props.parent_scope;
  5276. this.enclosed = props.enclosed;
  5277. this.cname = props.cname;
  5278. this.body = props.body;
  5279. this.block_scope = props.block_scope;
  5280. this.start = props.start;
  5281. this.end = props.end;
  5282. }
  5283. this.flags = 0;
  5284. }, {
  5285. $documentation: "A class expression."
  5286. }, AST_Class);
  5287. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  5288. if (props) {
  5289. this.scope = props.scope;
  5290. this.name = props.name;
  5291. this.thedef = props.thedef;
  5292. this.start = props.start;
  5293. this.end = props.end;
  5294. }
  5295. this.flags = 0;
  5296. }, {
  5297. $propdoc: {
  5298. name: "[string] name of this symbol",
  5299. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  5300. thedef: "[SymbolDef/S] the definition of this symbol"
  5301. },
  5302. $documentation: "Base class for all symbols"
  5303. });
  5304. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  5305. if (props) {
  5306. this.start = props.start;
  5307. this.end = props.end;
  5308. }
  5309. this.flags = 0;
  5310. }, {
  5311. $documentation: "A reference to new.target"
  5312. });
  5313. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  5314. if (props) {
  5315. this.init = props.init;
  5316. this.scope = props.scope;
  5317. this.name = props.name;
  5318. this.thedef = props.thedef;
  5319. this.start = props.start;
  5320. this.end = props.end;
  5321. }
  5322. this.flags = 0;
  5323. }, {
  5324. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  5325. }, AST_Symbol);
  5326. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
  5327. if (props) {
  5328. this.init = props.init;
  5329. this.scope = props.scope;
  5330. this.name = props.name;
  5331. this.thedef = props.thedef;
  5332. this.start = props.start;
  5333. this.end = props.end;
  5334. }
  5335. this.flags = 0;
  5336. }, {
  5337. $documentation: "Symbol defining a variable",
  5338. }, AST_SymbolDeclaration);
  5339. var AST_SymbolBlockDeclaration = DEFNODE(
  5340. "SymbolBlockDeclaration",
  5341. null,
  5342. function AST_SymbolBlockDeclaration(props) {
  5343. if (props) {
  5344. this.init = props.init;
  5345. this.scope = props.scope;
  5346. this.name = props.name;
  5347. this.thedef = props.thedef;
  5348. this.start = props.start;
  5349. this.end = props.end;
  5350. }
  5351. this.flags = 0;
  5352. },
  5353. {
  5354. $documentation: "Base class for block-scoped declaration symbols"
  5355. },
  5356. AST_SymbolDeclaration
  5357. );
  5358. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  5359. if (props) {
  5360. this.init = props.init;
  5361. this.scope = props.scope;
  5362. this.name = props.name;
  5363. this.thedef = props.thedef;
  5364. this.start = props.start;
  5365. this.end = props.end;
  5366. }
  5367. this.flags = 0;
  5368. }, {
  5369. $documentation: "A constant declaration"
  5370. }, AST_SymbolBlockDeclaration);
  5371. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(props) {
  5372. if (props) {
  5373. this.init = props.init;
  5374. this.scope = props.scope;
  5375. this.name = props.name;
  5376. this.thedef = props.thedef;
  5377. this.start = props.start;
  5378. this.end = props.end;
  5379. }
  5380. this.flags = 0;
  5381. }, {
  5382. $documentation: "A block-scoped `let` declaration"
  5383. }, AST_SymbolBlockDeclaration);
  5384. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
  5385. if (props) {
  5386. this.init = props.init;
  5387. this.scope = props.scope;
  5388. this.name = props.name;
  5389. this.thedef = props.thedef;
  5390. this.start = props.start;
  5391. this.end = props.end;
  5392. }
  5393. this.flags = 0;
  5394. }, {
  5395. $documentation: "Symbol naming a function argument",
  5396. }, AST_SymbolVar);
  5397. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
  5398. if (props) {
  5399. this.init = props.init;
  5400. this.scope = props.scope;
  5401. this.name = props.name;
  5402. this.thedef = props.thedef;
  5403. this.start = props.start;
  5404. this.end = props.end;
  5405. }
  5406. this.flags = 0;
  5407. }, {
  5408. $documentation: "Symbol defining a function",
  5409. }, AST_SymbolDeclaration);
  5410. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  5411. if (props) {
  5412. this.scope = props.scope;
  5413. this.name = props.name;
  5414. this.thedef = props.thedef;
  5415. this.start = props.start;
  5416. this.end = props.end;
  5417. }
  5418. this.flags = 0;
  5419. }, {
  5420. $documentation: "Symbol in an object defining a method",
  5421. }, AST_Symbol);
  5422. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  5423. if (props) {
  5424. this.scope = props.scope;
  5425. this.name = props.name;
  5426. this.thedef = props.thedef;
  5427. this.start = props.start;
  5428. this.end = props.end;
  5429. }
  5430. this.flags = 0;
  5431. }, {
  5432. $documentation: "Symbol for a class property",
  5433. }, AST_Symbol);
  5434. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  5435. if (props) {
  5436. this.init = props.init;
  5437. this.scope = props.scope;
  5438. this.name = props.name;
  5439. this.thedef = props.thedef;
  5440. this.start = props.start;
  5441. this.end = props.end;
  5442. }
  5443. this.flags = 0;
  5444. }, {
  5445. $documentation: "Symbol naming a function expression",
  5446. }, AST_SymbolDeclaration);
  5447. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
  5448. if (props) {
  5449. this.init = props.init;
  5450. this.scope = props.scope;
  5451. this.name = props.name;
  5452. this.thedef = props.thedef;
  5453. this.start = props.start;
  5454. this.end = props.end;
  5455. }
  5456. this.flags = 0;
  5457. }, {
  5458. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  5459. }, AST_SymbolBlockDeclaration);
  5460. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
  5461. if (props) {
  5462. this.init = props.init;
  5463. this.scope = props.scope;
  5464. this.name = props.name;
  5465. this.thedef = props.thedef;
  5466. this.start = props.start;
  5467. this.end = props.end;
  5468. }
  5469. this.flags = 0;
  5470. }, {
  5471. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  5472. }, AST_SymbolDeclaration);
  5473. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
  5474. if (props) {
  5475. this.init = props.init;
  5476. this.scope = props.scope;
  5477. this.name = props.name;
  5478. this.thedef = props.thedef;
  5479. this.start = props.start;
  5480. this.end = props.end;
  5481. }
  5482. this.flags = 0;
  5483. }, {
  5484. $documentation: "Symbol naming the exception in catch",
  5485. }, AST_SymbolBlockDeclaration);
  5486. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
  5487. if (props) {
  5488. this.init = props.init;
  5489. this.scope = props.scope;
  5490. this.name = props.name;
  5491. this.thedef = props.thedef;
  5492. this.start = props.start;
  5493. this.end = props.end;
  5494. }
  5495. this.flags = 0;
  5496. }, {
  5497. $documentation: "Symbol referring to an imported name",
  5498. }, AST_SymbolBlockDeclaration);
  5499. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
  5500. if (props) {
  5501. this.scope = props.scope;
  5502. this.name = props.name;
  5503. this.thedef = props.thedef;
  5504. this.start = props.start;
  5505. this.end = props.end;
  5506. }
  5507. this.flags = 0;
  5508. }, {
  5509. $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",
  5510. }, AST_Symbol);
  5511. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  5512. if (props) {
  5513. this.references = props.references;
  5514. this.scope = props.scope;
  5515. this.name = props.name;
  5516. this.thedef = props.thedef;
  5517. this.start = props.start;
  5518. this.end = props.end;
  5519. this.initialize();
  5520. }
  5521. this.flags = 0;
  5522. }, {
  5523. $documentation: "Symbol naming a label (declaration)",
  5524. $propdoc: {
  5525. references: "[AST_LoopControl*] a list of nodes referring to this label"
  5526. },
  5527. initialize: function() {
  5528. this.references = [];
  5529. this.thedef = this;
  5530. }
  5531. }, AST_Symbol);
  5532. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  5533. if (props) {
  5534. this.scope = props.scope;
  5535. this.name = props.name;
  5536. this.thedef = props.thedef;
  5537. this.start = props.start;
  5538. this.end = props.end;
  5539. }
  5540. this.flags = 0;
  5541. }, {
  5542. $documentation: "Reference to some symbol (not definition/declaration)",
  5543. }, AST_Symbol);
  5544. var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
  5545. if (props) {
  5546. this.scope = props.scope;
  5547. this.name = props.name;
  5548. this.thedef = props.thedef;
  5549. this.start = props.start;
  5550. this.end = props.end;
  5551. }
  5552. this.flags = 0;
  5553. }, {
  5554. $documentation: "Symbol referring to a name to export",
  5555. }, AST_SymbolRef);
  5556. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
  5557. if (props) {
  5558. this.scope = props.scope;
  5559. this.name = props.name;
  5560. this.thedef = props.thedef;
  5561. this.start = props.start;
  5562. this.end = props.end;
  5563. }
  5564. this.flags = 0;
  5565. }, {
  5566. $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",
  5567. }, AST_Symbol);
  5568. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  5569. if (props) {
  5570. this.scope = props.scope;
  5571. this.name = props.name;
  5572. this.thedef = props.thedef;
  5573. this.start = props.start;
  5574. this.end = props.end;
  5575. }
  5576. this.flags = 0;
  5577. }, {
  5578. $documentation: "Reference to a label symbol",
  5579. }, AST_Symbol);
  5580. var AST_This = DEFNODE("This", null, function AST_This(props) {
  5581. if (props) {
  5582. this.scope = props.scope;
  5583. this.name = props.name;
  5584. this.thedef = props.thedef;
  5585. this.start = props.start;
  5586. this.end = props.end;
  5587. }
  5588. this.flags = 0;
  5589. }, {
  5590. $documentation: "The `this` symbol",
  5591. }, AST_Symbol);
  5592. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  5593. if (props) {
  5594. this.scope = props.scope;
  5595. this.name = props.name;
  5596. this.thedef = props.thedef;
  5597. this.start = props.start;
  5598. this.end = props.end;
  5599. }
  5600. this.flags = 0;
  5601. }, {
  5602. $documentation: "The `super` symbol",
  5603. }, AST_This);
  5604. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  5605. if (props) {
  5606. this.start = props.start;
  5607. this.end = props.end;
  5608. }
  5609. this.flags = 0;
  5610. }, {
  5611. $documentation: "Base class for all constants",
  5612. getValue: function() {
  5613. return this.value;
  5614. }
  5615. });
  5616. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  5617. if (props) {
  5618. this.value = props.value;
  5619. this.quote = props.quote;
  5620. this.start = props.start;
  5621. this.end = props.end;
  5622. }
  5623. this.flags = 0;
  5624. }, {
  5625. $documentation: "A string literal",
  5626. $propdoc: {
  5627. value: "[string] the contents of this string",
  5628. quote: "[string] the original quote character"
  5629. }
  5630. }, AST_Constant);
  5631. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  5632. if (props) {
  5633. this.value = props.value;
  5634. this.raw = props.raw;
  5635. this.start = props.start;
  5636. this.end = props.end;
  5637. }
  5638. this.flags = 0;
  5639. }, {
  5640. $documentation: "A number literal",
  5641. $propdoc: {
  5642. value: "[number] the numeric value",
  5643. raw: "[string] numeric value as string"
  5644. }
  5645. }, AST_Constant);
  5646. var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
  5647. if (props) {
  5648. this.value = props.value;
  5649. this.start = props.start;
  5650. this.end = props.end;
  5651. }
  5652. this.flags = 0;
  5653. }, {
  5654. $documentation: "A big int literal",
  5655. $propdoc: {
  5656. value: "[string] big int value"
  5657. }
  5658. }, AST_Constant);
  5659. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  5660. if (props) {
  5661. this.value = props.value;
  5662. this.start = props.start;
  5663. this.end = props.end;
  5664. }
  5665. this.flags = 0;
  5666. }, {
  5667. $documentation: "A regexp literal",
  5668. $propdoc: {
  5669. value: "[RegExp] the actual regexp",
  5670. }
  5671. }, AST_Constant);
  5672. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  5673. if (props) {
  5674. this.start = props.start;
  5675. this.end = props.end;
  5676. }
  5677. this.flags = 0;
  5678. }, {
  5679. $documentation: "Base class for atoms",
  5680. }, AST_Constant);
  5681. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  5682. if (props) {
  5683. this.start = props.start;
  5684. this.end = props.end;
  5685. }
  5686. this.flags = 0;
  5687. }, {
  5688. $documentation: "The `null` atom",
  5689. value: null
  5690. }, AST_Atom);
  5691. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  5692. if (props) {
  5693. this.start = props.start;
  5694. this.end = props.end;
  5695. }
  5696. this.flags = 0;
  5697. }, {
  5698. $documentation: "The impossible value",
  5699. value: 0/0
  5700. }, AST_Atom);
  5701. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  5702. if (props) {
  5703. this.start = props.start;
  5704. this.end = props.end;
  5705. }
  5706. this.flags = 0;
  5707. }, {
  5708. $documentation: "The `undefined` value",
  5709. value: (function() {}())
  5710. }, AST_Atom);
  5711. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  5712. if (props) {
  5713. this.start = props.start;
  5714. this.end = props.end;
  5715. }
  5716. this.flags = 0;
  5717. }, {
  5718. $documentation: "A hole in an array",
  5719. value: (function() {}())
  5720. }, AST_Atom);
  5721. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  5722. if (props) {
  5723. this.start = props.start;
  5724. this.end = props.end;
  5725. }
  5726. this.flags = 0;
  5727. }, {
  5728. $documentation: "The `Infinity` value",
  5729. value: 1/0
  5730. }, AST_Atom);
  5731. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  5732. if (props) {
  5733. this.start = props.start;
  5734. this.end = props.end;
  5735. }
  5736. this.flags = 0;
  5737. }, {
  5738. $documentation: "Base class for booleans",
  5739. }, AST_Atom);
  5740. var AST_False = DEFNODE("False", null, function AST_False(props) {
  5741. if (props) {
  5742. this.start = props.start;
  5743. this.end = props.end;
  5744. }
  5745. this.flags = 0;
  5746. }, {
  5747. $documentation: "The `false` atom",
  5748. value: false
  5749. }, AST_Boolean);
  5750. var AST_True = DEFNODE("True", null, function AST_True(props) {
  5751. if (props) {
  5752. this.start = props.start;
  5753. this.end = props.end;
  5754. }
  5755. this.flags = 0;
  5756. }, {
  5757. $documentation: "The `true` atom",
  5758. value: true
  5759. }, AST_Boolean);
  5760. /* -----[ Walk function ]---- */
  5761. /**
  5762. * Walk nodes in depth-first search fashion.
  5763. * Callback can return `walk_abort` symbol to stop iteration.
  5764. * It can also return `true` to stop iteration just for child nodes.
  5765. * Iteration can be stopped and continued by passing the `to_visit` argument,
  5766. * which is given to the callback in the second argument.
  5767. **/
  5768. function walk(node, cb, to_visit = [node]) {
  5769. const push = to_visit.push.bind(to_visit);
  5770. while (to_visit.length) {
  5771. const node = to_visit.pop();
  5772. const ret = cb(node, to_visit);
  5773. if (ret) {
  5774. if (ret === walk_abort) return true;
  5775. continue;
  5776. }
  5777. node._children_backwards(push);
  5778. }
  5779. return false;
  5780. }
  5781. /**
  5782. * Walks an AST node and its children.
  5783. *
  5784. * {cb} can return `walk_abort` to interrupt the walk.
  5785. *
  5786. * @param node
  5787. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  5788. *
  5789. * @returns {boolean} whether the walk was aborted
  5790. *
  5791. * @example
  5792. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  5793. * if (some_cond(node, parent())) return walk_abort
  5794. * });
  5795. */
  5796. function walk_parent(node, cb, initial_stack) {
  5797. const to_visit = [node];
  5798. const push = to_visit.push.bind(to_visit);
  5799. const stack = initial_stack ? initial_stack.slice() : [];
  5800. const parent_pop_indices = [];
  5801. let current;
  5802. const info = {
  5803. parent: (n = 0) => {
  5804. if (n === -1) {
  5805. return current;
  5806. }
  5807. // [ p1 p0 ] [ 1 0 ]
  5808. if (initial_stack && n >= stack.length) {
  5809. n -= stack.length;
  5810. return initial_stack[
  5811. initial_stack.length - (n + 1)
  5812. ];
  5813. }
  5814. return stack[stack.length - (1 + n)];
  5815. },
  5816. };
  5817. while (to_visit.length) {
  5818. current = to_visit.pop();
  5819. while (
  5820. parent_pop_indices.length &&
  5821. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  5822. ) {
  5823. stack.pop();
  5824. parent_pop_indices.pop();
  5825. }
  5826. const ret = cb(current, info);
  5827. if (ret) {
  5828. if (ret === walk_abort) return true;
  5829. continue;
  5830. }
  5831. const visit_length = to_visit.length;
  5832. current._children_backwards(push);
  5833. // Push only if we're going to traverse the children
  5834. if (to_visit.length > visit_length) {
  5835. stack.push(current);
  5836. parent_pop_indices.push(visit_length - 1);
  5837. }
  5838. }
  5839. return false;
  5840. }
  5841. const walk_abort = Symbol("abort walk");
  5842. /* -----[ TreeWalker ]----- */
  5843. class TreeWalker {
  5844. constructor(callback) {
  5845. this.visit = callback;
  5846. this.stack = [];
  5847. this.directives = Object.create(null);
  5848. }
  5849. _visit(node, descend) {
  5850. this.push(node);
  5851. var ret = this.visit(node, descend ? function() {
  5852. descend.call(node);
  5853. } : noop);
  5854. if (!ret && descend) {
  5855. descend.call(node);
  5856. }
  5857. this.pop();
  5858. return ret;
  5859. }
  5860. parent(n) {
  5861. return this.stack[this.stack.length - 2 - (n || 0)];
  5862. }
  5863. push(node) {
  5864. if (node instanceof AST_Lambda) {
  5865. this.directives = Object.create(this.directives);
  5866. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  5867. this.directives[node.value] = node;
  5868. } else if (node instanceof AST_Class) {
  5869. this.directives = Object.create(this.directives);
  5870. if (!this.directives["use strict"]) {
  5871. this.directives["use strict"] = node;
  5872. }
  5873. }
  5874. this.stack.push(node);
  5875. }
  5876. pop() {
  5877. var node = this.stack.pop();
  5878. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  5879. this.directives = Object.getPrototypeOf(this.directives);
  5880. }
  5881. }
  5882. self() {
  5883. return this.stack[this.stack.length - 1];
  5884. }
  5885. find_parent(type) {
  5886. var stack = this.stack;
  5887. for (var i = stack.length; --i >= 0;) {
  5888. var x = stack[i];
  5889. if (x instanceof type) return x;
  5890. }
  5891. }
  5892. find_scope() {
  5893. for (let i = 0;;i++) {
  5894. const p = this.parent(i);
  5895. if (p instanceof AST_Toplevel) return p;
  5896. if (p instanceof AST_Lambda) return p;
  5897. if (p.block_scope) return p.block_scope;
  5898. }
  5899. }
  5900. has_directive(type) {
  5901. var dir = this.directives[type];
  5902. if (dir) return dir;
  5903. var node = this.stack[this.stack.length - 1];
  5904. if (node instanceof AST_Scope && node.body) {
  5905. for (var i = 0; i < node.body.length; ++i) {
  5906. var st = node.body[i];
  5907. if (!(st instanceof AST_Directive)) break;
  5908. if (st.value == type) return st;
  5909. }
  5910. }
  5911. }
  5912. loopcontrol_target(node) {
  5913. var stack = this.stack;
  5914. if (node.label) for (var i = stack.length; --i >= 0;) {
  5915. var x = stack[i];
  5916. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  5917. return x.body;
  5918. } else for (var i = stack.length; --i >= 0;) {
  5919. var x = stack[i];
  5920. if (x instanceof AST_IterationStatement
  5921. || node instanceof AST_Break && x instanceof AST_Switch)
  5922. return x;
  5923. }
  5924. }
  5925. }
  5926. // Tree transformer helpers.
  5927. class TreeTransformer extends TreeWalker {
  5928. constructor(before, after) {
  5929. super();
  5930. this.before = before;
  5931. this.after = after;
  5932. }
  5933. }
  5934. const _PURE = 0b00000001;
  5935. const _INLINE = 0b00000010;
  5936. const _NOINLINE = 0b00000100;
  5937. /***********************************************************************
  5938. A JavaScript tokenizer / parser / beautifier / compressor.
  5939. https://github.com/mishoo/UglifyJS2
  5940. -------------------------------- (C) ---------------------------------
  5941. Author: Mihai Bazon
  5942. <mihai.bazon@gmail.com>
  5943. http://mihai.bazon.net/blog
  5944. Distributed under the BSD license:
  5945. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  5946. Redistribution and use in source and binary forms, with or without
  5947. modification, are permitted provided that the following conditions
  5948. are met:
  5949. * Redistributions of source code must retain the above
  5950. copyright notice, this list of conditions and the following
  5951. disclaimer.
  5952. * Redistributions in binary form must reproduce the above
  5953. copyright notice, this list of conditions and the following
  5954. disclaimer in the documentation and/or other materials
  5955. provided with the distribution.
  5956. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  5957. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5958. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  5959. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  5960. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  5961. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  5962. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  5963. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  5964. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  5965. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  5966. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5967. SUCH DAMAGE.
  5968. ***********************************************************************/
  5969. function def_transform(node, descend) {
  5970. node.DEFMETHOD("transform", function(tw, in_list) {
  5971. let transformed = undefined;
  5972. tw.push(this);
  5973. if (tw.before) transformed = tw.before(this, descend, in_list);
  5974. if (transformed === undefined) {
  5975. transformed = this;
  5976. descend(transformed, tw);
  5977. if (tw.after) {
  5978. const after_ret = tw.after(transformed, in_list);
  5979. if (after_ret !== undefined) transformed = after_ret;
  5980. }
  5981. }
  5982. tw.pop();
  5983. return transformed;
  5984. });
  5985. }
  5986. function do_list(list, tw) {
  5987. return MAP(list, function(node) {
  5988. return node.transform(tw, true);
  5989. });
  5990. }
  5991. def_transform(AST_Node, noop);
  5992. def_transform(AST_LabeledStatement, function(self, tw) {
  5993. self.label = self.label.transform(tw);
  5994. self.body = self.body.transform(tw);
  5995. });
  5996. def_transform(AST_SimpleStatement, function(self, tw) {
  5997. self.body = self.body.transform(tw);
  5998. });
  5999. def_transform(AST_Block, function(self, tw) {
  6000. self.body = do_list(self.body, tw);
  6001. });
  6002. def_transform(AST_Do, function(self, tw) {
  6003. self.body = self.body.transform(tw);
  6004. self.condition = self.condition.transform(tw);
  6005. });
  6006. def_transform(AST_While, function(self, tw) {
  6007. self.condition = self.condition.transform(tw);
  6008. self.body = self.body.transform(tw);
  6009. });
  6010. def_transform(AST_For, function(self, tw) {
  6011. if (self.init) self.init = self.init.transform(tw);
  6012. if (self.condition) self.condition = self.condition.transform(tw);
  6013. if (self.step) self.step = self.step.transform(tw);
  6014. self.body = self.body.transform(tw);
  6015. });
  6016. def_transform(AST_ForIn, function(self, tw) {
  6017. self.init = self.init.transform(tw);
  6018. self.object = self.object.transform(tw);
  6019. self.body = self.body.transform(tw);
  6020. });
  6021. def_transform(AST_With, function(self, tw) {
  6022. self.expression = self.expression.transform(tw);
  6023. self.body = self.body.transform(tw);
  6024. });
  6025. def_transform(AST_Exit, function(self, tw) {
  6026. if (self.value) self.value = self.value.transform(tw);
  6027. });
  6028. def_transform(AST_LoopControl, function(self, tw) {
  6029. if (self.label) self.label = self.label.transform(tw);
  6030. });
  6031. def_transform(AST_If, function(self, tw) {
  6032. self.condition = self.condition.transform(tw);
  6033. self.body = self.body.transform(tw);
  6034. if (self.alternative) self.alternative = self.alternative.transform(tw);
  6035. });
  6036. def_transform(AST_Switch, function(self, tw) {
  6037. self.expression = self.expression.transform(tw);
  6038. self.body = do_list(self.body, tw);
  6039. });
  6040. def_transform(AST_Case, function(self, tw) {
  6041. self.expression = self.expression.transform(tw);
  6042. self.body = do_list(self.body, tw);
  6043. });
  6044. def_transform(AST_Try, function(self, tw) {
  6045. self.body = do_list(self.body, tw);
  6046. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  6047. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  6048. });
  6049. def_transform(AST_Catch, function(self, tw) {
  6050. if (self.argname) self.argname = self.argname.transform(tw);
  6051. self.body = do_list(self.body, tw);
  6052. });
  6053. def_transform(AST_Definitions, function(self, tw) {
  6054. self.definitions = do_list(self.definitions, tw);
  6055. });
  6056. def_transform(AST_VarDef, function(self, tw) {
  6057. self.name = self.name.transform(tw);
  6058. if (self.value) self.value = self.value.transform(tw);
  6059. });
  6060. def_transform(AST_Destructuring, function(self, tw) {
  6061. self.names = do_list(self.names, tw);
  6062. });
  6063. def_transform(AST_Lambda, function(self, tw) {
  6064. if (self.name) self.name = self.name.transform(tw);
  6065. self.argnames = do_list(self.argnames, tw);
  6066. if (self.body instanceof AST_Node) {
  6067. self.body = self.body.transform(tw);
  6068. } else {
  6069. self.body = do_list(self.body, tw);
  6070. }
  6071. });
  6072. def_transform(AST_Call, function(self, tw) {
  6073. self.expression = self.expression.transform(tw);
  6074. self.args = do_list(self.args, tw);
  6075. });
  6076. def_transform(AST_Sequence, function(self, tw) {
  6077. const result = do_list(self.expressions, tw);
  6078. self.expressions = result.length
  6079. ? result
  6080. : [new AST_Number({ value: 0 })];
  6081. });
  6082. def_transform(AST_PropAccess, function(self, tw) {
  6083. self.expression = self.expression.transform(tw);
  6084. });
  6085. def_transform(AST_Sub, function(self, tw) {
  6086. self.expression = self.expression.transform(tw);
  6087. self.property = self.property.transform(tw);
  6088. });
  6089. def_transform(AST_Chain, function(self, tw) {
  6090. self.expression = self.expression.transform(tw);
  6091. });
  6092. def_transform(AST_Yield, function(self, tw) {
  6093. if (self.expression) self.expression = self.expression.transform(tw);
  6094. });
  6095. def_transform(AST_Await, function(self, tw) {
  6096. self.expression = self.expression.transform(tw);
  6097. });
  6098. def_transform(AST_Unary, function(self, tw) {
  6099. self.expression = self.expression.transform(tw);
  6100. });
  6101. def_transform(AST_Binary, function(self, tw) {
  6102. self.left = self.left.transform(tw);
  6103. self.right = self.right.transform(tw);
  6104. });
  6105. def_transform(AST_Conditional, function(self, tw) {
  6106. self.condition = self.condition.transform(tw);
  6107. self.consequent = self.consequent.transform(tw);
  6108. self.alternative = self.alternative.transform(tw);
  6109. });
  6110. def_transform(AST_Array, function(self, tw) {
  6111. self.elements = do_list(self.elements, tw);
  6112. });
  6113. def_transform(AST_Object, function(self, tw) {
  6114. self.properties = do_list(self.properties, tw);
  6115. });
  6116. def_transform(AST_ObjectProperty, function(self, tw) {
  6117. if (self.key instanceof AST_Node) {
  6118. self.key = self.key.transform(tw);
  6119. }
  6120. if (self.value) self.value = self.value.transform(tw);
  6121. });
  6122. def_transform(AST_Class, function(self, tw) {
  6123. if (self.name) self.name = self.name.transform(tw);
  6124. if (self.extends) self.extends = self.extends.transform(tw);
  6125. self.properties = do_list(self.properties, tw);
  6126. });
  6127. def_transform(AST_ClassStaticBlock, function(self, tw) {
  6128. self.body = do_list(self.body, tw);
  6129. });
  6130. def_transform(AST_Expansion, function(self, tw) {
  6131. self.expression = self.expression.transform(tw);
  6132. });
  6133. def_transform(AST_NameMapping, function(self, tw) {
  6134. self.foreign_name = self.foreign_name.transform(tw);
  6135. self.name = self.name.transform(tw);
  6136. });
  6137. def_transform(AST_Import, function(self, tw) {
  6138. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  6139. if (self.imported_names) do_list(self.imported_names, tw);
  6140. self.module_name = self.module_name.transform(tw);
  6141. });
  6142. def_transform(AST_Export, function(self, tw) {
  6143. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  6144. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  6145. if (self.exported_names) do_list(self.exported_names, tw);
  6146. if (self.module_name) self.module_name = self.module_name.transform(tw);
  6147. });
  6148. def_transform(AST_TemplateString, function(self, tw) {
  6149. self.segments = do_list(self.segments, tw);
  6150. });
  6151. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  6152. self.prefix = self.prefix.transform(tw);
  6153. self.template_string = self.template_string.transform(tw);
  6154. });
  6155. /***********************************************************************
  6156. A JavaScript tokenizer / parser / beautifier / compressor.
  6157. https://github.com/mishoo/UglifyJS2
  6158. -------------------------------- (C) ---------------------------------
  6159. Author: Mihai Bazon
  6160. <mihai.bazon@gmail.com>
  6161. http://mihai.bazon.net/blog
  6162. Distributed under the BSD license:
  6163. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6164. Redistribution and use in source and binary forms, with or without
  6165. modification, are permitted provided that the following conditions
  6166. are met:
  6167. * Redistributions of source code must retain the above
  6168. copyright notice, this list of conditions and the following
  6169. disclaimer.
  6170. * Redistributions in binary form must reproduce the above
  6171. copyright notice, this list of conditions and the following
  6172. disclaimer in the documentation and/or other materials
  6173. provided with the distribution.
  6174. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6175. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6176. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6177. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6178. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6179. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6180. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6181. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6182. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6183. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6184. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6185. SUCH DAMAGE.
  6186. ***********************************************************************/
  6187. (function() {
  6188. var normalize_directives = function(body) {
  6189. var in_directive = true;
  6190. for (var i = 0; i < body.length; i++) {
  6191. if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  6192. body[i] = new AST_Directive({
  6193. start: body[i].start,
  6194. end: body[i].end,
  6195. value: body[i].body.value
  6196. });
  6197. } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
  6198. in_directive = false;
  6199. }
  6200. }
  6201. return body;
  6202. };
  6203. const assert_clause_from_moz = (assertions) => {
  6204. if (assertions && assertions.length > 0) {
  6205. return new AST_Object({
  6206. start: my_start_token(assertions),
  6207. end: my_end_token(assertions),
  6208. properties: assertions.map((assertion_kv) =>
  6209. new AST_ObjectKeyVal({
  6210. start: my_start_token(assertion_kv),
  6211. end: my_end_token(assertion_kv),
  6212. key: assertion_kv.key.name || assertion_kv.key.value,
  6213. value: from_moz(assertion_kv.value)
  6214. })
  6215. )
  6216. });
  6217. }
  6218. return null;
  6219. };
  6220. var MOZ_TO_ME = {
  6221. Program: function(M) {
  6222. return new AST_Toplevel({
  6223. start: my_start_token(M),
  6224. end: my_end_token(M),
  6225. body: normalize_directives(M.body.map(from_moz))
  6226. });
  6227. },
  6228. ArrayPattern: function(M) {
  6229. return new AST_Destructuring({
  6230. start: my_start_token(M),
  6231. end: my_end_token(M),
  6232. names: M.elements.map(function(elm) {
  6233. if (elm === null) {
  6234. return new AST_Hole();
  6235. }
  6236. return from_moz(elm);
  6237. }),
  6238. is_array: true
  6239. });
  6240. },
  6241. ObjectPattern: function(M) {
  6242. return new AST_Destructuring({
  6243. start: my_start_token(M),
  6244. end: my_end_token(M),
  6245. names: M.properties.map(from_moz),
  6246. is_array: false
  6247. });
  6248. },
  6249. AssignmentPattern: function(M) {
  6250. return new AST_DefaultAssign({
  6251. start: my_start_token(M),
  6252. end: my_end_token(M),
  6253. left: from_moz(M.left),
  6254. operator: "=",
  6255. right: from_moz(M.right)
  6256. });
  6257. },
  6258. SpreadElement: function(M) {
  6259. return new AST_Expansion({
  6260. start: my_start_token(M),
  6261. end: my_end_token(M),
  6262. expression: from_moz(M.argument)
  6263. });
  6264. },
  6265. RestElement: function(M) {
  6266. return new AST_Expansion({
  6267. start: my_start_token(M),
  6268. end: my_end_token(M),
  6269. expression: from_moz(M.argument)
  6270. });
  6271. },
  6272. TemplateElement: function(M) {
  6273. return new AST_TemplateSegment({
  6274. start: my_start_token(M),
  6275. end: my_end_token(M),
  6276. value: M.value.cooked,
  6277. raw: M.value.raw
  6278. });
  6279. },
  6280. TemplateLiteral: function(M) {
  6281. var segments = [];
  6282. for (var i = 0; i < M.quasis.length; i++) {
  6283. segments.push(from_moz(M.quasis[i]));
  6284. if (M.expressions[i]) {
  6285. segments.push(from_moz(M.expressions[i]));
  6286. }
  6287. }
  6288. return new AST_TemplateString({
  6289. start: my_start_token(M),
  6290. end: my_end_token(M),
  6291. segments: segments
  6292. });
  6293. },
  6294. TaggedTemplateExpression: function(M) {
  6295. return new AST_PrefixedTemplateString({
  6296. start: my_start_token(M),
  6297. end: my_end_token(M),
  6298. template_string: from_moz(M.quasi),
  6299. prefix: from_moz(M.tag)
  6300. });
  6301. },
  6302. FunctionDeclaration: function(M) {
  6303. return new AST_Defun({
  6304. start: my_start_token(M),
  6305. end: my_end_token(M),
  6306. name: from_moz(M.id),
  6307. argnames: M.params.map(from_moz),
  6308. is_generator: M.generator,
  6309. async: M.async,
  6310. body: normalize_directives(from_moz(M.body).body)
  6311. });
  6312. },
  6313. FunctionExpression: function(M) {
  6314. return new AST_Function({
  6315. start: my_start_token(M),
  6316. end: my_end_token(M),
  6317. name: from_moz(M.id),
  6318. argnames: M.params.map(from_moz),
  6319. is_generator: M.generator,
  6320. async: M.async,
  6321. body: normalize_directives(from_moz(M.body).body)
  6322. });
  6323. },
  6324. ArrowFunctionExpression: function(M) {
  6325. const body = M.body.type === "BlockStatement"
  6326. ? from_moz(M.body).body
  6327. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  6328. return new AST_Arrow({
  6329. start: my_start_token(M),
  6330. end: my_end_token(M),
  6331. argnames: M.params.map(from_moz),
  6332. body,
  6333. async: M.async,
  6334. });
  6335. },
  6336. ExpressionStatement: function(M) {
  6337. return new AST_SimpleStatement({
  6338. start: my_start_token(M),
  6339. end: my_end_token(M),
  6340. body: from_moz(M.expression)
  6341. });
  6342. },
  6343. TryStatement: function(M) {
  6344. var handlers = M.handlers || [M.handler];
  6345. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  6346. throw new Error("Multiple catch clauses are not supported.");
  6347. }
  6348. return new AST_Try({
  6349. start : my_start_token(M),
  6350. end : my_end_token(M),
  6351. body : from_moz(M.block).body,
  6352. bcatch : from_moz(handlers[0]),
  6353. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  6354. });
  6355. },
  6356. Property: function(M) {
  6357. var key = M.key;
  6358. var args = {
  6359. start : my_start_token(key || M.value),
  6360. end : my_end_token(M.value),
  6361. key : key.type == "Identifier" ? key.name : key.value,
  6362. value : from_moz(M.value)
  6363. };
  6364. if (M.computed) {
  6365. args.key = from_moz(M.key);
  6366. }
  6367. if (M.method) {
  6368. args.is_generator = M.value.generator;
  6369. args.async = M.value.async;
  6370. if (!M.computed) {
  6371. args.key = new AST_SymbolMethod({ name: args.key });
  6372. } else {
  6373. args.key = from_moz(M.key);
  6374. }
  6375. return new AST_ConciseMethod(args);
  6376. }
  6377. if (M.kind == "init") {
  6378. if (key.type != "Identifier" && key.type != "Literal") {
  6379. args.key = from_moz(key);
  6380. }
  6381. return new AST_ObjectKeyVal(args);
  6382. }
  6383. if (typeof args.key === "string" || typeof args.key === "number") {
  6384. args.key = new AST_SymbolMethod({
  6385. name: args.key
  6386. });
  6387. }
  6388. args.value = new AST_Accessor(args.value);
  6389. if (M.kind == "get") return new AST_ObjectGetter(args);
  6390. if (M.kind == "set") return new AST_ObjectSetter(args);
  6391. if (M.kind == "method") {
  6392. args.async = M.value.async;
  6393. args.is_generator = M.value.generator;
  6394. args.quote = M.computed ? "\"" : null;
  6395. return new AST_ConciseMethod(args);
  6396. }
  6397. },
  6398. MethodDefinition: function(M) {
  6399. var args = {
  6400. start : my_start_token(M),
  6401. end : my_end_token(M),
  6402. key : M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value }),
  6403. value : from_moz(M.value),
  6404. static : M.static,
  6405. };
  6406. if (M.kind == "get") {
  6407. return new AST_ObjectGetter(args);
  6408. }
  6409. if (M.kind == "set") {
  6410. return new AST_ObjectSetter(args);
  6411. }
  6412. args.is_generator = M.value.generator;
  6413. args.async = M.value.async;
  6414. return new AST_ConciseMethod(args);
  6415. },
  6416. FieldDefinition: function(M) {
  6417. let key;
  6418. if (M.computed) {
  6419. key = from_moz(M.key);
  6420. } else {
  6421. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  6422. key = from_moz(M.key);
  6423. }
  6424. return new AST_ClassProperty({
  6425. start : my_start_token(M),
  6426. end : my_end_token(M),
  6427. key,
  6428. value : from_moz(M.value),
  6429. static : M.static,
  6430. });
  6431. },
  6432. PropertyDefinition: function(M) {
  6433. let key;
  6434. if (M.computed) {
  6435. key = from_moz(M.key);
  6436. } else {
  6437. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in PropertyDefinition");
  6438. key = from_moz(M.key);
  6439. }
  6440. return new AST_ClassProperty({
  6441. start : my_start_token(M),
  6442. end : my_end_token(M),
  6443. key,
  6444. value : from_moz(M.value),
  6445. static : M.static,
  6446. });
  6447. },
  6448. StaticBlock: function(M) {
  6449. return new AST_ClassStaticBlock({
  6450. start : my_start_token(M),
  6451. end : my_end_token(M),
  6452. body : M.body.map(from_moz),
  6453. });
  6454. },
  6455. ArrayExpression: function(M) {
  6456. return new AST_Array({
  6457. start : my_start_token(M),
  6458. end : my_end_token(M),
  6459. elements : M.elements.map(function(elem) {
  6460. return elem === null ? new AST_Hole() : from_moz(elem);
  6461. })
  6462. });
  6463. },
  6464. ObjectExpression: function(M) {
  6465. return new AST_Object({
  6466. start : my_start_token(M),
  6467. end : my_end_token(M),
  6468. properties : M.properties.map(function(prop) {
  6469. if (prop.type === "SpreadElement") {
  6470. return from_moz(prop);
  6471. }
  6472. prop.type = "Property";
  6473. return from_moz(prop);
  6474. })
  6475. });
  6476. },
  6477. SequenceExpression: function(M) {
  6478. return new AST_Sequence({
  6479. start : my_start_token(M),
  6480. end : my_end_token(M),
  6481. expressions: M.expressions.map(from_moz)
  6482. });
  6483. },
  6484. MemberExpression: function(M) {
  6485. return new (M.computed ? AST_Sub : AST_Dot)({
  6486. start : my_start_token(M),
  6487. end : my_end_token(M),
  6488. property : M.computed ? from_moz(M.property) : M.property.name,
  6489. expression : from_moz(M.object),
  6490. optional : M.optional || false
  6491. });
  6492. },
  6493. ChainExpression: function(M) {
  6494. return new AST_Chain({
  6495. start : my_start_token(M),
  6496. end : my_end_token(M),
  6497. expression : from_moz(M.expression)
  6498. });
  6499. },
  6500. SwitchCase: function(M) {
  6501. return new (M.test ? AST_Case : AST_Default)({
  6502. start : my_start_token(M),
  6503. end : my_end_token(M),
  6504. expression : from_moz(M.test),
  6505. body : M.consequent.map(from_moz)
  6506. });
  6507. },
  6508. VariableDeclaration: function(M) {
  6509. return new (M.kind === "const" ? AST_Const :
  6510. M.kind === "let" ? AST_Let : AST_Var)({
  6511. start : my_start_token(M),
  6512. end : my_end_token(M),
  6513. definitions : M.declarations.map(from_moz)
  6514. });
  6515. },
  6516. ImportDeclaration: function(M) {
  6517. var imported_name = null;
  6518. var imported_names = null;
  6519. M.specifiers.forEach(function (specifier) {
  6520. if (specifier.type === "ImportSpecifier") {
  6521. if (!imported_names) { imported_names = []; }
  6522. imported_names.push(new AST_NameMapping({
  6523. start: my_start_token(specifier),
  6524. end: my_end_token(specifier),
  6525. foreign_name: from_moz(specifier.imported),
  6526. name: from_moz(specifier.local)
  6527. }));
  6528. } else if (specifier.type === "ImportDefaultSpecifier") {
  6529. imported_name = from_moz(specifier.local);
  6530. } else if (specifier.type === "ImportNamespaceSpecifier") {
  6531. if (!imported_names) { imported_names = []; }
  6532. imported_names.push(new AST_NameMapping({
  6533. start: my_start_token(specifier),
  6534. end: my_end_token(specifier),
  6535. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  6536. name: from_moz(specifier.local)
  6537. }));
  6538. }
  6539. });
  6540. return new AST_Import({
  6541. start : my_start_token(M),
  6542. end : my_end_token(M),
  6543. imported_name: imported_name,
  6544. imported_names : imported_names,
  6545. module_name : from_moz(M.source),
  6546. assert_clause: assert_clause_from_moz(M.assertions)
  6547. });
  6548. },
  6549. ExportAllDeclaration: function(M) {
  6550. return new AST_Export({
  6551. start: my_start_token(M),
  6552. end: my_end_token(M),
  6553. exported_names: [
  6554. new AST_NameMapping({
  6555. name: new AST_SymbolExportForeign({ name: "*" }),
  6556. foreign_name: new AST_SymbolExportForeign({ name: "*" })
  6557. })
  6558. ],
  6559. module_name: from_moz(M.source),
  6560. assert_clause: assert_clause_from_moz(M.assertions)
  6561. });
  6562. },
  6563. ExportNamedDeclaration: function(M) {
  6564. return new AST_Export({
  6565. start: my_start_token(M),
  6566. end: my_end_token(M),
  6567. exported_definition: from_moz(M.declaration),
  6568. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(function (specifier) {
  6569. return new AST_NameMapping({
  6570. foreign_name: from_moz(specifier.exported),
  6571. name: from_moz(specifier.local)
  6572. });
  6573. }) : null,
  6574. module_name: from_moz(M.source),
  6575. assert_clause: assert_clause_from_moz(M.assertions)
  6576. });
  6577. },
  6578. ExportDefaultDeclaration: function(M) {
  6579. return new AST_Export({
  6580. start: my_start_token(M),
  6581. end: my_end_token(M),
  6582. exported_value: from_moz(M.declaration),
  6583. is_default: true
  6584. });
  6585. },
  6586. Literal: function(M) {
  6587. var val = M.value, args = {
  6588. start : my_start_token(M),
  6589. end : my_end_token(M)
  6590. };
  6591. var rx = M.regex;
  6592. if (rx && rx.pattern) {
  6593. // RegExpLiteral as per ESTree AST spec
  6594. args.value = {
  6595. source: rx.pattern,
  6596. flags: rx.flags
  6597. };
  6598. return new AST_RegExp(args);
  6599. } else if (rx) {
  6600. // support legacy RegExp
  6601. const rx_source = M.raw || val;
  6602. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  6603. if (!match) throw new Error("Invalid regex source " + rx_source);
  6604. const [_, source, flags] = match;
  6605. args.value = { source, flags };
  6606. return new AST_RegExp(args);
  6607. }
  6608. if (val === null) return new AST_Null(args);
  6609. switch (typeof val) {
  6610. case "string":
  6611. args.value = val;
  6612. return new AST_String(args);
  6613. case "number":
  6614. args.value = val;
  6615. args.raw = M.raw || val.toString();
  6616. return new AST_Number(args);
  6617. case "boolean":
  6618. return new (val ? AST_True : AST_False)(args);
  6619. }
  6620. },
  6621. MetaProperty: function(M) {
  6622. if (M.meta.name === "new" && M.property.name === "target") {
  6623. return new AST_NewTarget({
  6624. start: my_start_token(M),
  6625. end: my_end_token(M)
  6626. });
  6627. } else if (M.meta.name === "import" && M.property.name === "meta") {
  6628. return new AST_ImportMeta({
  6629. start: my_start_token(M),
  6630. end: my_end_token(M)
  6631. });
  6632. }
  6633. },
  6634. Identifier: function(M) {
  6635. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6636. return new ( p.type == "LabeledStatement" ? AST_Label
  6637. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  6638. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  6639. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  6640. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  6641. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  6642. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  6643. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  6644. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  6645. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  6646. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  6647. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  6648. : p.type == "CatchClause" ? AST_SymbolCatch
  6649. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  6650. : AST_SymbolRef)({
  6651. start : my_start_token(M),
  6652. end : my_end_token(M),
  6653. name : M.name
  6654. });
  6655. },
  6656. BigIntLiteral(M) {
  6657. return new AST_BigInt({
  6658. start : my_start_token(M),
  6659. end : my_end_token(M),
  6660. value : M.value
  6661. });
  6662. },
  6663. EmptyStatement: function(M) {
  6664. return new AST_EmptyStatement({
  6665. start: my_start_token(M),
  6666. end: my_end_token(M)
  6667. });
  6668. },
  6669. BlockStatement: function(M) {
  6670. return new AST_BlockStatement({
  6671. start: my_start_token(M),
  6672. end: my_end_token(M),
  6673. body: M.body.map(from_moz)
  6674. });
  6675. },
  6676. IfStatement: function(M) {
  6677. return new AST_If({
  6678. start: my_start_token(M),
  6679. end: my_end_token(M),
  6680. condition: from_moz(M.test),
  6681. body: from_moz(M.consequent),
  6682. alternative: from_moz(M.alternate)
  6683. });
  6684. },
  6685. LabeledStatement: function(M) {
  6686. return new AST_LabeledStatement({
  6687. start: my_start_token(M),
  6688. end: my_end_token(M),
  6689. label: from_moz(M.label),
  6690. body: from_moz(M.body)
  6691. });
  6692. },
  6693. BreakStatement: function(M) {
  6694. return new AST_Break({
  6695. start: my_start_token(M),
  6696. end: my_end_token(M),
  6697. label: from_moz(M.label)
  6698. });
  6699. },
  6700. ContinueStatement: function(M) {
  6701. return new AST_Continue({
  6702. start: my_start_token(M),
  6703. end: my_end_token(M),
  6704. label: from_moz(M.label)
  6705. });
  6706. },
  6707. WithStatement: function(M) {
  6708. return new AST_With({
  6709. start: my_start_token(M),
  6710. end: my_end_token(M),
  6711. expression: from_moz(M.object),
  6712. body: from_moz(M.body)
  6713. });
  6714. },
  6715. SwitchStatement: function(M) {
  6716. return new AST_Switch({
  6717. start: my_start_token(M),
  6718. end: my_end_token(M),
  6719. expression: from_moz(M.discriminant),
  6720. body: M.cases.map(from_moz)
  6721. });
  6722. },
  6723. ReturnStatement: function(M) {
  6724. return new AST_Return({
  6725. start: my_start_token(M),
  6726. end: my_end_token(M),
  6727. value: from_moz(M.argument)
  6728. });
  6729. },
  6730. ThrowStatement: function(M) {
  6731. return new AST_Throw({
  6732. start: my_start_token(M),
  6733. end: my_end_token(M),
  6734. value: from_moz(M.argument)
  6735. });
  6736. },
  6737. WhileStatement: function(M) {
  6738. return new AST_While({
  6739. start: my_start_token(M),
  6740. end: my_end_token(M),
  6741. condition: from_moz(M.test),
  6742. body: from_moz(M.body)
  6743. });
  6744. },
  6745. DoWhileStatement: function(M) {
  6746. return new AST_Do({
  6747. start: my_start_token(M),
  6748. end: my_end_token(M),
  6749. condition: from_moz(M.test),
  6750. body: from_moz(M.body)
  6751. });
  6752. },
  6753. ForStatement: function(M) {
  6754. return new AST_For({
  6755. start: my_start_token(M),
  6756. end: my_end_token(M),
  6757. init: from_moz(M.init),
  6758. condition: from_moz(M.test),
  6759. step: from_moz(M.update),
  6760. body: from_moz(M.body)
  6761. });
  6762. },
  6763. ForInStatement: function(M) {
  6764. return new AST_ForIn({
  6765. start: my_start_token(M),
  6766. end: my_end_token(M),
  6767. init: from_moz(M.left),
  6768. object: from_moz(M.right),
  6769. body: from_moz(M.body)
  6770. });
  6771. },
  6772. ForOfStatement: function(M) {
  6773. return new AST_ForOf({
  6774. start: my_start_token(M),
  6775. end: my_end_token(M),
  6776. init: from_moz(M.left),
  6777. object: from_moz(M.right),
  6778. body: from_moz(M.body),
  6779. await: M.await
  6780. });
  6781. },
  6782. AwaitExpression: function(M) {
  6783. return new AST_Await({
  6784. start: my_start_token(M),
  6785. end: my_end_token(M),
  6786. expression: from_moz(M.argument)
  6787. });
  6788. },
  6789. YieldExpression: function(M) {
  6790. return new AST_Yield({
  6791. start: my_start_token(M),
  6792. end: my_end_token(M),
  6793. expression: from_moz(M.argument),
  6794. is_star: M.delegate
  6795. });
  6796. },
  6797. DebuggerStatement: function(M) {
  6798. return new AST_Debugger({
  6799. start: my_start_token(M),
  6800. end: my_end_token(M)
  6801. });
  6802. },
  6803. VariableDeclarator: function(M) {
  6804. return new AST_VarDef({
  6805. start: my_start_token(M),
  6806. end: my_end_token(M),
  6807. name: from_moz(M.id),
  6808. value: from_moz(M.init)
  6809. });
  6810. },
  6811. CatchClause: function(M) {
  6812. return new AST_Catch({
  6813. start: my_start_token(M),
  6814. end: my_end_token(M),
  6815. argname: from_moz(M.param),
  6816. body: from_moz(M.body).body
  6817. });
  6818. },
  6819. ThisExpression: function(M) {
  6820. return new AST_This({
  6821. start: my_start_token(M),
  6822. end: my_end_token(M)
  6823. });
  6824. },
  6825. Super: function(M) {
  6826. return new AST_Super({
  6827. start: my_start_token(M),
  6828. end: my_end_token(M)
  6829. });
  6830. },
  6831. BinaryExpression: function(M) {
  6832. return new AST_Binary({
  6833. start: my_start_token(M),
  6834. end: my_end_token(M),
  6835. operator: M.operator,
  6836. left: from_moz(M.left),
  6837. right: from_moz(M.right)
  6838. });
  6839. },
  6840. LogicalExpression: function(M) {
  6841. return new AST_Binary({
  6842. start: my_start_token(M),
  6843. end: my_end_token(M),
  6844. operator: M.operator,
  6845. left: from_moz(M.left),
  6846. right: from_moz(M.right)
  6847. });
  6848. },
  6849. AssignmentExpression: function(M) {
  6850. return new AST_Assign({
  6851. start: my_start_token(M),
  6852. end: my_end_token(M),
  6853. operator: M.operator,
  6854. left: from_moz(M.left),
  6855. right: from_moz(M.right)
  6856. });
  6857. },
  6858. ConditionalExpression: function(M) {
  6859. return new AST_Conditional({
  6860. start: my_start_token(M),
  6861. end: my_end_token(M),
  6862. condition: from_moz(M.test),
  6863. consequent: from_moz(M.consequent),
  6864. alternative: from_moz(M.alternate)
  6865. });
  6866. },
  6867. NewExpression: function(M) {
  6868. return new AST_New({
  6869. start: my_start_token(M),
  6870. end: my_end_token(M),
  6871. expression: from_moz(M.callee),
  6872. args: M.arguments.map(from_moz)
  6873. });
  6874. },
  6875. CallExpression: function(M) {
  6876. return new AST_Call({
  6877. start: my_start_token(M),
  6878. end: my_end_token(M),
  6879. expression: from_moz(M.callee),
  6880. optional: M.optional,
  6881. args: M.arguments.map(from_moz)
  6882. });
  6883. }
  6884. };
  6885. MOZ_TO_ME.UpdateExpression =
  6886. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  6887. var prefix = "prefix" in M ? M.prefix
  6888. : M.type == "UnaryExpression" ? true : false;
  6889. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  6890. start : my_start_token(M),
  6891. end : my_end_token(M),
  6892. operator : M.operator,
  6893. expression : from_moz(M.argument)
  6894. });
  6895. };
  6896. MOZ_TO_ME.ClassDeclaration =
  6897. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  6898. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  6899. start : my_start_token(M),
  6900. end : my_end_token(M),
  6901. name : from_moz(M.id),
  6902. extends : from_moz(M.superClass),
  6903. properties: M.body.body.map(from_moz)
  6904. });
  6905. };
  6906. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  6907. return {
  6908. type: "EmptyStatement"
  6909. };
  6910. });
  6911. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  6912. return {
  6913. type: "BlockStatement",
  6914. body: M.body.map(to_moz)
  6915. };
  6916. });
  6917. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  6918. return {
  6919. type: "IfStatement",
  6920. test: to_moz(M.condition),
  6921. consequent: to_moz(M.body),
  6922. alternate: to_moz(M.alternative)
  6923. };
  6924. });
  6925. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  6926. return {
  6927. type: "LabeledStatement",
  6928. label: to_moz(M.label),
  6929. body: to_moz(M.body)
  6930. };
  6931. });
  6932. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  6933. return {
  6934. type: "BreakStatement",
  6935. label: to_moz(M.label)
  6936. };
  6937. });
  6938. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  6939. return {
  6940. type: "ContinueStatement",
  6941. label: to_moz(M.label)
  6942. };
  6943. });
  6944. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  6945. return {
  6946. type: "WithStatement",
  6947. object: to_moz(M.expression),
  6948. body: to_moz(M.body)
  6949. };
  6950. });
  6951. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  6952. return {
  6953. type: "SwitchStatement",
  6954. discriminant: to_moz(M.expression),
  6955. cases: M.body.map(to_moz)
  6956. };
  6957. });
  6958. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  6959. return {
  6960. type: "ReturnStatement",
  6961. argument: to_moz(M.value)
  6962. };
  6963. });
  6964. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  6965. return {
  6966. type: "ThrowStatement",
  6967. argument: to_moz(M.value)
  6968. };
  6969. });
  6970. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  6971. return {
  6972. type: "WhileStatement",
  6973. test: to_moz(M.condition),
  6974. body: to_moz(M.body)
  6975. };
  6976. });
  6977. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  6978. return {
  6979. type: "DoWhileStatement",
  6980. test: to_moz(M.condition),
  6981. body: to_moz(M.body)
  6982. };
  6983. });
  6984. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  6985. return {
  6986. type: "ForStatement",
  6987. init: to_moz(M.init),
  6988. test: to_moz(M.condition),
  6989. update: to_moz(M.step),
  6990. body: to_moz(M.body)
  6991. };
  6992. });
  6993. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  6994. return {
  6995. type: "ForInStatement",
  6996. left: to_moz(M.init),
  6997. right: to_moz(M.object),
  6998. body: to_moz(M.body)
  6999. };
  7000. });
  7001. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  7002. return {
  7003. type: "ForOfStatement",
  7004. left: to_moz(M.init),
  7005. right: to_moz(M.object),
  7006. body: to_moz(M.body),
  7007. await: M.await
  7008. };
  7009. });
  7010. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  7011. return {
  7012. type: "AwaitExpression",
  7013. argument: to_moz(M.expression)
  7014. };
  7015. });
  7016. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  7017. return {
  7018. type: "YieldExpression",
  7019. argument: to_moz(M.expression),
  7020. delegate: M.is_star
  7021. };
  7022. });
  7023. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  7024. return {
  7025. type: "DebuggerStatement"
  7026. };
  7027. });
  7028. def_to_moz(AST_VarDef, function To_Moz_VariableDeclarator(M) {
  7029. return {
  7030. type: "VariableDeclarator",
  7031. id: to_moz(M.name),
  7032. init: to_moz(M.value)
  7033. };
  7034. });
  7035. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7036. return {
  7037. type: "CatchClause",
  7038. param: to_moz(M.argname),
  7039. body: to_moz_block(M)
  7040. };
  7041. });
  7042. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  7043. return {
  7044. type: "ThisExpression"
  7045. };
  7046. });
  7047. def_to_moz(AST_Super, function To_Moz_Super() {
  7048. return {
  7049. type: "Super"
  7050. };
  7051. });
  7052. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7053. return {
  7054. type: "BinaryExpression",
  7055. operator: M.operator,
  7056. left: to_moz(M.left),
  7057. right: to_moz(M.right)
  7058. };
  7059. });
  7060. def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
  7061. return {
  7062. type: "LogicalExpression",
  7063. operator: M.operator,
  7064. left: to_moz(M.left),
  7065. right: to_moz(M.right)
  7066. };
  7067. });
  7068. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  7069. return {
  7070. type: "AssignmentExpression",
  7071. operator: M.operator,
  7072. left: to_moz(M.left),
  7073. right: to_moz(M.right)
  7074. };
  7075. });
  7076. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  7077. return {
  7078. type: "ConditionalExpression",
  7079. test: to_moz(M.condition),
  7080. consequent: to_moz(M.consequent),
  7081. alternate: to_moz(M.alternative)
  7082. };
  7083. });
  7084. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  7085. return {
  7086. type: "NewExpression",
  7087. callee: to_moz(M.expression),
  7088. arguments: M.args.map(to_moz)
  7089. };
  7090. });
  7091. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  7092. return {
  7093. type: "CallExpression",
  7094. callee: to_moz(M.expression),
  7095. optional: M.optional,
  7096. arguments: M.args.map(to_moz)
  7097. };
  7098. });
  7099. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  7100. return to_moz_scope("Program", M);
  7101. });
  7102. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  7103. return {
  7104. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  7105. argument: to_moz(M.expression)
  7106. };
  7107. });
  7108. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  7109. return {
  7110. type: "TaggedTemplateExpression",
  7111. tag: to_moz(M.prefix),
  7112. quasi: to_moz(M.template_string)
  7113. };
  7114. });
  7115. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  7116. var quasis = [];
  7117. var expressions = [];
  7118. for (var i = 0; i < M.segments.length; i++) {
  7119. if (i % 2 !== 0) {
  7120. expressions.push(to_moz(M.segments[i]));
  7121. } else {
  7122. quasis.push({
  7123. type: "TemplateElement",
  7124. value: {
  7125. raw: M.segments[i].raw,
  7126. cooked: M.segments[i].value
  7127. },
  7128. tail: i === M.segments.length - 1
  7129. });
  7130. }
  7131. }
  7132. return {
  7133. type: "TemplateLiteral",
  7134. quasis: quasis,
  7135. expressions: expressions
  7136. };
  7137. });
  7138. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  7139. return {
  7140. type: "FunctionDeclaration",
  7141. id: to_moz(M.name),
  7142. params: M.argnames.map(to_moz),
  7143. generator: M.is_generator,
  7144. async: M.async,
  7145. body: to_moz_scope("BlockStatement", M)
  7146. };
  7147. });
  7148. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  7149. var is_generator = parent.is_generator !== undefined ?
  7150. parent.is_generator : M.is_generator;
  7151. return {
  7152. type: "FunctionExpression",
  7153. id: to_moz(M.name),
  7154. params: M.argnames.map(to_moz),
  7155. generator: is_generator,
  7156. async: M.async,
  7157. body: to_moz_scope("BlockStatement", M)
  7158. };
  7159. });
  7160. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  7161. var body = {
  7162. type: "BlockStatement",
  7163. body: M.body.map(to_moz)
  7164. };
  7165. return {
  7166. type: "ArrowFunctionExpression",
  7167. params: M.argnames.map(to_moz),
  7168. async: M.async,
  7169. body: body
  7170. };
  7171. });
  7172. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  7173. if (M.is_array) {
  7174. return {
  7175. type: "ArrayPattern",
  7176. elements: M.names.map(to_moz)
  7177. };
  7178. }
  7179. return {
  7180. type: "ObjectPattern",
  7181. properties: M.names.map(to_moz)
  7182. };
  7183. });
  7184. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  7185. return {
  7186. type: "ExpressionStatement",
  7187. expression: {
  7188. type: "Literal",
  7189. value: M.value,
  7190. raw: M.print_to_string()
  7191. },
  7192. directive: M.value
  7193. };
  7194. });
  7195. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  7196. return {
  7197. type: "ExpressionStatement",
  7198. expression: to_moz(M.body)
  7199. };
  7200. });
  7201. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  7202. return {
  7203. type: "SwitchCase",
  7204. test: to_moz(M.expression),
  7205. consequent: M.body.map(to_moz)
  7206. };
  7207. });
  7208. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  7209. return {
  7210. type: "TryStatement",
  7211. block: to_moz_block(M),
  7212. handler: to_moz(M.bcatch),
  7213. guardedHandlers: [],
  7214. finalizer: to_moz(M.bfinally)
  7215. };
  7216. });
  7217. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7218. return {
  7219. type: "CatchClause",
  7220. param: to_moz(M.argname),
  7221. guard: null,
  7222. body: to_moz_block(M)
  7223. };
  7224. });
  7225. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  7226. return {
  7227. type: "VariableDeclaration",
  7228. kind:
  7229. M instanceof AST_Const ? "const" :
  7230. M instanceof AST_Let ? "let" : "var",
  7231. declarations: M.definitions.map(to_moz)
  7232. };
  7233. });
  7234. const assert_clause_to_moz = assert_clause => {
  7235. const assertions = [];
  7236. if (assert_clause) {
  7237. for (const { key, value } of assert_clause.properties) {
  7238. const key_moz = is_basic_identifier_string(key)
  7239. ? { type: "Identifier", name: key }
  7240. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  7241. assertions.push({
  7242. type: "ImportAttribute",
  7243. key: key_moz,
  7244. value: to_moz(value)
  7245. });
  7246. }
  7247. }
  7248. return assertions;
  7249. };
  7250. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  7251. if (M.exported_names) {
  7252. if (M.exported_names[0].name.name === "*") {
  7253. return {
  7254. type: "ExportAllDeclaration",
  7255. source: to_moz(M.module_name),
  7256. assertions: assert_clause_to_moz(M.assert_clause)
  7257. };
  7258. }
  7259. return {
  7260. type: "ExportNamedDeclaration",
  7261. specifiers: M.exported_names.map(function (name_mapping) {
  7262. return {
  7263. type: "ExportSpecifier",
  7264. exported: to_moz(name_mapping.foreign_name),
  7265. local: to_moz(name_mapping.name)
  7266. };
  7267. }),
  7268. declaration: to_moz(M.exported_definition),
  7269. source: to_moz(M.module_name),
  7270. assertions: assert_clause_to_moz(M.assert_clause)
  7271. };
  7272. }
  7273. return {
  7274. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  7275. declaration: to_moz(M.exported_value || M.exported_definition)
  7276. };
  7277. });
  7278. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  7279. var specifiers = [];
  7280. if (M.imported_name) {
  7281. specifiers.push({
  7282. type: "ImportDefaultSpecifier",
  7283. local: to_moz(M.imported_name)
  7284. });
  7285. }
  7286. if (M.imported_names && M.imported_names[0].foreign_name.name === "*") {
  7287. specifiers.push({
  7288. type: "ImportNamespaceSpecifier",
  7289. local: to_moz(M.imported_names[0].name)
  7290. });
  7291. } else if (M.imported_names) {
  7292. M.imported_names.forEach(function(name_mapping) {
  7293. specifiers.push({
  7294. type: "ImportSpecifier",
  7295. local: to_moz(name_mapping.name),
  7296. imported: to_moz(name_mapping.foreign_name)
  7297. });
  7298. });
  7299. }
  7300. return {
  7301. type: "ImportDeclaration",
  7302. specifiers: specifiers,
  7303. source: to_moz(M.module_name),
  7304. assertions: assert_clause_to_moz(M.assert_clause)
  7305. };
  7306. });
  7307. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  7308. return {
  7309. type: "MetaProperty",
  7310. meta: {
  7311. type: "Identifier",
  7312. name: "import"
  7313. },
  7314. property: {
  7315. type: "Identifier",
  7316. name: "meta"
  7317. }
  7318. };
  7319. });
  7320. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  7321. return {
  7322. type: "SequenceExpression",
  7323. expressions: M.expressions.map(to_moz)
  7324. };
  7325. });
  7326. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  7327. return {
  7328. type: "MemberExpression",
  7329. object: to_moz(M.expression),
  7330. computed: false,
  7331. property: {
  7332. type: "PrivateIdentifier",
  7333. name: M.property
  7334. },
  7335. optional: M.optional
  7336. };
  7337. });
  7338. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  7339. var isComputed = M instanceof AST_Sub;
  7340. return {
  7341. type: "MemberExpression",
  7342. object: to_moz(M.expression),
  7343. computed: isComputed,
  7344. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  7345. optional: M.optional
  7346. };
  7347. });
  7348. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  7349. return {
  7350. type: "ChainExpression",
  7351. expression: to_moz(M.expression)
  7352. };
  7353. });
  7354. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  7355. return {
  7356. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  7357. operator: M.operator,
  7358. prefix: M instanceof AST_UnaryPrefix,
  7359. argument: to_moz(M.expression)
  7360. };
  7361. });
  7362. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7363. if (M.operator == "=" && to_moz_in_destructuring()) {
  7364. return {
  7365. type: "AssignmentPattern",
  7366. left: to_moz(M.left),
  7367. right: to_moz(M.right)
  7368. };
  7369. }
  7370. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  7371. ? "LogicalExpression"
  7372. : "BinaryExpression";
  7373. return {
  7374. type,
  7375. left: to_moz(M.left),
  7376. operator: M.operator,
  7377. right: to_moz(M.right)
  7378. };
  7379. });
  7380. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  7381. return {
  7382. type: "ArrayExpression",
  7383. elements: M.elements.map(to_moz)
  7384. };
  7385. });
  7386. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  7387. return {
  7388. type: "ObjectExpression",
  7389. properties: M.properties.map(to_moz)
  7390. };
  7391. });
  7392. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  7393. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  7394. type: "Identifier",
  7395. value: M.key
  7396. };
  7397. if (typeof M.key === "number") {
  7398. key = {
  7399. type: "Literal",
  7400. value: Number(M.key)
  7401. };
  7402. }
  7403. if (typeof M.key === "string") {
  7404. key = {
  7405. type: "Identifier",
  7406. name: M.key
  7407. };
  7408. }
  7409. var kind;
  7410. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  7411. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  7412. if (M instanceof AST_ObjectKeyVal) {
  7413. kind = "init";
  7414. computed = !string_or_num;
  7415. } else
  7416. if (M instanceof AST_ObjectGetter) {
  7417. kind = "get";
  7418. } else
  7419. if (M instanceof AST_ObjectSetter) {
  7420. kind = "set";
  7421. }
  7422. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  7423. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  7424. return {
  7425. type: "MethodDefinition",
  7426. computed: false,
  7427. kind: kind,
  7428. static: M.static,
  7429. key: {
  7430. type: "PrivateIdentifier",
  7431. name: M.key.name
  7432. },
  7433. value: to_moz(M.value)
  7434. };
  7435. }
  7436. if (M instanceof AST_ClassPrivateProperty) {
  7437. return {
  7438. type: "PropertyDefinition",
  7439. key: {
  7440. type: "PrivateIdentifier",
  7441. name: M.key.name
  7442. },
  7443. value: to_moz(M.value),
  7444. computed: false,
  7445. static: M.static
  7446. };
  7447. }
  7448. if (M instanceof AST_ClassProperty) {
  7449. return {
  7450. type: "PropertyDefinition",
  7451. key,
  7452. value: to_moz(M.value),
  7453. computed,
  7454. static: M.static
  7455. };
  7456. }
  7457. if (parent instanceof AST_Class) {
  7458. return {
  7459. type: "MethodDefinition",
  7460. computed: computed,
  7461. kind: kind,
  7462. static: M.static,
  7463. key: to_moz(M.key),
  7464. value: to_moz(M.value)
  7465. };
  7466. }
  7467. return {
  7468. type: "Property",
  7469. computed: computed,
  7470. kind: kind,
  7471. key: key,
  7472. value: to_moz(M.value)
  7473. };
  7474. });
  7475. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  7476. if (parent instanceof AST_Object) {
  7477. return {
  7478. type: "Property",
  7479. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7480. kind: "init",
  7481. method: true,
  7482. shorthand: false,
  7483. key: to_moz(M.key),
  7484. value: to_moz(M.value)
  7485. };
  7486. }
  7487. const key = M instanceof AST_PrivateMethod
  7488. ? {
  7489. type: "PrivateIdentifier",
  7490. name: M.key.name
  7491. }
  7492. : to_moz(M.key);
  7493. return {
  7494. type: "MethodDefinition",
  7495. kind: M.key === "constructor" ? "constructor" : "method",
  7496. key,
  7497. value: to_moz(M.value),
  7498. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7499. static: M.static,
  7500. };
  7501. });
  7502. def_to_moz(AST_Class, function To_Moz_Class(M) {
  7503. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  7504. return {
  7505. type: type,
  7506. superClass: to_moz(M.extends),
  7507. id: M.name ? to_moz(M.name) : null,
  7508. body: {
  7509. type: "ClassBody",
  7510. body: M.properties.map(to_moz)
  7511. }
  7512. };
  7513. });
  7514. def_to_moz(AST_ClassStaticBlock, function To_Moz_StaticBlock(M) {
  7515. return {
  7516. type: "StaticBlock",
  7517. body: M.body.map(to_moz),
  7518. };
  7519. });
  7520. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  7521. return {
  7522. type: "MetaProperty",
  7523. meta: {
  7524. type: "Identifier",
  7525. name: "new"
  7526. },
  7527. property: {
  7528. type: "Identifier",
  7529. name: "target"
  7530. }
  7531. };
  7532. });
  7533. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  7534. if (M instanceof AST_SymbolMethod && parent.quote) {
  7535. return {
  7536. type: "Literal",
  7537. value: M.name
  7538. };
  7539. }
  7540. var def = M.definition();
  7541. return {
  7542. type: "Identifier",
  7543. name: def ? def.mangled_name || def.name : M.name
  7544. };
  7545. });
  7546. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  7547. const pattern = M.value.source;
  7548. const flags = M.value.flags;
  7549. return {
  7550. type: "Literal",
  7551. value: null,
  7552. raw: M.print_to_string(),
  7553. regex: { pattern, flags }
  7554. };
  7555. });
  7556. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  7557. var value = M.value;
  7558. return {
  7559. type: "Literal",
  7560. value: value,
  7561. raw: M.raw || M.print_to_string()
  7562. };
  7563. });
  7564. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  7565. return {
  7566. type: "Identifier",
  7567. name: String(M.value)
  7568. };
  7569. });
  7570. def_to_moz(AST_BigInt, M => ({
  7571. type: "BigIntLiteral",
  7572. value: M.value
  7573. }));
  7574. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7575. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7576. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  7577. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  7578. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  7579. /* -----[ tools ]----- */
  7580. function my_start_token(moznode) {
  7581. var loc = moznode.loc, start = loc && loc.start;
  7582. var range = moznode.range;
  7583. return new AST_Token(
  7584. "",
  7585. "",
  7586. start && start.line || 0,
  7587. start && start.column || 0,
  7588. range ? range [0] : moznode.start,
  7589. false,
  7590. [],
  7591. [],
  7592. loc && loc.source,
  7593. );
  7594. }
  7595. function my_end_token(moznode) {
  7596. var loc = moznode.loc, end = loc && loc.end;
  7597. var range = moznode.range;
  7598. return new AST_Token(
  7599. "",
  7600. "",
  7601. end && end.line || 0,
  7602. end && end.column || 0,
  7603. range ? range [0] : moznode.end,
  7604. false,
  7605. [],
  7606. [],
  7607. loc && loc.source,
  7608. );
  7609. }
  7610. var FROM_MOZ_STACK = null;
  7611. function from_moz(node) {
  7612. FROM_MOZ_STACK.push(node);
  7613. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  7614. FROM_MOZ_STACK.pop();
  7615. return ret;
  7616. }
  7617. AST_Node.from_mozilla_ast = function(node) {
  7618. var save_stack = FROM_MOZ_STACK;
  7619. FROM_MOZ_STACK = [];
  7620. var ast = from_moz(node);
  7621. FROM_MOZ_STACK = save_stack;
  7622. return ast;
  7623. };
  7624. function set_moz_loc(mynode, moznode) {
  7625. var start = mynode.start;
  7626. var end = mynode.end;
  7627. if (!(start && end)) {
  7628. return moznode;
  7629. }
  7630. if (start.pos != null && end.endpos != null) {
  7631. moznode.range = [start.pos, end.endpos];
  7632. }
  7633. if (start.line) {
  7634. moznode.loc = {
  7635. start: {line: start.line, column: start.col},
  7636. end: end.endline ? {line: end.endline, column: end.endcol} : null
  7637. };
  7638. if (start.file) {
  7639. moznode.loc.source = start.file;
  7640. }
  7641. }
  7642. return moznode;
  7643. }
  7644. function def_to_moz(mytype, handler) {
  7645. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  7646. return set_moz_loc(this, handler(this, parent));
  7647. });
  7648. }
  7649. var TO_MOZ_STACK = null;
  7650. function to_moz(node) {
  7651. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  7652. TO_MOZ_STACK.push(node);
  7653. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  7654. TO_MOZ_STACK.pop();
  7655. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  7656. return ast;
  7657. }
  7658. function to_moz_in_destructuring() {
  7659. var i = TO_MOZ_STACK.length;
  7660. while (i--) {
  7661. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  7662. return true;
  7663. }
  7664. }
  7665. return false;
  7666. }
  7667. function to_moz_block(node) {
  7668. return {
  7669. type: "BlockStatement",
  7670. body: node.body.map(to_moz)
  7671. };
  7672. }
  7673. function to_moz_scope(type, node) {
  7674. var body = node.body.map(to_moz);
  7675. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  7676. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  7677. }
  7678. return {
  7679. type: type,
  7680. body: body
  7681. };
  7682. }
  7683. })();
  7684. // return true if the node at the top of the stack (that means the
  7685. // innermost node in the current output) is lexically the first in
  7686. // a statement.
  7687. function first_in_statement(stack) {
  7688. let node = stack.parent(-1);
  7689. for (let i = 0, p; p = stack.parent(i); i++) {
  7690. if (p instanceof AST_Statement && p.body === node)
  7691. return true;
  7692. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  7693. (p.TYPE === "Call" && p.expression === node) ||
  7694. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  7695. (p instanceof AST_Dot && p.expression === node) ||
  7696. (p instanceof AST_Sub && p.expression === node) ||
  7697. (p instanceof AST_Conditional && p.condition === node) ||
  7698. (p instanceof AST_Binary && p.left === node) ||
  7699. (p instanceof AST_UnaryPostfix && p.expression === node)
  7700. ) {
  7701. node = p;
  7702. } else {
  7703. return false;
  7704. }
  7705. }
  7706. }
  7707. // Returns whether the leftmost item in the expression is an object
  7708. function left_is_object(node) {
  7709. if (node instanceof AST_Object) return true;
  7710. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  7711. if (node.TYPE === "Call") return left_is_object(node.expression);
  7712. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  7713. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  7714. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  7715. if (node instanceof AST_Binary) return left_is_object(node.left);
  7716. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  7717. return false;
  7718. }
  7719. /***********************************************************************
  7720. A JavaScript tokenizer / parser / beautifier / compressor.
  7721. https://github.com/mishoo/UglifyJS2
  7722. -------------------------------- (C) ---------------------------------
  7723. Author: Mihai Bazon
  7724. <mihai.bazon@gmail.com>
  7725. http://mihai.bazon.net/blog
  7726. Distributed under the BSD license:
  7727. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  7728. Redistribution and use in source and binary forms, with or without
  7729. modification, are permitted provided that the following conditions
  7730. are met:
  7731. * Redistributions of source code must retain the above
  7732. copyright notice, this list of conditions and the following
  7733. disclaimer.
  7734. * Redistributions in binary form must reproduce the above
  7735. copyright notice, this list of conditions and the following
  7736. disclaimer in the documentation and/or other materials
  7737. provided with the distribution.
  7738. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  7739. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7740. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  7741. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  7742. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  7743. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  7744. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  7745. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7746. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  7747. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  7748. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  7749. SUCH DAMAGE.
  7750. ***********************************************************************/
  7751. const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
  7752. const CODE_LINE_BREAK = 10;
  7753. const CODE_SPACE = 32;
  7754. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/g;
  7755. function is_some_comments(comment) {
  7756. // multiline comment
  7757. return (
  7758. (comment.type === "comment2" || comment.type === "comment1")
  7759. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  7760. );
  7761. }
  7762. class Rope {
  7763. constructor() {
  7764. this.committed = "";
  7765. this.current = "";
  7766. }
  7767. append(str) {
  7768. this.current += str;
  7769. }
  7770. insertAt(char, index) {
  7771. const { committed, current } = this;
  7772. if (index < committed.length) {
  7773. this.committed = committed.slice(0, index) + char + committed.slice(index);
  7774. } else if (index === committed.length) {
  7775. this.committed += char;
  7776. } else {
  7777. index -= committed.length;
  7778. this.committed += current.slice(0, index) + char;
  7779. this.current = current.slice(index);
  7780. }
  7781. }
  7782. charAt(index) {
  7783. const { committed } = this;
  7784. if (index < committed.length) return committed[index];
  7785. return this.current[index - committed.length];
  7786. }
  7787. curLength() {
  7788. return this.current.length;
  7789. }
  7790. length() {
  7791. return this.committed.length + this.current.length;
  7792. }
  7793. toString() {
  7794. return this.committed + this.current;
  7795. }
  7796. }
  7797. function OutputStream(options) {
  7798. var readonly = !options;
  7799. options = defaults(options, {
  7800. ascii_only : false,
  7801. beautify : false,
  7802. braces : false,
  7803. comments : "some",
  7804. ecma : 5,
  7805. ie8 : false,
  7806. indent_level : 4,
  7807. indent_start : 0,
  7808. inline_script : true,
  7809. keep_numbers : false,
  7810. keep_quoted_props : false,
  7811. max_line_len : false,
  7812. preamble : null,
  7813. preserve_annotations : false,
  7814. quote_keys : false,
  7815. quote_style : 0,
  7816. safari10 : false,
  7817. semicolons : true,
  7818. shebang : true,
  7819. shorthand : undefined,
  7820. source_map : null,
  7821. webkit : false,
  7822. width : 80,
  7823. wrap_iife : false,
  7824. wrap_func_args : true,
  7825. _destroy_ast : false
  7826. }, true);
  7827. if (options.shorthand === undefined)
  7828. options.shorthand = options.ecma > 5;
  7829. // Convert comment option to RegExp if neccessary and set up comments filter
  7830. var comment_filter = return_false; // Default case, throw all comments away
  7831. if (options.comments) {
  7832. let comments = options.comments;
  7833. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  7834. var regex_pos = options.comments.lastIndexOf("/");
  7835. comments = new RegExp(
  7836. options.comments.substr(1, regex_pos - 1),
  7837. options.comments.substr(regex_pos + 1)
  7838. );
  7839. }
  7840. if (comments instanceof RegExp) {
  7841. comment_filter = function(comment) {
  7842. return comment.type != "comment5" && comments.test(comment.value);
  7843. };
  7844. } else if (typeof comments === "function") {
  7845. comment_filter = function(comment) {
  7846. return comment.type != "comment5" && comments(this, comment);
  7847. };
  7848. } else if (comments === "some") {
  7849. comment_filter = is_some_comments;
  7850. } else { // NOTE includes "all" option
  7851. comment_filter = return_true;
  7852. }
  7853. }
  7854. var indentation = 0;
  7855. var current_col = 0;
  7856. var current_line = 1;
  7857. var current_pos = 0;
  7858. var OUTPUT = new Rope();
  7859. let printed_comments = new Set();
  7860. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  7861. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  7862. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  7863. var code = get_full_char_code(ch, 0).toString(16);
  7864. return "\\u{" + code + "}";
  7865. });
  7866. }
  7867. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  7868. var code = ch.charCodeAt(0).toString(16);
  7869. if (code.length <= 2 && !identifier) {
  7870. while (code.length < 2) code = "0" + code;
  7871. return "\\x" + code;
  7872. } else {
  7873. while (code.length < 4) code = "0" + code;
  7874. return "\\u" + code;
  7875. }
  7876. });
  7877. } : function(str) {
  7878. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  7879. if (lone) {
  7880. return "\\u" + lone.charCodeAt(0).toString(16);
  7881. }
  7882. return match;
  7883. });
  7884. };
  7885. function make_string(str, quote) {
  7886. var dq = 0, sq = 0;
  7887. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  7888. function(s, i) {
  7889. switch (s) {
  7890. case '"': ++dq; return '"';
  7891. case "'": ++sq; return "'";
  7892. case "\\": return "\\\\";
  7893. case "\n": return "\\n";
  7894. case "\r": return "\\r";
  7895. case "\t": return "\\t";
  7896. case "\b": return "\\b";
  7897. case "\f": return "\\f";
  7898. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  7899. case "\u2028": return "\\u2028";
  7900. case "\u2029": return "\\u2029";
  7901. case "\ufeff": return "\\ufeff";
  7902. case "\0":
  7903. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  7904. }
  7905. return s;
  7906. });
  7907. function quote_single() {
  7908. return "'" + str.replace(/\x27/g, "\\'") + "'";
  7909. }
  7910. function quote_double() {
  7911. return '"' + str.replace(/\x22/g, '\\"') + '"';
  7912. }
  7913. function quote_template() {
  7914. return "`" + str.replace(/`/g, "\\`") + "`";
  7915. }
  7916. str = to_utf8(str);
  7917. if (quote === "`") return quote_template();
  7918. switch (options.quote_style) {
  7919. case 1:
  7920. return quote_single();
  7921. case 2:
  7922. return quote_double();
  7923. case 3:
  7924. return quote == "'" ? quote_single() : quote_double();
  7925. default:
  7926. return dq > sq ? quote_single() : quote_double();
  7927. }
  7928. }
  7929. function encode_string(str, quote) {
  7930. var ret = make_string(str, quote);
  7931. if (options.inline_script) {
  7932. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  7933. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  7934. ret = ret.replace(/--\x3e/g, "--\\x3e");
  7935. }
  7936. return ret;
  7937. }
  7938. function make_name(name) {
  7939. name = name.toString();
  7940. name = to_utf8(name, true);
  7941. return name;
  7942. }
  7943. function make_indent(back) {
  7944. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  7945. }
  7946. /* -----[ beautification/minification ]----- */
  7947. var has_parens = false;
  7948. var might_need_space = false;
  7949. var might_need_semicolon = false;
  7950. var might_add_newline = 0;
  7951. var need_newline_indented = false;
  7952. var need_space = false;
  7953. var newline_insert = -1;
  7954. var last = "";
  7955. var mapping_token, mapping_name, mappings = options.source_map && [];
  7956. var do_add_mapping = mappings ? function() {
  7957. mappings.forEach(function(mapping) {
  7958. try {
  7959. let { name, token } = mapping;
  7960. if (token.type == "name" || token.type === "privatename") {
  7961. name = token.value;
  7962. } else if (name instanceof AST_Symbol) {
  7963. name = token.type === "string" ? token.value : name.name;
  7964. }
  7965. options.source_map.add(
  7966. mapping.token.file,
  7967. mapping.line, mapping.col,
  7968. mapping.token.line, mapping.token.col,
  7969. is_basic_identifier_string(name) ? name : undefined
  7970. );
  7971. } catch(ex) {
  7972. // Ignore bad mapping
  7973. }
  7974. });
  7975. mappings = [];
  7976. } : noop;
  7977. var ensure_line_len = options.max_line_len ? function() {
  7978. if (current_col > options.max_line_len) {
  7979. if (might_add_newline) {
  7980. OUTPUT.insertAt("\n", might_add_newline);
  7981. const curLength = OUTPUT.curLength();
  7982. if (mappings) {
  7983. var delta = curLength - current_col;
  7984. mappings.forEach(function(mapping) {
  7985. mapping.line++;
  7986. mapping.col += delta;
  7987. });
  7988. }
  7989. current_line++;
  7990. current_pos++;
  7991. current_col = curLength;
  7992. }
  7993. }
  7994. if (might_add_newline) {
  7995. might_add_newline = 0;
  7996. do_add_mapping();
  7997. }
  7998. } : noop;
  7999. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  8000. function print(str) {
  8001. str = String(str);
  8002. var ch = get_full_char(str, 0);
  8003. if (need_newline_indented && ch) {
  8004. need_newline_indented = false;
  8005. if (ch !== "\n") {
  8006. print("\n");
  8007. indent();
  8008. }
  8009. }
  8010. if (need_space && ch) {
  8011. need_space = false;
  8012. if (!/[\s;})]/.test(ch)) {
  8013. space();
  8014. }
  8015. }
  8016. newline_insert = -1;
  8017. var prev = last.charAt(last.length - 1);
  8018. if (might_need_semicolon) {
  8019. might_need_semicolon = false;
  8020. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  8021. if (options.semicolons || requireSemicolonChars.has(ch)) {
  8022. OUTPUT.append(";");
  8023. current_col++;
  8024. current_pos++;
  8025. } else {
  8026. ensure_line_len();
  8027. if (current_col > 0) {
  8028. OUTPUT.append("\n");
  8029. current_pos++;
  8030. current_line++;
  8031. current_col = 0;
  8032. }
  8033. if (/^\s+$/.test(str)) {
  8034. // reset the semicolon flag, since we didn't print one
  8035. // now and might still have to later
  8036. might_need_semicolon = true;
  8037. }
  8038. }
  8039. if (!options.beautify)
  8040. might_need_space = false;
  8041. }
  8042. }
  8043. if (might_need_space) {
  8044. if ((is_identifier_char(prev)
  8045. && (is_identifier_char(ch) || ch == "\\"))
  8046. || (ch == "/" && ch == prev)
  8047. || ((ch == "+" || ch == "-") && ch == last)
  8048. ) {
  8049. OUTPUT.append(" ");
  8050. current_col++;
  8051. current_pos++;
  8052. }
  8053. might_need_space = false;
  8054. }
  8055. if (mapping_token) {
  8056. mappings.push({
  8057. token: mapping_token,
  8058. name: mapping_name,
  8059. line: current_line,
  8060. col: current_col
  8061. });
  8062. mapping_token = false;
  8063. if (!might_add_newline) do_add_mapping();
  8064. }
  8065. OUTPUT.append(str);
  8066. has_parens = str[str.length - 1] == "(";
  8067. current_pos += str.length;
  8068. var a = str.split(/\r?\n/), n = a.length - 1;
  8069. current_line += n;
  8070. current_col += a[0].length;
  8071. if (n > 0) {
  8072. ensure_line_len();
  8073. current_col = a[n].length;
  8074. }
  8075. last = str;
  8076. }
  8077. var star = function() {
  8078. print("*");
  8079. };
  8080. var space = options.beautify ? function() {
  8081. print(" ");
  8082. } : function() {
  8083. might_need_space = true;
  8084. };
  8085. var indent = options.beautify ? function(half) {
  8086. if (options.beautify) {
  8087. print(make_indent(half ? 0.5 : 0));
  8088. }
  8089. } : noop;
  8090. var with_indent = options.beautify ? function(col, cont) {
  8091. if (col === true) col = next_indent();
  8092. var save_indentation = indentation;
  8093. indentation = col;
  8094. var ret = cont();
  8095. indentation = save_indentation;
  8096. return ret;
  8097. } : function(col, cont) { return cont(); };
  8098. var newline = options.beautify ? function() {
  8099. if (newline_insert < 0) return print("\n");
  8100. if (OUTPUT.charAt(newline_insert) != "\n") {
  8101. OUTPUT.insertAt("\n", newline_insert);
  8102. current_pos++;
  8103. current_line++;
  8104. }
  8105. newline_insert++;
  8106. } : options.max_line_len ? function() {
  8107. ensure_line_len();
  8108. might_add_newline = OUTPUT.length();
  8109. } : noop;
  8110. var semicolon = options.beautify ? function() {
  8111. print(";");
  8112. } : function() {
  8113. might_need_semicolon = true;
  8114. };
  8115. function force_semicolon() {
  8116. might_need_semicolon = false;
  8117. print(";");
  8118. }
  8119. function next_indent() {
  8120. return indentation + options.indent_level;
  8121. }
  8122. function with_block(cont) {
  8123. var ret;
  8124. print("{");
  8125. newline();
  8126. with_indent(next_indent(), function() {
  8127. ret = cont();
  8128. });
  8129. indent();
  8130. print("}");
  8131. return ret;
  8132. }
  8133. function with_parens(cont) {
  8134. print("(");
  8135. //XXX: still nice to have that for argument lists
  8136. //var ret = with_indent(current_col, cont);
  8137. var ret = cont();
  8138. print(")");
  8139. return ret;
  8140. }
  8141. function with_square(cont) {
  8142. print("[");
  8143. //var ret = with_indent(current_col, cont);
  8144. var ret = cont();
  8145. print("]");
  8146. return ret;
  8147. }
  8148. function comma() {
  8149. print(",");
  8150. space();
  8151. }
  8152. function colon() {
  8153. print(":");
  8154. space();
  8155. }
  8156. var add_mapping = mappings ? function(token, name) {
  8157. mapping_token = token;
  8158. mapping_name = name;
  8159. } : noop;
  8160. function get() {
  8161. if (might_add_newline) {
  8162. ensure_line_len();
  8163. }
  8164. return OUTPUT.toString();
  8165. }
  8166. function has_nlb() {
  8167. const output = OUTPUT.toString();
  8168. let n = output.length - 1;
  8169. while (n >= 0) {
  8170. const code = output.charCodeAt(n);
  8171. if (code === CODE_LINE_BREAK) {
  8172. return true;
  8173. }
  8174. if (code !== CODE_SPACE) {
  8175. return false;
  8176. }
  8177. n--;
  8178. }
  8179. return true;
  8180. }
  8181. function filter_comment(comment) {
  8182. if (!options.preserve_annotations) {
  8183. comment = comment.replace(r_annotation, " ");
  8184. }
  8185. if (/^\s*$/.test(comment)) {
  8186. return "";
  8187. }
  8188. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  8189. }
  8190. function prepend_comments(node) {
  8191. var self = this;
  8192. var start = node.start;
  8193. if (!start) return;
  8194. var printed_comments = self.printed_comments;
  8195. // There cannot be a newline between return and its value.
  8196. const return_with_value = node instanceof AST_Exit && node.value;
  8197. if (
  8198. start.comments_before
  8199. && printed_comments.has(start.comments_before)
  8200. ) {
  8201. if (return_with_value) {
  8202. start.comments_before = [];
  8203. } else {
  8204. return;
  8205. }
  8206. }
  8207. var comments = start.comments_before;
  8208. if (!comments) {
  8209. comments = start.comments_before = [];
  8210. }
  8211. printed_comments.add(comments);
  8212. if (return_with_value) {
  8213. var tw = new TreeWalker(function(node) {
  8214. var parent = tw.parent();
  8215. if (parent instanceof AST_Exit
  8216. || parent instanceof AST_Binary && parent.left === node
  8217. || parent.TYPE == "Call" && parent.expression === node
  8218. || parent instanceof AST_Conditional && parent.condition === node
  8219. || parent instanceof AST_Dot && parent.expression === node
  8220. || parent instanceof AST_Sequence && parent.expressions[0] === node
  8221. || parent instanceof AST_Sub && parent.expression === node
  8222. || parent instanceof AST_UnaryPostfix) {
  8223. if (!node.start) return;
  8224. var text = node.start.comments_before;
  8225. if (text && !printed_comments.has(text)) {
  8226. printed_comments.add(text);
  8227. comments = comments.concat(text);
  8228. }
  8229. } else {
  8230. return true;
  8231. }
  8232. });
  8233. tw.push(node);
  8234. node.value.walk(tw);
  8235. }
  8236. if (current_pos == 0) {
  8237. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  8238. && !printed_comments.has(comments[0])) {
  8239. print("#!" + comments.shift().value + "\n");
  8240. indent();
  8241. }
  8242. var preamble = options.preamble;
  8243. if (preamble) {
  8244. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  8245. }
  8246. }
  8247. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  8248. if (comments.length == 0) return;
  8249. var last_nlb = has_nlb();
  8250. comments.forEach(function(c, i) {
  8251. printed_comments.add(c);
  8252. if (!last_nlb) {
  8253. if (c.nlb) {
  8254. print("\n");
  8255. indent();
  8256. last_nlb = true;
  8257. } else if (i > 0) {
  8258. space();
  8259. }
  8260. }
  8261. if (/comment[134]/.test(c.type)) {
  8262. var value = filter_comment(c.value);
  8263. if (value) {
  8264. print("//" + value + "\n");
  8265. indent();
  8266. }
  8267. last_nlb = true;
  8268. } else if (c.type == "comment2") {
  8269. var value = filter_comment(c.value);
  8270. if (value) {
  8271. print("/*" + value + "*/");
  8272. }
  8273. last_nlb = false;
  8274. }
  8275. });
  8276. if (!last_nlb) {
  8277. if (start.nlb) {
  8278. print("\n");
  8279. indent();
  8280. } else {
  8281. space();
  8282. }
  8283. }
  8284. }
  8285. function append_comments(node, tail) {
  8286. var self = this;
  8287. var token = node.end;
  8288. if (!token) return;
  8289. var printed_comments = self.printed_comments;
  8290. var comments = token[tail ? "comments_before" : "comments_after"];
  8291. if (!comments || printed_comments.has(comments)) return;
  8292. if (!(node instanceof AST_Statement || comments.every((c) =>
  8293. !/comment[134]/.test(c.type)
  8294. ))) return;
  8295. printed_comments.add(comments);
  8296. var insert = OUTPUT.length();
  8297. comments.filter(comment_filter, node).forEach(function(c, i) {
  8298. if (printed_comments.has(c)) return;
  8299. printed_comments.add(c);
  8300. need_space = false;
  8301. if (need_newline_indented) {
  8302. print("\n");
  8303. indent();
  8304. need_newline_indented = false;
  8305. } else if (c.nlb && (i > 0 || !has_nlb())) {
  8306. print("\n");
  8307. indent();
  8308. } else if (i > 0 || !tail) {
  8309. space();
  8310. }
  8311. if (/comment[134]/.test(c.type)) {
  8312. const value = filter_comment(c.value);
  8313. if (value) {
  8314. print("//" + value);
  8315. }
  8316. need_newline_indented = true;
  8317. } else if (c.type == "comment2") {
  8318. const value = filter_comment(c.value);
  8319. if (value) {
  8320. print("/*" + value + "*/");
  8321. }
  8322. need_space = true;
  8323. }
  8324. });
  8325. if (OUTPUT.length() > insert) newline_insert = insert;
  8326. }
  8327. /**
  8328. * When output.option("_destroy_ast") is enabled, destroy the function.
  8329. * Call this after printing it.
  8330. */
  8331. const gc_scope =
  8332. options["_destroy_ast"]
  8333. ? function gc_scope(scope) {
  8334. scope.body.length = 0;
  8335. scope.argnames.length = 0;
  8336. }
  8337. : noop;
  8338. var stack = [];
  8339. return {
  8340. get : get,
  8341. toString : get,
  8342. indent : indent,
  8343. in_directive : false,
  8344. use_asm : null,
  8345. active_scope : null,
  8346. indentation : function() { return indentation; },
  8347. current_width : function() { return current_col - indentation; },
  8348. should_break : function() { return options.width && this.current_width() >= options.width; },
  8349. has_parens : function() { return has_parens; },
  8350. newline : newline,
  8351. print : print,
  8352. star : star,
  8353. space : space,
  8354. comma : comma,
  8355. colon : colon,
  8356. last : function() { return last; },
  8357. semicolon : semicolon,
  8358. force_semicolon : force_semicolon,
  8359. to_utf8 : to_utf8,
  8360. print_name : function(name) { print(make_name(name)); },
  8361. print_string : function(str, quote, escape_directive) {
  8362. var encoded = encode_string(str, quote);
  8363. if (escape_directive === true && !encoded.includes("\\")) {
  8364. // Insert semicolons to break directive prologue
  8365. if (!EXPECT_DIRECTIVE.test(OUTPUT.toString())) {
  8366. force_semicolon();
  8367. }
  8368. force_semicolon();
  8369. }
  8370. print(encoded);
  8371. },
  8372. print_template_string_chars: function(str) {
  8373. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  8374. return print(encoded.substr(1, encoded.length - 2));
  8375. },
  8376. encode_string : encode_string,
  8377. next_indent : next_indent,
  8378. with_indent : with_indent,
  8379. with_block : with_block,
  8380. with_parens : with_parens,
  8381. with_square : with_square,
  8382. add_mapping : add_mapping,
  8383. option : function(opt) { return options[opt]; },
  8384. gc_scope,
  8385. printed_comments: printed_comments,
  8386. prepend_comments: readonly ? noop : prepend_comments,
  8387. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  8388. line : function() { return current_line; },
  8389. col : function() { return current_col; },
  8390. pos : function() { return current_pos; },
  8391. push_node : function(node) { stack.push(node); },
  8392. pop_node : function() { return stack.pop(); },
  8393. parent : function(n) {
  8394. return stack[stack.length - 2 - (n || 0)];
  8395. }
  8396. };
  8397. }
  8398. /* -----[ code generators ]----- */
  8399. (function() {
  8400. /* -----[ utils ]----- */
  8401. function DEFPRINT(nodetype, generator) {
  8402. nodetype.DEFMETHOD("_codegen", generator);
  8403. }
  8404. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  8405. var self = this, generator = self._codegen;
  8406. if (self instanceof AST_Scope) {
  8407. output.active_scope = self;
  8408. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  8409. output.use_asm = output.active_scope;
  8410. }
  8411. function doit() {
  8412. output.prepend_comments(self);
  8413. self.add_source_map(output);
  8414. generator(self, output);
  8415. output.append_comments(self);
  8416. }
  8417. output.push_node(self);
  8418. if (force_parens || self.needs_parens(output)) {
  8419. output.with_parens(doit);
  8420. } else {
  8421. doit();
  8422. }
  8423. output.pop_node();
  8424. if (self === output.use_asm) {
  8425. output.use_asm = null;
  8426. }
  8427. });
  8428. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  8429. AST_Node.DEFMETHOD("print_to_string", function(options) {
  8430. var output = OutputStream(options);
  8431. this.print(output);
  8432. return output.get();
  8433. });
  8434. /* -----[ PARENTHESES ]----- */
  8435. function PARENS(nodetype, func) {
  8436. if (Array.isArray(nodetype)) {
  8437. nodetype.forEach(function(nodetype) {
  8438. PARENS(nodetype, func);
  8439. });
  8440. } else {
  8441. nodetype.DEFMETHOD("needs_parens", func);
  8442. }
  8443. }
  8444. PARENS(AST_Node, return_false);
  8445. // a function expression needs parens around it when it's provably
  8446. // the first token to appear in a statement.
  8447. PARENS(AST_Function, function(output) {
  8448. if (!output.has_parens() && first_in_statement(output)) {
  8449. return true;
  8450. }
  8451. if (output.option("webkit")) {
  8452. var p = output.parent();
  8453. if (p instanceof AST_PropAccess && p.expression === this) {
  8454. return true;
  8455. }
  8456. }
  8457. if (output.option("wrap_iife")) {
  8458. var p = output.parent();
  8459. if (p instanceof AST_Call && p.expression === this) {
  8460. return true;
  8461. }
  8462. }
  8463. if (output.option("wrap_func_args")) {
  8464. var p = output.parent();
  8465. if (p instanceof AST_Call && p.args.includes(this)) {
  8466. return true;
  8467. }
  8468. }
  8469. return false;
  8470. });
  8471. PARENS(AST_Arrow, function(output) {
  8472. var p = output.parent();
  8473. if (
  8474. output.option("wrap_func_args")
  8475. && p instanceof AST_Call
  8476. && p.args.includes(this)
  8477. ) {
  8478. return true;
  8479. }
  8480. return p instanceof AST_PropAccess && p.expression === this;
  8481. });
  8482. // same goes for an object literal (as in AST_Function), because
  8483. // otherwise {...} would be interpreted as a block of code.
  8484. PARENS(AST_Object, function(output) {
  8485. return !output.has_parens() && first_in_statement(output);
  8486. });
  8487. PARENS(AST_ClassExpression, first_in_statement);
  8488. PARENS(AST_Unary, function(output) {
  8489. var p = output.parent();
  8490. return p instanceof AST_PropAccess && p.expression === this
  8491. || p instanceof AST_Call && p.expression === this
  8492. || p instanceof AST_Binary
  8493. && p.operator === "**"
  8494. && this instanceof AST_UnaryPrefix
  8495. && p.left === this
  8496. && this.operator !== "++"
  8497. && this.operator !== "--";
  8498. });
  8499. PARENS(AST_Await, function(output) {
  8500. var p = output.parent();
  8501. return p instanceof AST_PropAccess && p.expression === this
  8502. || p instanceof AST_Call && p.expression === this
  8503. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  8504. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  8505. });
  8506. PARENS(AST_Sequence, function(output) {
  8507. var p = output.parent();
  8508. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  8509. || p instanceof AST_Unary // !(foo, bar, baz)
  8510. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  8511. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  8512. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  8513. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  8514. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  8515. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  8516. * ==> 20 (side effect, set a := 10 and b := 20) */
  8517. || p instanceof AST_Arrow // x => (x, x)
  8518. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  8519. || p instanceof AST_Expansion // [...(a, b)]
  8520. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  8521. || p instanceof AST_Yield // yield (foo, bar)
  8522. || p instanceof AST_Export // export default (foo, bar)
  8523. ;
  8524. });
  8525. PARENS(AST_Binary, function(output) {
  8526. var p = output.parent();
  8527. // (foo && bar)()
  8528. if (p instanceof AST_Call && p.expression === this)
  8529. return true;
  8530. // typeof (foo && bar)
  8531. if (p instanceof AST_Unary)
  8532. return true;
  8533. // (foo && bar)["prop"], (foo && bar).prop
  8534. if (p instanceof AST_PropAccess && p.expression === this)
  8535. return true;
  8536. // this deals with precedence: 3 * (2 + 1)
  8537. if (p instanceof AST_Binary) {
  8538. const po = p.operator;
  8539. const so = this.operator;
  8540. if (so === "??" && (po === "||" || po === "&&")) {
  8541. return true;
  8542. }
  8543. if (po === "??" && (so === "||" || so === "&&")) {
  8544. return true;
  8545. }
  8546. const pp = PRECEDENCE[po];
  8547. const sp = PRECEDENCE[so];
  8548. if (pp > sp
  8549. || (pp == sp
  8550. && (this === p.right || po == "**"))) {
  8551. return true;
  8552. }
  8553. }
  8554. });
  8555. PARENS(AST_Yield, function(output) {
  8556. var p = output.parent();
  8557. // (yield 1) + (yield 2)
  8558. // a = yield 3
  8559. if (p instanceof AST_Binary && p.operator !== "=")
  8560. return true;
  8561. // (yield 1)()
  8562. // new (yield 1)()
  8563. if (p instanceof AST_Call && p.expression === this)
  8564. return true;
  8565. // (yield 1) ? yield 2 : yield 3
  8566. if (p instanceof AST_Conditional && p.condition === this)
  8567. return true;
  8568. // -(yield 4)
  8569. if (p instanceof AST_Unary)
  8570. return true;
  8571. // (yield x).foo
  8572. // (yield x)['foo']
  8573. if (p instanceof AST_PropAccess && p.expression === this)
  8574. return true;
  8575. });
  8576. PARENS(AST_PropAccess, function(output) {
  8577. var p = output.parent();
  8578. if (p instanceof AST_New && p.expression === this) {
  8579. // i.e. new (foo.bar().baz)
  8580. //
  8581. // if there's one call into this subtree, then we need
  8582. // parens around it too, otherwise the call will be
  8583. // interpreted as passing the arguments to the upper New
  8584. // expression.
  8585. return walk(this, node => {
  8586. if (node instanceof AST_Scope) return true;
  8587. if (node instanceof AST_Call) {
  8588. return walk_abort; // makes walk() return true.
  8589. }
  8590. });
  8591. }
  8592. });
  8593. PARENS(AST_Call, function(output) {
  8594. var p = output.parent(), p1;
  8595. if (p instanceof AST_New && p.expression === this
  8596. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  8597. return true;
  8598. // workaround for Safari bug.
  8599. // https://bugs.webkit.org/show_bug.cgi?id=123506
  8600. return this.expression instanceof AST_Function
  8601. && p instanceof AST_PropAccess
  8602. && p.expression === this
  8603. && (p1 = output.parent(1)) instanceof AST_Assign
  8604. && p1.left === p;
  8605. });
  8606. PARENS(AST_New, function(output) {
  8607. var p = output.parent();
  8608. if (this.args.length === 0
  8609. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  8610. || p instanceof AST_Call && p.expression === this
  8611. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  8612. return true;
  8613. });
  8614. PARENS(AST_Number, function(output) {
  8615. var p = output.parent();
  8616. if (p instanceof AST_PropAccess && p.expression === this) {
  8617. var value = this.getValue();
  8618. if (value < 0 || /^0/.test(make_num(value))) {
  8619. return true;
  8620. }
  8621. }
  8622. });
  8623. PARENS(AST_BigInt, function(output) {
  8624. var p = output.parent();
  8625. if (p instanceof AST_PropAccess && p.expression === this) {
  8626. var value = this.getValue();
  8627. if (value.startsWith("-")) {
  8628. return true;
  8629. }
  8630. }
  8631. });
  8632. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  8633. var p = output.parent();
  8634. // !(a = false) → true
  8635. if (p instanceof AST_Unary)
  8636. return true;
  8637. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  8638. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  8639. return true;
  8640. // (a = func)() —or— new (a = Object)()
  8641. if (p instanceof AST_Call && p.expression === this)
  8642. return true;
  8643. // (a = foo) ? bar : baz
  8644. if (p instanceof AST_Conditional && p.condition === this)
  8645. return true;
  8646. // (a = foo)["prop"] —or— (a = foo).prop
  8647. if (p instanceof AST_PropAccess && p.expression === this)
  8648. return true;
  8649. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  8650. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  8651. return true;
  8652. });
  8653. /* -----[ PRINTERS ]----- */
  8654. DEFPRINT(AST_Directive, function(self, output) {
  8655. output.print_string(self.value, self.quote);
  8656. output.semicolon();
  8657. });
  8658. DEFPRINT(AST_Expansion, function (self, output) {
  8659. output.print("...");
  8660. self.expression.print(output);
  8661. });
  8662. DEFPRINT(AST_Destructuring, function (self, output) {
  8663. output.print(self.is_array ? "[" : "{");
  8664. var len = self.names.length;
  8665. self.names.forEach(function (name, i) {
  8666. if (i > 0) output.comma();
  8667. name.print(output);
  8668. // If the final element is a hole, we need to make sure it
  8669. // doesn't look like a trailing comma, by inserting an actual
  8670. // trailing comma.
  8671. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  8672. });
  8673. output.print(self.is_array ? "]" : "}");
  8674. });
  8675. DEFPRINT(AST_Debugger, function(self, output) {
  8676. output.print("debugger");
  8677. output.semicolon();
  8678. });
  8679. /* -----[ statements ]----- */
  8680. function display_body(body, is_toplevel, output, allow_directives) {
  8681. var last = body.length - 1;
  8682. output.in_directive = allow_directives;
  8683. body.forEach(function(stmt, i) {
  8684. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  8685. stmt instanceof AST_EmptyStatement ||
  8686. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  8687. )) {
  8688. output.in_directive = false;
  8689. }
  8690. if (!(stmt instanceof AST_EmptyStatement)) {
  8691. output.indent();
  8692. stmt.print(output);
  8693. if (!(i == last && is_toplevel)) {
  8694. output.newline();
  8695. if (is_toplevel) output.newline();
  8696. }
  8697. }
  8698. if (output.in_directive === true &&
  8699. stmt instanceof AST_SimpleStatement &&
  8700. stmt.body instanceof AST_String
  8701. ) {
  8702. output.in_directive = false;
  8703. }
  8704. });
  8705. output.in_directive = false;
  8706. }
  8707. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  8708. force_statement(this.body, output);
  8709. });
  8710. DEFPRINT(AST_Statement, function(self, output) {
  8711. self.body.print(output);
  8712. output.semicolon();
  8713. });
  8714. DEFPRINT(AST_Toplevel, function(self, output) {
  8715. display_body(self.body, true, output, true);
  8716. output.print("");
  8717. });
  8718. DEFPRINT(AST_LabeledStatement, function(self, output) {
  8719. self.label.print(output);
  8720. output.colon();
  8721. self.body.print(output);
  8722. });
  8723. DEFPRINT(AST_SimpleStatement, function(self, output) {
  8724. self.body.print(output);
  8725. output.semicolon();
  8726. });
  8727. function print_braced_empty(self, output) {
  8728. output.print("{");
  8729. output.with_indent(output.next_indent(), function() {
  8730. output.append_comments(self, true);
  8731. });
  8732. output.add_mapping(self.end);
  8733. output.print("}");
  8734. }
  8735. function print_braced(self, output, allow_directives) {
  8736. if (self.body.length > 0) {
  8737. output.with_block(function() {
  8738. display_body(self.body, false, output, allow_directives);
  8739. output.add_mapping(self.end);
  8740. });
  8741. } else print_braced_empty(self, output);
  8742. }
  8743. DEFPRINT(AST_BlockStatement, function(self, output) {
  8744. print_braced(self, output);
  8745. });
  8746. DEFPRINT(AST_EmptyStatement, function(self, output) {
  8747. output.semicolon();
  8748. });
  8749. DEFPRINT(AST_Do, function(self, output) {
  8750. output.print("do");
  8751. output.space();
  8752. make_block(self.body, output);
  8753. output.space();
  8754. output.print("while");
  8755. output.space();
  8756. output.with_parens(function() {
  8757. self.condition.print(output);
  8758. });
  8759. output.semicolon();
  8760. });
  8761. DEFPRINT(AST_While, function(self, output) {
  8762. output.print("while");
  8763. output.space();
  8764. output.with_parens(function() {
  8765. self.condition.print(output);
  8766. });
  8767. output.space();
  8768. self._do_print_body(output);
  8769. });
  8770. DEFPRINT(AST_For, function(self, output) {
  8771. output.print("for");
  8772. output.space();
  8773. output.with_parens(function() {
  8774. if (self.init) {
  8775. if (self.init instanceof AST_Definitions) {
  8776. self.init.print(output);
  8777. } else {
  8778. parenthesize_for_noin(self.init, output, true);
  8779. }
  8780. output.print(";");
  8781. output.space();
  8782. } else {
  8783. output.print(";");
  8784. }
  8785. if (self.condition) {
  8786. self.condition.print(output);
  8787. output.print(";");
  8788. output.space();
  8789. } else {
  8790. output.print(";");
  8791. }
  8792. if (self.step) {
  8793. self.step.print(output);
  8794. }
  8795. });
  8796. output.space();
  8797. self._do_print_body(output);
  8798. });
  8799. DEFPRINT(AST_ForIn, function(self, output) {
  8800. output.print("for");
  8801. if (self.await) {
  8802. output.space();
  8803. output.print("await");
  8804. }
  8805. output.space();
  8806. output.with_parens(function() {
  8807. self.init.print(output);
  8808. output.space();
  8809. output.print(self instanceof AST_ForOf ? "of" : "in");
  8810. output.space();
  8811. self.object.print(output);
  8812. });
  8813. output.space();
  8814. self._do_print_body(output);
  8815. });
  8816. DEFPRINT(AST_With, function(self, output) {
  8817. output.print("with");
  8818. output.space();
  8819. output.with_parens(function() {
  8820. self.expression.print(output);
  8821. });
  8822. output.space();
  8823. self._do_print_body(output);
  8824. });
  8825. /* -----[ functions ]----- */
  8826. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  8827. var self = this;
  8828. if (!nokeyword) {
  8829. if (self.async) {
  8830. output.print("async");
  8831. output.space();
  8832. }
  8833. output.print("function");
  8834. if (self.is_generator) {
  8835. output.star();
  8836. }
  8837. if (self.name) {
  8838. output.space();
  8839. }
  8840. }
  8841. if (self.name instanceof AST_Symbol) {
  8842. self.name.print(output);
  8843. } else if (nokeyword && self.name instanceof AST_Node) {
  8844. output.with_square(function() {
  8845. self.name.print(output); // Computed method name
  8846. });
  8847. }
  8848. output.with_parens(function() {
  8849. self.argnames.forEach(function(arg, i) {
  8850. if (i) output.comma();
  8851. arg.print(output);
  8852. });
  8853. });
  8854. output.space();
  8855. print_braced(self, output, true);
  8856. });
  8857. DEFPRINT(AST_Lambda, function(self, output) {
  8858. self._do_print(output);
  8859. output.gc_scope(self);
  8860. });
  8861. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  8862. var tag = self.prefix;
  8863. var parenthesize_tag = tag instanceof AST_Lambda
  8864. || tag instanceof AST_Binary
  8865. || tag instanceof AST_Conditional
  8866. || tag instanceof AST_Sequence
  8867. || tag instanceof AST_Unary
  8868. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  8869. if (parenthesize_tag) output.print("(");
  8870. self.prefix.print(output);
  8871. if (parenthesize_tag) output.print(")");
  8872. self.template_string.print(output);
  8873. });
  8874. DEFPRINT(AST_TemplateString, function(self, output) {
  8875. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  8876. output.print("`");
  8877. for (var i = 0; i < self.segments.length; i++) {
  8878. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  8879. output.print("${");
  8880. self.segments[i].print(output);
  8881. output.print("}");
  8882. } else if (is_tagged) {
  8883. output.print(self.segments[i].raw);
  8884. } else {
  8885. output.print_template_string_chars(self.segments[i].value);
  8886. }
  8887. }
  8888. output.print("`");
  8889. });
  8890. DEFPRINT(AST_TemplateSegment, function(self, output) {
  8891. output.print_template_string_chars(self.value);
  8892. });
  8893. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  8894. var self = this;
  8895. var parent = output.parent();
  8896. var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
  8897. parent instanceof AST_Unary ||
  8898. (parent instanceof AST_Call && self === parent.expression);
  8899. if (needs_parens) { output.print("("); }
  8900. if (self.async) {
  8901. output.print("async");
  8902. output.space();
  8903. }
  8904. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  8905. self.argnames[0].print(output);
  8906. } else {
  8907. output.with_parens(function() {
  8908. self.argnames.forEach(function(arg, i) {
  8909. if (i) output.comma();
  8910. arg.print(output);
  8911. });
  8912. });
  8913. }
  8914. output.space();
  8915. output.print("=>");
  8916. output.space();
  8917. const first_statement = self.body[0];
  8918. if (
  8919. self.body.length === 1
  8920. && first_statement instanceof AST_Return
  8921. ) {
  8922. const returned = first_statement.value;
  8923. if (!returned) {
  8924. output.print("{}");
  8925. } else if (left_is_object(returned)) {
  8926. output.print("(");
  8927. returned.print(output);
  8928. output.print(")");
  8929. } else {
  8930. returned.print(output);
  8931. }
  8932. } else {
  8933. print_braced(self, output);
  8934. }
  8935. if (needs_parens) { output.print(")"); }
  8936. output.gc_scope(self);
  8937. });
  8938. /* -----[ exits ]----- */
  8939. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  8940. output.print(kind);
  8941. if (this.value) {
  8942. output.space();
  8943. const comments = this.value.start.comments_before;
  8944. if (comments && comments.length && !output.printed_comments.has(comments)) {
  8945. output.print("(");
  8946. this.value.print(output);
  8947. output.print(")");
  8948. } else {
  8949. this.value.print(output);
  8950. }
  8951. }
  8952. output.semicolon();
  8953. });
  8954. DEFPRINT(AST_Return, function(self, output) {
  8955. self._do_print(output, "return");
  8956. });
  8957. DEFPRINT(AST_Throw, function(self, output) {
  8958. self._do_print(output, "throw");
  8959. });
  8960. /* -----[ yield ]----- */
  8961. DEFPRINT(AST_Yield, function(self, output) {
  8962. var star = self.is_star ? "*" : "";
  8963. output.print("yield" + star);
  8964. if (self.expression) {
  8965. output.space();
  8966. self.expression.print(output);
  8967. }
  8968. });
  8969. DEFPRINT(AST_Await, function(self, output) {
  8970. output.print("await");
  8971. output.space();
  8972. var e = self.expression;
  8973. var parens = !(
  8974. e instanceof AST_Call
  8975. || e instanceof AST_SymbolRef
  8976. || e instanceof AST_PropAccess
  8977. || e instanceof AST_Unary
  8978. || e instanceof AST_Constant
  8979. || e instanceof AST_Await
  8980. || e instanceof AST_Object
  8981. );
  8982. if (parens) output.print("(");
  8983. self.expression.print(output);
  8984. if (parens) output.print(")");
  8985. });
  8986. /* -----[ loop control ]----- */
  8987. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  8988. output.print(kind);
  8989. if (this.label) {
  8990. output.space();
  8991. this.label.print(output);
  8992. }
  8993. output.semicolon();
  8994. });
  8995. DEFPRINT(AST_Break, function(self, output) {
  8996. self._do_print(output, "break");
  8997. });
  8998. DEFPRINT(AST_Continue, function(self, output) {
  8999. self._do_print(output, "continue");
  9000. });
  9001. /* -----[ if ]----- */
  9002. function make_then(self, output) {
  9003. var b = self.body;
  9004. if (output.option("braces")
  9005. || output.option("ie8") && b instanceof AST_Do)
  9006. return make_block(b, output);
  9007. // The squeezer replaces "block"-s that contain only a single
  9008. // statement with the statement itself; technically, the AST
  9009. // is correct, but this can create problems when we output an
  9010. // IF having an ELSE clause where the THEN clause ends in an
  9011. // IF *without* an ELSE block (then the outer ELSE would refer
  9012. // to the inner IF). This function checks for this case and
  9013. // adds the block braces if needed.
  9014. if (!b) return output.force_semicolon();
  9015. while (true) {
  9016. if (b instanceof AST_If) {
  9017. if (!b.alternative) {
  9018. make_block(self.body, output);
  9019. return;
  9020. }
  9021. b = b.alternative;
  9022. } else if (b instanceof AST_StatementWithBody) {
  9023. b = b.body;
  9024. } else break;
  9025. }
  9026. force_statement(self.body, output);
  9027. }
  9028. DEFPRINT(AST_If, function(self, output) {
  9029. output.print("if");
  9030. output.space();
  9031. output.with_parens(function() {
  9032. self.condition.print(output);
  9033. });
  9034. output.space();
  9035. if (self.alternative) {
  9036. make_then(self, output);
  9037. output.space();
  9038. output.print("else");
  9039. output.space();
  9040. if (self.alternative instanceof AST_If)
  9041. self.alternative.print(output);
  9042. else
  9043. force_statement(self.alternative, output);
  9044. } else {
  9045. self._do_print_body(output);
  9046. }
  9047. });
  9048. /* -----[ switch ]----- */
  9049. DEFPRINT(AST_Switch, function(self, output) {
  9050. output.print("switch");
  9051. output.space();
  9052. output.with_parens(function() {
  9053. self.expression.print(output);
  9054. });
  9055. output.space();
  9056. var last = self.body.length - 1;
  9057. if (last < 0) print_braced_empty(self, output);
  9058. else output.with_block(function() {
  9059. self.body.forEach(function(branch, i) {
  9060. output.indent(true);
  9061. branch.print(output);
  9062. if (i < last && branch.body.length > 0)
  9063. output.newline();
  9064. });
  9065. });
  9066. });
  9067. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  9068. output.newline();
  9069. this.body.forEach(function(stmt) {
  9070. output.indent();
  9071. stmt.print(output);
  9072. output.newline();
  9073. });
  9074. });
  9075. DEFPRINT(AST_Default, function(self, output) {
  9076. output.print("default:");
  9077. self._do_print_body(output);
  9078. });
  9079. DEFPRINT(AST_Case, function(self, output) {
  9080. output.print("case");
  9081. output.space();
  9082. self.expression.print(output);
  9083. output.print(":");
  9084. self._do_print_body(output);
  9085. });
  9086. /* -----[ exceptions ]----- */
  9087. DEFPRINT(AST_Try, function(self, output) {
  9088. output.print("try");
  9089. output.space();
  9090. print_braced(self, output);
  9091. if (self.bcatch) {
  9092. output.space();
  9093. self.bcatch.print(output);
  9094. }
  9095. if (self.bfinally) {
  9096. output.space();
  9097. self.bfinally.print(output);
  9098. }
  9099. });
  9100. DEFPRINT(AST_Catch, function(self, output) {
  9101. output.print("catch");
  9102. if (self.argname) {
  9103. output.space();
  9104. output.with_parens(function() {
  9105. self.argname.print(output);
  9106. });
  9107. }
  9108. output.space();
  9109. print_braced(self, output);
  9110. });
  9111. DEFPRINT(AST_Finally, function(self, output) {
  9112. output.print("finally");
  9113. output.space();
  9114. print_braced(self, output);
  9115. });
  9116. /* -----[ var/const ]----- */
  9117. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  9118. output.print(kind);
  9119. output.space();
  9120. this.definitions.forEach(function(def, i) {
  9121. if (i) output.comma();
  9122. def.print(output);
  9123. });
  9124. var p = output.parent();
  9125. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  9126. var output_semicolon = !in_for || p && p.init !== this;
  9127. if (output_semicolon)
  9128. output.semicolon();
  9129. });
  9130. DEFPRINT(AST_Let, function(self, output) {
  9131. self._do_print(output, "let");
  9132. });
  9133. DEFPRINT(AST_Var, function(self, output) {
  9134. self._do_print(output, "var");
  9135. });
  9136. DEFPRINT(AST_Const, function(self, output) {
  9137. self._do_print(output, "const");
  9138. });
  9139. DEFPRINT(AST_Import, function(self, output) {
  9140. output.print("import");
  9141. output.space();
  9142. if (self.imported_name) {
  9143. self.imported_name.print(output);
  9144. }
  9145. if (self.imported_name && self.imported_names) {
  9146. output.print(",");
  9147. output.space();
  9148. }
  9149. if (self.imported_names) {
  9150. if (self.imported_names.length === 1 && self.imported_names[0].foreign_name.name === "*") {
  9151. self.imported_names[0].print(output);
  9152. } else {
  9153. output.print("{");
  9154. self.imported_names.forEach(function (name_import, i) {
  9155. output.space();
  9156. name_import.print(output);
  9157. if (i < self.imported_names.length - 1) {
  9158. output.print(",");
  9159. }
  9160. });
  9161. output.space();
  9162. output.print("}");
  9163. }
  9164. }
  9165. if (self.imported_name || self.imported_names) {
  9166. output.space();
  9167. output.print("from");
  9168. output.space();
  9169. }
  9170. self.module_name.print(output);
  9171. if (self.assert_clause) {
  9172. output.print("assert");
  9173. self.assert_clause.print(output);
  9174. }
  9175. output.semicolon();
  9176. });
  9177. DEFPRINT(AST_ImportMeta, function(self, output) {
  9178. output.print("import.meta");
  9179. });
  9180. DEFPRINT(AST_NameMapping, function(self, output) {
  9181. var is_import = output.parent() instanceof AST_Import;
  9182. var definition = self.name.definition();
  9183. var names_are_different =
  9184. (definition && definition.mangled_name || self.name.name) !==
  9185. self.foreign_name.name;
  9186. if (names_are_different) {
  9187. if (is_import) {
  9188. output.print(self.foreign_name.name);
  9189. } else {
  9190. self.name.print(output);
  9191. }
  9192. output.space();
  9193. output.print("as");
  9194. output.space();
  9195. if (is_import) {
  9196. self.name.print(output);
  9197. } else {
  9198. output.print(self.foreign_name.name);
  9199. }
  9200. } else {
  9201. self.name.print(output);
  9202. }
  9203. });
  9204. DEFPRINT(AST_Export, function(self, output) {
  9205. output.print("export");
  9206. output.space();
  9207. if (self.is_default) {
  9208. output.print("default");
  9209. output.space();
  9210. }
  9211. if (self.exported_names) {
  9212. if (self.exported_names.length === 1 && self.exported_names[0].name.name === "*") {
  9213. self.exported_names[0].print(output);
  9214. } else {
  9215. output.print("{");
  9216. self.exported_names.forEach(function(name_export, i) {
  9217. output.space();
  9218. name_export.print(output);
  9219. if (i < self.exported_names.length - 1) {
  9220. output.print(",");
  9221. }
  9222. });
  9223. output.space();
  9224. output.print("}");
  9225. }
  9226. } else if (self.exported_value) {
  9227. self.exported_value.print(output);
  9228. } else if (self.exported_definition) {
  9229. self.exported_definition.print(output);
  9230. if (self.exported_definition instanceof AST_Definitions) return;
  9231. }
  9232. if (self.module_name) {
  9233. output.space();
  9234. output.print("from");
  9235. output.space();
  9236. self.module_name.print(output);
  9237. }
  9238. if (self.assert_clause) {
  9239. output.print("assert");
  9240. self.assert_clause.print(output);
  9241. }
  9242. if (self.exported_value
  9243. && !(self.exported_value instanceof AST_Defun ||
  9244. self.exported_value instanceof AST_Function ||
  9245. self.exported_value instanceof AST_Class)
  9246. || self.module_name
  9247. || self.exported_names
  9248. ) {
  9249. output.semicolon();
  9250. }
  9251. });
  9252. function parenthesize_for_noin(node, output, noin) {
  9253. var parens = false;
  9254. // need to take some precautions here:
  9255. // https://github.com/mishoo/UglifyJS2/issues/60
  9256. if (noin) {
  9257. parens = walk(node, node => {
  9258. // Don't go into scopes -- except arrow functions:
  9259. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  9260. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  9261. return true;
  9262. }
  9263. if (node instanceof AST_Binary && node.operator == "in") {
  9264. return walk_abort; // makes walk() return true
  9265. }
  9266. });
  9267. }
  9268. node.print(output, parens);
  9269. }
  9270. DEFPRINT(AST_VarDef, function(self, output) {
  9271. self.name.print(output);
  9272. if (self.value) {
  9273. output.space();
  9274. output.print("=");
  9275. output.space();
  9276. var p = output.parent(1);
  9277. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  9278. parenthesize_for_noin(self.value, output, noin);
  9279. }
  9280. });
  9281. /* -----[ other expressions ]----- */
  9282. DEFPRINT(AST_Call, function(self, output) {
  9283. self.expression.print(output);
  9284. if (self instanceof AST_New && self.args.length === 0)
  9285. return;
  9286. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  9287. output.add_mapping(self.start);
  9288. }
  9289. if (self.optional) output.print("?.");
  9290. output.with_parens(function() {
  9291. self.args.forEach(function(expr, i) {
  9292. if (i) output.comma();
  9293. expr.print(output);
  9294. });
  9295. });
  9296. });
  9297. DEFPRINT(AST_New, function(self, output) {
  9298. output.print("new");
  9299. output.space();
  9300. AST_Call.prototype._codegen(self, output);
  9301. });
  9302. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  9303. this.expressions.forEach(function(node, index) {
  9304. if (index > 0) {
  9305. output.comma();
  9306. if (output.should_break()) {
  9307. output.newline();
  9308. output.indent();
  9309. }
  9310. }
  9311. node.print(output);
  9312. });
  9313. });
  9314. DEFPRINT(AST_Sequence, function(self, output) {
  9315. self._do_print(output);
  9316. // var p = output.parent();
  9317. // if (p instanceof AST_Statement) {
  9318. // output.with_indent(output.next_indent(), function(){
  9319. // self._do_print(output);
  9320. // });
  9321. // } else {
  9322. // self._do_print(output);
  9323. // }
  9324. });
  9325. DEFPRINT(AST_Dot, function(self, output) {
  9326. var expr = self.expression;
  9327. expr.print(output);
  9328. var prop = self.property;
  9329. var print_computed = ALL_RESERVED_WORDS.has(prop)
  9330. ? output.option("ie8")
  9331. : !is_identifier_string(
  9332. prop,
  9333. output.option("ecma") >= 2015 || output.option("safari10")
  9334. );
  9335. if (self.optional) output.print("?.");
  9336. if (print_computed) {
  9337. output.print("[");
  9338. output.add_mapping(self.end);
  9339. output.print_string(prop);
  9340. output.print("]");
  9341. } else {
  9342. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  9343. if (!/[xa-f.)]/i.test(output.last())) {
  9344. output.print(".");
  9345. }
  9346. }
  9347. if (!self.optional) output.print(".");
  9348. // the name after dot would be mapped about here.
  9349. output.add_mapping(self.end);
  9350. output.print_name(prop);
  9351. }
  9352. });
  9353. DEFPRINT(AST_DotHash, function(self, output) {
  9354. var expr = self.expression;
  9355. expr.print(output);
  9356. var prop = self.property;
  9357. if (self.optional) output.print("?");
  9358. output.print(".#");
  9359. output.add_mapping(self.end);
  9360. output.print_name(prop);
  9361. });
  9362. DEFPRINT(AST_Sub, function(self, output) {
  9363. self.expression.print(output);
  9364. if (self.optional) output.print("?.");
  9365. output.print("[");
  9366. self.property.print(output);
  9367. output.print("]");
  9368. });
  9369. DEFPRINT(AST_Chain, function(self, output) {
  9370. self.expression.print(output);
  9371. });
  9372. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  9373. var op = self.operator;
  9374. output.print(op);
  9375. if (/^[a-z]/i.test(op)
  9376. || (/[+-]$/.test(op)
  9377. && self.expression instanceof AST_UnaryPrefix
  9378. && /^[+-]/.test(self.expression.operator))) {
  9379. output.space();
  9380. }
  9381. self.expression.print(output);
  9382. });
  9383. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  9384. self.expression.print(output);
  9385. output.print(self.operator);
  9386. });
  9387. DEFPRINT(AST_Binary, function(self, output) {
  9388. var op = self.operator;
  9389. self.left.print(output);
  9390. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  9391. && self.left instanceof AST_UnaryPostfix
  9392. && self.left.operator == "--") {
  9393. // space is mandatory to avoid outputting -->
  9394. output.print(" ");
  9395. } else {
  9396. // the space is optional depending on "beautify"
  9397. output.space();
  9398. }
  9399. output.print(op);
  9400. if ((op == "<" || op == "<<")
  9401. && self.right instanceof AST_UnaryPrefix
  9402. && self.right.operator == "!"
  9403. && self.right.expression instanceof AST_UnaryPrefix
  9404. && self.right.expression.operator == "--") {
  9405. // space is mandatory to avoid outputting <!--
  9406. output.print(" ");
  9407. } else {
  9408. // the space is optional depending on "beautify"
  9409. output.space();
  9410. }
  9411. self.right.print(output);
  9412. });
  9413. DEFPRINT(AST_Conditional, function(self, output) {
  9414. self.condition.print(output);
  9415. output.space();
  9416. output.print("?");
  9417. output.space();
  9418. self.consequent.print(output);
  9419. output.space();
  9420. output.colon();
  9421. self.alternative.print(output);
  9422. });
  9423. /* -----[ literals ]----- */
  9424. DEFPRINT(AST_Array, function(self, output) {
  9425. output.with_square(function() {
  9426. var a = self.elements, len = a.length;
  9427. if (len > 0) output.space();
  9428. a.forEach(function(exp, i) {
  9429. if (i) output.comma();
  9430. exp.print(output);
  9431. // If the final element is a hole, we need to make sure it
  9432. // doesn't look like a trailing comma, by inserting an actual
  9433. // trailing comma.
  9434. if (i === len - 1 && exp instanceof AST_Hole)
  9435. output.comma();
  9436. });
  9437. if (len > 0) output.space();
  9438. });
  9439. });
  9440. DEFPRINT(AST_Object, function(self, output) {
  9441. if (self.properties.length > 0) output.with_block(function() {
  9442. self.properties.forEach(function(prop, i) {
  9443. if (i) {
  9444. output.print(",");
  9445. output.newline();
  9446. }
  9447. output.indent();
  9448. prop.print(output);
  9449. });
  9450. output.newline();
  9451. });
  9452. else print_braced_empty(self, output);
  9453. });
  9454. DEFPRINT(AST_Class, function(self, output) {
  9455. output.print("class");
  9456. output.space();
  9457. if (self.name) {
  9458. self.name.print(output);
  9459. output.space();
  9460. }
  9461. if (self.extends) {
  9462. var parens = (
  9463. !(self.extends instanceof AST_SymbolRef)
  9464. && !(self.extends instanceof AST_PropAccess)
  9465. && !(self.extends instanceof AST_ClassExpression)
  9466. && !(self.extends instanceof AST_Function)
  9467. );
  9468. output.print("extends");
  9469. if (parens) {
  9470. output.print("(");
  9471. } else {
  9472. output.space();
  9473. }
  9474. self.extends.print(output);
  9475. if (parens) {
  9476. output.print(")");
  9477. } else {
  9478. output.space();
  9479. }
  9480. }
  9481. if (self.properties.length > 0) output.with_block(function() {
  9482. self.properties.forEach(function(prop, i) {
  9483. if (i) {
  9484. output.newline();
  9485. }
  9486. output.indent();
  9487. prop.print(output);
  9488. });
  9489. output.newline();
  9490. });
  9491. else output.print("{}");
  9492. });
  9493. DEFPRINT(AST_NewTarget, function(self, output) {
  9494. output.print("new.target");
  9495. });
  9496. function print_property_name(key, quote, output) {
  9497. if (output.option("quote_keys")) {
  9498. return output.print_string(key);
  9499. }
  9500. if ("" + +key == key && key >= 0) {
  9501. if (output.option("keep_numbers")) {
  9502. return output.print(key);
  9503. }
  9504. return output.print(make_num(key));
  9505. }
  9506. var print_string = ALL_RESERVED_WORDS.has(key)
  9507. ? output.option("ie8")
  9508. : (
  9509. output.option("ecma") < 2015 || output.option("safari10")
  9510. ? !is_basic_identifier_string(key)
  9511. : !is_identifier_string(key, true)
  9512. );
  9513. if (print_string || (quote && output.option("keep_quoted_props"))) {
  9514. return output.print_string(key, quote);
  9515. }
  9516. return output.print_name(key);
  9517. }
  9518. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  9519. function get_name(self) {
  9520. var def = self.definition();
  9521. return def ? def.mangled_name || def.name : self.name;
  9522. }
  9523. var allowShortHand = output.option("shorthand");
  9524. if (allowShortHand &&
  9525. self.value instanceof AST_Symbol &&
  9526. is_identifier_string(
  9527. self.key,
  9528. output.option("ecma") >= 2015 || output.option("safari10")
  9529. ) &&
  9530. get_name(self.value) === self.key &&
  9531. !ALL_RESERVED_WORDS.has(self.key)
  9532. ) {
  9533. print_property_name(self.key, self.quote, output);
  9534. } else if (allowShortHand &&
  9535. self.value instanceof AST_DefaultAssign &&
  9536. self.value.left instanceof AST_Symbol &&
  9537. is_identifier_string(
  9538. self.key,
  9539. output.option("ecma") >= 2015 || output.option("safari10")
  9540. ) &&
  9541. get_name(self.value.left) === self.key
  9542. ) {
  9543. print_property_name(self.key, self.quote, output);
  9544. output.space();
  9545. output.print("=");
  9546. output.space();
  9547. self.value.right.print(output);
  9548. } else {
  9549. if (!(self.key instanceof AST_Node)) {
  9550. print_property_name(self.key, self.quote, output);
  9551. } else {
  9552. output.with_square(function() {
  9553. self.key.print(output);
  9554. });
  9555. }
  9556. output.colon();
  9557. self.value.print(output);
  9558. }
  9559. });
  9560. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  9561. if (self.static) {
  9562. output.print("static");
  9563. output.space();
  9564. }
  9565. output.print("#");
  9566. print_property_name(self.key.name, self.quote, output);
  9567. if (self.value) {
  9568. output.print("=");
  9569. self.value.print(output);
  9570. }
  9571. output.semicolon();
  9572. });
  9573. DEFPRINT(AST_ClassProperty, (self, output) => {
  9574. if (self.static) {
  9575. output.print("static");
  9576. output.space();
  9577. }
  9578. if (self.key instanceof AST_SymbolClassProperty) {
  9579. print_property_name(self.key.name, self.quote, output);
  9580. } else {
  9581. output.print("[");
  9582. self.key.print(output);
  9583. output.print("]");
  9584. }
  9585. if (self.value) {
  9586. output.print("=");
  9587. self.value.print(output);
  9588. }
  9589. output.semicolon();
  9590. });
  9591. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  9592. var self = this;
  9593. if (self.static) {
  9594. output.print("static");
  9595. output.space();
  9596. }
  9597. if (type) {
  9598. output.print(type);
  9599. output.space();
  9600. }
  9601. if (self.key instanceof AST_SymbolMethod) {
  9602. if (is_private) output.print("#");
  9603. print_property_name(self.key.name, self.quote, output);
  9604. } else {
  9605. output.with_square(function() {
  9606. self.key.print(output);
  9607. });
  9608. }
  9609. self.value._do_print(output, true);
  9610. });
  9611. DEFPRINT(AST_ObjectSetter, function(self, output) {
  9612. self._print_getter_setter("set", false, output);
  9613. });
  9614. DEFPRINT(AST_ObjectGetter, function(self, output) {
  9615. self._print_getter_setter("get", false, output);
  9616. });
  9617. DEFPRINT(AST_PrivateSetter, function(self, output) {
  9618. self._print_getter_setter("set", true, output);
  9619. });
  9620. DEFPRINT(AST_PrivateGetter, function(self, output) {
  9621. self._print_getter_setter("get", true, output);
  9622. });
  9623. DEFPRINT(AST_PrivateMethod, function(self, output) {
  9624. var type;
  9625. if (self.is_generator && self.async) {
  9626. type = "async*";
  9627. } else if (self.is_generator) {
  9628. type = "*";
  9629. } else if (self.async) {
  9630. type = "async";
  9631. }
  9632. self._print_getter_setter(type, true, output);
  9633. });
  9634. DEFPRINT(AST_ConciseMethod, function(self, output) {
  9635. var type;
  9636. if (self.is_generator && self.async) {
  9637. type = "async*";
  9638. } else if (self.is_generator) {
  9639. type = "*";
  9640. } else if (self.async) {
  9641. type = "async";
  9642. }
  9643. self._print_getter_setter(type, false, output);
  9644. });
  9645. DEFPRINT(AST_ClassStaticBlock, function (self, output) {
  9646. output.print("static");
  9647. output.space();
  9648. print_braced(self, output);
  9649. });
  9650. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  9651. var def = this.definition();
  9652. output.print_name(def ? def.mangled_name || def.name : this.name);
  9653. });
  9654. DEFPRINT(AST_Symbol, function (self, output) {
  9655. self._do_print(output);
  9656. });
  9657. DEFPRINT(AST_Hole, noop);
  9658. DEFPRINT(AST_This, function(self, output) {
  9659. output.print("this");
  9660. });
  9661. DEFPRINT(AST_Super, function(self, output) {
  9662. output.print("super");
  9663. });
  9664. DEFPRINT(AST_Constant, function(self, output) {
  9665. output.print(self.getValue());
  9666. });
  9667. DEFPRINT(AST_String, function(self, output) {
  9668. output.print_string(self.getValue(), self.quote, output.in_directive);
  9669. });
  9670. DEFPRINT(AST_Number, function(self, output) {
  9671. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  9672. output.print(self.raw);
  9673. } else {
  9674. output.print(make_num(self.getValue()));
  9675. }
  9676. });
  9677. DEFPRINT(AST_BigInt, function(self, output) {
  9678. output.print(self.getValue() + "n");
  9679. });
  9680. const r_slash_script = /(<\s*\/\s*script)/i;
  9681. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  9682. DEFPRINT(AST_RegExp, function(self, output) {
  9683. let { source, flags } = self.getValue();
  9684. source = regexp_source_fix(source);
  9685. flags = flags ? sort_regexp_flags(flags) : "";
  9686. source = source.replace(r_slash_script, slash_script_replace);
  9687. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  9688. const parent = output.parent();
  9689. if (
  9690. parent instanceof AST_Binary
  9691. && /^\w/.test(parent.operator)
  9692. && parent.left === self
  9693. ) {
  9694. output.print(" ");
  9695. }
  9696. });
  9697. function force_statement(stat, output) {
  9698. if (output.option("braces")) {
  9699. make_block(stat, output);
  9700. } else {
  9701. if (!stat || stat instanceof AST_EmptyStatement)
  9702. output.force_semicolon();
  9703. else
  9704. stat.print(output);
  9705. }
  9706. }
  9707. function best_of(a) {
  9708. var best = a[0], len = best.length;
  9709. for (var i = 1; i < a.length; ++i) {
  9710. if (a[i].length < len) {
  9711. best = a[i];
  9712. len = best.length;
  9713. }
  9714. }
  9715. return best;
  9716. }
  9717. function make_num(num) {
  9718. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  9719. var candidates = [ str ];
  9720. if (Math.floor(num) === num) {
  9721. if (num < 0) {
  9722. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  9723. } else {
  9724. candidates.push("0x" + num.toString(16).toLowerCase());
  9725. }
  9726. }
  9727. var match, len, digits;
  9728. if (match = /^\.0+/.exec(str)) {
  9729. len = match[0].length;
  9730. digits = str.slice(len);
  9731. candidates.push(digits + "e-" + (digits.length + len - 1));
  9732. } else if (match = /0+$/.exec(str)) {
  9733. len = match[0].length;
  9734. candidates.push(str.slice(0, -len) + "e" + len);
  9735. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  9736. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  9737. }
  9738. return best_of(candidates);
  9739. }
  9740. function make_block(stmt, output) {
  9741. if (!stmt || stmt instanceof AST_EmptyStatement)
  9742. output.print("{}");
  9743. else if (stmt instanceof AST_BlockStatement)
  9744. stmt.print(output);
  9745. else output.with_block(function() {
  9746. output.indent();
  9747. stmt.print(output);
  9748. output.newline();
  9749. });
  9750. }
  9751. /* -----[ source map generators ]----- */
  9752. function DEFMAP(nodetype, generator) {
  9753. nodetype.forEach(function(nodetype) {
  9754. nodetype.DEFMETHOD("add_source_map", generator);
  9755. });
  9756. }
  9757. DEFMAP([
  9758. // We could easily add info for ALL nodes, but it seems to me that
  9759. // would be quite wasteful, hence this noop in the base class.
  9760. AST_Node,
  9761. // since the label symbol will mark it
  9762. AST_LabeledStatement,
  9763. AST_Toplevel,
  9764. ], noop);
  9765. // XXX: I'm not exactly sure if we need it for all of these nodes,
  9766. // or if we should add even more.
  9767. DEFMAP([
  9768. AST_Array,
  9769. AST_BlockStatement,
  9770. AST_Catch,
  9771. AST_Class,
  9772. AST_Constant,
  9773. AST_Debugger,
  9774. AST_Definitions,
  9775. AST_Directive,
  9776. AST_Finally,
  9777. AST_Jump,
  9778. AST_Lambda,
  9779. AST_New,
  9780. AST_Object,
  9781. AST_StatementWithBody,
  9782. AST_Symbol,
  9783. AST_Switch,
  9784. AST_SwitchBranch,
  9785. AST_TemplateString,
  9786. AST_TemplateSegment,
  9787. AST_Try,
  9788. ], function(output) {
  9789. output.add_mapping(this.start);
  9790. });
  9791. DEFMAP([
  9792. AST_ObjectGetter,
  9793. AST_ObjectSetter,
  9794. AST_PrivateGetter,
  9795. AST_PrivateSetter,
  9796. ], function(output) {
  9797. output.add_mapping(this.key.end, this.key.name);
  9798. });
  9799. DEFMAP([ AST_ObjectProperty ], function(output) {
  9800. output.add_mapping(this.start, this.key);
  9801. });
  9802. })();
  9803. const shallow_cmp = (node1, node2) => {
  9804. return (
  9805. node1 === null && node2 === null
  9806. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  9807. );
  9808. };
  9809. const equivalent_to = (tree1, tree2) => {
  9810. if (!shallow_cmp(tree1, tree2)) return false;
  9811. const walk_1_state = [tree1];
  9812. const walk_2_state = [tree2];
  9813. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  9814. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  9815. while (walk_1_state.length && walk_2_state.length) {
  9816. const node_1 = walk_1_state.pop();
  9817. const node_2 = walk_2_state.pop();
  9818. if (!shallow_cmp(node_1, node_2)) return false;
  9819. node_1._children_backwards(walk_1_push);
  9820. node_2._children_backwards(walk_2_push);
  9821. if (walk_1_state.length !== walk_2_state.length) {
  9822. // Different number of children
  9823. return false;
  9824. }
  9825. }
  9826. return walk_1_state.length == 0 && walk_2_state.length == 0;
  9827. };
  9828. const pass_through = () => true;
  9829. AST_Node.prototype.shallow_cmp = function () {
  9830. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  9831. };
  9832. AST_Debugger.prototype.shallow_cmp = pass_through;
  9833. AST_Directive.prototype.shallow_cmp = function(other) {
  9834. return this.value === other.value;
  9835. };
  9836. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  9837. AST_Block.prototype.shallow_cmp = pass_through;
  9838. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  9839. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  9840. return this.label.name === other.label.name;
  9841. };
  9842. AST_Do.prototype.shallow_cmp = pass_through;
  9843. AST_While.prototype.shallow_cmp = pass_through;
  9844. AST_For.prototype.shallow_cmp = function(other) {
  9845. 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);
  9846. };
  9847. AST_ForIn.prototype.shallow_cmp = pass_through;
  9848. AST_ForOf.prototype.shallow_cmp = pass_through;
  9849. AST_With.prototype.shallow_cmp = pass_through;
  9850. AST_Toplevel.prototype.shallow_cmp = pass_through;
  9851. AST_Expansion.prototype.shallow_cmp = pass_through;
  9852. AST_Lambda.prototype.shallow_cmp = function(other) {
  9853. return this.is_generator === other.is_generator && this.async === other.async;
  9854. };
  9855. AST_Destructuring.prototype.shallow_cmp = function(other) {
  9856. return this.is_array === other.is_array;
  9857. };
  9858. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  9859. AST_TemplateString.prototype.shallow_cmp = pass_through;
  9860. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  9861. return this.value === other.value;
  9862. };
  9863. AST_Jump.prototype.shallow_cmp = pass_through;
  9864. AST_LoopControl.prototype.shallow_cmp = pass_through;
  9865. AST_Await.prototype.shallow_cmp = pass_through;
  9866. AST_Yield.prototype.shallow_cmp = function(other) {
  9867. return this.is_star === other.is_star;
  9868. };
  9869. AST_If.prototype.shallow_cmp = function(other) {
  9870. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  9871. };
  9872. AST_Switch.prototype.shallow_cmp = pass_through;
  9873. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  9874. AST_Try.prototype.shallow_cmp = function(other) {
  9875. return (this.bcatch == null ? other.bcatch == null : this.bcatch === other.bcatch) && (this.bfinally == null ? other.bfinally == null : this.bfinally === other.bfinally);
  9876. };
  9877. AST_Catch.prototype.shallow_cmp = function(other) {
  9878. return this.argname == null ? other.argname == null : this.argname === other.argname;
  9879. };
  9880. AST_Finally.prototype.shallow_cmp = pass_through;
  9881. AST_Definitions.prototype.shallow_cmp = pass_through;
  9882. AST_VarDef.prototype.shallow_cmp = function(other) {
  9883. return this.value == null ? other.value == null : this.value === other.value;
  9884. };
  9885. AST_NameMapping.prototype.shallow_cmp = pass_through;
  9886. AST_Import.prototype.shallow_cmp = function(other) {
  9887. 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);
  9888. };
  9889. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  9890. AST_Export.prototype.shallow_cmp = function(other) {
  9891. 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;
  9892. };
  9893. AST_Call.prototype.shallow_cmp = pass_through;
  9894. AST_Sequence.prototype.shallow_cmp = pass_through;
  9895. AST_PropAccess.prototype.shallow_cmp = pass_through;
  9896. AST_Chain.prototype.shallow_cmp = pass_through;
  9897. AST_Dot.prototype.shallow_cmp = function(other) {
  9898. return this.property === other.property;
  9899. };
  9900. AST_DotHash.prototype.shallow_cmp = function(other) {
  9901. return this.property === other.property;
  9902. };
  9903. AST_Unary.prototype.shallow_cmp = function(other) {
  9904. return this.operator === other.operator;
  9905. };
  9906. AST_Binary.prototype.shallow_cmp = function(other) {
  9907. return this.operator === other.operator;
  9908. };
  9909. AST_Conditional.prototype.shallow_cmp = pass_through;
  9910. AST_Array.prototype.shallow_cmp = pass_through;
  9911. AST_Object.prototype.shallow_cmp = pass_through;
  9912. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  9913. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  9914. return this.key === other.key;
  9915. };
  9916. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  9917. return this.static === other.static;
  9918. };
  9919. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  9920. return this.static === other.static;
  9921. };
  9922. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  9923. return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
  9924. };
  9925. AST_Class.prototype.shallow_cmp = function(other) {
  9926. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  9927. };
  9928. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  9929. return this.static === other.static;
  9930. };
  9931. AST_Symbol.prototype.shallow_cmp = function(other) {
  9932. return this.name === other.name;
  9933. };
  9934. AST_NewTarget.prototype.shallow_cmp = pass_through;
  9935. AST_This.prototype.shallow_cmp = pass_through;
  9936. AST_Super.prototype.shallow_cmp = pass_through;
  9937. AST_String.prototype.shallow_cmp = function(other) {
  9938. return this.value === other.value;
  9939. };
  9940. AST_Number.prototype.shallow_cmp = function(other) {
  9941. return this.value === other.value;
  9942. };
  9943. AST_BigInt.prototype.shallow_cmp = function(other) {
  9944. return this.value === other.value;
  9945. };
  9946. AST_RegExp.prototype.shallow_cmp = function (other) {
  9947. return (
  9948. this.value.flags === other.value.flags
  9949. && this.value.source === other.value.source
  9950. );
  9951. };
  9952. AST_Atom.prototype.shallow_cmp = pass_through;
  9953. /***********************************************************************
  9954. A JavaScript tokenizer / parser / beautifier / compressor.
  9955. https://github.com/mishoo/UglifyJS2
  9956. -------------------------------- (C) ---------------------------------
  9957. Author: Mihai Bazon
  9958. <mihai.bazon@gmail.com>
  9959. http://mihai.bazon.net/blog
  9960. Distributed under the BSD license:
  9961. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  9962. Redistribution and use in source and binary forms, with or without
  9963. modification, are permitted provided that the following conditions
  9964. are met:
  9965. * Redistributions of source code must retain the above
  9966. copyright notice, this list of conditions and the following
  9967. disclaimer.
  9968. * Redistributions in binary form must reproduce the above
  9969. copyright notice, this list of conditions and the following
  9970. disclaimer in the documentation and/or other materials
  9971. provided with the distribution.
  9972. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  9973. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9974. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9975. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  9976. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  9977. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9978. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9979. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9980. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  9981. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  9982. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9983. SUCH DAMAGE.
  9984. ***********************************************************************/
  9985. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  9986. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  9987. let function_defs = null;
  9988. let unmangleable_names = null;
  9989. /**
  9990. * When defined, there is a function declaration somewhere that's inside of a block.
  9991. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  9992. */
  9993. let scopes_with_block_defuns = null;
  9994. class SymbolDef {
  9995. constructor(scope, orig, init) {
  9996. this.name = orig.name;
  9997. this.orig = [ orig ];
  9998. this.init = init;
  9999. this.eliminated = 0;
  10000. this.assignments = 0;
  10001. this.scope = scope;
  10002. this.replaced = 0;
  10003. this.global = false;
  10004. this.export = 0;
  10005. this.mangled_name = null;
  10006. this.undeclared = false;
  10007. this.id = SymbolDef.next_id++;
  10008. this.chained = false;
  10009. this.direct_access = false;
  10010. this.escaped = 0;
  10011. this.recursive_refs = 0;
  10012. this.references = [];
  10013. this.should_replace = undefined;
  10014. this.single_use = false;
  10015. this.fixed = false;
  10016. Object.seal(this);
  10017. }
  10018. fixed_value() {
  10019. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  10020. return this.fixed();
  10021. }
  10022. unmangleable(options) {
  10023. if (!options) options = {};
  10024. if (
  10025. function_defs &&
  10026. function_defs.has(this.id) &&
  10027. keep_name(options.keep_fnames, this.orig[0].name)
  10028. ) return true;
  10029. return this.global && !options.toplevel
  10030. || (this.export & MASK_EXPORT_DONT_MANGLE)
  10031. || this.undeclared
  10032. || !options.eval && this.scope.pinned()
  10033. || (this.orig[0] instanceof AST_SymbolLambda
  10034. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  10035. || this.orig[0] instanceof AST_SymbolMethod
  10036. || (this.orig[0] instanceof AST_SymbolClass
  10037. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  10038. }
  10039. mangle(options) {
  10040. const cache = options.cache && options.cache.props;
  10041. if (this.global && cache && cache.has(this.name)) {
  10042. this.mangled_name = cache.get(this.name);
  10043. } else if (!this.mangled_name && !this.unmangleable(options)) {
  10044. var s = this.scope;
  10045. var sym = this.orig[0];
  10046. if (options.ie8 && sym instanceof AST_SymbolLambda)
  10047. s = s.parent_scope;
  10048. const redefinition = redefined_catch_def(this);
  10049. this.mangled_name = redefinition
  10050. ? redefinition.mangled_name || redefinition.name
  10051. : s.next_mangled(options, this);
  10052. if (this.global && cache) {
  10053. cache.set(this.name, this.mangled_name);
  10054. }
  10055. }
  10056. }
  10057. }
  10058. SymbolDef.next_id = 1;
  10059. function redefined_catch_def(def) {
  10060. if (def.orig[0] instanceof AST_SymbolCatch
  10061. && def.scope.is_block_scope()
  10062. ) {
  10063. return def.scope.get_defun_scope().variables.get(def.name);
  10064. }
  10065. }
  10066. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  10067. options = defaults(options, {
  10068. cache: null,
  10069. ie8: false,
  10070. safari10: false,
  10071. });
  10072. if (!(toplevel instanceof AST_Toplevel)) {
  10073. throw new Error("Invalid toplevel scope");
  10074. }
  10075. // pass 1: setup scope chaining and handle definitions
  10076. var scope = this.parent_scope = parent_scope;
  10077. var labels = new Map();
  10078. var defun = null;
  10079. var in_destructuring = null;
  10080. var for_scopes = [];
  10081. var tw = new TreeWalker((node, descend) => {
  10082. if (node.is_block_scope()) {
  10083. const save_scope = scope;
  10084. node.block_scope = scope = new AST_Scope(node);
  10085. scope._block_scope = true;
  10086. // AST_Try in the AST sadly *is* (not has) a body itself,
  10087. // and its catch and finally branches are children of the AST_Try itself
  10088. const parent_scope = node instanceof AST_Catch
  10089. ? save_scope.parent_scope
  10090. : save_scope;
  10091. scope.init_scope_vars(parent_scope);
  10092. scope.uses_with = save_scope.uses_with;
  10093. scope.uses_eval = save_scope.uses_eval;
  10094. if (options.safari10) {
  10095. if (node instanceof AST_For || node instanceof AST_ForIn) {
  10096. for_scopes.push(scope);
  10097. }
  10098. }
  10099. if (node instanceof AST_Switch) {
  10100. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  10101. // AST_Switch has a scope within the body, but it itself "is a block scope"
  10102. // This means the switched expression has to belong to the outer scope
  10103. // while the body inside belongs to the switch itself.
  10104. // This is pretty nasty and warrants an AST change similar to AST_Try (read above)
  10105. const the_block_scope = scope;
  10106. scope = save_scope;
  10107. node.expression.walk(tw);
  10108. scope = the_block_scope;
  10109. for (let i = 0; i < node.body.length; i++) {
  10110. node.body[i].walk(tw);
  10111. }
  10112. } else {
  10113. descend();
  10114. }
  10115. scope = save_scope;
  10116. return true;
  10117. }
  10118. if (node instanceof AST_Destructuring) {
  10119. const save_destructuring = in_destructuring;
  10120. in_destructuring = node;
  10121. descend();
  10122. in_destructuring = save_destructuring;
  10123. return true;
  10124. }
  10125. if (node instanceof AST_Scope) {
  10126. node.init_scope_vars(scope);
  10127. var save_scope = scope;
  10128. var save_defun = defun;
  10129. var save_labels = labels;
  10130. defun = scope = node;
  10131. labels = new Map();
  10132. descend();
  10133. scope = save_scope;
  10134. defun = save_defun;
  10135. labels = save_labels;
  10136. return true; // don't descend again in TreeWalker
  10137. }
  10138. if (node instanceof AST_LabeledStatement) {
  10139. var l = node.label;
  10140. if (labels.has(l.name)) {
  10141. throw new Error(string_template("Label {name} defined twice", l));
  10142. }
  10143. labels.set(l.name, l);
  10144. descend();
  10145. labels.delete(l.name);
  10146. return true; // no descend again
  10147. }
  10148. if (node instanceof AST_With) {
  10149. for (var s = scope; s; s = s.parent_scope)
  10150. s.uses_with = true;
  10151. return;
  10152. }
  10153. if (node instanceof AST_Symbol) {
  10154. node.scope = scope;
  10155. }
  10156. if (node instanceof AST_Label) {
  10157. node.thedef = node;
  10158. node.references = [];
  10159. }
  10160. if (node instanceof AST_SymbolLambda) {
  10161. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  10162. } else if (node instanceof AST_SymbolDefun) {
  10163. // Careful here, the scope where this should be defined is
  10164. // the parent scope. The reason is that we enter a new
  10165. // scope when we encounter the AST_Defun node (which is
  10166. // instanceof AST_Scope) but we get to the symbol a bit
  10167. // later.
  10168. const closest_scope = defun.parent_scope;
  10169. // In strict mode, function definitions are block-scoped
  10170. node.scope = tw.directives["use strict"]
  10171. ? closest_scope
  10172. : closest_scope.get_defun_scope();
  10173. mark_export(node.scope.def_function(node, defun), 1);
  10174. } else if (node instanceof AST_SymbolClass) {
  10175. mark_export(defun.def_variable(node, defun), 1);
  10176. } else if (node instanceof AST_SymbolImport) {
  10177. scope.def_variable(node);
  10178. } else if (node instanceof AST_SymbolDefClass) {
  10179. // This deals with the name of the class being available
  10180. // inside the class.
  10181. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  10182. } else if (
  10183. node instanceof AST_SymbolVar
  10184. || node instanceof AST_SymbolLet
  10185. || node instanceof AST_SymbolConst
  10186. || node instanceof AST_SymbolCatch
  10187. ) {
  10188. var def;
  10189. if (node instanceof AST_SymbolBlockDeclaration) {
  10190. def = scope.def_variable(node, null);
  10191. } else {
  10192. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  10193. }
  10194. if (!def.orig.every((sym) => {
  10195. if (sym === node) return true;
  10196. if (node instanceof AST_SymbolBlockDeclaration) {
  10197. return sym instanceof AST_SymbolLambda;
  10198. }
  10199. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  10200. })) {
  10201. js_error(
  10202. `"${node.name}" is redeclared`,
  10203. node.start.file,
  10204. node.start.line,
  10205. node.start.col,
  10206. node.start.pos
  10207. );
  10208. }
  10209. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  10210. if (defun !== scope) {
  10211. node.mark_enclosed();
  10212. var def = scope.find_variable(node);
  10213. if (node.thedef !== def) {
  10214. node.thedef = def;
  10215. node.reference();
  10216. }
  10217. }
  10218. } else if (node instanceof AST_LabelRef) {
  10219. var sym = labels.get(node.name);
  10220. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  10221. name: node.name,
  10222. line: node.start.line,
  10223. col: node.start.col
  10224. }));
  10225. node.thedef = sym;
  10226. }
  10227. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  10228. js_error(
  10229. `"${node.TYPE}" statement may only appear at the top level`,
  10230. node.start.file,
  10231. node.start.line,
  10232. node.start.col,
  10233. node.start.pos
  10234. );
  10235. }
  10236. });
  10237. this.walk(tw);
  10238. function mark_export(def, level) {
  10239. if (in_destructuring) {
  10240. var i = 0;
  10241. do {
  10242. level++;
  10243. } while (tw.parent(i++) !== in_destructuring);
  10244. }
  10245. var node = tw.parent(level);
  10246. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  10247. var exported = node.exported_definition;
  10248. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  10249. def.export = MASK_EXPORT_WANT_MANGLE;
  10250. }
  10251. }
  10252. }
  10253. // pass 2: find back references and eval
  10254. const is_toplevel = this instanceof AST_Toplevel;
  10255. if (is_toplevel) {
  10256. this.globals = new Map();
  10257. }
  10258. var tw = new TreeWalker(node => {
  10259. if (node instanceof AST_LoopControl && node.label) {
  10260. node.label.thedef.references.push(node);
  10261. return true;
  10262. }
  10263. if (node instanceof AST_SymbolRef) {
  10264. var name = node.name;
  10265. if (name == "eval" && tw.parent() instanceof AST_Call) {
  10266. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  10267. s.uses_eval = true;
  10268. }
  10269. }
  10270. var sym;
  10271. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  10272. || !(sym = node.scope.find_variable(name))) {
  10273. sym = toplevel.def_global(node);
  10274. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  10275. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  10276. sym.scope.uses_arguments = true;
  10277. }
  10278. node.thedef = sym;
  10279. node.reference();
  10280. if (node.scope.is_block_scope()
  10281. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  10282. node.scope = node.scope.get_defun_scope();
  10283. }
  10284. return true;
  10285. }
  10286. // ensure mangling works if catch reuses a scope variable
  10287. var def;
  10288. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  10289. var s = node.scope;
  10290. while (s) {
  10291. push_uniq(s.enclosed, def);
  10292. if (s === def.scope) break;
  10293. s = s.parent_scope;
  10294. }
  10295. }
  10296. });
  10297. this.walk(tw);
  10298. // pass 3: work around IE8 and Safari catch scope bugs
  10299. if (options.ie8 || options.safari10) {
  10300. walk(this, node => {
  10301. if (node instanceof AST_SymbolCatch) {
  10302. var name = node.name;
  10303. var refs = node.thedef.references;
  10304. var scope = node.scope.get_defun_scope();
  10305. var def = scope.find_variable(name)
  10306. || toplevel.globals.get(name)
  10307. || scope.def_variable(node);
  10308. refs.forEach(function(ref) {
  10309. ref.thedef = def;
  10310. ref.reference();
  10311. });
  10312. node.thedef = def;
  10313. node.reference();
  10314. return true;
  10315. }
  10316. });
  10317. }
  10318. // pass 4: add symbol definitions to loop scopes
  10319. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  10320. // https://github.com/mishoo/UglifyJS2/issues/1753
  10321. // https://bugs.webkit.org/show_bug.cgi?id=171041
  10322. if (options.safari10) {
  10323. for (const scope of for_scopes) {
  10324. scope.parent_scope.variables.forEach(function(def) {
  10325. push_uniq(scope.enclosed, def);
  10326. });
  10327. }
  10328. }
  10329. });
  10330. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  10331. var globals = this.globals, name = node.name;
  10332. if (globals.has(name)) {
  10333. return globals.get(name);
  10334. } else {
  10335. var g = new SymbolDef(this, node);
  10336. g.undeclared = true;
  10337. g.global = true;
  10338. globals.set(name, g);
  10339. return g;
  10340. }
  10341. });
  10342. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  10343. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  10344. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  10345. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  10346. this.parent_scope = parent_scope; // the parent scope
  10347. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  10348. this.cname = -1; // the current index for mangling functions/variables
  10349. });
  10350. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  10351. return (
  10352. this.enclosed.find(def => def.name === name)
  10353. || this.variables.has(name)
  10354. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  10355. );
  10356. });
  10357. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  10358. return (
  10359. this.enclosed.find(def => def.name === name)
  10360. || this.variables.has(name)
  10361. );
  10362. });
  10363. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  10364. // `scope` is going to be moved into `this` right now.
  10365. // Update the required scopes' information
  10366. if (scope.parent_scope === this) return;
  10367. scope.parent_scope = this;
  10368. // TODO uses_with, uses_eval, etc
  10369. const scope_ancestry = (() => {
  10370. const ancestry = [];
  10371. let cur = this;
  10372. do {
  10373. ancestry.push(cur);
  10374. } while ((cur = cur.parent_scope));
  10375. ancestry.reverse();
  10376. return ancestry;
  10377. })();
  10378. const new_scope_enclosed_set = new Set(scope.enclosed);
  10379. const to_enclose = [];
  10380. for (const scope_topdown of scope_ancestry) {
  10381. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  10382. for (const def of scope_topdown.variables.values()) {
  10383. if (new_scope_enclosed_set.has(def)) {
  10384. push_uniq(to_enclose, def);
  10385. push_uniq(scope_topdown.enclosed, def);
  10386. }
  10387. }
  10388. }
  10389. });
  10390. function find_scopes_visible_from(scopes) {
  10391. const found_scopes = new Set();
  10392. for (const scope of new Set(scopes)) {
  10393. (function bubble_up(scope) {
  10394. if (scope == null || found_scopes.has(scope)) return;
  10395. found_scopes.add(scope);
  10396. bubble_up(scope.parent_scope);
  10397. })(scope);
  10398. }
  10399. return [...found_scopes];
  10400. }
  10401. // Creates a symbol during compression
  10402. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  10403. source,
  10404. tentative_name,
  10405. scope,
  10406. conflict_scopes = [scope],
  10407. init = null
  10408. } = {}) {
  10409. let symbol_name;
  10410. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  10411. if (tentative_name) {
  10412. // Implement hygiene (no new names are conflicting with existing names)
  10413. tentative_name =
  10414. symbol_name =
  10415. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  10416. let i = 0;
  10417. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  10418. symbol_name = tentative_name + "$" + i++;
  10419. }
  10420. }
  10421. if (!symbol_name) {
  10422. throw new Error("No symbol name could be generated in create_symbol()");
  10423. }
  10424. const symbol = make_node(SymClass, source, {
  10425. name: symbol_name,
  10426. scope
  10427. });
  10428. this.def_variable(symbol, init || null);
  10429. symbol.mark_enclosed();
  10430. return symbol;
  10431. });
  10432. AST_Node.DEFMETHOD("is_block_scope", return_false);
  10433. AST_Class.DEFMETHOD("is_block_scope", return_false);
  10434. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  10435. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  10436. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  10437. AST_Block.DEFMETHOD("is_block_scope", return_true);
  10438. AST_Scope.DEFMETHOD("is_block_scope", function () {
  10439. return this._block_scope || false;
  10440. });
  10441. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  10442. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  10443. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10444. this.uses_arguments = false;
  10445. this.def_variable(new AST_SymbolFunarg({
  10446. name: "arguments",
  10447. start: this.start,
  10448. end: this.end
  10449. }));
  10450. });
  10451. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  10452. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10453. this.uses_arguments = false;
  10454. });
  10455. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  10456. var def = this.definition();
  10457. var s = this.scope;
  10458. while (s) {
  10459. push_uniq(s.enclosed, def);
  10460. if (s === def.scope) break;
  10461. s = s.parent_scope;
  10462. }
  10463. });
  10464. AST_Symbol.DEFMETHOD("reference", function() {
  10465. this.definition().references.push(this);
  10466. this.mark_enclosed();
  10467. });
  10468. AST_Scope.DEFMETHOD("find_variable", function(name) {
  10469. if (name instanceof AST_Symbol) name = name.name;
  10470. return this.variables.get(name)
  10471. || (this.parent_scope && this.parent_scope.find_variable(name));
  10472. });
  10473. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  10474. var def = this.def_variable(symbol, init);
  10475. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  10476. return def;
  10477. });
  10478. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  10479. var def = this.variables.get(symbol.name);
  10480. if (def) {
  10481. def.orig.push(symbol);
  10482. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  10483. def.init = init;
  10484. }
  10485. } else {
  10486. def = new SymbolDef(this, symbol, init);
  10487. this.variables.set(symbol.name, def);
  10488. def.global = !this.parent_scope;
  10489. }
  10490. return symbol.thedef = def;
  10491. });
  10492. function next_mangled(scope, options) {
  10493. let defun_scope;
  10494. if (
  10495. scopes_with_block_defuns
  10496. && (defun_scope = scope.get_defun_scope())
  10497. && scopes_with_block_defuns.has(defun_scope)
  10498. ) {
  10499. scope = defun_scope;
  10500. }
  10501. var ext = scope.enclosed;
  10502. var nth_identifier = options.nth_identifier;
  10503. out: while (true) {
  10504. var m = nth_identifier.get(++scope.cname);
  10505. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  10506. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  10507. // shadow a name reserved from mangling.
  10508. if (options.reserved.has(m)) continue;
  10509. // Functions with short names might collide with base54 output
  10510. // and therefore cause collisions when keep_fnames is true.
  10511. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  10512. // we must ensure that the mangled name does not shadow a name
  10513. // from some parent scope that is referenced in this or in
  10514. // inner scopes.
  10515. for (let i = ext.length; --i >= 0;) {
  10516. const def = ext[i];
  10517. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  10518. if (m == name) continue out;
  10519. }
  10520. return m;
  10521. }
  10522. }
  10523. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  10524. return next_mangled(this, options);
  10525. });
  10526. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  10527. let name;
  10528. const mangled_names = this.mangled_names;
  10529. do {
  10530. name = next_mangled(this, options);
  10531. } while (mangled_names.has(name));
  10532. return name;
  10533. });
  10534. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  10535. // #179, #326
  10536. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  10537. // a function expression's argument cannot shadow the function expression's name
  10538. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  10539. // the function's mangled_name is null when keep_fnames is true
  10540. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  10541. while (true) {
  10542. var name = next_mangled(this, options);
  10543. if (!tricky_name || tricky_name != name)
  10544. return name;
  10545. }
  10546. });
  10547. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  10548. var def = this.definition();
  10549. return !def || def.unmangleable(options);
  10550. });
  10551. // labels are always mangleable
  10552. AST_Label.DEFMETHOD("unmangleable", return_false);
  10553. AST_Symbol.DEFMETHOD("unreferenced", function() {
  10554. return !this.definition().references.length && !this.scope.pinned();
  10555. });
  10556. AST_Symbol.DEFMETHOD("definition", function() {
  10557. return this.thedef;
  10558. });
  10559. AST_Symbol.DEFMETHOD("global", function() {
  10560. return this.thedef.global;
  10561. });
  10562. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  10563. options = defaults(options, {
  10564. eval : false,
  10565. nth_identifier : base54,
  10566. ie8 : false,
  10567. keep_classnames: false,
  10568. keep_fnames : false,
  10569. module : false,
  10570. reserved : [],
  10571. toplevel : false,
  10572. });
  10573. if (options.module) options.toplevel = true;
  10574. if (!Array.isArray(options.reserved)
  10575. && !(options.reserved instanceof Set)
  10576. ) {
  10577. options.reserved = [];
  10578. }
  10579. options.reserved = new Set(options.reserved);
  10580. // Never mangle arguments
  10581. options.reserved.add("arguments");
  10582. return options;
  10583. });
  10584. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  10585. options = this._default_mangler_options(options);
  10586. var nth_identifier = options.nth_identifier;
  10587. // We only need to mangle declaration nodes. Special logic wired
  10588. // into the code generator will display the mangled name if it's
  10589. // present (and for AST_SymbolRef-s it'll use the mangled name of
  10590. // the AST_SymbolDeclaration that it points to).
  10591. var lname = -1;
  10592. var to_mangle = [];
  10593. if (options.keep_fnames) {
  10594. function_defs = new Set();
  10595. }
  10596. const mangled_names = this.mangled_names = new Set();
  10597. unmangleable_names = new Set();
  10598. if (options.cache) {
  10599. this.globals.forEach(collect);
  10600. if (options.cache.props) {
  10601. options.cache.props.forEach(function(mangled_name) {
  10602. mangled_names.add(mangled_name);
  10603. });
  10604. }
  10605. }
  10606. var tw = new TreeWalker(function(node, descend) {
  10607. if (node instanceof AST_LabeledStatement) {
  10608. // lname is incremented when we get to the AST_Label
  10609. var save_nesting = lname;
  10610. descend();
  10611. lname = save_nesting;
  10612. return true; // don't descend again in TreeWalker
  10613. }
  10614. if (
  10615. node instanceof AST_Defun
  10616. && !(tw.parent() instanceof AST_Scope)
  10617. ) {
  10618. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  10619. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  10620. }
  10621. if (node instanceof AST_Scope) {
  10622. node.variables.forEach(collect);
  10623. return;
  10624. }
  10625. if (node.is_block_scope()) {
  10626. node.block_scope.variables.forEach(collect);
  10627. return;
  10628. }
  10629. if (
  10630. function_defs
  10631. && node instanceof AST_VarDef
  10632. && node.value instanceof AST_Lambda
  10633. && !node.value.name
  10634. && keep_name(options.keep_fnames, node.name.name)
  10635. ) {
  10636. function_defs.add(node.name.definition().id);
  10637. return;
  10638. }
  10639. if (node instanceof AST_Label) {
  10640. let name;
  10641. do {
  10642. name = nth_identifier.get(++lname);
  10643. } while (ALL_RESERVED_WORDS.has(name));
  10644. node.mangled_name = name;
  10645. return true;
  10646. }
  10647. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  10648. to_mangle.push(node.definition());
  10649. return;
  10650. }
  10651. });
  10652. this.walk(tw);
  10653. if (options.keep_fnames || options.keep_classnames) {
  10654. // Collect a set of short names which are unmangleable,
  10655. // for use in avoiding collisions in next_mangled.
  10656. to_mangle.forEach(def => {
  10657. if (def.name.length < 6 && def.unmangleable(options)) {
  10658. unmangleable_names.add(def.name);
  10659. }
  10660. });
  10661. }
  10662. to_mangle.forEach(def => { def.mangle(options); });
  10663. function_defs = null;
  10664. unmangleable_names = null;
  10665. scopes_with_block_defuns = null;
  10666. function collect(symbol) {
  10667. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  10668. unmangleable_names.add(symbol.name);
  10669. } else if (!options.reserved.has(symbol.name)) {
  10670. to_mangle.push(symbol);
  10671. }
  10672. }
  10673. });
  10674. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  10675. const cache = options.cache && options.cache.props;
  10676. const avoid = new Set();
  10677. options.reserved.forEach(to_avoid);
  10678. this.globals.forEach(add_def);
  10679. this.walk(new TreeWalker(function(node) {
  10680. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  10681. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  10682. }));
  10683. return avoid;
  10684. function to_avoid(name) {
  10685. avoid.add(name);
  10686. }
  10687. function add_def(def) {
  10688. var name = def.name;
  10689. if (def.global && cache && cache.has(name)) name = cache.get(name);
  10690. else if (!def.unmangleable(options)) return;
  10691. to_avoid(name);
  10692. }
  10693. });
  10694. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  10695. options = this._default_mangler_options(options);
  10696. var nth_identifier = options.nth_identifier;
  10697. if (nth_identifier.reset && nth_identifier.sort) {
  10698. nth_identifier.reset();
  10699. nth_identifier.sort();
  10700. }
  10701. var avoid = this.find_colliding_names(options);
  10702. var cname = 0;
  10703. this.globals.forEach(rename);
  10704. this.walk(new TreeWalker(function(node) {
  10705. if (node instanceof AST_Scope) node.variables.forEach(rename);
  10706. if (node instanceof AST_SymbolCatch) rename(node.definition());
  10707. }));
  10708. function next_name() {
  10709. var name;
  10710. do {
  10711. name = nth_identifier.get(cname++);
  10712. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  10713. return name;
  10714. }
  10715. function rename(def) {
  10716. if (def.global && options.cache) return;
  10717. if (def.unmangleable(options)) return;
  10718. if (options.reserved.has(def.name)) return;
  10719. const redefinition = redefined_catch_def(def);
  10720. const name = def.name = redefinition ? redefinition.name : next_name();
  10721. def.orig.forEach(function(sym) {
  10722. sym.name = name;
  10723. });
  10724. def.references.forEach(function(sym) {
  10725. sym.name = name;
  10726. });
  10727. }
  10728. });
  10729. AST_Node.DEFMETHOD("tail_node", return_this);
  10730. AST_Sequence.DEFMETHOD("tail_node", function() {
  10731. return this.expressions[this.expressions.length - 1];
  10732. });
  10733. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  10734. options = this._default_mangler_options(options);
  10735. var nth_identifier = options.nth_identifier;
  10736. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  10737. // If the identifier mangler is invariant, skip computing character frequency.
  10738. return;
  10739. }
  10740. nth_identifier.reset();
  10741. try {
  10742. AST_Node.prototype.print = function(stream, force_parens) {
  10743. this._print(stream, force_parens);
  10744. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  10745. nth_identifier.consider(this.name, -1);
  10746. } else if (options.properties) {
  10747. if (this instanceof AST_DotHash) {
  10748. nth_identifier.consider("#" + this.property, -1);
  10749. } else if (this instanceof AST_Dot) {
  10750. nth_identifier.consider(this.property, -1);
  10751. } else if (this instanceof AST_Sub) {
  10752. skip_string(this.property);
  10753. }
  10754. }
  10755. };
  10756. nth_identifier.consider(this.print_to_string(), 1);
  10757. } finally {
  10758. AST_Node.prototype.print = AST_Node.prototype._print;
  10759. }
  10760. nth_identifier.sort();
  10761. function skip_string(node) {
  10762. if (node instanceof AST_String) {
  10763. nth_identifier.consider(node.value, -1);
  10764. } else if (node instanceof AST_Conditional) {
  10765. skip_string(node.consequent);
  10766. skip_string(node.alternative);
  10767. } else if (node instanceof AST_Sequence) {
  10768. skip_string(node.tail_node());
  10769. }
  10770. }
  10771. });
  10772. const base54 = (() => {
  10773. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  10774. const digits = "0123456789".split("");
  10775. let chars;
  10776. let frequency;
  10777. function reset() {
  10778. frequency = new Map();
  10779. leading.forEach(function(ch) {
  10780. frequency.set(ch, 0);
  10781. });
  10782. digits.forEach(function(ch) {
  10783. frequency.set(ch, 0);
  10784. });
  10785. }
  10786. function consider(str, delta) {
  10787. for (var i = str.length; --i >= 0;) {
  10788. frequency.set(str[i], frequency.get(str[i]) + delta);
  10789. }
  10790. }
  10791. function compare(a, b) {
  10792. return frequency.get(b) - frequency.get(a);
  10793. }
  10794. function sort() {
  10795. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  10796. }
  10797. // Ensure this is in a usable initial state.
  10798. reset();
  10799. sort();
  10800. function base54(num) {
  10801. var ret = "", base = 54;
  10802. num++;
  10803. do {
  10804. num--;
  10805. ret += chars[num % base];
  10806. num = Math.floor(num / base);
  10807. base = 64;
  10808. } while (num > 0);
  10809. return ret;
  10810. }
  10811. return {
  10812. get: base54,
  10813. consider,
  10814. reset,
  10815. sort
  10816. };
  10817. })();
  10818. let mangle_options = undefined;
  10819. AST_Node.prototype.size = function (compressor, stack) {
  10820. mangle_options = compressor && compressor.mangle_options;
  10821. let size = 0;
  10822. walk_parent(this, (node, info) => {
  10823. size += node._size(info);
  10824. // Braceless arrow functions have fake "return" statements
  10825. if (node instanceof AST_Arrow && node.is_braceless()) {
  10826. size += node.body[0].value._size(info);
  10827. return true;
  10828. }
  10829. }, stack || (compressor && compressor.stack));
  10830. // just to save a bit of memory
  10831. mangle_options = undefined;
  10832. return size;
  10833. };
  10834. AST_Node.prototype._size = () => 0;
  10835. AST_Debugger.prototype._size = () => 8;
  10836. AST_Directive.prototype._size = function () {
  10837. // TODO string encoding stuff
  10838. return 2 + this.value.length;
  10839. };
  10840. /** Count commas/semicolons necessary to show a list of expressions/statements */
  10841. const list_overhead = (array) => array.length && array.length - 1;
  10842. AST_Block.prototype._size = function () {
  10843. return 2 + list_overhead(this.body);
  10844. };
  10845. AST_Toplevel.prototype._size = function() {
  10846. return list_overhead(this.body);
  10847. };
  10848. AST_EmptyStatement.prototype._size = () => 1;
  10849. AST_LabeledStatement.prototype._size = () => 2; // x:
  10850. AST_Do.prototype._size = () => 9;
  10851. AST_While.prototype._size = () => 7;
  10852. AST_For.prototype._size = () => 8;
  10853. AST_ForIn.prototype._size = () => 8;
  10854. // AST_ForOf inherits ^
  10855. AST_With.prototype._size = () => 6;
  10856. AST_Expansion.prototype._size = () => 3;
  10857. const lambda_modifiers = func =>
  10858. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  10859. AST_Accessor.prototype._size = function () {
  10860. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  10861. };
  10862. AST_Function.prototype._size = function (info) {
  10863. const first = !!first_in_statement(info);
  10864. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  10865. };
  10866. AST_Defun.prototype._size = function () {
  10867. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  10868. };
  10869. AST_Arrow.prototype._size = function () {
  10870. let args_and_arrow = 2 + list_overhead(this.argnames);
  10871. if (
  10872. !(
  10873. this.argnames.length === 1
  10874. && this.argnames[0] instanceof AST_Symbol
  10875. )
  10876. ) {
  10877. args_and_arrow += 2; // parens around the args
  10878. }
  10879. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  10880. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  10881. };
  10882. AST_Destructuring.prototype._size = () => 2;
  10883. AST_TemplateString.prototype._size = function () {
  10884. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  10885. };
  10886. AST_TemplateSegment.prototype._size = function () {
  10887. return this.value.length;
  10888. };
  10889. AST_Return.prototype._size = function () {
  10890. return this.value ? 7 : 6;
  10891. };
  10892. AST_Throw.prototype._size = () => 6;
  10893. AST_Break.prototype._size = function () {
  10894. return this.label ? 6 : 5;
  10895. };
  10896. AST_Continue.prototype._size = function () {
  10897. return this.label ? 9 : 8;
  10898. };
  10899. AST_If.prototype._size = () => 4;
  10900. AST_Switch.prototype._size = function () {
  10901. return 8 + list_overhead(this.body);
  10902. };
  10903. AST_Case.prototype._size = function () {
  10904. return 5 + list_overhead(this.body);
  10905. };
  10906. AST_Default.prototype._size = function () {
  10907. return 8 + list_overhead(this.body);
  10908. };
  10909. AST_Try.prototype._size = function () {
  10910. return 3 + list_overhead(this.body);
  10911. };
  10912. AST_Catch.prototype._size = function () {
  10913. let size = 7 + list_overhead(this.body);
  10914. if (this.argname) {
  10915. size += 2;
  10916. }
  10917. return size;
  10918. };
  10919. AST_Finally.prototype._size = function () {
  10920. return 7 + list_overhead(this.body);
  10921. };
  10922. AST_Var.prototype._size = function () {
  10923. return 4 + list_overhead(this.definitions);
  10924. };
  10925. AST_Let.prototype._size = function () {
  10926. return 4 + list_overhead(this.definitions);
  10927. };
  10928. AST_Const.prototype._size = function () {
  10929. return 6 + list_overhead(this.definitions);
  10930. };
  10931. AST_VarDef.prototype._size = function () {
  10932. return this.value ? 1 : 0;
  10933. };
  10934. AST_NameMapping.prototype._size = function () {
  10935. // foreign name isn't mangled
  10936. return this.name ? 4 : 0;
  10937. };
  10938. AST_Import.prototype._size = function () {
  10939. // import
  10940. let size = 6;
  10941. if (this.imported_name) size += 1;
  10942. // from
  10943. if (this.imported_name || this.imported_names) size += 5;
  10944. // braces, and the commas
  10945. if (this.imported_names) {
  10946. size += 2 + list_overhead(this.imported_names);
  10947. }
  10948. return size;
  10949. };
  10950. AST_ImportMeta.prototype._size = () => 11;
  10951. AST_Export.prototype._size = function () {
  10952. let size = 7 + (this.is_default ? 8 : 0);
  10953. if (this.exported_value) {
  10954. size += this.exported_value._size();
  10955. }
  10956. if (this.exported_names) {
  10957. // Braces and commas
  10958. size += 2 + list_overhead(this.exported_names);
  10959. }
  10960. if (this.module_name) {
  10961. // "from "
  10962. size += 5;
  10963. }
  10964. return size;
  10965. };
  10966. AST_Call.prototype._size = function () {
  10967. if (this.optional) {
  10968. return 4 + list_overhead(this.args);
  10969. }
  10970. return 2 + list_overhead(this.args);
  10971. };
  10972. AST_New.prototype._size = function () {
  10973. return 6 + list_overhead(this.args);
  10974. };
  10975. AST_Sequence.prototype._size = function () {
  10976. return list_overhead(this.expressions);
  10977. };
  10978. AST_Dot.prototype._size = function () {
  10979. if (this.optional) {
  10980. return this.property.length + 2;
  10981. }
  10982. return this.property.length + 1;
  10983. };
  10984. AST_DotHash.prototype._size = function () {
  10985. if (this.optional) {
  10986. return this.property.length + 3;
  10987. }
  10988. return this.property.length + 2;
  10989. };
  10990. AST_Sub.prototype._size = function () {
  10991. return this.optional ? 4 : 2;
  10992. };
  10993. AST_Unary.prototype._size = function () {
  10994. if (this.operator === "typeof") return 7;
  10995. if (this.operator === "void") return 5;
  10996. return this.operator.length;
  10997. };
  10998. AST_Binary.prototype._size = function (info) {
  10999. if (this.operator === "in") return 4;
  11000. let size = this.operator.length;
  11001. if (
  11002. (this.operator === "+" || this.operator === "-")
  11003. && this.right instanceof AST_Unary && this.right.operator === this.operator
  11004. ) {
  11005. // 1+ +a > needs space between the +
  11006. size += 1;
  11007. }
  11008. if (this.needs_parens(info)) {
  11009. size += 2;
  11010. }
  11011. return size;
  11012. };
  11013. AST_Conditional.prototype._size = () => 3;
  11014. AST_Array.prototype._size = function () {
  11015. return 2 + list_overhead(this.elements);
  11016. };
  11017. AST_Object.prototype._size = function (info) {
  11018. let base = 2;
  11019. if (first_in_statement(info)) {
  11020. base += 2; // parens
  11021. }
  11022. return base + list_overhead(this.properties);
  11023. };
  11024. /*#__INLINE__*/
  11025. const key_size = key =>
  11026. typeof key === "string" ? key.length : 0;
  11027. AST_ObjectKeyVal.prototype._size = function () {
  11028. return key_size(this.key) + 1;
  11029. };
  11030. /*#__INLINE__*/
  11031. const static_size = is_static => is_static ? 7 : 0;
  11032. AST_ObjectGetter.prototype._size = function () {
  11033. return 5 + static_size(this.static) + key_size(this.key);
  11034. };
  11035. AST_ObjectSetter.prototype._size = function () {
  11036. return 5 + static_size(this.static) + key_size(this.key);
  11037. };
  11038. AST_ConciseMethod.prototype._size = function () {
  11039. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  11040. };
  11041. AST_PrivateMethod.prototype._size = function () {
  11042. return AST_ConciseMethod.prototype._size.call(this) + 1;
  11043. };
  11044. AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
  11045. return AST_ConciseMethod.prototype._size.call(this) + 4;
  11046. };
  11047. AST_Class.prototype._size = function () {
  11048. return (
  11049. (this.name ? 8 : 7)
  11050. + (this.extends ? 8 : 0)
  11051. );
  11052. };
  11053. AST_ClassStaticBlock.prototype._size = function () {
  11054. // "class{}" + semicolons
  11055. return 7 + list_overhead(this.body);
  11056. };
  11057. AST_ClassProperty.prototype._size = function () {
  11058. return (
  11059. static_size(this.static)
  11060. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  11061. + (this.value ? 1 : 0)
  11062. );
  11063. };
  11064. AST_ClassPrivateProperty.prototype._size = function () {
  11065. return AST_ClassProperty.prototype._size.call(this) + 1;
  11066. };
  11067. AST_Symbol.prototype._size = function () {
  11068. return !mangle_options || this.definition().unmangleable(mangle_options)
  11069. ? this.name.length
  11070. : 1;
  11071. };
  11072. // TODO take propmangle into account
  11073. AST_SymbolClassProperty.prototype._size = function () {
  11074. return this.name.length;
  11075. };
  11076. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  11077. const { name, thedef } = this;
  11078. if (thedef && thedef.global) return name.length;
  11079. if (name === "arguments") return 9;
  11080. return AST_Symbol.prototype._size.call(this);
  11081. };
  11082. AST_NewTarget.prototype._size = () => 10;
  11083. AST_SymbolImportForeign.prototype._size = function () {
  11084. return this.name.length;
  11085. };
  11086. AST_SymbolExportForeign.prototype._size = function () {
  11087. return this.name.length;
  11088. };
  11089. AST_This.prototype._size = () => 4;
  11090. AST_Super.prototype._size = () => 5;
  11091. AST_String.prototype._size = function () {
  11092. return this.value.length + 2;
  11093. };
  11094. AST_Number.prototype._size = function () {
  11095. const { value } = this;
  11096. if (value === 0) return 1;
  11097. if (value > 0 && Math.floor(value) === value) {
  11098. return Math.floor(Math.log10(value) + 1);
  11099. }
  11100. return value.toString().length;
  11101. };
  11102. AST_BigInt.prototype._size = function () {
  11103. return this.value.length;
  11104. };
  11105. AST_RegExp.prototype._size = function () {
  11106. return this.value.toString().length;
  11107. };
  11108. AST_Null.prototype._size = () => 4;
  11109. AST_NaN.prototype._size = () => 3;
  11110. AST_Undefined.prototype._size = () => 6; // "void 0"
  11111. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  11112. AST_Infinity.prototype._size = () => 8;
  11113. AST_True.prototype._size = () => 4;
  11114. AST_False.prototype._size = () => 5;
  11115. AST_Await.prototype._size = () => 6;
  11116. AST_Yield.prototype._size = () => 6;
  11117. /***********************************************************************
  11118. A JavaScript tokenizer / parser / beautifier / compressor.
  11119. https://github.com/mishoo/UglifyJS2
  11120. -------------------------------- (C) ---------------------------------
  11121. Author: Mihai Bazon
  11122. <mihai.bazon@gmail.com>
  11123. http://mihai.bazon.net/blog
  11124. Distributed under the BSD license:
  11125. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11126. Redistribution and use in source and binary forms, with or without
  11127. modification, are permitted provided that the following conditions
  11128. are met:
  11129. * Redistributions of source code must retain the above
  11130. copyright notice, this list of conditions and the following
  11131. disclaimer.
  11132. * Redistributions in binary form must reproduce the above
  11133. copyright notice, this list of conditions and the following
  11134. disclaimer in the documentation and/or other materials
  11135. provided with the distribution.
  11136. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11137. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11138. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11139. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11140. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11141. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11142. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11143. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11144. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11145. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11146. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11147. SUCH DAMAGE.
  11148. ***********************************************************************/
  11149. // bitfield flags to be stored in node.flags.
  11150. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  11151. const UNUSED = 0b00000001;
  11152. const TRUTHY = 0b00000010;
  11153. const FALSY = 0b00000100;
  11154. const UNDEFINED = 0b00001000;
  11155. const INLINED = 0b00010000;
  11156. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  11157. const WRITE_ONLY = 0b00100000;
  11158. // information specific to a single compression pass
  11159. const SQUEEZED = 0b0000000100000000;
  11160. const OPTIMIZED = 0b0000001000000000;
  11161. const TOP = 0b0000010000000000;
  11162. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  11163. const has_flag = (node, flag) => node.flags & flag;
  11164. const set_flag = (node, flag) => { node.flags |= flag; };
  11165. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  11166. /***********************************************************************
  11167. A JavaScript tokenizer / parser / beautifier / compressor.
  11168. https://github.com/mishoo/UglifyJS2
  11169. -------------------------------- (C) ---------------------------------
  11170. Author: Mihai Bazon
  11171. <mihai.bazon@gmail.com>
  11172. http://mihai.bazon.net/blog
  11173. Distributed under the BSD license:
  11174. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11175. Redistribution and use in source and binary forms, with or without
  11176. modification, are permitted provided that the following conditions
  11177. are met:
  11178. * Redistributions of source code must retain the above
  11179. copyright notice, this list of conditions and the following
  11180. disclaimer.
  11181. * Redistributions in binary form must reproduce the above
  11182. copyright notice, this list of conditions and the following
  11183. disclaimer in the documentation and/or other materials
  11184. provided with the distribution.
  11185. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11186. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11187. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11188. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11189. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11190. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11191. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11192. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11193. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11194. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11195. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11196. SUCH DAMAGE.
  11197. ***********************************************************************/
  11198. function merge_sequence(array, node) {
  11199. if (node instanceof AST_Sequence) {
  11200. array.push(...node.expressions);
  11201. } else {
  11202. array.push(node);
  11203. }
  11204. return array;
  11205. }
  11206. function make_sequence(orig, expressions) {
  11207. if (expressions.length == 1) return expressions[0];
  11208. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  11209. return make_node(AST_Sequence, orig, {
  11210. expressions: expressions.reduce(merge_sequence, [])
  11211. });
  11212. }
  11213. function make_node_from_constant(val, orig) {
  11214. switch (typeof val) {
  11215. case "string":
  11216. return make_node(AST_String, orig, {
  11217. value: val
  11218. });
  11219. case "number":
  11220. if (isNaN(val)) return make_node(AST_NaN, orig);
  11221. if (isFinite(val)) {
  11222. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11223. operator: "-",
  11224. expression: make_node(AST_Number, orig, { value: -val })
  11225. }) : make_node(AST_Number, orig, { value: val });
  11226. }
  11227. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11228. operator: "-",
  11229. expression: make_node(AST_Infinity, orig)
  11230. }) : make_node(AST_Infinity, orig);
  11231. case "boolean":
  11232. return make_node(val ? AST_True : AST_False, orig);
  11233. case "undefined":
  11234. return make_node(AST_Undefined, orig);
  11235. default:
  11236. if (val === null) {
  11237. return make_node(AST_Null, orig, { value: null });
  11238. }
  11239. if (val instanceof RegExp) {
  11240. return make_node(AST_RegExp, orig, {
  11241. value: {
  11242. source: regexp_source_fix(val.source),
  11243. flags: val.flags
  11244. }
  11245. });
  11246. }
  11247. throw new Error(string_template("Can't handle constant of type: {type}", {
  11248. type: typeof val
  11249. }));
  11250. }
  11251. }
  11252. function best_of_expression(ast1, ast2) {
  11253. return ast1.size() > ast2.size() ? ast2 : ast1;
  11254. }
  11255. function best_of_statement(ast1, ast2) {
  11256. return best_of_expression(
  11257. make_node(AST_SimpleStatement, ast1, {
  11258. body: ast1
  11259. }),
  11260. make_node(AST_SimpleStatement, ast2, {
  11261. body: ast2
  11262. })
  11263. ).body;
  11264. }
  11265. /** Find which node is smaller, and return that */
  11266. function best_of(compressor, ast1, ast2) {
  11267. if (first_in_statement(compressor)) {
  11268. return best_of_statement(ast1, ast2);
  11269. } else {
  11270. return best_of_expression(ast1, ast2);
  11271. }
  11272. }
  11273. /** Simplify an object property's key, if possible */
  11274. function get_simple_key(key) {
  11275. if (key instanceof AST_Constant) {
  11276. return key.getValue();
  11277. }
  11278. if (key instanceof AST_UnaryPrefix
  11279. && key.operator == "void"
  11280. && key.expression instanceof AST_Constant) {
  11281. return;
  11282. }
  11283. return key;
  11284. }
  11285. function read_property(obj, key) {
  11286. key = get_simple_key(key);
  11287. if (key instanceof AST_Node) return;
  11288. var value;
  11289. if (obj instanceof AST_Array) {
  11290. var elements = obj.elements;
  11291. if (key == "length") return make_node_from_constant(elements.length, obj);
  11292. if (typeof key == "number" && key in elements) value = elements[key];
  11293. } else if (obj instanceof AST_Object) {
  11294. key = "" + key;
  11295. var props = obj.properties;
  11296. for (var i = props.length; --i >= 0;) {
  11297. var prop = props[i];
  11298. if (!(prop instanceof AST_ObjectKeyVal)) return;
  11299. if (!value && props[i].key === key) value = props[i].value;
  11300. }
  11301. }
  11302. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  11303. }
  11304. function has_break_or_continue(loop, parent) {
  11305. var found = false;
  11306. var tw = new TreeWalker(function(node) {
  11307. if (found || node instanceof AST_Scope) return true;
  11308. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  11309. return found = true;
  11310. }
  11311. });
  11312. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  11313. tw.push(loop);
  11314. loop.body.walk(tw);
  11315. return found;
  11316. }
  11317. // we shouldn't compress (1,func)(something) to
  11318. // func(something) because that changes the meaning of
  11319. // the func (becomes lexical instead of global).
  11320. function maintain_this_binding(parent, orig, val) {
  11321. if (
  11322. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  11323. || parent instanceof AST_Call && parent.expression === orig
  11324. && (
  11325. val instanceof AST_PropAccess
  11326. || val instanceof AST_SymbolRef && val.name == "eval"
  11327. )
  11328. ) {
  11329. const zero = make_node(AST_Number, orig, { value: 0 });
  11330. return make_sequence(orig, [ zero, val ]);
  11331. } else {
  11332. return val;
  11333. }
  11334. }
  11335. function is_func_expr(node) {
  11336. return node instanceof AST_Arrow || node instanceof AST_Function;
  11337. }
  11338. function is_iife_call(node) {
  11339. // Used to determine whether the node can benefit from negation.
  11340. // Not the case with arrow functions (you need an extra set of parens).
  11341. if (node.TYPE != "Call") return false;
  11342. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  11343. }
  11344. function is_empty(thing) {
  11345. if (thing === null) return true;
  11346. if (thing instanceof AST_EmptyStatement) return true;
  11347. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  11348. return false;
  11349. }
  11350. const identifier_atom = makePredicate("Infinity NaN undefined");
  11351. function is_identifier_atom(node) {
  11352. return node instanceof AST_Infinity
  11353. || node instanceof AST_NaN
  11354. || node instanceof AST_Undefined;
  11355. }
  11356. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  11357. function is_ref_of(ref, type) {
  11358. if (!(ref instanceof AST_SymbolRef)) return false;
  11359. var orig = ref.definition().orig;
  11360. for (var i = orig.length; --i >= 0;) {
  11361. if (orig[i] instanceof type) return true;
  11362. }
  11363. }
  11364. // Can we turn { block contents... } into just the block contents ?
  11365. // Not if one of these is inside.
  11366. function can_be_evicted_from_block(node) {
  11367. return !(
  11368. node instanceof AST_DefClass ||
  11369. node instanceof AST_Defun ||
  11370. node instanceof AST_Let ||
  11371. node instanceof AST_Const ||
  11372. node instanceof AST_Export ||
  11373. node instanceof AST_Import
  11374. );
  11375. }
  11376. function as_statement_array(thing) {
  11377. if (thing === null) return [];
  11378. if (thing instanceof AST_BlockStatement) return thing.body;
  11379. if (thing instanceof AST_EmptyStatement) return [];
  11380. if (thing instanceof AST_Statement) return [ thing ];
  11381. throw new Error("Can't convert thing to statement array");
  11382. }
  11383. function is_reachable(scope_node, defs) {
  11384. const find_ref = node => {
  11385. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  11386. return walk_abort;
  11387. }
  11388. };
  11389. return walk_parent(scope_node, (node, info) => {
  11390. if (node instanceof AST_Scope && node !== scope_node) {
  11391. var parent = info.parent();
  11392. if (
  11393. parent instanceof AST_Call
  11394. && parent.expression === node
  11395. // Async/Generators aren't guaranteed to sync evaluate all of
  11396. // their body steps, so it's possible they close over the variable.
  11397. && !(node.async || node.is_generator)
  11398. ) {
  11399. return;
  11400. }
  11401. if (walk(node, find_ref)) return walk_abort;
  11402. return true;
  11403. }
  11404. });
  11405. }
  11406. /** Check if a ref refers to the name of a function/class it's defined within */
  11407. function is_recursive_ref(compressor, def) {
  11408. var node;
  11409. for (var i = 0; node = compressor.parent(i); i++) {
  11410. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  11411. var name = node.name;
  11412. if (name && name.definition() === def) {
  11413. return true;
  11414. }
  11415. }
  11416. }
  11417. return false;
  11418. }
  11419. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  11420. function retain_top_func(fn, compressor) {
  11421. return compressor.top_retain
  11422. && fn instanceof AST_Defun
  11423. && has_flag(fn, TOP)
  11424. && fn.name
  11425. && compressor.top_retain(fn.name);
  11426. }
  11427. /***********************************************************************
  11428. A JavaScript tokenizer / parser / beautifier / compressor.
  11429. https://github.com/mishoo/UglifyJS2
  11430. -------------------------------- (C) ---------------------------------
  11431. Author: Mihai Bazon
  11432. <mihai.bazon@gmail.com>
  11433. http://mihai.bazon.net/blog
  11434. Distributed under the BSD license:
  11435. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11436. Redistribution and use in source and binary forms, with or without
  11437. modification, are permitted provided that the following conditions
  11438. are met:
  11439. * Redistributions of source code must retain the above
  11440. copyright notice, this list of conditions and the following
  11441. disclaimer.
  11442. * Redistributions in binary form must reproduce the above
  11443. copyright notice, this list of conditions and the following
  11444. disclaimer in the documentation and/or other materials
  11445. provided with the distribution.
  11446. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11447. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11448. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11449. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11450. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11451. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11452. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11453. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11454. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11455. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11456. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11457. SUCH DAMAGE.
  11458. ***********************************************************************/
  11459. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  11460. // Note: Lots of methods and functions are missing here, in case they aren't pure
  11461. // or not available in all JS environments.
  11462. function make_nested_lookup(obj) {
  11463. const out = new Map();
  11464. for (var key of Object.keys(obj)) {
  11465. out.set(key, makePredicate(obj[key]));
  11466. }
  11467. const does_have = (global_name, fname) => {
  11468. const inner_map = out.get(global_name);
  11469. return inner_map != null && inner_map.has(fname);
  11470. };
  11471. return does_have;
  11472. }
  11473. // Objects which are safe to access without throwing or causing a side effect.
  11474. // Usually we'd check the `unsafe` option first but these are way too common for that
  11475. const pure_prop_access_globals = new Set([
  11476. "Number",
  11477. "String",
  11478. "Array",
  11479. "Object",
  11480. "Function",
  11481. "Promise",
  11482. ]);
  11483. const object_methods = [
  11484. "constructor",
  11485. "toString",
  11486. "valueOf",
  11487. ];
  11488. const is_pure_native_method = make_nested_lookup({
  11489. Array: [
  11490. "indexOf",
  11491. "join",
  11492. "lastIndexOf",
  11493. "slice",
  11494. ...object_methods,
  11495. ],
  11496. Boolean: object_methods,
  11497. Function: object_methods,
  11498. Number: [
  11499. "toExponential",
  11500. "toFixed",
  11501. "toPrecision",
  11502. ...object_methods,
  11503. ],
  11504. Object: object_methods,
  11505. RegExp: [
  11506. "test",
  11507. ...object_methods,
  11508. ],
  11509. String: [
  11510. "charAt",
  11511. "charCodeAt",
  11512. "concat",
  11513. "indexOf",
  11514. "italics",
  11515. "lastIndexOf",
  11516. "match",
  11517. "replace",
  11518. "search",
  11519. "slice",
  11520. "split",
  11521. "substr",
  11522. "substring",
  11523. "toLowerCase",
  11524. "toUpperCase",
  11525. "trim",
  11526. ...object_methods,
  11527. ],
  11528. });
  11529. const is_pure_native_fn = make_nested_lookup({
  11530. Array: [
  11531. "isArray",
  11532. ],
  11533. Math: [
  11534. "abs",
  11535. "acos",
  11536. "asin",
  11537. "atan",
  11538. "ceil",
  11539. "cos",
  11540. "exp",
  11541. "floor",
  11542. "log",
  11543. "round",
  11544. "sin",
  11545. "sqrt",
  11546. "tan",
  11547. "atan2",
  11548. "pow",
  11549. "max",
  11550. "min",
  11551. ],
  11552. Number: [
  11553. "isFinite",
  11554. "isNaN",
  11555. ],
  11556. Object: [
  11557. "create",
  11558. "getOwnPropertyDescriptor",
  11559. "getOwnPropertyNames",
  11560. "getPrototypeOf",
  11561. "isExtensible",
  11562. "isFrozen",
  11563. "isSealed",
  11564. "hasOwn",
  11565. "keys",
  11566. ],
  11567. String: [
  11568. "fromCharCode",
  11569. ],
  11570. });
  11571. // Known numeric values which come with JS environments
  11572. const is_pure_native_value = make_nested_lookup({
  11573. Math: [
  11574. "E",
  11575. "LN10",
  11576. "LN2",
  11577. "LOG2E",
  11578. "LOG10E",
  11579. "PI",
  11580. "SQRT1_2",
  11581. "SQRT2",
  11582. ],
  11583. Number: [
  11584. "MAX_VALUE",
  11585. "MIN_VALUE",
  11586. "NaN",
  11587. "NEGATIVE_INFINITY",
  11588. "POSITIVE_INFINITY",
  11589. ],
  11590. });
  11591. /***********************************************************************
  11592. A JavaScript tokenizer / parser / beautifier / compressor.
  11593. https://github.com/mishoo/UglifyJS2
  11594. -------------------------------- (C) ---------------------------------
  11595. Author: Mihai Bazon
  11596. <mihai.bazon@gmail.com>
  11597. http://mihai.bazon.net/blog
  11598. Distributed under the BSD license:
  11599. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11600. Redistribution and use in source and binary forms, with or without
  11601. modification, are permitted provided that the following conditions
  11602. are met:
  11603. * Redistributions of source code must retain the above
  11604. copyright notice, this list of conditions and the following
  11605. disclaimer.
  11606. * Redistributions in binary form must reproduce the above
  11607. copyright notice, this list of conditions and the following
  11608. disclaimer in the documentation and/or other materials
  11609. provided with the distribution.
  11610. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11611. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11612. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11613. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11614. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11615. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11616. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11617. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11618. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11619. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11620. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11621. SUCH DAMAGE.
  11622. ***********************************************************************/
  11623. // Functions and methods to infer certain facts about expressions
  11624. // It's not always possible to be 100% sure about something just by static analysis,
  11625. // so `true` means yes, and `false` means maybe
  11626. const is_undeclared_ref = (node) =>
  11627. node instanceof AST_SymbolRef && node.definition().undeclared;
  11628. const lazy_op = makePredicate("&& || ??");
  11629. const unary_side_effects = makePredicate("delete ++ --");
  11630. // methods to determine whether an expression has a boolean result type
  11631. (function(def_is_boolean) {
  11632. const unary_bool = makePredicate("! delete");
  11633. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  11634. def_is_boolean(AST_Node, return_false);
  11635. def_is_boolean(AST_UnaryPrefix, function() {
  11636. return unary_bool.has(this.operator);
  11637. });
  11638. def_is_boolean(AST_Binary, function() {
  11639. return binary_bool.has(this.operator)
  11640. || lazy_op.has(this.operator)
  11641. && this.left.is_boolean()
  11642. && this.right.is_boolean();
  11643. });
  11644. def_is_boolean(AST_Conditional, function() {
  11645. return this.consequent.is_boolean() && this.alternative.is_boolean();
  11646. });
  11647. def_is_boolean(AST_Assign, function() {
  11648. return this.operator == "=" && this.right.is_boolean();
  11649. });
  11650. def_is_boolean(AST_Sequence, function() {
  11651. return this.tail_node().is_boolean();
  11652. });
  11653. def_is_boolean(AST_True, return_true);
  11654. def_is_boolean(AST_False, return_true);
  11655. })(function(node, func) {
  11656. node.DEFMETHOD("is_boolean", func);
  11657. });
  11658. // methods to determine if an expression has a numeric result type
  11659. (function(def_is_number) {
  11660. def_is_number(AST_Node, return_false);
  11661. def_is_number(AST_Number, return_true);
  11662. const unary = makePredicate("+ - ~ ++ --");
  11663. def_is_number(AST_Unary, function() {
  11664. return unary.has(this.operator);
  11665. });
  11666. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  11667. def_is_number(AST_Binary, function(compressor) {
  11668. return numeric_ops.has(this.operator) || this.operator == "+"
  11669. && this.left.is_number(compressor)
  11670. && this.right.is_number(compressor);
  11671. });
  11672. def_is_number(AST_Assign, function(compressor) {
  11673. return numeric_ops.has(this.operator.slice(0, -1))
  11674. || this.operator == "=" && this.right.is_number(compressor);
  11675. });
  11676. def_is_number(AST_Sequence, function(compressor) {
  11677. return this.tail_node().is_number(compressor);
  11678. });
  11679. def_is_number(AST_Conditional, function(compressor) {
  11680. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  11681. });
  11682. })(function(node, func) {
  11683. node.DEFMETHOD("is_number", func);
  11684. });
  11685. // methods to determine if an expression has a string result type
  11686. (function(def_is_string) {
  11687. def_is_string(AST_Node, return_false);
  11688. def_is_string(AST_String, return_true);
  11689. def_is_string(AST_TemplateString, return_true);
  11690. def_is_string(AST_UnaryPrefix, function() {
  11691. return this.operator == "typeof";
  11692. });
  11693. def_is_string(AST_Binary, function(compressor) {
  11694. return this.operator == "+" &&
  11695. (this.left.is_string(compressor) || this.right.is_string(compressor));
  11696. });
  11697. def_is_string(AST_Assign, function(compressor) {
  11698. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  11699. });
  11700. def_is_string(AST_Sequence, function(compressor) {
  11701. return this.tail_node().is_string(compressor);
  11702. });
  11703. def_is_string(AST_Conditional, function(compressor) {
  11704. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  11705. });
  11706. })(function(node, func) {
  11707. node.DEFMETHOD("is_string", func);
  11708. });
  11709. function is_undefined(node, compressor) {
  11710. return (
  11711. has_flag(node, UNDEFINED)
  11712. || node instanceof AST_Undefined
  11713. || node instanceof AST_UnaryPrefix
  11714. && node.operator == "void"
  11715. && !node.expression.has_side_effects(compressor)
  11716. );
  11717. }
  11718. // Is the node explicitly null or undefined.
  11719. function is_null_or_undefined(node, compressor) {
  11720. let fixed;
  11721. return (
  11722. node instanceof AST_Null
  11723. || is_undefined(node, compressor)
  11724. || (
  11725. node instanceof AST_SymbolRef
  11726. && (fixed = node.definition().fixed) instanceof AST_Node
  11727. && is_nullish(fixed, compressor)
  11728. )
  11729. );
  11730. }
  11731. // Find out if this expression is optionally chained from a base-point that we
  11732. // can statically analyze as null or undefined.
  11733. function is_nullish_shortcircuited(node, compressor) {
  11734. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  11735. return (
  11736. (node.optional && is_null_or_undefined(node.expression, compressor))
  11737. || is_nullish_shortcircuited(node.expression, compressor)
  11738. );
  11739. }
  11740. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  11741. return false;
  11742. }
  11743. // Find out if something is == null, or can short circuit into nullish.
  11744. // Used to optimize ?. and ??
  11745. function is_nullish(node, compressor) {
  11746. if (is_null_or_undefined(node, compressor)) return true;
  11747. return is_nullish_shortcircuited(node, compressor);
  11748. }
  11749. // Determine if expression might cause side effects
  11750. // If there's a possibility that a node may change something when it's executed, this returns true
  11751. (function(def_has_side_effects) {
  11752. def_has_side_effects(AST_Node, return_true);
  11753. def_has_side_effects(AST_EmptyStatement, return_false);
  11754. def_has_side_effects(AST_Constant, return_false);
  11755. def_has_side_effects(AST_This, return_false);
  11756. function any(list, compressor) {
  11757. for (var i = list.length; --i >= 0;)
  11758. if (list[i].has_side_effects(compressor))
  11759. return true;
  11760. return false;
  11761. }
  11762. def_has_side_effects(AST_Block, function(compressor) {
  11763. return any(this.body, compressor);
  11764. });
  11765. def_has_side_effects(AST_Call, function(compressor) {
  11766. if (
  11767. !this.is_callee_pure(compressor)
  11768. && (!this.expression.is_call_pure(compressor)
  11769. || this.expression.has_side_effects(compressor))
  11770. ) {
  11771. return true;
  11772. }
  11773. return any(this.args, compressor);
  11774. });
  11775. def_has_side_effects(AST_Switch, function(compressor) {
  11776. return this.expression.has_side_effects(compressor)
  11777. || any(this.body, compressor);
  11778. });
  11779. def_has_side_effects(AST_Case, function(compressor) {
  11780. return this.expression.has_side_effects(compressor)
  11781. || any(this.body, compressor);
  11782. });
  11783. def_has_side_effects(AST_Try, function(compressor) {
  11784. return any(this.body, compressor)
  11785. || this.bcatch && this.bcatch.has_side_effects(compressor)
  11786. || this.bfinally && this.bfinally.has_side_effects(compressor);
  11787. });
  11788. def_has_side_effects(AST_If, function(compressor) {
  11789. return this.condition.has_side_effects(compressor)
  11790. || this.body && this.body.has_side_effects(compressor)
  11791. || this.alternative && this.alternative.has_side_effects(compressor);
  11792. });
  11793. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  11794. return this.body.has_side_effects(compressor);
  11795. });
  11796. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  11797. return this.body.has_side_effects(compressor);
  11798. });
  11799. def_has_side_effects(AST_Lambda, return_false);
  11800. def_has_side_effects(AST_Class, function (compressor) {
  11801. if (this.extends && this.extends.has_side_effects(compressor)) {
  11802. return true;
  11803. }
  11804. return any(this.properties, compressor);
  11805. });
  11806. def_has_side_effects(AST_ClassStaticBlock, function(compressor) {
  11807. return any(this.body, compressor);
  11808. });
  11809. def_has_side_effects(AST_Binary, function(compressor) {
  11810. return this.left.has_side_effects(compressor)
  11811. || this.right.has_side_effects(compressor);
  11812. });
  11813. def_has_side_effects(AST_Assign, return_true);
  11814. def_has_side_effects(AST_Conditional, function(compressor) {
  11815. return this.condition.has_side_effects(compressor)
  11816. || this.consequent.has_side_effects(compressor)
  11817. || this.alternative.has_side_effects(compressor);
  11818. });
  11819. def_has_side_effects(AST_Unary, function(compressor) {
  11820. return unary_side_effects.has(this.operator)
  11821. || this.expression.has_side_effects(compressor);
  11822. });
  11823. def_has_side_effects(AST_SymbolRef, function(compressor) {
  11824. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  11825. });
  11826. def_has_side_effects(AST_SymbolClassProperty, return_false);
  11827. def_has_side_effects(AST_SymbolDeclaration, return_false);
  11828. def_has_side_effects(AST_Object, function(compressor) {
  11829. return any(this.properties, compressor);
  11830. });
  11831. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  11832. return (
  11833. this.computed_key() && this.key.has_side_effects(compressor)
  11834. || this.value && this.value.has_side_effects(compressor)
  11835. );
  11836. });
  11837. def_has_side_effects(AST_ClassProperty, function(compressor) {
  11838. return (
  11839. this.computed_key() && this.key.has_side_effects(compressor)
  11840. || this.static && this.value && this.value.has_side_effects(compressor)
  11841. );
  11842. });
  11843. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  11844. return this.computed_key() && this.key.has_side_effects(compressor);
  11845. });
  11846. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  11847. return this.computed_key() && this.key.has_side_effects(compressor);
  11848. });
  11849. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  11850. return this.computed_key() && this.key.has_side_effects(compressor);
  11851. });
  11852. def_has_side_effects(AST_Array, function(compressor) {
  11853. return any(this.elements, compressor);
  11854. });
  11855. def_has_side_effects(AST_Dot, function(compressor) {
  11856. if (is_nullish(this, compressor)) return false;
  11857. return !this.optional && this.expression.may_throw_on_access(compressor)
  11858. || this.expression.has_side_effects(compressor);
  11859. });
  11860. def_has_side_effects(AST_Sub, function(compressor) {
  11861. if (is_nullish(this, compressor)) return false;
  11862. return !this.optional && this.expression.may_throw_on_access(compressor)
  11863. || this.expression.has_side_effects(compressor)
  11864. || this.property.has_side_effects(compressor);
  11865. });
  11866. def_has_side_effects(AST_Chain, function (compressor) {
  11867. return this.expression.has_side_effects(compressor);
  11868. });
  11869. def_has_side_effects(AST_Sequence, function(compressor) {
  11870. return any(this.expressions, compressor);
  11871. });
  11872. def_has_side_effects(AST_Definitions, function(compressor) {
  11873. return any(this.definitions, compressor);
  11874. });
  11875. def_has_side_effects(AST_VarDef, function() {
  11876. return this.value;
  11877. });
  11878. def_has_side_effects(AST_TemplateSegment, return_false);
  11879. def_has_side_effects(AST_TemplateString, function(compressor) {
  11880. return any(this.segments, compressor);
  11881. });
  11882. })(function(node, func) {
  11883. node.DEFMETHOD("has_side_effects", func);
  11884. });
  11885. // determine if expression may throw
  11886. (function(def_may_throw) {
  11887. def_may_throw(AST_Node, return_true);
  11888. def_may_throw(AST_Constant, return_false);
  11889. def_may_throw(AST_EmptyStatement, return_false);
  11890. def_may_throw(AST_Lambda, return_false);
  11891. def_may_throw(AST_SymbolDeclaration, return_false);
  11892. def_may_throw(AST_This, return_false);
  11893. function any(list, compressor) {
  11894. for (var i = list.length; --i >= 0;)
  11895. if (list[i].may_throw(compressor))
  11896. return true;
  11897. return false;
  11898. }
  11899. def_may_throw(AST_Class, function(compressor) {
  11900. if (this.extends && this.extends.may_throw(compressor)) return true;
  11901. return any(this.properties, compressor);
  11902. });
  11903. def_may_throw(AST_ClassStaticBlock, function (compressor) {
  11904. return any(this.body, compressor);
  11905. });
  11906. def_may_throw(AST_Array, function(compressor) {
  11907. return any(this.elements, compressor);
  11908. });
  11909. def_may_throw(AST_Assign, function(compressor) {
  11910. if (this.right.may_throw(compressor)) return true;
  11911. if (!compressor.has_directive("use strict")
  11912. && this.operator == "="
  11913. && this.left instanceof AST_SymbolRef) {
  11914. return false;
  11915. }
  11916. return this.left.may_throw(compressor);
  11917. });
  11918. def_may_throw(AST_Binary, function(compressor) {
  11919. return this.left.may_throw(compressor)
  11920. || this.right.may_throw(compressor);
  11921. });
  11922. def_may_throw(AST_Block, function(compressor) {
  11923. return any(this.body, compressor);
  11924. });
  11925. def_may_throw(AST_Call, function(compressor) {
  11926. if (is_nullish(this, compressor)) return false;
  11927. if (any(this.args, compressor)) return true;
  11928. if (this.is_callee_pure(compressor)) return false;
  11929. if (this.expression.may_throw(compressor)) return true;
  11930. return !(this.expression instanceof AST_Lambda)
  11931. || any(this.expression.body, compressor);
  11932. });
  11933. def_may_throw(AST_Case, function(compressor) {
  11934. return this.expression.may_throw(compressor)
  11935. || any(this.body, compressor);
  11936. });
  11937. def_may_throw(AST_Conditional, function(compressor) {
  11938. return this.condition.may_throw(compressor)
  11939. || this.consequent.may_throw(compressor)
  11940. || this.alternative.may_throw(compressor);
  11941. });
  11942. def_may_throw(AST_Definitions, function(compressor) {
  11943. return any(this.definitions, compressor);
  11944. });
  11945. def_may_throw(AST_If, function(compressor) {
  11946. return this.condition.may_throw(compressor)
  11947. || this.body && this.body.may_throw(compressor)
  11948. || this.alternative && this.alternative.may_throw(compressor);
  11949. });
  11950. def_may_throw(AST_LabeledStatement, function(compressor) {
  11951. return this.body.may_throw(compressor);
  11952. });
  11953. def_may_throw(AST_Object, function(compressor) {
  11954. return any(this.properties, compressor);
  11955. });
  11956. def_may_throw(AST_ObjectProperty, function(compressor) {
  11957. // TODO key may throw too
  11958. return this.value ? this.value.may_throw(compressor) : false;
  11959. });
  11960. def_may_throw(AST_ClassProperty, function(compressor) {
  11961. return (
  11962. this.computed_key() && this.key.may_throw(compressor)
  11963. || this.static && this.value && this.value.may_throw(compressor)
  11964. );
  11965. });
  11966. def_may_throw(AST_ConciseMethod, function(compressor) {
  11967. return this.computed_key() && this.key.may_throw(compressor);
  11968. });
  11969. def_may_throw(AST_ObjectGetter, function(compressor) {
  11970. return this.computed_key() && this.key.may_throw(compressor);
  11971. });
  11972. def_may_throw(AST_ObjectSetter, function(compressor) {
  11973. return this.computed_key() && this.key.may_throw(compressor);
  11974. });
  11975. def_may_throw(AST_Return, function(compressor) {
  11976. return this.value && this.value.may_throw(compressor);
  11977. });
  11978. def_may_throw(AST_Sequence, function(compressor) {
  11979. return any(this.expressions, compressor);
  11980. });
  11981. def_may_throw(AST_SimpleStatement, function(compressor) {
  11982. return this.body.may_throw(compressor);
  11983. });
  11984. def_may_throw(AST_Dot, function(compressor) {
  11985. if (is_nullish(this, compressor)) return false;
  11986. return !this.optional && this.expression.may_throw_on_access(compressor)
  11987. || this.expression.may_throw(compressor);
  11988. });
  11989. def_may_throw(AST_Sub, function(compressor) {
  11990. if (is_nullish(this, compressor)) return false;
  11991. return !this.optional && this.expression.may_throw_on_access(compressor)
  11992. || this.expression.may_throw(compressor)
  11993. || this.property.may_throw(compressor);
  11994. });
  11995. def_may_throw(AST_Chain, function(compressor) {
  11996. return this.expression.may_throw(compressor);
  11997. });
  11998. def_may_throw(AST_Switch, function(compressor) {
  11999. return this.expression.may_throw(compressor)
  12000. || any(this.body, compressor);
  12001. });
  12002. def_may_throw(AST_SymbolRef, function(compressor) {
  12003. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12004. });
  12005. def_may_throw(AST_SymbolClassProperty, return_false);
  12006. def_may_throw(AST_Try, function(compressor) {
  12007. return this.bcatch ? this.bcatch.may_throw(compressor) : any(this.body, compressor)
  12008. || this.bfinally && this.bfinally.may_throw(compressor);
  12009. });
  12010. def_may_throw(AST_Unary, function(compressor) {
  12011. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12012. return false;
  12013. return this.expression.may_throw(compressor);
  12014. });
  12015. def_may_throw(AST_VarDef, function(compressor) {
  12016. if (!this.value) return false;
  12017. return this.value.may_throw(compressor);
  12018. });
  12019. })(function(node, func) {
  12020. node.DEFMETHOD("may_throw", func);
  12021. });
  12022. // determine if expression is constant
  12023. (function(def_is_constant_expression) {
  12024. function all_refs_local(scope) {
  12025. let result = true;
  12026. walk(this, node => {
  12027. if (node instanceof AST_SymbolRef) {
  12028. if (has_flag(this, INLINED)) {
  12029. result = false;
  12030. return walk_abort;
  12031. }
  12032. var def = node.definition();
  12033. if (
  12034. member(def, this.enclosed)
  12035. && !this.variables.has(def.name)
  12036. ) {
  12037. if (scope) {
  12038. var scope_def = scope.find_variable(node);
  12039. if (def.undeclared ? !scope_def : scope_def === def) {
  12040. result = "f";
  12041. return true;
  12042. }
  12043. }
  12044. result = false;
  12045. return walk_abort;
  12046. }
  12047. return true;
  12048. }
  12049. if (node instanceof AST_This && this instanceof AST_Arrow) {
  12050. // TODO check arguments too!
  12051. result = false;
  12052. return walk_abort;
  12053. }
  12054. });
  12055. return result;
  12056. }
  12057. def_is_constant_expression(AST_Node, return_false);
  12058. def_is_constant_expression(AST_Constant, return_true);
  12059. def_is_constant_expression(AST_Class, function(scope) {
  12060. if (this.extends && !this.extends.is_constant_expression(scope)) {
  12061. return false;
  12062. }
  12063. for (const prop of this.properties) {
  12064. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  12065. return false;
  12066. }
  12067. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  12068. return false;
  12069. }
  12070. if (prop instanceof AST_ClassStaticBlock) {
  12071. return false;
  12072. }
  12073. }
  12074. return all_refs_local.call(this, scope);
  12075. });
  12076. def_is_constant_expression(AST_Lambda, all_refs_local);
  12077. def_is_constant_expression(AST_Unary, function() {
  12078. return this.expression.is_constant_expression();
  12079. });
  12080. def_is_constant_expression(AST_Binary, function() {
  12081. return this.left.is_constant_expression()
  12082. && this.right.is_constant_expression();
  12083. });
  12084. def_is_constant_expression(AST_Array, function() {
  12085. return this.elements.every((l) => l.is_constant_expression());
  12086. });
  12087. def_is_constant_expression(AST_Object, function() {
  12088. return this.properties.every((l) => l.is_constant_expression());
  12089. });
  12090. def_is_constant_expression(AST_ObjectProperty, function() {
  12091. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  12092. });
  12093. })(function(node, func) {
  12094. node.DEFMETHOD("is_constant_expression", func);
  12095. });
  12096. // may_throw_on_access()
  12097. // returns true if this node may be null, undefined or contain `AST_Accessor`
  12098. (function(def_may_throw_on_access) {
  12099. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  12100. return !compressor.option("pure_getters")
  12101. || this._dot_throw(compressor);
  12102. });
  12103. function is_strict(compressor) {
  12104. return /strict/.test(compressor.option("pure_getters"));
  12105. }
  12106. def_may_throw_on_access(AST_Node, is_strict);
  12107. def_may_throw_on_access(AST_Null, return_true);
  12108. def_may_throw_on_access(AST_Undefined, return_true);
  12109. def_may_throw_on_access(AST_Constant, return_false);
  12110. def_may_throw_on_access(AST_Array, return_false);
  12111. def_may_throw_on_access(AST_Object, function(compressor) {
  12112. if (!is_strict(compressor)) return false;
  12113. for (var i = this.properties.length; --i >=0;)
  12114. if (this.properties[i]._dot_throw(compressor)) return true;
  12115. return false;
  12116. });
  12117. // Do not be as strict with classes as we are with objects.
  12118. // Hopefully the community is not going to abuse static getters and setters.
  12119. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  12120. def_may_throw_on_access(AST_Class, return_false);
  12121. def_may_throw_on_access(AST_ObjectProperty, return_false);
  12122. def_may_throw_on_access(AST_ObjectGetter, return_true);
  12123. def_may_throw_on_access(AST_Expansion, function(compressor) {
  12124. return this.expression._dot_throw(compressor);
  12125. });
  12126. def_may_throw_on_access(AST_Function, return_false);
  12127. def_may_throw_on_access(AST_Arrow, return_false);
  12128. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  12129. def_may_throw_on_access(AST_UnaryPrefix, function() {
  12130. return this.operator == "void";
  12131. });
  12132. def_may_throw_on_access(AST_Binary, function(compressor) {
  12133. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  12134. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  12135. });
  12136. def_may_throw_on_access(AST_Assign, function(compressor) {
  12137. if (this.logical) return true;
  12138. return this.operator == "="
  12139. && this.right._dot_throw(compressor);
  12140. });
  12141. def_may_throw_on_access(AST_Conditional, function(compressor) {
  12142. return this.consequent._dot_throw(compressor)
  12143. || this.alternative._dot_throw(compressor);
  12144. });
  12145. def_may_throw_on_access(AST_Dot, function(compressor) {
  12146. if (!is_strict(compressor)) return false;
  12147. if (this.property == "prototype") {
  12148. return !(
  12149. this.expression instanceof AST_Function
  12150. || this.expression instanceof AST_Class
  12151. );
  12152. }
  12153. return true;
  12154. });
  12155. def_may_throw_on_access(AST_Chain, function(compressor) {
  12156. return this.expression._dot_throw(compressor);
  12157. });
  12158. def_may_throw_on_access(AST_Sequence, function(compressor) {
  12159. return this.tail_node()._dot_throw(compressor);
  12160. });
  12161. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  12162. if (this.name === "arguments") return false;
  12163. if (has_flag(this, UNDEFINED)) return true;
  12164. if (!is_strict(compressor)) return false;
  12165. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  12166. if (this.is_immutable()) return false;
  12167. var fixed = this.fixed_value();
  12168. return !fixed || fixed._dot_throw(compressor);
  12169. });
  12170. })(function(node, func) {
  12171. node.DEFMETHOD("_dot_throw", func);
  12172. });
  12173. function is_lhs(node, parent) {
  12174. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  12175. if (parent instanceof AST_Assign && parent.left === node) return node;
  12176. }
  12177. (function(def_find_defs) {
  12178. function to_node(value, orig) {
  12179. if (value instanceof AST_Node) {
  12180. if (!(value instanceof AST_Constant)) {
  12181. // Value may be a function, an array including functions and even a complex assign / block expression,
  12182. // so it should never be shared in different places.
  12183. // Otherwise wrong information may be used in the compression phase
  12184. value = value.clone(true);
  12185. }
  12186. return make_node(value.CTOR, orig, value);
  12187. }
  12188. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  12189. elements: value.map(function(value) {
  12190. return to_node(value, orig);
  12191. })
  12192. });
  12193. if (value && typeof value == "object") {
  12194. var props = [];
  12195. for (var key in value) if (HOP(value, key)) {
  12196. props.push(make_node(AST_ObjectKeyVal, orig, {
  12197. key: key,
  12198. value: to_node(value[key], orig)
  12199. }));
  12200. }
  12201. return make_node(AST_Object, orig, {
  12202. properties: props
  12203. });
  12204. }
  12205. return make_node_from_constant(value, orig);
  12206. }
  12207. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  12208. if (!compressor.option("global_defs")) return this;
  12209. this.figure_out_scope({ ie8: compressor.option("ie8") });
  12210. return this.transform(new TreeTransformer(function(node) {
  12211. var def = node._find_defs(compressor, "");
  12212. if (!def) return;
  12213. var level = 0, child = node, parent;
  12214. while (parent = this.parent(level++)) {
  12215. if (!(parent instanceof AST_PropAccess)) break;
  12216. if (parent.expression !== child) break;
  12217. child = parent;
  12218. }
  12219. if (is_lhs(child, parent)) {
  12220. return;
  12221. }
  12222. return def;
  12223. }));
  12224. });
  12225. def_find_defs(AST_Node, noop);
  12226. def_find_defs(AST_Chain, function(compressor, suffix) {
  12227. return this.expression._find_defs(compressor, suffix);
  12228. });
  12229. def_find_defs(AST_Dot, function(compressor, suffix) {
  12230. return this.expression._find_defs(compressor, "." + this.property + suffix);
  12231. });
  12232. def_find_defs(AST_SymbolDeclaration, function() {
  12233. if (!this.global()) return;
  12234. });
  12235. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  12236. if (!this.global()) return;
  12237. var defines = compressor.option("global_defs");
  12238. var name = this.name + suffix;
  12239. if (HOP(defines, name)) return to_node(defines[name], this);
  12240. });
  12241. })(function(node, func) {
  12242. node.DEFMETHOD("_find_defs", func);
  12243. });
  12244. // method to negate an expression
  12245. (function(def_negate) {
  12246. function basic_negation(exp) {
  12247. return make_node(AST_UnaryPrefix, exp, {
  12248. operator: "!",
  12249. expression: exp
  12250. });
  12251. }
  12252. function best(orig, alt, first_in_statement) {
  12253. var negated = basic_negation(orig);
  12254. if (first_in_statement) {
  12255. var stat = make_node(AST_SimpleStatement, alt, {
  12256. body: alt
  12257. });
  12258. return best_of_expression(negated, stat) === stat ? alt : negated;
  12259. }
  12260. return best_of_expression(negated, alt);
  12261. }
  12262. def_negate(AST_Node, function() {
  12263. return basic_negation(this);
  12264. });
  12265. def_negate(AST_Statement, function() {
  12266. throw new Error("Cannot negate a statement");
  12267. });
  12268. def_negate(AST_Function, function() {
  12269. return basic_negation(this);
  12270. });
  12271. def_negate(AST_Arrow, function() {
  12272. return basic_negation(this);
  12273. });
  12274. def_negate(AST_UnaryPrefix, function() {
  12275. if (this.operator == "!")
  12276. return this.expression;
  12277. return basic_negation(this);
  12278. });
  12279. def_negate(AST_Sequence, function(compressor) {
  12280. var expressions = this.expressions.slice();
  12281. expressions.push(expressions.pop().negate(compressor));
  12282. return make_sequence(this, expressions);
  12283. });
  12284. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  12285. var self = this.clone();
  12286. self.consequent = self.consequent.negate(compressor);
  12287. self.alternative = self.alternative.negate(compressor);
  12288. return best(this, self, first_in_statement);
  12289. });
  12290. def_negate(AST_Binary, function(compressor, first_in_statement) {
  12291. var self = this.clone(), op = this.operator;
  12292. if (compressor.option("unsafe_comps")) {
  12293. switch (op) {
  12294. case "<=" : self.operator = ">" ; return self;
  12295. case "<" : self.operator = ">=" ; return self;
  12296. case ">=" : self.operator = "<" ; return self;
  12297. case ">" : self.operator = "<=" ; return self;
  12298. }
  12299. }
  12300. switch (op) {
  12301. case "==" : self.operator = "!="; return self;
  12302. case "!=" : self.operator = "=="; return self;
  12303. case "===": self.operator = "!=="; return self;
  12304. case "!==": self.operator = "==="; return self;
  12305. case "&&":
  12306. self.operator = "||";
  12307. self.left = self.left.negate(compressor, first_in_statement);
  12308. self.right = self.right.negate(compressor);
  12309. return best(this, self, first_in_statement);
  12310. case "||":
  12311. self.operator = "&&";
  12312. self.left = self.left.negate(compressor, first_in_statement);
  12313. self.right = self.right.negate(compressor);
  12314. return best(this, self, first_in_statement);
  12315. }
  12316. return basic_negation(this);
  12317. });
  12318. })(function(node, func) {
  12319. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  12320. return func.call(this, compressor, first_in_statement);
  12321. });
  12322. });
  12323. // Is the callee of this function pure?
  12324. 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");
  12325. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  12326. if (compressor.option("unsafe")) {
  12327. var expr = this.expression;
  12328. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  12329. if (
  12330. expr.expression && expr.expression.name === "hasOwnProperty" &&
  12331. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  12332. ) {
  12333. return false;
  12334. }
  12335. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  12336. if (
  12337. expr instanceof AST_Dot
  12338. && is_undeclared_ref(expr.expression)
  12339. && is_pure_native_fn(expr.expression.name, expr.property)
  12340. ) {
  12341. return true;
  12342. }
  12343. }
  12344. return !!has_annotation(this, _PURE) || !compressor.pure_funcs(this);
  12345. });
  12346. // If I call this, is it a pure function?
  12347. AST_Node.DEFMETHOD("is_call_pure", return_false);
  12348. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  12349. if (!compressor.option("unsafe")) return;
  12350. const expr = this.expression;
  12351. let native_obj;
  12352. if (expr instanceof AST_Array) {
  12353. native_obj = "Array";
  12354. } else if (expr.is_boolean()) {
  12355. native_obj = "Boolean";
  12356. } else if (expr.is_number(compressor)) {
  12357. native_obj = "Number";
  12358. } else if (expr instanceof AST_RegExp) {
  12359. native_obj = "RegExp";
  12360. } else if (expr.is_string(compressor)) {
  12361. native_obj = "String";
  12362. } else if (!this.may_throw_on_access(compressor)) {
  12363. native_obj = "Object";
  12364. }
  12365. return native_obj != null && is_pure_native_method(native_obj, this.property);
  12366. });
  12367. // tell me if a statement aborts
  12368. const aborts = (thing) => thing && thing.aborts();
  12369. (function(def_aborts) {
  12370. def_aborts(AST_Statement, return_null);
  12371. def_aborts(AST_Jump, return_this);
  12372. function block_aborts() {
  12373. for (var i = 0; i < this.body.length; i++) {
  12374. if (aborts(this.body[i])) {
  12375. return this.body[i];
  12376. }
  12377. }
  12378. return null;
  12379. }
  12380. def_aborts(AST_Import, return_null);
  12381. def_aborts(AST_BlockStatement, block_aborts);
  12382. def_aborts(AST_SwitchBranch, block_aborts);
  12383. def_aborts(AST_DefClass, function () {
  12384. for (const prop of this.properties) {
  12385. if (prop instanceof AST_ClassStaticBlock) {
  12386. if (prop.aborts()) return prop;
  12387. }
  12388. }
  12389. return null;
  12390. });
  12391. def_aborts(AST_ClassStaticBlock, block_aborts);
  12392. def_aborts(AST_If, function() {
  12393. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  12394. });
  12395. })(function(node, func) {
  12396. node.DEFMETHOD("aborts", func);
  12397. });
  12398. function is_modified(compressor, tw, node, value, level, immutable) {
  12399. var parent = tw.parent(level);
  12400. var lhs = is_lhs(node, parent);
  12401. if (lhs) return lhs;
  12402. if (!immutable
  12403. && parent instanceof AST_Call
  12404. && parent.expression === node
  12405. && !(value instanceof AST_Arrow)
  12406. && !(value instanceof AST_Class)
  12407. && !parent.is_callee_pure(compressor)
  12408. && (!(value instanceof AST_Function)
  12409. || !(parent instanceof AST_New) && value.contains_this())) {
  12410. return true;
  12411. }
  12412. if (parent instanceof AST_Array) {
  12413. return is_modified(compressor, tw, parent, parent, level + 1);
  12414. }
  12415. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  12416. var obj = tw.parent(level + 1);
  12417. return is_modified(compressor, tw, obj, obj, level + 2);
  12418. }
  12419. if (parent instanceof AST_PropAccess && parent.expression === node) {
  12420. var prop = read_property(value, parent.property);
  12421. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  12422. }
  12423. }
  12424. /***********************************************************************
  12425. A JavaScript tokenizer / parser / beautifier / compressor.
  12426. https://github.com/mishoo/UglifyJS2
  12427. -------------------------------- (C) ---------------------------------
  12428. Author: Mihai Bazon
  12429. <mihai.bazon@gmail.com>
  12430. http://mihai.bazon.net/blog
  12431. Distributed under the BSD license:
  12432. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12433. Redistribution and use in source and binary forms, with or without
  12434. modification, are permitted provided that the following conditions
  12435. are met:
  12436. * Redistributions of source code must retain the above
  12437. copyright notice, this list of conditions and the following
  12438. disclaimer.
  12439. * Redistributions in binary form must reproduce the above
  12440. copyright notice, this list of conditions and the following
  12441. disclaimer in the documentation and/or other materials
  12442. provided with the distribution.
  12443. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12444. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12445. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12446. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12447. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12448. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12449. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12450. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12451. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12452. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12453. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12454. SUCH DAMAGE.
  12455. ***********************************************************************/
  12456. // methods to evaluate a constant expression
  12457. function def_eval(node, func) {
  12458. node.DEFMETHOD("_eval", func);
  12459. }
  12460. // Used to propagate a nullish short-circuit signal upwards through the chain.
  12461. const nullish = Symbol("This AST_Chain is nullish");
  12462. // If the node has been successfully reduced to a constant,
  12463. // then its value is returned; otherwise the element itself
  12464. // is returned.
  12465. // They can be distinguished as constant value is never a
  12466. // descendant of AST_Node.
  12467. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  12468. if (!compressor.option("evaluate"))
  12469. return this;
  12470. var val = this._eval(compressor, 1);
  12471. if (!val || val instanceof RegExp)
  12472. return val;
  12473. if (typeof val == "function" || typeof val == "object" || val == nullish)
  12474. return this;
  12475. return val;
  12476. });
  12477. var unaryPrefix = makePredicate("! ~ - + void");
  12478. AST_Node.DEFMETHOD("is_constant", function () {
  12479. // Accomodate when compress option evaluate=false
  12480. // as well as the common constant expressions !0 and -1
  12481. if (this instanceof AST_Constant) {
  12482. return !(this instanceof AST_RegExp);
  12483. } else {
  12484. return this instanceof AST_UnaryPrefix
  12485. && this.expression instanceof AST_Constant
  12486. && unaryPrefix.has(this.operator);
  12487. }
  12488. });
  12489. def_eval(AST_Statement, function () {
  12490. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  12491. });
  12492. def_eval(AST_Lambda, return_this);
  12493. def_eval(AST_Class, return_this);
  12494. def_eval(AST_Node, return_this);
  12495. def_eval(AST_Constant, function () {
  12496. return this.getValue();
  12497. });
  12498. def_eval(AST_BigInt, return_this);
  12499. def_eval(AST_RegExp, function (compressor) {
  12500. let evaluated = compressor.evaluated_regexps.get(this.value);
  12501. if (evaluated === undefined && regexp_is_safe(this.value.source)) {
  12502. try {
  12503. const { source, flags } = this.value;
  12504. evaluated = new RegExp(source, flags);
  12505. } catch (e) {
  12506. evaluated = null;
  12507. }
  12508. compressor.evaluated_regexps.set(this.value, evaluated);
  12509. }
  12510. return evaluated || this;
  12511. });
  12512. def_eval(AST_TemplateString, function () {
  12513. if (this.segments.length !== 1) return this;
  12514. return this.segments[0].value;
  12515. });
  12516. def_eval(AST_Function, function (compressor) {
  12517. if (compressor.option("unsafe")) {
  12518. var fn = function () { };
  12519. fn.node = this;
  12520. fn.toString = () => this.print_to_string();
  12521. return fn;
  12522. }
  12523. return this;
  12524. });
  12525. def_eval(AST_Array, function (compressor, depth) {
  12526. if (compressor.option("unsafe")) {
  12527. var elements = [];
  12528. for (var i = 0, len = this.elements.length; i < len; i++) {
  12529. var element = this.elements[i];
  12530. var value = element._eval(compressor, depth);
  12531. if (element === value)
  12532. return this;
  12533. elements.push(value);
  12534. }
  12535. return elements;
  12536. }
  12537. return this;
  12538. });
  12539. def_eval(AST_Object, function (compressor, depth) {
  12540. if (compressor.option("unsafe")) {
  12541. var val = {};
  12542. for (var i = 0, len = this.properties.length; i < len; i++) {
  12543. var prop = this.properties[i];
  12544. if (prop instanceof AST_Expansion)
  12545. return this;
  12546. var key = prop.key;
  12547. if (key instanceof AST_Symbol) {
  12548. key = key.name;
  12549. } else if (key instanceof AST_Node) {
  12550. key = key._eval(compressor, depth);
  12551. if (key === prop.key)
  12552. return this;
  12553. }
  12554. if (typeof Object.prototype[key] === "function") {
  12555. return this;
  12556. }
  12557. if (prop.value instanceof AST_Function)
  12558. continue;
  12559. val[key] = prop.value._eval(compressor, depth);
  12560. if (val[key] === prop.value)
  12561. return this;
  12562. }
  12563. return val;
  12564. }
  12565. return this;
  12566. });
  12567. var non_converting_unary = makePredicate("! typeof void");
  12568. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  12569. var e = this.expression;
  12570. // Function would be evaluated to an array and so typeof would
  12571. // incorrectly return 'object'. Hence making is a special case.
  12572. if (compressor.option("typeofs")
  12573. && this.operator == "typeof"
  12574. && (e instanceof AST_Lambda
  12575. || e instanceof AST_SymbolRef
  12576. && e.fixed_value() instanceof AST_Lambda)) {
  12577. return typeof function () { };
  12578. }
  12579. if (!non_converting_unary.has(this.operator))
  12580. depth++;
  12581. e = e._eval(compressor, depth);
  12582. if (e === this.expression)
  12583. return this;
  12584. switch (this.operator) {
  12585. case "!": return !e;
  12586. case "typeof":
  12587. // typeof <RegExp> returns "object" or "function" on different platforms
  12588. // so cannot evaluate reliably
  12589. if (e instanceof RegExp)
  12590. return this;
  12591. return typeof e;
  12592. case "void": return void e;
  12593. case "~": return ~e;
  12594. case "-": return -e;
  12595. case "+": return +e;
  12596. }
  12597. return this;
  12598. });
  12599. var non_converting_binary = makePredicate("&& || ?? === !==");
  12600. const identity_comparison = makePredicate("== != === !==");
  12601. const has_identity = value => typeof value === "object"
  12602. || typeof value === "function"
  12603. || typeof value === "symbol";
  12604. def_eval(AST_Binary, function (compressor, depth) {
  12605. if (!non_converting_binary.has(this.operator))
  12606. depth++;
  12607. var left = this.left._eval(compressor, depth);
  12608. if (left === this.left)
  12609. return this;
  12610. var right = this.right._eval(compressor, depth);
  12611. if (right === this.right)
  12612. return this;
  12613. var result;
  12614. if (left != null
  12615. && right != null
  12616. && identity_comparison.has(this.operator)
  12617. && has_identity(left)
  12618. && has_identity(right)
  12619. && typeof left === typeof right) {
  12620. // Do not compare by reference
  12621. return this;
  12622. }
  12623. switch (this.operator) {
  12624. case "&&": result = left && right; break;
  12625. case "||": result = left || right; break;
  12626. case "??": result = left != null ? left : right; break;
  12627. case "|": result = left | right; break;
  12628. case "&": result = left & right; break;
  12629. case "^": result = left ^ right; break;
  12630. case "+": result = left + right; break;
  12631. case "*": result = left * right; break;
  12632. case "**": result = Math.pow(left, right); break;
  12633. case "/": result = left / right; break;
  12634. case "%": result = left % right; break;
  12635. case "-": result = left - right; break;
  12636. case "<<": result = left << right; break;
  12637. case ">>": result = left >> right; break;
  12638. case ">>>": result = left >>> right; break;
  12639. case "==": result = left == right; break;
  12640. case "===": result = left === right; break;
  12641. case "!=": result = left != right; break;
  12642. case "!==": result = left !== right; break;
  12643. case "<": result = left < right; break;
  12644. case "<=": result = left <= right; break;
  12645. case ">": result = left > right; break;
  12646. case ">=": result = left >= right; break;
  12647. default:
  12648. return this;
  12649. }
  12650. if (isNaN(result) && compressor.find_parent(AST_With)) {
  12651. // leave original expression as is
  12652. return this;
  12653. }
  12654. return result;
  12655. });
  12656. def_eval(AST_Conditional, function (compressor, depth) {
  12657. var condition = this.condition._eval(compressor, depth);
  12658. if (condition === this.condition)
  12659. return this;
  12660. var node = condition ? this.consequent : this.alternative;
  12661. var value = node._eval(compressor, depth);
  12662. return value === node ? this : value;
  12663. });
  12664. // Set of AST_SymbolRef which are currently being evaluated.
  12665. // Avoids infinite recursion of ._eval()
  12666. const reentrant_ref_eval = new Set();
  12667. def_eval(AST_SymbolRef, function (compressor, depth) {
  12668. if (reentrant_ref_eval.has(this))
  12669. return this;
  12670. var fixed = this.fixed_value();
  12671. if (!fixed)
  12672. return this;
  12673. reentrant_ref_eval.add(this);
  12674. const value = fixed._eval(compressor, depth);
  12675. reentrant_ref_eval.delete(this);
  12676. if (value === fixed)
  12677. return this;
  12678. if (value && typeof value == "object") {
  12679. var escaped = this.definition().escaped;
  12680. if (escaped && depth > escaped)
  12681. return this;
  12682. }
  12683. return value;
  12684. });
  12685. const global_objs = { Array, Math, Number, Object, String };
  12686. const regexp_flags = new Set([
  12687. "dotAll",
  12688. "global",
  12689. "ignoreCase",
  12690. "multiline",
  12691. "sticky",
  12692. "unicode",
  12693. ]);
  12694. def_eval(AST_PropAccess, function (compressor, depth) {
  12695. let obj = this.expression._eval(compressor, depth + 1);
  12696. if (obj === nullish || (this.optional && obj == null)) return nullish;
  12697. if (compressor.option("unsafe")) {
  12698. var key = this.property;
  12699. if (key instanceof AST_Node) {
  12700. key = key._eval(compressor, depth);
  12701. if (key === this.property)
  12702. return this;
  12703. }
  12704. var exp = this.expression;
  12705. if (is_undeclared_ref(exp)) {
  12706. var aa;
  12707. var first_arg = exp.name === "hasOwnProperty"
  12708. && key === "call"
  12709. && (aa = compressor.parent() && compressor.parent().args)
  12710. && (aa && aa[0]
  12711. && aa[0].evaluate(compressor));
  12712. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  12713. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  12714. return this.clone();
  12715. }
  12716. if (!is_pure_native_value(exp.name, key))
  12717. return this;
  12718. obj = global_objs[exp.name];
  12719. } else {
  12720. if (obj instanceof RegExp) {
  12721. if (key == "source") {
  12722. return regexp_source_fix(obj.source);
  12723. } else if (key == "flags" || regexp_flags.has(key)) {
  12724. return obj[key];
  12725. }
  12726. }
  12727. if (!obj || obj === exp || !HOP(obj, key))
  12728. return this;
  12729. if (typeof obj == "function")
  12730. switch (key) {
  12731. case "name":
  12732. return obj.node.name ? obj.node.name.name : "";
  12733. case "length":
  12734. return obj.node.length_property();
  12735. default:
  12736. return this;
  12737. }
  12738. }
  12739. return obj[key];
  12740. }
  12741. return this;
  12742. });
  12743. def_eval(AST_Chain, function (compressor, depth) {
  12744. const evaluated = this.expression._eval(compressor, depth);
  12745. return evaluated === nullish
  12746. ? undefined
  12747. : evaluated === this.expression
  12748. ? this
  12749. : evaluated;
  12750. });
  12751. def_eval(AST_Call, function (compressor, depth) {
  12752. var exp = this.expression;
  12753. const callee = exp._eval(compressor, depth);
  12754. if (callee === nullish || (this.optional && callee == null)) return nullish;
  12755. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  12756. var key = exp.property;
  12757. if (key instanceof AST_Node) {
  12758. key = key._eval(compressor, depth);
  12759. if (key === exp.property)
  12760. return this;
  12761. }
  12762. var val;
  12763. var e = exp.expression;
  12764. if (is_undeclared_ref(e)) {
  12765. var first_arg = e.name === "hasOwnProperty" &&
  12766. key === "call" &&
  12767. (this.args[0] && this.args[0].evaluate(compressor));
  12768. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  12769. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  12770. return this.clone();
  12771. }
  12772. if (!is_pure_native_fn(e.name, key)) return this;
  12773. val = global_objs[e.name];
  12774. } else {
  12775. val = e._eval(compressor, depth + 1);
  12776. if (val === e || !val)
  12777. return this;
  12778. if (!is_pure_native_method(val.constructor.name, key))
  12779. return this;
  12780. }
  12781. var args = [];
  12782. for (var i = 0, len = this.args.length; i < len; i++) {
  12783. var arg = this.args[i];
  12784. var value = arg._eval(compressor, depth);
  12785. if (arg === value)
  12786. return this;
  12787. if (arg instanceof AST_Lambda)
  12788. return this;
  12789. args.push(value);
  12790. }
  12791. try {
  12792. return val[key].apply(val, args);
  12793. } catch (ex) {
  12794. // We don't really care
  12795. }
  12796. }
  12797. return this;
  12798. });
  12799. // Also a subclass of AST_Call
  12800. def_eval(AST_New, return_this);
  12801. /***********************************************************************
  12802. A JavaScript tokenizer / parser / beautifier / compressor.
  12803. https://github.com/mishoo/UglifyJS2
  12804. -------------------------------- (C) ---------------------------------
  12805. Author: Mihai Bazon
  12806. <mihai.bazon@gmail.com>
  12807. http://mihai.bazon.net/blog
  12808. Distributed under the BSD license:
  12809. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12810. Redistribution and use in source and binary forms, with or without
  12811. modification, are permitted provided that the following conditions
  12812. are met:
  12813. * Redistributions of source code must retain the above
  12814. copyright notice, this list of conditions and the following
  12815. disclaimer.
  12816. * Redistributions in binary form must reproduce the above
  12817. copyright notice, this list of conditions and the following
  12818. disclaimer in the documentation and/or other materials
  12819. provided with the distribution.
  12820. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12821. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12822. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12823. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12824. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12825. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12826. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12827. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12828. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12829. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12830. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12831. SUCH DAMAGE.
  12832. ***********************************************************************/
  12833. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  12834. // only about side effects. We'll be defining this method for each node type in this module
  12835. //
  12836. // Examples:
  12837. // foo++ -> foo++
  12838. // 1 + func() -> func()
  12839. // 10 -> (nothing)
  12840. // knownPureFunc(foo++) -> foo++
  12841. function def_drop_side_effect_free(node, func) {
  12842. node.DEFMETHOD("drop_side_effect_free", func);
  12843. }
  12844. // Drop side-effect-free elements from an array of expressions.
  12845. // Returns an array of expressions with side-effects or null
  12846. // if all elements were dropped. Note: original array may be
  12847. // returned if nothing changed.
  12848. function trim(nodes, compressor, first_in_statement) {
  12849. var len = nodes.length;
  12850. if (!len) return null;
  12851. var ret = [], changed = false;
  12852. for (var i = 0; i < len; i++) {
  12853. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  12854. changed |= node !== nodes[i];
  12855. if (node) {
  12856. ret.push(node);
  12857. first_in_statement = false;
  12858. }
  12859. }
  12860. return changed ? ret.length ? ret : null : nodes;
  12861. }
  12862. def_drop_side_effect_free(AST_Node, return_this);
  12863. def_drop_side_effect_free(AST_Constant, return_null);
  12864. def_drop_side_effect_free(AST_This, return_null);
  12865. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  12866. if (is_nullish_shortcircuited(this, compressor)) {
  12867. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  12868. }
  12869. if (!this.is_callee_pure(compressor)) {
  12870. if (this.expression.is_call_pure(compressor)) {
  12871. var exprs = this.args.slice();
  12872. exprs.unshift(this.expression.expression);
  12873. exprs = trim(exprs, compressor, first_in_statement);
  12874. return exprs && make_sequence(this, exprs);
  12875. }
  12876. if (is_func_expr(this.expression)
  12877. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  12878. var node = this.clone();
  12879. node.expression.process_expression(false, compressor);
  12880. return node;
  12881. }
  12882. return this;
  12883. }
  12884. var args = trim(this.args, compressor, first_in_statement);
  12885. return args && make_sequence(this, args);
  12886. });
  12887. def_drop_side_effect_free(AST_Accessor, return_null);
  12888. def_drop_side_effect_free(AST_Function, return_null);
  12889. def_drop_side_effect_free(AST_Arrow, return_null);
  12890. def_drop_side_effect_free(AST_Class, function (compressor) {
  12891. const with_effects = [];
  12892. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  12893. if (trimmed_extends)
  12894. with_effects.push(trimmed_extends);
  12895. for (const prop of this.properties) {
  12896. if (prop instanceof AST_ClassStaticBlock) {
  12897. if (prop.body.some(stat => stat.has_side_effects(compressor))) {
  12898. return this;
  12899. } else {
  12900. continue;
  12901. }
  12902. }
  12903. const trimmed_prop = prop.drop_side_effect_free(compressor);
  12904. if (trimmed_prop)
  12905. with_effects.push(trimmed_prop);
  12906. }
  12907. if (!with_effects.length)
  12908. return null;
  12909. return make_sequence(this, with_effects);
  12910. });
  12911. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  12912. var right = this.right.drop_side_effect_free(compressor);
  12913. if (!right)
  12914. return this.left.drop_side_effect_free(compressor, first_in_statement);
  12915. if (lazy_op.has(this.operator)) {
  12916. if (right === this.right)
  12917. return this;
  12918. var node = this.clone();
  12919. node.right = right;
  12920. return node;
  12921. } else {
  12922. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  12923. if (!left)
  12924. return this.right.drop_side_effect_free(compressor, first_in_statement);
  12925. return make_sequence(this, [left, right]);
  12926. }
  12927. });
  12928. def_drop_side_effect_free(AST_Assign, function (compressor) {
  12929. if (this.logical)
  12930. return this;
  12931. var left = this.left;
  12932. if (left.has_side_effects(compressor)
  12933. || compressor.has_directive("use strict")
  12934. && left instanceof AST_PropAccess
  12935. && left.expression.is_constant()) {
  12936. return this;
  12937. }
  12938. set_flag(this, WRITE_ONLY);
  12939. while (left instanceof AST_PropAccess) {
  12940. left = left.expression;
  12941. }
  12942. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  12943. return this.right.drop_side_effect_free(compressor);
  12944. }
  12945. return this;
  12946. });
  12947. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  12948. var consequent = this.consequent.drop_side_effect_free(compressor);
  12949. var alternative = this.alternative.drop_side_effect_free(compressor);
  12950. if (consequent === this.consequent && alternative === this.alternative)
  12951. return this;
  12952. if (!consequent)
  12953. return alternative ? make_node(AST_Binary, this, {
  12954. operator: "||",
  12955. left: this.condition,
  12956. right: alternative
  12957. }) : this.condition.drop_side_effect_free(compressor);
  12958. if (!alternative)
  12959. return make_node(AST_Binary, this, {
  12960. operator: "&&",
  12961. left: this.condition,
  12962. right: consequent
  12963. });
  12964. var node = this.clone();
  12965. node.consequent = consequent;
  12966. node.alternative = alternative;
  12967. return node;
  12968. });
  12969. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  12970. if (unary_side_effects.has(this.operator)) {
  12971. if (!this.expression.has_side_effects(compressor)) {
  12972. set_flag(this, WRITE_ONLY);
  12973. } else {
  12974. clear_flag(this, WRITE_ONLY);
  12975. }
  12976. return this;
  12977. }
  12978. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12979. return null;
  12980. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  12981. if (first_in_statement && expression && is_iife_call(expression)) {
  12982. if (expression === this.expression && this.operator == "!")
  12983. return this;
  12984. return expression.negate(compressor, first_in_statement);
  12985. }
  12986. return expression;
  12987. });
  12988. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  12989. const safe_access = this.is_declared(compressor)
  12990. || pure_prop_access_globals.has(this.name);
  12991. return safe_access ? null : this;
  12992. });
  12993. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  12994. var values = trim(this.properties, compressor, first_in_statement);
  12995. return values && make_sequence(this, values);
  12996. });
  12997. def_drop_side_effect_free(AST_ObjectProperty, function (compressor, first_in_statement) {
  12998. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  12999. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  13000. const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
  13001. if (key && value) {
  13002. return make_sequence(this, [key, value]);
  13003. }
  13004. return key || value;
  13005. });
  13006. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  13007. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  13008. const value = this.static && this.value
  13009. && this.value.drop_side_effect_free(compressor);
  13010. if (key && value)
  13011. return make_sequence(this, [key, value]);
  13012. return key || value || null;
  13013. });
  13014. def_drop_side_effect_free(AST_ConciseMethod, function () {
  13015. return this.computed_key() ? this.key : null;
  13016. });
  13017. def_drop_side_effect_free(AST_ObjectGetter, function () {
  13018. return this.computed_key() ? this.key : null;
  13019. });
  13020. def_drop_side_effect_free(AST_ObjectSetter, function () {
  13021. return this.computed_key() ? this.key : null;
  13022. });
  13023. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  13024. var values = trim(this.elements, compressor, first_in_statement);
  13025. return values && make_sequence(this, values);
  13026. });
  13027. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  13028. if (is_nullish_shortcircuited(this, compressor)) {
  13029. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13030. }
  13031. if (this.expression.may_throw_on_access(compressor)) return this;
  13032. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13033. });
  13034. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  13035. if (is_nullish_shortcircuited(this, compressor)) {
  13036. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13037. }
  13038. if (this.expression.may_throw_on_access(compressor)) return this;
  13039. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13040. if (!expression)
  13041. return this.property.drop_side_effect_free(compressor, first_in_statement);
  13042. var property = this.property.drop_side_effect_free(compressor);
  13043. if (!property)
  13044. return expression;
  13045. return make_sequence(this, [expression, property]);
  13046. });
  13047. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  13048. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13049. });
  13050. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  13051. var last = this.tail_node();
  13052. var expr = last.drop_side_effect_free(compressor);
  13053. if (expr === last)
  13054. return this;
  13055. var expressions = this.expressions.slice(0, -1);
  13056. if (expr)
  13057. expressions.push(expr);
  13058. if (!expressions.length) {
  13059. return make_node(AST_Number, this, { value: 0 });
  13060. }
  13061. return make_sequence(this, expressions);
  13062. });
  13063. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  13064. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13065. });
  13066. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  13067. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  13068. var values = trim(this.segments, compressor, first_in_statement);
  13069. return values && make_sequence(this, values);
  13070. });
  13071. /***********************************************************************
  13072. A JavaScript tokenizer / parser / beautifier / compressor.
  13073. https://github.com/mishoo/UglifyJS2
  13074. -------------------------------- (C) ---------------------------------
  13075. Author: Mihai Bazon
  13076. <mihai.bazon@gmail.com>
  13077. http://mihai.bazon.net/blog
  13078. Distributed under the BSD license:
  13079. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13080. Redistribution and use in source and binary forms, with or without
  13081. modification, are permitted provided that the following conditions
  13082. are met:
  13083. * Redistributions of source code must retain the above
  13084. copyright notice, this list of conditions and the following
  13085. disclaimer.
  13086. * Redistributions in binary form must reproduce the above
  13087. copyright notice, this list of conditions and the following
  13088. disclaimer in the documentation and/or other materials
  13089. provided with the distribution.
  13090. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13091. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13092. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13093. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13094. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13095. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13096. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13097. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13098. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13099. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13100. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13101. SUCH DAMAGE.
  13102. ***********************************************************************/
  13103. // Define the method AST_Node#reduce_vars, which goes through the AST in
  13104. // execution order to perform basic flow analysis
  13105. function def_reduce_vars(node, func) {
  13106. node.DEFMETHOD("reduce_vars", func);
  13107. }
  13108. def_reduce_vars(AST_Node, noop);
  13109. function reset_def(compressor, def) {
  13110. def.assignments = 0;
  13111. def.chained = false;
  13112. def.direct_access = false;
  13113. def.escaped = 0;
  13114. def.recursive_refs = 0;
  13115. def.references = [];
  13116. def.single_use = undefined;
  13117. if (def.scope.pinned()) {
  13118. def.fixed = false;
  13119. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  13120. def.fixed = def.init;
  13121. } else {
  13122. def.fixed = false;
  13123. }
  13124. }
  13125. function reset_variables(tw, compressor, node) {
  13126. node.variables.forEach(function(def) {
  13127. reset_def(compressor, def);
  13128. if (def.fixed === null) {
  13129. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  13130. mark(tw, def, true);
  13131. } else if (def.fixed) {
  13132. tw.loop_ids.set(def.id, tw.in_loop);
  13133. mark(tw, def, true);
  13134. }
  13135. });
  13136. }
  13137. function reset_block_variables(compressor, node) {
  13138. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  13139. reset_def(compressor, def);
  13140. });
  13141. }
  13142. function push(tw) {
  13143. tw.safe_ids = Object.create(tw.safe_ids);
  13144. }
  13145. function pop(tw) {
  13146. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  13147. }
  13148. function mark(tw, def, safe) {
  13149. tw.safe_ids[def.id] = safe;
  13150. }
  13151. function safe_to_read(tw, def) {
  13152. if (def.single_use == "m") return false;
  13153. if (tw.safe_ids[def.id]) {
  13154. if (def.fixed == null) {
  13155. var orig = def.orig[0];
  13156. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  13157. def.fixed = make_node(AST_Undefined, orig);
  13158. }
  13159. return true;
  13160. }
  13161. return def.fixed instanceof AST_Defun;
  13162. }
  13163. function safe_to_assign(tw, def, scope, value) {
  13164. if (def.fixed === undefined) return true;
  13165. let def_safe_ids;
  13166. if (def.fixed === null
  13167. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  13168. ) {
  13169. def_safe_ids[def.id] = false;
  13170. tw.defs_to_safe_ids.delete(def.id);
  13171. return true;
  13172. }
  13173. if (!HOP(tw.safe_ids, def.id)) return false;
  13174. if (!safe_to_read(tw, def)) return false;
  13175. if (def.fixed === false) return false;
  13176. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  13177. if (def.fixed instanceof AST_Defun) {
  13178. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  13179. }
  13180. return def.orig.every((sym) => {
  13181. return !(sym instanceof AST_SymbolConst
  13182. || sym instanceof AST_SymbolDefun
  13183. || sym instanceof AST_SymbolLambda);
  13184. });
  13185. }
  13186. function ref_once(tw, compressor, def) {
  13187. return compressor.option("unused")
  13188. && !def.scope.pinned()
  13189. && def.references.length - def.recursive_refs == 1
  13190. && tw.loop_ids.get(def.id) === tw.in_loop;
  13191. }
  13192. function is_immutable(value) {
  13193. if (!value) return false;
  13194. return value.is_constant()
  13195. || value instanceof AST_Lambda
  13196. || value instanceof AST_This;
  13197. }
  13198. // A definition "escapes" when its value can leave the point of use.
  13199. // Example: `a = b || c`
  13200. // In this example, "b" and "c" are escaping, because they're going into "a"
  13201. //
  13202. // def.escaped is != 0 when it escapes.
  13203. //
  13204. // When greater than 1, it means that N chained properties will be read off
  13205. // of that def before an escape occurs. This is useful for evaluating
  13206. // property accesses, where you need to know when to stop.
  13207. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  13208. var parent = tw.parent(level);
  13209. if (value) {
  13210. if (value.is_constant()) return;
  13211. if (value instanceof AST_ClassExpression) return;
  13212. }
  13213. if (
  13214. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  13215. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  13216. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  13217. || parent instanceof AST_VarDef && node === parent.value
  13218. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  13219. ) {
  13220. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  13221. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  13222. return;
  13223. } else if (
  13224. parent instanceof AST_Array
  13225. || parent instanceof AST_Await
  13226. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  13227. || parent instanceof AST_Conditional && node !== parent.condition
  13228. || parent instanceof AST_Expansion
  13229. || parent instanceof AST_Sequence && node === parent.tail_node()
  13230. ) {
  13231. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  13232. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  13233. var obj = tw.parent(level + 1);
  13234. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  13235. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  13236. value = read_property(value, parent.property);
  13237. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  13238. if (value) return;
  13239. }
  13240. if (level > 0) return;
  13241. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  13242. if (parent instanceof AST_SimpleStatement) return;
  13243. d.direct_access = true;
  13244. }
  13245. const suppress = node => walk(node, node => {
  13246. if (!(node instanceof AST_Symbol)) return;
  13247. var d = node.definition();
  13248. if (!d) return;
  13249. if (node instanceof AST_SymbolRef) d.references.push(node);
  13250. d.fixed = false;
  13251. });
  13252. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  13253. push(tw);
  13254. reset_variables(tw, compressor, this);
  13255. descend();
  13256. pop(tw);
  13257. return true;
  13258. });
  13259. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  13260. var node = this;
  13261. if (node.left instanceof AST_Destructuring) {
  13262. suppress(node.left);
  13263. return;
  13264. }
  13265. const finish_walk = () => {
  13266. if (node.logical) {
  13267. node.left.walk(tw);
  13268. push(tw);
  13269. node.right.walk(tw);
  13270. pop(tw);
  13271. return true;
  13272. }
  13273. };
  13274. var sym = node.left;
  13275. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  13276. var def = sym.definition();
  13277. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  13278. def.assignments++;
  13279. if (!safe) return finish_walk();
  13280. var fixed = def.fixed;
  13281. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  13282. var eq = node.operator == "=";
  13283. var value = eq ? node.right : node;
  13284. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  13285. def.references.push(sym);
  13286. if (!node.logical) {
  13287. if (!eq) def.chained = true;
  13288. def.fixed = eq ? function() {
  13289. return node.right;
  13290. } : function() {
  13291. return make_node(AST_Binary, node, {
  13292. operator: node.operator.slice(0, -1),
  13293. left: fixed instanceof AST_Node ? fixed : fixed(),
  13294. right: node.right
  13295. });
  13296. };
  13297. }
  13298. if (node.logical) {
  13299. mark(tw, def, false);
  13300. push(tw);
  13301. node.right.walk(tw);
  13302. pop(tw);
  13303. return true;
  13304. }
  13305. mark(tw, def, false);
  13306. node.right.walk(tw);
  13307. mark(tw, def, true);
  13308. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  13309. return true;
  13310. });
  13311. def_reduce_vars(AST_Binary, function(tw) {
  13312. if (!lazy_op.has(this.operator)) return;
  13313. this.left.walk(tw);
  13314. push(tw);
  13315. this.right.walk(tw);
  13316. pop(tw);
  13317. return true;
  13318. });
  13319. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  13320. reset_block_variables(compressor, this);
  13321. });
  13322. def_reduce_vars(AST_Case, function(tw) {
  13323. push(tw);
  13324. this.expression.walk(tw);
  13325. pop(tw);
  13326. push(tw);
  13327. walk_body(this, tw);
  13328. pop(tw);
  13329. return true;
  13330. });
  13331. def_reduce_vars(AST_Class, function(tw, descend) {
  13332. clear_flag(this, INLINED);
  13333. push(tw);
  13334. descend();
  13335. pop(tw);
  13336. return true;
  13337. });
  13338. def_reduce_vars(AST_ClassStaticBlock, function(tw, descend, compressor) {
  13339. reset_block_variables(compressor, this);
  13340. });
  13341. def_reduce_vars(AST_Conditional, function(tw) {
  13342. this.condition.walk(tw);
  13343. push(tw);
  13344. this.consequent.walk(tw);
  13345. pop(tw);
  13346. push(tw);
  13347. this.alternative.walk(tw);
  13348. pop(tw);
  13349. return true;
  13350. });
  13351. def_reduce_vars(AST_Chain, function(tw, descend) {
  13352. // Chains' conditions apply left-to-right, cumulatively.
  13353. // If we walk normally we don't go in that order because we would pop before pushing again
  13354. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  13355. // Then we pop everything when they are done being walked.
  13356. const safe_ids = tw.safe_ids;
  13357. descend();
  13358. // Unroll back to start
  13359. tw.safe_ids = safe_ids;
  13360. return true;
  13361. });
  13362. def_reduce_vars(AST_Call, function (tw) {
  13363. this.expression.walk(tw);
  13364. if (this.optional) {
  13365. // Never pop -- it's popped at AST_Chain above
  13366. push(tw);
  13367. }
  13368. for (const arg of this.args) arg.walk(tw);
  13369. return true;
  13370. });
  13371. def_reduce_vars(AST_PropAccess, function (tw) {
  13372. if (!this.optional) return;
  13373. this.expression.walk(tw);
  13374. // Never pop -- it's popped at AST_Chain above
  13375. push(tw);
  13376. if (this.property instanceof AST_Node) this.property.walk(tw);
  13377. return true;
  13378. });
  13379. def_reduce_vars(AST_Default, function(tw, descend) {
  13380. push(tw);
  13381. descend();
  13382. pop(tw);
  13383. return true;
  13384. });
  13385. function mark_lambda(tw, descend, compressor) {
  13386. clear_flag(this, INLINED);
  13387. push(tw);
  13388. reset_variables(tw, compressor, this);
  13389. if (this.uses_arguments) {
  13390. descend();
  13391. pop(tw);
  13392. return;
  13393. }
  13394. var iife;
  13395. if (!this.name
  13396. && (iife = tw.parent()) instanceof AST_Call
  13397. && iife.expression === this
  13398. && !iife.args.some(arg => arg instanceof AST_Expansion)
  13399. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  13400. ) {
  13401. // Virtually turn IIFE parameters into variable definitions:
  13402. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  13403. // So existing transformation rules can work on them.
  13404. this.argnames.forEach((arg, i) => {
  13405. if (!arg.definition) return;
  13406. var d = arg.definition();
  13407. // Avoid setting fixed when there's more than one origin for a variable value
  13408. if (d.orig.length > 1) return;
  13409. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  13410. d.fixed = function() {
  13411. return iife.args[i] || make_node(AST_Undefined, iife);
  13412. };
  13413. tw.loop_ids.set(d.id, tw.in_loop);
  13414. mark(tw, d, true);
  13415. } else {
  13416. d.fixed = false;
  13417. }
  13418. });
  13419. }
  13420. descend();
  13421. pop(tw);
  13422. return true;
  13423. }
  13424. def_reduce_vars(AST_Lambda, mark_lambda);
  13425. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  13426. reset_block_variables(compressor, this);
  13427. const saved_loop = tw.in_loop;
  13428. tw.in_loop = this;
  13429. push(tw);
  13430. this.body.walk(tw);
  13431. if (has_break_or_continue(this)) {
  13432. pop(tw);
  13433. push(tw);
  13434. }
  13435. this.condition.walk(tw);
  13436. pop(tw);
  13437. tw.in_loop = saved_loop;
  13438. return true;
  13439. });
  13440. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  13441. reset_block_variables(compressor, this);
  13442. if (this.init) this.init.walk(tw);
  13443. const saved_loop = tw.in_loop;
  13444. tw.in_loop = this;
  13445. push(tw);
  13446. if (this.condition) this.condition.walk(tw);
  13447. this.body.walk(tw);
  13448. if (this.step) {
  13449. if (has_break_or_continue(this)) {
  13450. pop(tw);
  13451. push(tw);
  13452. }
  13453. this.step.walk(tw);
  13454. }
  13455. pop(tw);
  13456. tw.in_loop = saved_loop;
  13457. return true;
  13458. });
  13459. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  13460. reset_block_variables(compressor, this);
  13461. suppress(this.init);
  13462. this.object.walk(tw);
  13463. const saved_loop = tw.in_loop;
  13464. tw.in_loop = this;
  13465. push(tw);
  13466. this.body.walk(tw);
  13467. pop(tw);
  13468. tw.in_loop = saved_loop;
  13469. return true;
  13470. });
  13471. def_reduce_vars(AST_If, function(tw) {
  13472. this.condition.walk(tw);
  13473. push(tw);
  13474. this.body.walk(tw);
  13475. pop(tw);
  13476. if (this.alternative) {
  13477. push(tw);
  13478. this.alternative.walk(tw);
  13479. pop(tw);
  13480. }
  13481. return true;
  13482. });
  13483. def_reduce_vars(AST_LabeledStatement, function(tw) {
  13484. push(tw);
  13485. this.body.walk(tw);
  13486. pop(tw);
  13487. return true;
  13488. });
  13489. def_reduce_vars(AST_SymbolCatch, function() {
  13490. this.definition().fixed = false;
  13491. });
  13492. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  13493. var d = this.definition();
  13494. d.references.push(this);
  13495. if (d.references.length == 1
  13496. && !d.fixed
  13497. && d.orig[0] instanceof AST_SymbolDefun) {
  13498. tw.loop_ids.set(d.id, tw.in_loop);
  13499. }
  13500. var fixed_value;
  13501. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  13502. d.fixed = false;
  13503. } else if (d.fixed) {
  13504. fixed_value = this.fixed_value();
  13505. if (
  13506. fixed_value instanceof AST_Lambda
  13507. && is_recursive_ref(tw, d)
  13508. ) {
  13509. d.recursive_refs++;
  13510. } else if (fixed_value
  13511. && !compressor.exposed(d)
  13512. && ref_once(tw, compressor, d)
  13513. ) {
  13514. d.single_use =
  13515. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  13516. || fixed_value instanceof AST_Class
  13517. || d.scope === this.scope && fixed_value.is_constant_expression();
  13518. } else {
  13519. d.single_use = false;
  13520. }
  13521. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  13522. if (d.single_use) {
  13523. d.single_use = "m";
  13524. } else {
  13525. d.fixed = false;
  13526. }
  13527. }
  13528. }
  13529. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  13530. });
  13531. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  13532. this.globals.forEach(function(def) {
  13533. reset_def(compressor, def);
  13534. });
  13535. reset_variables(tw, compressor, this);
  13536. });
  13537. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  13538. reset_block_variables(compressor, this);
  13539. push(tw);
  13540. walk_body(this, tw);
  13541. pop(tw);
  13542. if (this.bcatch) {
  13543. push(tw);
  13544. this.bcatch.walk(tw);
  13545. pop(tw);
  13546. }
  13547. if (this.bfinally) this.bfinally.walk(tw);
  13548. return true;
  13549. });
  13550. def_reduce_vars(AST_Unary, function(tw) {
  13551. var node = this;
  13552. if (node.operator !== "++" && node.operator !== "--") return;
  13553. var exp = node.expression;
  13554. if (!(exp instanceof AST_SymbolRef)) return;
  13555. var def = exp.definition();
  13556. var safe = safe_to_assign(tw, def, exp.scope, true);
  13557. def.assignments++;
  13558. if (!safe) return;
  13559. var fixed = def.fixed;
  13560. if (!fixed) return;
  13561. def.references.push(exp);
  13562. def.chained = true;
  13563. def.fixed = function() {
  13564. return make_node(AST_Binary, node, {
  13565. operator: node.operator.slice(0, -1),
  13566. left: make_node(AST_UnaryPrefix, node, {
  13567. operator: "+",
  13568. expression: fixed instanceof AST_Node ? fixed : fixed()
  13569. }),
  13570. right: make_node(AST_Number, node, {
  13571. value: 1
  13572. })
  13573. });
  13574. };
  13575. mark(tw, def, true);
  13576. return true;
  13577. });
  13578. def_reduce_vars(AST_VarDef, function(tw, descend) {
  13579. var node = this;
  13580. if (node.name instanceof AST_Destructuring) {
  13581. suppress(node.name);
  13582. return;
  13583. }
  13584. var d = node.name.definition();
  13585. if (node.value) {
  13586. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  13587. d.fixed = function() {
  13588. return node.value;
  13589. };
  13590. tw.loop_ids.set(d.id, tw.in_loop);
  13591. mark(tw, d, false);
  13592. descend();
  13593. mark(tw, d, true);
  13594. return true;
  13595. } else {
  13596. d.fixed = false;
  13597. }
  13598. }
  13599. });
  13600. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  13601. reset_block_variables(compressor, this);
  13602. const saved_loop = tw.in_loop;
  13603. tw.in_loop = this;
  13604. push(tw);
  13605. descend();
  13606. pop(tw);
  13607. tw.in_loop = saved_loop;
  13608. return true;
  13609. });
  13610. /***********************************************************************
  13611. A JavaScript tokenizer / parser / beautifier / compressor.
  13612. https://github.com/mishoo/UglifyJS2
  13613. -------------------------------- (C) ---------------------------------
  13614. Author: Mihai Bazon
  13615. <mihai.bazon@gmail.com>
  13616. http://mihai.bazon.net/blog
  13617. Distributed under the BSD license:
  13618. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13619. Redistribution and use in source and binary forms, with or without
  13620. modification, are permitted provided that the following conditions
  13621. are met:
  13622. * Redistributions of source code must retain the above
  13623. copyright notice, this list of conditions and the following
  13624. disclaimer.
  13625. * Redistributions in binary form must reproduce the above
  13626. copyright notice, this list of conditions and the following
  13627. disclaimer in the documentation and/or other materials
  13628. provided with the distribution.
  13629. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13630. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13631. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13632. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13633. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13634. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13635. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13636. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13637. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13638. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13639. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13640. SUCH DAMAGE.
  13641. ***********************************************************************/
  13642. function loop_body(x) {
  13643. if (x instanceof AST_IterationStatement) {
  13644. return x.body instanceof AST_BlockStatement ? x.body : x;
  13645. }
  13646. return x;
  13647. }
  13648. function is_lhs_read_only(lhs) {
  13649. if (lhs instanceof AST_This) return true;
  13650. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  13651. if (lhs instanceof AST_PropAccess) {
  13652. lhs = lhs.expression;
  13653. if (lhs instanceof AST_SymbolRef) {
  13654. if (lhs.is_immutable()) return false;
  13655. lhs = lhs.fixed_value();
  13656. }
  13657. if (!lhs) return true;
  13658. if (lhs instanceof AST_RegExp) return false;
  13659. if (lhs instanceof AST_Constant) return true;
  13660. return is_lhs_read_only(lhs);
  13661. }
  13662. return false;
  13663. }
  13664. // Remove code which we know is unreachable.
  13665. function trim_unreachable_code(compressor, stat, target) {
  13666. walk(stat, node => {
  13667. if (node instanceof AST_Var) {
  13668. node.remove_initializers();
  13669. target.push(node);
  13670. return true;
  13671. }
  13672. if (
  13673. node instanceof AST_Defun
  13674. && (node === stat || !compressor.has_directive("use strict"))
  13675. ) {
  13676. target.push(node === stat ? node : make_node(AST_Var, node, {
  13677. definitions: [
  13678. make_node(AST_VarDef, node, {
  13679. name: make_node(AST_SymbolVar, node.name, node.name),
  13680. value: null
  13681. })
  13682. ]
  13683. }));
  13684. return true;
  13685. }
  13686. if (node instanceof AST_Export || node instanceof AST_Import) {
  13687. target.push(node);
  13688. return true;
  13689. }
  13690. if (node instanceof AST_Scope) {
  13691. return true;
  13692. }
  13693. });
  13694. }
  13695. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  13696. function tighten_body(statements, compressor) {
  13697. var in_loop, in_try;
  13698. var scope = compressor.find_parent(AST_Scope).get_defun_scope();
  13699. find_loop_scope_try();
  13700. var CHANGED, max_iter = 10;
  13701. do {
  13702. CHANGED = false;
  13703. eliminate_spurious_blocks(statements);
  13704. if (compressor.option("dead_code")) {
  13705. eliminate_dead_code(statements, compressor);
  13706. }
  13707. if (compressor.option("if_return")) {
  13708. handle_if_return(statements, compressor);
  13709. }
  13710. if (compressor.sequences_limit > 0) {
  13711. sequencesize(statements, compressor);
  13712. sequencesize_2(statements, compressor);
  13713. }
  13714. if (compressor.option("join_vars")) {
  13715. join_consecutive_vars(statements);
  13716. }
  13717. if (compressor.option("collapse_vars")) {
  13718. collapse(statements, compressor);
  13719. }
  13720. } while (CHANGED && max_iter-- > 0);
  13721. function find_loop_scope_try() {
  13722. var node = compressor.self(), level = 0;
  13723. do {
  13724. if (node instanceof AST_Catch || node instanceof AST_Finally) {
  13725. level++;
  13726. } else if (node instanceof AST_IterationStatement) {
  13727. in_loop = true;
  13728. } else if (node instanceof AST_Scope) {
  13729. scope = node;
  13730. break;
  13731. } else if (node instanceof AST_Try) {
  13732. in_try = true;
  13733. }
  13734. } while (node = compressor.parent(level++));
  13735. }
  13736. // Search from right to left for assignment-like expressions:
  13737. // - `var a = x;`
  13738. // - `a = x;`
  13739. // - `++a`
  13740. // For each candidate, scan from left to right for first usage, then try
  13741. // to fold assignment into the site for compression.
  13742. // Will not attempt to collapse assignments into or past code blocks
  13743. // which are not sequentially executed, e.g. loops and conditionals.
  13744. function collapse(statements, compressor) {
  13745. if (scope.pinned())
  13746. return statements;
  13747. var args;
  13748. var candidates = [];
  13749. var stat_index = statements.length;
  13750. var scanner = new TreeTransformer(function (node) {
  13751. if (abort)
  13752. return node;
  13753. // Skip nodes before `candidate` as quickly as possible
  13754. if (!hit) {
  13755. if (node !== hit_stack[hit_index])
  13756. return node;
  13757. hit_index++;
  13758. if (hit_index < hit_stack.length)
  13759. return handle_custom_scan_order(node);
  13760. hit = true;
  13761. stop_after = find_stop(node, 0);
  13762. if (stop_after === node)
  13763. abort = true;
  13764. return node;
  13765. }
  13766. // Stop immediately if these node types are encountered
  13767. var parent = scanner.parent();
  13768. if (node instanceof AST_Assign
  13769. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  13770. || node instanceof AST_Await
  13771. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  13772. || node instanceof AST_Debugger
  13773. || node instanceof AST_Destructuring
  13774. || node instanceof AST_Expansion
  13775. && node.expression instanceof AST_Symbol
  13776. && (
  13777. node.expression instanceof AST_This
  13778. || node.expression.definition().references.length > 1
  13779. )
  13780. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  13781. || node instanceof AST_LoopControl
  13782. || node instanceof AST_Try
  13783. || node instanceof AST_With
  13784. || node instanceof AST_Yield
  13785. || node instanceof AST_Export
  13786. || node instanceof AST_Class
  13787. || parent instanceof AST_For && node !== parent.init
  13788. || !replace_all
  13789. && (
  13790. node instanceof AST_SymbolRef
  13791. && !node.is_declared(compressor)
  13792. && !pure_prop_access_globals.has(node)
  13793. )
  13794. || node instanceof AST_SymbolRef
  13795. && parent instanceof AST_Call
  13796. && has_annotation(parent, _NOINLINE)
  13797. ) {
  13798. abort = true;
  13799. return node;
  13800. }
  13801. // Stop only if candidate is found within conditional branches
  13802. if (!stop_if_hit && (!lhs_local || !replace_all)
  13803. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  13804. || parent instanceof AST_Conditional && parent.condition !== node
  13805. || parent instanceof AST_If && parent.condition !== node)) {
  13806. stop_if_hit = parent;
  13807. }
  13808. // Replace variable with assignment when found
  13809. if (can_replace
  13810. && !(node instanceof AST_SymbolDeclaration)
  13811. && lhs.equivalent_to(node)
  13812. && !shadows(node.scope, lvalues)
  13813. ) {
  13814. if (stop_if_hit) {
  13815. abort = true;
  13816. return node;
  13817. }
  13818. if (is_lhs(node, parent)) {
  13819. if (value_def)
  13820. replaced++;
  13821. return node;
  13822. } else {
  13823. replaced++;
  13824. if (value_def && candidate instanceof AST_VarDef)
  13825. return node;
  13826. }
  13827. CHANGED = abort = true;
  13828. if (candidate instanceof AST_UnaryPostfix) {
  13829. return make_node(AST_UnaryPrefix, candidate, candidate);
  13830. }
  13831. if (candidate instanceof AST_VarDef) {
  13832. var def = candidate.name.definition();
  13833. var value = candidate.value;
  13834. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  13835. def.replaced++;
  13836. if (funarg && is_identifier_atom(value)) {
  13837. return value.transform(compressor);
  13838. } else {
  13839. return maintain_this_binding(parent, node, value);
  13840. }
  13841. }
  13842. return make_node(AST_Assign, candidate, {
  13843. operator: "=",
  13844. logical: false,
  13845. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  13846. right: value
  13847. });
  13848. }
  13849. clear_flag(candidate, WRITE_ONLY);
  13850. return candidate;
  13851. }
  13852. // These node types have child nodes that execute sequentially,
  13853. // but are otherwise not safe to scan into or beyond them.
  13854. var sym;
  13855. if (node instanceof AST_Call
  13856. || node instanceof AST_Exit
  13857. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  13858. || node instanceof AST_PropAccess
  13859. && (side_effects || node.expression.may_throw_on_access(compressor))
  13860. || node instanceof AST_SymbolRef
  13861. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  13862. || node instanceof AST_VarDef && node.value
  13863. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  13864. || (sym = is_lhs(node.left, node))
  13865. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  13866. || may_throw
  13867. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  13868. stop_after = node;
  13869. if (node instanceof AST_Scope)
  13870. abort = true;
  13871. }
  13872. return handle_custom_scan_order(node);
  13873. }, function (node) {
  13874. if (abort)
  13875. return;
  13876. if (stop_after === node)
  13877. abort = true;
  13878. if (stop_if_hit === node)
  13879. stop_if_hit = null;
  13880. });
  13881. var multi_replacer = new TreeTransformer(function (node) {
  13882. if (abort)
  13883. return node;
  13884. // Skip nodes before `candidate` as quickly as possible
  13885. if (!hit) {
  13886. if (node !== hit_stack[hit_index])
  13887. return node;
  13888. hit_index++;
  13889. if (hit_index < hit_stack.length)
  13890. return;
  13891. hit = true;
  13892. return node;
  13893. }
  13894. // Replace variable when found
  13895. if (node instanceof AST_SymbolRef
  13896. && node.name == def.name) {
  13897. if (!--replaced)
  13898. abort = true;
  13899. if (is_lhs(node, multi_replacer.parent()))
  13900. return node;
  13901. def.replaced++;
  13902. value_def.replaced--;
  13903. return candidate.value;
  13904. }
  13905. // Skip (non-executed) functions and (leading) default case in switch statements
  13906. if (node instanceof AST_Default || node instanceof AST_Scope)
  13907. return node;
  13908. });
  13909. while (--stat_index >= 0) {
  13910. // Treat parameters as collapsible in IIFE, i.e.
  13911. // function(a, b){ ... }(x());
  13912. // would be translated into equivalent assignments:
  13913. // var a = x(), b = undefined;
  13914. if (stat_index == 0 && compressor.option("unused"))
  13915. extract_args();
  13916. // Find collapsible assignments
  13917. var hit_stack = [];
  13918. extract_candidates(statements[stat_index]);
  13919. while (candidates.length > 0) {
  13920. hit_stack = candidates.pop();
  13921. var hit_index = 0;
  13922. var candidate = hit_stack[hit_stack.length - 1];
  13923. var value_def = null;
  13924. var stop_after = null;
  13925. var stop_if_hit = null;
  13926. var lhs = get_lhs(candidate);
  13927. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  13928. continue;
  13929. // Locate symbols which may execute code outside of scanning range
  13930. var lvalues = get_lvalues(candidate);
  13931. var lhs_local = is_lhs_local(lhs);
  13932. if (lhs instanceof AST_SymbolRef) {
  13933. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  13934. }
  13935. var side_effects = value_has_side_effects(candidate);
  13936. var replace_all = replace_all_symbols();
  13937. var may_throw = candidate.may_throw(compressor);
  13938. var funarg = candidate.name instanceof AST_SymbolFunarg;
  13939. var hit = funarg;
  13940. var abort = false, replaced = 0, can_replace = !args || !hit;
  13941. if (!can_replace) {
  13942. for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
  13943. args[j].transform(scanner);
  13944. }
  13945. can_replace = true;
  13946. }
  13947. for (var i = stat_index; !abort && i < statements.length; i++) {
  13948. statements[i].transform(scanner);
  13949. }
  13950. if (value_def) {
  13951. var def = candidate.name.definition();
  13952. if (abort && def.references.length - def.replaced > replaced)
  13953. replaced = false;
  13954. else {
  13955. abort = false;
  13956. hit_index = 0;
  13957. hit = funarg;
  13958. for (var i = stat_index; !abort && i < statements.length; i++) {
  13959. statements[i].transform(multi_replacer);
  13960. }
  13961. value_def.single_use = false;
  13962. }
  13963. }
  13964. if (replaced && !remove_candidate(candidate))
  13965. statements.splice(stat_index, 1);
  13966. }
  13967. }
  13968. function handle_custom_scan_order(node) {
  13969. // Skip (non-executed) functions
  13970. if (node instanceof AST_Scope)
  13971. return node;
  13972. // Scan case expressions first in a switch statement
  13973. if (node instanceof AST_Switch) {
  13974. node.expression = node.expression.transform(scanner);
  13975. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  13976. var branch = node.body[i];
  13977. if (branch instanceof AST_Case) {
  13978. if (!hit) {
  13979. if (branch !== hit_stack[hit_index])
  13980. continue;
  13981. hit_index++;
  13982. }
  13983. branch.expression = branch.expression.transform(scanner);
  13984. if (!replace_all)
  13985. break;
  13986. }
  13987. }
  13988. abort = true;
  13989. return node;
  13990. }
  13991. }
  13992. function redefined_within_scope(def, scope) {
  13993. if (def.global)
  13994. return false;
  13995. let cur_scope = def.scope;
  13996. while (cur_scope && cur_scope !== scope) {
  13997. if (cur_scope.variables.has(def.name)) {
  13998. return true;
  13999. }
  14000. cur_scope = cur_scope.parent_scope;
  14001. }
  14002. return false;
  14003. }
  14004. function has_overlapping_symbol(fn, arg, fn_strict) {
  14005. var found = false, scan_this = !(fn instanceof AST_Arrow);
  14006. arg.walk(new TreeWalker(function (node, descend) {
  14007. if (found)
  14008. return true;
  14009. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  14010. var s = node.definition().scope;
  14011. if (s !== scope)
  14012. while (s = s.parent_scope) {
  14013. if (s === scope)
  14014. return true;
  14015. }
  14016. return found = true;
  14017. }
  14018. if ((fn_strict || scan_this) && node instanceof AST_This) {
  14019. return found = true;
  14020. }
  14021. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  14022. var prev = scan_this;
  14023. scan_this = false;
  14024. descend();
  14025. scan_this = prev;
  14026. return true;
  14027. }
  14028. }));
  14029. return found;
  14030. }
  14031. function extract_args() {
  14032. var iife, fn = compressor.self();
  14033. if (is_func_expr(fn)
  14034. && !fn.name
  14035. && !fn.uses_arguments
  14036. && !fn.pinned()
  14037. && (iife = compressor.parent()) instanceof AST_Call
  14038. && iife.expression === fn
  14039. && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
  14040. var fn_strict = compressor.has_directive("use strict");
  14041. if (fn_strict && !member(fn_strict, fn.body))
  14042. fn_strict = false;
  14043. var len = fn.argnames.length;
  14044. args = iife.args.slice(len);
  14045. var names = new Set();
  14046. for (var i = len; --i >= 0;) {
  14047. var sym = fn.argnames[i];
  14048. var arg = iife.args[i];
  14049. // The following two line fix is a duplicate of the fix at
  14050. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  14051. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  14052. // Might be doing the exact same thing.
  14053. const def = sym.definition && sym.definition();
  14054. const is_reassigned = def && def.orig.length > 1;
  14055. if (is_reassigned)
  14056. continue;
  14057. args.unshift(make_node(AST_VarDef, sym, {
  14058. name: sym,
  14059. value: arg
  14060. }));
  14061. if (names.has(sym.name))
  14062. continue;
  14063. names.add(sym.name);
  14064. if (sym instanceof AST_Expansion) {
  14065. var elements = iife.args.slice(i);
  14066. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  14067. )) {
  14068. candidates.unshift([make_node(AST_VarDef, sym, {
  14069. name: sym.expression,
  14070. value: make_node(AST_Array, iife, {
  14071. elements: elements
  14072. })
  14073. })]);
  14074. }
  14075. } else {
  14076. if (!arg) {
  14077. arg = make_node(AST_Undefined, sym).transform(compressor);
  14078. } else if (arg instanceof AST_Lambda && arg.pinned()
  14079. || has_overlapping_symbol(fn, arg, fn_strict)) {
  14080. arg = null;
  14081. }
  14082. if (arg)
  14083. candidates.unshift([make_node(AST_VarDef, sym, {
  14084. name: sym,
  14085. value: arg
  14086. })]);
  14087. }
  14088. }
  14089. }
  14090. }
  14091. function extract_candidates(expr) {
  14092. hit_stack.push(expr);
  14093. if (expr instanceof AST_Assign) {
  14094. if (!expr.left.has_side_effects(compressor)
  14095. && !(expr.right instanceof AST_Chain)) {
  14096. candidates.push(hit_stack.slice());
  14097. }
  14098. extract_candidates(expr.right);
  14099. } else if (expr instanceof AST_Binary) {
  14100. extract_candidates(expr.left);
  14101. extract_candidates(expr.right);
  14102. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  14103. extract_candidates(expr.expression);
  14104. expr.args.forEach(extract_candidates);
  14105. } else if (expr instanceof AST_Case) {
  14106. extract_candidates(expr.expression);
  14107. } else if (expr instanceof AST_Conditional) {
  14108. extract_candidates(expr.condition);
  14109. extract_candidates(expr.consequent);
  14110. extract_candidates(expr.alternative);
  14111. } else if (expr instanceof AST_Definitions) {
  14112. var len = expr.definitions.length;
  14113. // limit number of trailing variable definitions for consideration
  14114. var i = len - 200;
  14115. if (i < 0)
  14116. i = 0;
  14117. for (; i < len; i++) {
  14118. extract_candidates(expr.definitions[i]);
  14119. }
  14120. } else if (expr instanceof AST_DWLoop) {
  14121. extract_candidates(expr.condition);
  14122. if (!(expr.body instanceof AST_Block)) {
  14123. extract_candidates(expr.body);
  14124. }
  14125. } else if (expr instanceof AST_Exit) {
  14126. if (expr.value)
  14127. extract_candidates(expr.value);
  14128. } else if (expr instanceof AST_For) {
  14129. if (expr.init)
  14130. extract_candidates(expr.init);
  14131. if (expr.condition)
  14132. extract_candidates(expr.condition);
  14133. if (expr.step)
  14134. extract_candidates(expr.step);
  14135. if (!(expr.body instanceof AST_Block)) {
  14136. extract_candidates(expr.body);
  14137. }
  14138. } else if (expr instanceof AST_ForIn) {
  14139. extract_candidates(expr.object);
  14140. if (!(expr.body instanceof AST_Block)) {
  14141. extract_candidates(expr.body);
  14142. }
  14143. } else if (expr instanceof AST_If) {
  14144. extract_candidates(expr.condition);
  14145. if (!(expr.body instanceof AST_Block)) {
  14146. extract_candidates(expr.body);
  14147. }
  14148. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  14149. extract_candidates(expr.alternative);
  14150. }
  14151. } else if (expr instanceof AST_Sequence) {
  14152. expr.expressions.forEach(extract_candidates);
  14153. } else if (expr instanceof AST_SimpleStatement) {
  14154. extract_candidates(expr.body);
  14155. } else if (expr instanceof AST_Switch) {
  14156. extract_candidates(expr.expression);
  14157. expr.body.forEach(extract_candidates);
  14158. } else if (expr instanceof AST_Unary) {
  14159. if (expr.operator == "++" || expr.operator == "--") {
  14160. candidates.push(hit_stack.slice());
  14161. }
  14162. } else if (expr instanceof AST_VarDef) {
  14163. if (expr.value && !(expr.value instanceof AST_Chain)) {
  14164. candidates.push(hit_stack.slice());
  14165. extract_candidates(expr.value);
  14166. }
  14167. }
  14168. hit_stack.pop();
  14169. }
  14170. function find_stop(node, level, write_only) {
  14171. var parent = scanner.parent(level);
  14172. if (parent instanceof AST_Assign) {
  14173. if (write_only
  14174. && !parent.logical
  14175. && !(parent.left instanceof AST_PropAccess
  14176. || lvalues.has(parent.left.name))) {
  14177. return find_stop(parent, level + 1, write_only);
  14178. }
  14179. return node;
  14180. }
  14181. if (parent instanceof AST_Binary) {
  14182. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  14183. return find_stop(parent, level + 1, write_only);
  14184. }
  14185. return node;
  14186. }
  14187. if (parent instanceof AST_Call)
  14188. return node;
  14189. if (parent instanceof AST_Case)
  14190. return node;
  14191. if (parent instanceof AST_Conditional) {
  14192. if (write_only && parent.condition === node) {
  14193. return find_stop(parent, level + 1, write_only);
  14194. }
  14195. return node;
  14196. }
  14197. if (parent instanceof AST_Definitions) {
  14198. return find_stop(parent, level + 1, true);
  14199. }
  14200. if (parent instanceof AST_Exit) {
  14201. return write_only ? find_stop(parent, level + 1, write_only) : node;
  14202. }
  14203. if (parent instanceof AST_If) {
  14204. if (write_only && parent.condition === node) {
  14205. return find_stop(parent, level + 1, write_only);
  14206. }
  14207. return node;
  14208. }
  14209. if (parent instanceof AST_IterationStatement)
  14210. return node;
  14211. if (parent instanceof AST_Sequence) {
  14212. return find_stop(parent, level + 1, parent.tail_node() !== node);
  14213. }
  14214. if (parent instanceof AST_SimpleStatement) {
  14215. return find_stop(parent, level + 1, true);
  14216. }
  14217. if (parent instanceof AST_Switch)
  14218. return node;
  14219. if (parent instanceof AST_VarDef)
  14220. return node;
  14221. return null;
  14222. }
  14223. function mangleable_var(var_def) {
  14224. var value = var_def.value;
  14225. if (!(value instanceof AST_SymbolRef))
  14226. return;
  14227. if (value.name == "arguments")
  14228. return;
  14229. var def = value.definition();
  14230. if (def.undeclared)
  14231. return;
  14232. return value_def = def;
  14233. }
  14234. function get_lhs(expr) {
  14235. if (expr instanceof AST_Assign && expr.logical) {
  14236. return false;
  14237. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  14238. var def = expr.name.definition();
  14239. if (!member(expr.name, def.orig))
  14240. return;
  14241. var referenced = def.references.length - def.replaced;
  14242. if (!referenced)
  14243. return;
  14244. var declared = def.orig.length - def.eliminated;
  14245. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  14246. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  14247. return make_node(AST_SymbolRef, expr.name, expr.name);
  14248. }
  14249. } else {
  14250. const lhs = expr instanceof AST_Assign
  14251. ? expr.left
  14252. : expr.expression;
  14253. return !is_ref_of(lhs, AST_SymbolConst)
  14254. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  14255. }
  14256. }
  14257. function get_rvalue(expr) {
  14258. if (expr instanceof AST_Assign) {
  14259. return expr.right;
  14260. } else {
  14261. return expr.value;
  14262. }
  14263. }
  14264. function get_lvalues(expr) {
  14265. var lvalues = new Map();
  14266. if (expr instanceof AST_Unary)
  14267. return lvalues;
  14268. var tw = new TreeWalker(function (node) {
  14269. var sym = node;
  14270. while (sym instanceof AST_PropAccess)
  14271. sym = sym.expression;
  14272. if (sym instanceof AST_SymbolRef) {
  14273. const prev = lvalues.get(sym.name);
  14274. if (!prev || !prev.modified) {
  14275. lvalues.set(sym.name, {
  14276. def: sym.definition(),
  14277. modified: is_modified(compressor, tw, node, node, 0)
  14278. });
  14279. }
  14280. }
  14281. });
  14282. get_rvalue(expr).walk(tw);
  14283. return lvalues;
  14284. }
  14285. function remove_candidate(expr) {
  14286. if (expr.name instanceof AST_SymbolFunarg) {
  14287. var iife = compressor.parent(), argnames = compressor.self().argnames;
  14288. var index = argnames.indexOf(expr.name);
  14289. if (index < 0) {
  14290. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  14291. } else {
  14292. var args = iife.args;
  14293. if (args[index])
  14294. args[index] = make_node(AST_Number, args[index], {
  14295. value: 0
  14296. });
  14297. }
  14298. return true;
  14299. }
  14300. var found = false;
  14301. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  14302. if (found)
  14303. return node;
  14304. if (node === expr || node.body === expr) {
  14305. found = true;
  14306. if (node instanceof AST_VarDef) {
  14307. node.value = node.name instanceof AST_SymbolConst
  14308. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  14309. : null;
  14310. return node;
  14311. }
  14312. return in_list ? MAP.skip : null;
  14313. }
  14314. }, function (node) {
  14315. if (node instanceof AST_Sequence)
  14316. switch (node.expressions.length) {
  14317. case 0: return null;
  14318. case 1: return node.expressions[0];
  14319. }
  14320. }));
  14321. }
  14322. function is_lhs_local(lhs) {
  14323. while (lhs instanceof AST_PropAccess)
  14324. lhs = lhs.expression;
  14325. return lhs instanceof AST_SymbolRef
  14326. && lhs.definition().scope === scope
  14327. && !(in_loop
  14328. && (lvalues.has(lhs.name)
  14329. || candidate instanceof AST_Unary
  14330. || (candidate instanceof AST_Assign
  14331. && !candidate.logical
  14332. && candidate.operator != "=")));
  14333. }
  14334. function value_has_side_effects(expr) {
  14335. if (expr instanceof AST_Unary)
  14336. return unary_side_effects.has(expr.operator);
  14337. return get_rvalue(expr).has_side_effects(compressor);
  14338. }
  14339. function replace_all_symbols() {
  14340. if (side_effects)
  14341. return false;
  14342. if (value_def)
  14343. return true;
  14344. if (lhs instanceof AST_SymbolRef) {
  14345. var def = lhs.definition();
  14346. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  14347. return true;
  14348. }
  14349. }
  14350. return false;
  14351. }
  14352. function may_modify(sym) {
  14353. if (!sym.definition)
  14354. return true; // AST_Destructuring
  14355. var def = sym.definition();
  14356. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  14357. return false;
  14358. if (def.scope.get_defun_scope() !== scope)
  14359. return true;
  14360. return !def.references.every((ref) => {
  14361. var s = ref.scope.get_defun_scope();
  14362. // "block" scope within AST_Catch
  14363. if (s.TYPE == "Scope")
  14364. s = s.parent_scope;
  14365. return s === scope;
  14366. });
  14367. }
  14368. function side_effects_external(node, lhs) {
  14369. if (node instanceof AST_Assign)
  14370. return side_effects_external(node.left, true);
  14371. if (node instanceof AST_Unary)
  14372. return side_effects_external(node.expression, true);
  14373. if (node instanceof AST_VarDef)
  14374. return node.value && side_effects_external(node.value);
  14375. if (lhs) {
  14376. if (node instanceof AST_Dot)
  14377. return side_effects_external(node.expression, true);
  14378. if (node instanceof AST_Sub)
  14379. return side_effects_external(node.expression, true);
  14380. if (node instanceof AST_SymbolRef)
  14381. return node.definition().scope !== scope;
  14382. }
  14383. return false;
  14384. }
  14385. function shadows(newScope, lvalues) {
  14386. for (const {def} of lvalues.values()) {
  14387. let current = newScope;
  14388. while (current && current !== def.scope) {
  14389. let nested_def = current.variables.get(def.name);
  14390. if (nested_def && nested_def !== def) return true;
  14391. current = current.parent_scope;
  14392. }
  14393. }
  14394. return false;
  14395. }
  14396. }
  14397. function eliminate_spurious_blocks(statements) {
  14398. var seen_dirs = [];
  14399. for (var i = 0; i < statements.length;) {
  14400. var stat = statements[i];
  14401. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  14402. CHANGED = true;
  14403. eliminate_spurious_blocks(stat.body);
  14404. statements.splice(i, 1, ...stat.body);
  14405. i += stat.body.length;
  14406. } else if (stat instanceof AST_EmptyStatement) {
  14407. CHANGED = true;
  14408. statements.splice(i, 1);
  14409. } else if (stat instanceof AST_Directive) {
  14410. if (seen_dirs.indexOf(stat.value) < 0) {
  14411. i++;
  14412. seen_dirs.push(stat.value);
  14413. } else {
  14414. CHANGED = true;
  14415. statements.splice(i, 1);
  14416. }
  14417. } else
  14418. i++;
  14419. }
  14420. }
  14421. function handle_if_return(statements, compressor) {
  14422. var self = compressor.self();
  14423. var multiple_if_returns = has_multiple_if_returns(statements);
  14424. var in_lambda = self instanceof AST_Lambda;
  14425. for (var i = statements.length; --i >= 0;) {
  14426. var stat = statements[i];
  14427. var j = next_index(i);
  14428. var next = statements[j];
  14429. if (in_lambda && !next && stat instanceof AST_Return) {
  14430. if (!stat.value) {
  14431. CHANGED = true;
  14432. statements.splice(i, 1);
  14433. continue;
  14434. }
  14435. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  14436. CHANGED = true;
  14437. statements[i] = make_node(AST_SimpleStatement, stat, {
  14438. body: stat.value.expression
  14439. });
  14440. continue;
  14441. }
  14442. }
  14443. if (stat instanceof AST_If) {
  14444. var ab = aborts(stat.body);
  14445. if (can_merge_flow(ab)) {
  14446. if (ab.label) {
  14447. remove(ab.label.thedef.references, ab);
  14448. }
  14449. CHANGED = true;
  14450. stat = stat.clone();
  14451. stat.condition = stat.condition.negate(compressor);
  14452. var body = as_statement_array_with_return(stat.body, ab);
  14453. stat.body = make_node(AST_BlockStatement, stat, {
  14454. body: as_statement_array(stat.alternative).concat(extract_functions())
  14455. });
  14456. stat.alternative = make_node(AST_BlockStatement, stat, {
  14457. body: body
  14458. });
  14459. statements[i] = stat.transform(compressor);
  14460. continue;
  14461. }
  14462. var ab = aborts(stat.alternative);
  14463. if (can_merge_flow(ab)) {
  14464. if (ab.label) {
  14465. remove(ab.label.thedef.references, ab);
  14466. }
  14467. CHANGED = true;
  14468. stat = stat.clone();
  14469. stat.body = make_node(AST_BlockStatement, stat.body, {
  14470. body: as_statement_array(stat.body).concat(extract_functions())
  14471. });
  14472. var body = as_statement_array_with_return(stat.alternative, ab);
  14473. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  14474. body: body
  14475. });
  14476. statements[i] = stat.transform(compressor);
  14477. continue;
  14478. }
  14479. }
  14480. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  14481. var value = stat.body.value;
  14482. //---
  14483. // pretty silly case, but:
  14484. // if (foo()) return; return; ==> foo(); return;
  14485. if (!value && !stat.alternative
  14486. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  14487. CHANGED = true;
  14488. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  14489. body: stat.condition
  14490. });
  14491. continue;
  14492. }
  14493. //---
  14494. // if (foo()) return x; return y; ==> return foo() ? x : y;
  14495. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  14496. CHANGED = true;
  14497. stat = stat.clone();
  14498. stat.alternative = next;
  14499. statements[i] = stat.transform(compressor);
  14500. statements.splice(j, 1);
  14501. continue;
  14502. }
  14503. //---
  14504. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  14505. if (value && !stat.alternative
  14506. && (!next && in_lambda && multiple_if_returns
  14507. || next instanceof AST_Return)) {
  14508. CHANGED = true;
  14509. stat = stat.clone();
  14510. stat.alternative = next || make_node(AST_Return, stat, {
  14511. value: null
  14512. });
  14513. statements[i] = stat.transform(compressor);
  14514. if (next)
  14515. statements.splice(j, 1);
  14516. continue;
  14517. }
  14518. //---
  14519. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  14520. //
  14521. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  14522. // however, with sequences on this helps producing slightly better output for
  14523. // the example code.
  14524. var prev = statements[prev_index(i)];
  14525. if (compressor.option("sequences") && in_lambda && !stat.alternative
  14526. && prev instanceof AST_If && prev.body instanceof AST_Return
  14527. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  14528. CHANGED = true;
  14529. stat = stat.clone();
  14530. stat.alternative = make_node(AST_BlockStatement, next, {
  14531. body: [
  14532. next,
  14533. make_node(AST_Return, next, {
  14534. value: null
  14535. })
  14536. ]
  14537. });
  14538. statements[i] = stat.transform(compressor);
  14539. statements.splice(j, 1);
  14540. continue;
  14541. }
  14542. }
  14543. }
  14544. function has_multiple_if_returns(statements) {
  14545. var n = 0;
  14546. for (var i = statements.length; --i >= 0;) {
  14547. var stat = statements[i];
  14548. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  14549. if (++n > 1)
  14550. return true;
  14551. }
  14552. }
  14553. return false;
  14554. }
  14555. function is_return_void(value) {
  14556. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  14557. }
  14558. function can_merge_flow(ab) {
  14559. if (!ab)
  14560. return false;
  14561. for (var j = i + 1, len = statements.length; j < len; j++) {
  14562. var stat = statements[j];
  14563. if (stat instanceof AST_Const || stat instanceof AST_Let)
  14564. return false;
  14565. }
  14566. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  14567. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  14568. || ab instanceof AST_Continue && self === loop_body(lct)
  14569. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  14570. }
  14571. function extract_functions() {
  14572. var tail = statements.slice(i + 1);
  14573. statements.length = i + 1;
  14574. return tail.filter(function (stat) {
  14575. if (stat instanceof AST_Defun) {
  14576. statements.push(stat);
  14577. return false;
  14578. }
  14579. return true;
  14580. });
  14581. }
  14582. function as_statement_array_with_return(node, ab) {
  14583. var body = as_statement_array(node).slice(0, -1);
  14584. if (ab.value) {
  14585. body.push(make_node(AST_SimpleStatement, ab.value, {
  14586. body: ab.value.expression
  14587. }));
  14588. }
  14589. return body;
  14590. }
  14591. function next_index(i) {
  14592. for (var j = i + 1, len = statements.length; j < len; j++) {
  14593. var stat = statements[j];
  14594. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  14595. break;
  14596. }
  14597. }
  14598. return j;
  14599. }
  14600. function prev_index(i) {
  14601. for (var j = i; --j >= 0;) {
  14602. var stat = statements[j];
  14603. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  14604. break;
  14605. }
  14606. }
  14607. return j;
  14608. }
  14609. }
  14610. function eliminate_dead_code(statements, compressor) {
  14611. var has_quit;
  14612. var self = compressor.self();
  14613. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  14614. var stat = statements[i];
  14615. if (stat instanceof AST_LoopControl) {
  14616. var lct = compressor.loopcontrol_target(stat);
  14617. if (stat instanceof AST_Break
  14618. && !(lct instanceof AST_IterationStatement)
  14619. && loop_body(lct) === self
  14620. || stat instanceof AST_Continue
  14621. && loop_body(lct) === self) {
  14622. if (stat.label) {
  14623. remove(stat.label.thedef.references, stat);
  14624. }
  14625. } else {
  14626. statements[n++] = stat;
  14627. }
  14628. } else {
  14629. statements[n++] = stat;
  14630. }
  14631. if (aborts(stat)) {
  14632. has_quit = statements.slice(i + 1);
  14633. break;
  14634. }
  14635. }
  14636. statements.length = n;
  14637. CHANGED = n != len;
  14638. if (has_quit)
  14639. has_quit.forEach(function (stat) {
  14640. trim_unreachable_code(compressor, stat, statements);
  14641. });
  14642. }
  14643. function declarations_only(node) {
  14644. return node.definitions.every((var_def) => !var_def.value
  14645. );
  14646. }
  14647. function sequencesize(statements, compressor) {
  14648. if (statements.length < 2)
  14649. return;
  14650. var seq = [], n = 0;
  14651. function push_seq() {
  14652. if (!seq.length)
  14653. return;
  14654. var body = make_sequence(seq[0], seq);
  14655. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  14656. seq = [];
  14657. }
  14658. for (var i = 0, len = statements.length; i < len; i++) {
  14659. var stat = statements[i];
  14660. if (stat instanceof AST_SimpleStatement) {
  14661. if (seq.length >= compressor.sequences_limit)
  14662. push_seq();
  14663. var body = stat.body;
  14664. if (seq.length > 0)
  14665. body = body.drop_side_effect_free(compressor);
  14666. if (body)
  14667. merge_sequence(seq, body);
  14668. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  14669. || stat instanceof AST_Defun) {
  14670. statements[n++] = stat;
  14671. } else {
  14672. push_seq();
  14673. statements[n++] = stat;
  14674. }
  14675. }
  14676. push_seq();
  14677. statements.length = n;
  14678. if (n != len)
  14679. CHANGED = true;
  14680. }
  14681. function to_simple_statement(block, decls) {
  14682. if (!(block instanceof AST_BlockStatement))
  14683. return block;
  14684. var stat = null;
  14685. for (var i = 0, len = block.body.length; i < len; i++) {
  14686. var line = block.body[i];
  14687. if (line instanceof AST_Var && declarations_only(line)) {
  14688. decls.push(line);
  14689. } else if (stat) {
  14690. return false;
  14691. } else {
  14692. stat = line;
  14693. }
  14694. }
  14695. return stat;
  14696. }
  14697. function sequencesize_2(statements, compressor) {
  14698. function cons_seq(right) {
  14699. n--;
  14700. CHANGED = true;
  14701. var left = prev.body;
  14702. return make_sequence(left, [left, right]).transform(compressor);
  14703. }
  14704. var n = 0, prev;
  14705. for (var i = 0; i < statements.length; i++) {
  14706. var stat = statements[i];
  14707. if (prev) {
  14708. if (stat instanceof AST_Exit) {
  14709. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  14710. } else if (stat instanceof AST_For) {
  14711. if (!(stat.init instanceof AST_Definitions)) {
  14712. const abort = walk(prev.body, node => {
  14713. if (node instanceof AST_Scope)
  14714. return true;
  14715. if (node instanceof AST_Binary
  14716. && node.operator === "in") {
  14717. return walk_abort;
  14718. }
  14719. });
  14720. if (!abort) {
  14721. if (stat.init)
  14722. stat.init = cons_seq(stat.init);
  14723. else {
  14724. stat.init = prev.body;
  14725. n--;
  14726. CHANGED = true;
  14727. }
  14728. }
  14729. }
  14730. } else if (stat instanceof AST_ForIn) {
  14731. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  14732. stat.object = cons_seq(stat.object);
  14733. }
  14734. } else if (stat instanceof AST_If) {
  14735. stat.condition = cons_seq(stat.condition);
  14736. } else if (stat instanceof AST_Switch) {
  14737. stat.expression = cons_seq(stat.expression);
  14738. } else if (stat instanceof AST_With) {
  14739. stat.expression = cons_seq(stat.expression);
  14740. }
  14741. }
  14742. if (compressor.option("conditionals") && stat instanceof AST_If) {
  14743. var decls = [];
  14744. var body = to_simple_statement(stat.body, decls);
  14745. var alt = to_simple_statement(stat.alternative, decls);
  14746. if (body !== false && alt !== false && decls.length > 0) {
  14747. var len = decls.length;
  14748. decls.push(make_node(AST_If, stat, {
  14749. condition: stat.condition,
  14750. body: body || make_node(AST_EmptyStatement, stat.body),
  14751. alternative: alt
  14752. }));
  14753. decls.unshift(n, 1);
  14754. [].splice.apply(statements, decls);
  14755. i += len;
  14756. n += len + 1;
  14757. prev = null;
  14758. CHANGED = true;
  14759. continue;
  14760. }
  14761. }
  14762. statements[n++] = stat;
  14763. prev = stat instanceof AST_SimpleStatement ? stat : null;
  14764. }
  14765. statements.length = n;
  14766. }
  14767. function join_object_assignments(defn, body) {
  14768. if (!(defn instanceof AST_Definitions))
  14769. return;
  14770. var def = defn.definitions[defn.definitions.length - 1];
  14771. if (!(def.value instanceof AST_Object))
  14772. return;
  14773. var exprs;
  14774. if (body instanceof AST_Assign && !body.logical) {
  14775. exprs = [body];
  14776. } else if (body instanceof AST_Sequence) {
  14777. exprs = body.expressions.slice();
  14778. }
  14779. if (!exprs)
  14780. return;
  14781. var trimmed = false;
  14782. do {
  14783. var node = exprs[0];
  14784. if (!(node instanceof AST_Assign))
  14785. break;
  14786. if (node.operator != "=")
  14787. break;
  14788. if (!(node.left instanceof AST_PropAccess))
  14789. break;
  14790. var sym = node.left.expression;
  14791. if (!(sym instanceof AST_SymbolRef))
  14792. break;
  14793. if (def.name.name != sym.name)
  14794. break;
  14795. if (!node.right.is_constant_expression(scope))
  14796. break;
  14797. var prop = node.left.property;
  14798. if (prop instanceof AST_Node) {
  14799. prop = prop.evaluate(compressor);
  14800. }
  14801. if (prop instanceof AST_Node)
  14802. break;
  14803. prop = "" + prop;
  14804. var diff = compressor.option("ecma") < 2015
  14805. && compressor.has_directive("use strict") ? function (node) {
  14806. return node.key != prop && (node.key && node.key.name != prop);
  14807. } : function (node) {
  14808. return node.key && node.key.name != prop;
  14809. };
  14810. if (!def.value.properties.every(diff))
  14811. break;
  14812. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  14813. if (!p) {
  14814. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  14815. key: prop,
  14816. value: node.right
  14817. }));
  14818. } else {
  14819. p.value = new AST_Sequence({
  14820. start: p.start,
  14821. expressions: [p.value.clone(), node.right.clone()],
  14822. end: p.end
  14823. });
  14824. }
  14825. exprs.shift();
  14826. trimmed = true;
  14827. } while (exprs.length);
  14828. return trimmed && exprs;
  14829. }
  14830. function join_consecutive_vars(statements) {
  14831. var defs;
  14832. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  14833. var stat = statements[i];
  14834. var prev = statements[j];
  14835. if (stat instanceof AST_Definitions) {
  14836. if (prev && prev.TYPE == stat.TYPE) {
  14837. prev.definitions = prev.definitions.concat(stat.definitions);
  14838. CHANGED = true;
  14839. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  14840. defs.definitions = defs.definitions.concat(stat.definitions);
  14841. CHANGED = true;
  14842. } else {
  14843. statements[++j] = stat;
  14844. defs = stat;
  14845. }
  14846. } else if (stat instanceof AST_Exit) {
  14847. stat.value = extract_object_assignments(stat.value);
  14848. } else if (stat instanceof AST_For) {
  14849. var exprs = join_object_assignments(prev, stat.init);
  14850. if (exprs) {
  14851. CHANGED = true;
  14852. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  14853. statements[++j] = stat;
  14854. } else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  14855. if (stat.init) {
  14856. prev.definitions = prev.definitions.concat(stat.init.definitions);
  14857. }
  14858. stat.init = prev;
  14859. statements[j] = stat;
  14860. CHANGED = true;
  14861. } else if (defs && stat.init && defs.TYPE == stat.init.TYPE && declarations_only(stat.init)) {
  14862. defs.definitions = defs.definitions.concat(stat.init.definitions);
  14863. stat.init = null;
  14864. statements[++j] = stat;
  14865. CHANGED = true;
  14866. } else {
  14867. statements[++j] = stat;
  14868. }
  14869. } else if (stat instanceof AST_ForIn) {
  14870. stat.object = extract_object_assignments(stat.object);
  14871. } else if (stat instanceof AST_If) {
  14872. stat.condition = extract_object_assignments(stat.condition);
  14873. } else if (stat instanceof AST_SimpleStatement) {
  14874. var exprs = join_object_assignments(prev, stat.body);
  14875. if (exprs) {
  14876. CHANGED = true;
  14877. if (!exprs.length)
  14878. continue;
  14879. stat.body = make_sequence(stat.body, exprs);
  14880. }
  14881. statements[++j] = stat;
  14882. } else if (stat instanceof AST_Switch) {
  14883. stat.expression = extract_object_assignments(stat.expression);
  14884. } else if (stat instanceof AST_With) {
  14885. stat.expression = extract_object_assignments(stat.expression);
  14886. } else {
  14887. statements[++j] = stat;
  14888. }
  14889. }
  14890. statements.length = j + 1;
  14891. function extract_object_assignments(value) {
  14892. statements[++j] = stat;
  14893. var exprs = join_object_assignments(prev, value);
  14894. if (exprs) {
  14895. CHANGED = true;
  14896. if (exprs.length) {
  14897. return make_sequence(value, exprs);
  14898. } else if (value instanceof AST_Sequence) {
  14899. return value.tail_node().left;
  14900. } else {
  14901. return value.left;
  14902. }
  14903. }
  14904. return value;
  14905. }
  14906. }
  14907. }
  14908. /***********************************************************************
  14909. A JavaScript tokenizer / parser / beautifier / compressor.
  14910. https://github.com/mishoo/UglifyJS2
  14911. -------------------------------- (C) ---------------------------------
  14912. Author: Mihai Bazon
  14913. <mihai.bazon@gmail.com>
  14914. http://mihai.bazon.net/blog
  14915. Distributed under the BSD license:
  14916. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14917. Redistribution and use in source and binary forms, with or without
  14918. modification, are permitted provided that the following conditions
  14919. are met:
  14920. * Redistributions of source code must retain the above
  14921. copyright notice, this list of conditions and the following
  14922. disclaimer.
  14923. * Redistributions in binary form must reproduce the above
  14924. copyright notice, this list of conditions and the following
  14925. disclaimer in the documentation and/or other materials
  14926. provided with the distribution.
  14927. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14928. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14929. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14930. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14931. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14932. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14933. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14934. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14935. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14936. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14937. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14938. SUCH DAMAGE.
  14939. ***********************************************************************/
  14940. function within_array_or_object_literal(compressor) {
  14941. var node, level = 0;
  14942. while (node = compressor.parent(level++)) {
  14943. if (node instanceof AST_Statement) return false;
  14944. if (node instanceof AST_Array
  14945. || node instanceof AST_ObjectKeyVal
  14946. || node instanceof AST_Object) {
  14947. return true;
  14948. }
  14949. }
  14950. return false;
  14951. }
  14952. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  14953. for (const enclosed of pulled_scope.enclosed) {
  14954. if (pulled_scope.variables.has(enclosed.name)) {
  14955. continue;
  14956. }
  14957. const looked_up = scope.find_variable(enclosed.name);
  14958. if (looked_up) {
  14959. if (looked_up === enclosed) continue;
  14960. return true;
  14961. }
  14962. }
  14963. return false;
  14964. }
  14965. function inline_into_symbolref(self, compressor) {
  14966. if (
  14967. !compressor.option("ie8")
  14968. && is_undeclared_ref(self)
  14969. && !compressor.find_parent(AST_With)
  14970. ) {
  14971. switch (self.name) {
  14972. case "undefined":
  14973. return make_node(AST_Undefined, self).optimize(compressor);
  14974. case "NaN":
  14975. return make_node(AST_NaN, self).optimize(compressor);
  14976. case "Infinity":
  14977. return make_node(AST_Infinity, self).optimize(compressor);
  14978. }
  14979. }
  14980. const parent = compressor.parent();
  14981. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  14982. const def = self.definition();
  14983. const nearest_scope = compressor.find_scope();
  14984. if (compressor.top_retain && def.global && compressor.top_retain(def)) {
  14985. def.fixed = false;
  14986. def.single_use = false;
  14987. return self;
  14988. }
  14989. let fixed = self.fixed_value();
  14990. let single_use = def.single_use
  14991. && !(parent instanceof AST_Call
  14992. && (parent.is_callee_pure(compressor))
  14993. || has_annotation(parent, _NOINLINE))
  14994. && !(parent instanceof AST_Export
  14995. && fixed instanceof AST_Lambda
  14996. && fixed.name);
  14997. if (single_use && fixed instanceof AST_Node) {
  14998. single_use =
  14999. !fixed.has_side_effects(compressor)
  15000. && !fixed.may_throw(compressor);
  15001. }
  15002. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  15003. if (retain_top_func(fixed, compressor)) {
  15004. single_use = false;
  15005. } else if (def.scope !== self.scope
  15006. && (def.escaped == 1
  15007. || has_flag(fixed, INLINED)
  15008. || within_array_or_object_literal(compressor)
  15009. || !compressor.option("reduce_funcs"))) {
  15010. single_use = false;
  15011. } else if (is_recursive_ref(compressor, def)) {
  15012. single_use = false;
  15013. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  15014. single_use = fixed.is_constant_expression(self.scope);
  15015. if (single_use == "f") {
  15016. var scope = self.scope;
  15017. do {
  15018. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  15019. set_flag(scope, INLINED);
  15020. }
  15021. } while (scope = scope.parent_scope);
  15022. }
  15023. }
  15024. }
  15025. if (single_use && fixed instanceof AST_Lambda) {
  15026. single_use =
  15027. def.scope === self.scope
  15028. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  15029. || parent instanceof AST_Call
  15030. && parent.expression === self
  15031. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  15032. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  15033. }
  15034. if (single_use && fixed) {
  15035. if (fixed instanceof AST_DefClass) {
  15036. set_flag(fixed, SQUEEZED);
  15037. fixed = make_node(AST_ClassExpression, fixed, fixed);
  15038. }
  15039. if (fixed instanceof AST_Defun) {
  15040. set_flag(fixed, SQUEEZED);
  15041. fixed = make_node(AST_Function, fixed, fixed);
  15042. }
  15043. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  15044. const defun_def = fixed.name.definition();
  15045. let lambda_def = fixed.variables.get(fixed.name.name);
  15046. let name = lambda_def && lambda_def.orig[0];
  15047. if (!(name instanceof AST_SymbolLambda)) {
  15048. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  15049. name.scope = fixed;
  15050. fixed.name = name;
  15051. lambda_def = fixed.def_function(name);
  15052. }
  15053. walk(fixed, node => {
  15054. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  15055. node.thedef = lambda_def;
  15056. lambda_def.references.push(node);
  15057. }
  15058. });
  15059. }
  15060. if (
  15061. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  15062. && fixed.parent_scope !== nearest_scope
  15063. ) {
  15064. fixed = fixed.clone(true, compressor.get_toplevel());
  15065. nearest_scope.add_child_scope(fixed);
  15066. }
  15067. return fixed.optimize(compressor);
  15068. }
  15069. // multiple uses
  15070. if (fixed) {
  15071. let replace;
  15072. if (fixed instanceof AST_This) {
  15073. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  15074. && def.references.every((ref) =>
  15075. def.scope === ref.scope
  15076. )) {
  15077. replace = fixed;
  15078. }
  15079. } else {
  15080. var ev = fixed.evaluate(compressor);
  15081. if (
  15082. ev !== fixed
  15083. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  15084. ) {
  15085. replace = make_node_from_constant(ev, fixed);
  15086. }
  15087. }
  15088. if (replace) {
  15089. const name_length = self.size(compressor);
  15090. const replace_size = replace.size(compressor);
  15091. let overhead = 0;
  15092. if (compressor.option("unused") && !compressor.exposed(def)) {
  15093. overhead =
  15094. (name_length + 2 + replace_size) /
  15095. (def.references.length - def.assignments);
  15096. }
  15097. if (replace_size <= name_length + overhead) {
  15098. return replace;
  15099. }
  15100. }
  15101. }
  15102. }
  15103. return self;
  15104. }
  15105. function inline_into_call(self, fn, compressor) {
  15106. var exp = self.expression;
  15107. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  15108. if (compressor.option("reduce_vars")
  15109. && fn instanceof AST_SymbolRef
  15110. && !has_annotation(self, _NOINLINE)
  15111. ) {
  15112. const fixed = fn.fixed_value();
  15113. if (!retain_top_func(fixed, compressor)) {
  15114. fn = fixed;
  15115. }
  15116. }
  15117. var is_func = fn instanceof AST_Lambda;
  15118. var stat = is_func && fn.body[0];
  15119. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  15120. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  15121. if (can_inline && stat instanceof AST_Return) {
  15122. let returned = stat.value;
  15123. if (!returned || returned.is_constant_expression()) {
  15124. if (returned) {
  15125. returned = returned.clone(true);
  15126. } else {
  15127. returned = make_node(AST_Undefined, self);
  15128. }
  15129. const args = self.args.concat(returned);
  15130. return make_sequence(self, args).optimize(compressor);
  15131. }
  15132. // optimize identity function
  15133. if (
  15134. fn.argnames.length === 1
  15135. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  15136. && self.args.length < 2
  15137. && !(self.args[0] instanceof AST_Expansion)
  15138. && returned instanceof AST_SymbolRef
  15139. && returned.name === fn.argnames[0].name
  15140. ) {
  15141. const replacement =
  15142. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  15143. let parent;
  15144. if (
  15145. replacement instanceof AST_PropAccess
  15146. && (parent = compressor.parent()) instanceof AST_Call
  15147. && parent.expression === self
  15148. ) {
  15149. // identity function was being used to remove `this`, like in
  15150. //
  15151. // id(bag.no_this)(...)
  15152. //
  15153. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  15154. return make_sequence(self, [
  15155. make_node(AST_Number, self, { value: 0 }),
  15156. replacement
  15157. ]);
  15158. }
  15159. // replace call with first argument or undefined if none passed
  15160. return replacement;
  15161. }
  15162. }
  15163. if (can_inline) {
  15164. var scope, in_loop, level = -1;
  15165. let def;
  15166. let returned_value;
  15167. let nearest_scope;
  15168. if (simple_args
  15169. && !fn.uses_arguments
  15170. && !(compressor.parent() instanceof AST_Class)
  15171. && !(fn.name && fn instanceof AST_Function)
  15172. && (returned_value = can_flatten_body(stat))
  15173. && (exp === fn
  15174. || has_annotation(self, _INLINE)
  15175. || compressor.option("unused")
  15176. && (def = exp.definition()).references.length == 1
  15177. && !is_recursive_ref(compressor, def)
  15178. && fn.is_constant_expression(exp.scope))
  15179. && !has_annotation(self, _PURE | _NOINLINE)
  15180. && !fn.contains_this()
  15181. && can_inject_symbols()
  15182. && (nearest_scope = compressor.find_scope())
  15183. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  15184. && !(function in_default_assign() {
  15185. // Due to the fact function parameters have their own scope
  15186. // which can't use `var something` in the function body within,
  15187. // we simply don't inline into DefaultAssign.
  15188. let i = 0;
  15189. let p;
  15190. while ((p = compressor.parent(i++))) {
  15191. if (p instanceof AST_DefaultAssign) return true;
  15192. if (p instanceof AST_Block) break;
  15193. }
  15194. return false;
  15195. })()
  15196. && !(scope instanceof AST_Class)
  15197. ) {
  15198. set_flag(fn, SQUEEZED);
  15199. nearest_scope.add_child_scope(fn);
  15200. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  15201. }
  15202. }
  15203. if (can_inline && has_annotation(self, _INLINE)) {
  15204. set_flag(fn, SQUEEZED);
  15205. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  15206. fn = fn.clone(true);
  15207. fn.figure_out_scope({}, {
  15208. parent_scope: compressor.find_scope(),
  15209. toplevel: compressor.get_toplevel()
  15210. });
  15211. return make_node(AST_Call, self, {
  15212. expression: fn,
  15213. args: self.args,
  15214. }).optimize(compressor);
  15215. }
  15216. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  15217. if (can_drop_this_call) {
  15218. var args = self.args.concat(make_node(AST_Undefined, self));
  15219. return make_sequence(self, args).optimize(compressor);
  15220. }
  15221. if (compressor.option("negate_iife")
  15222. && compressor.parent() instanceof AST_SimpleStatement
  15223. && is_iife_call(self)) {
  15224. return self.negate(compressor, true);
  15225. }
  15226. var ev = self.evaluate(compressor);
  15227. if (ev !== self) {
  15228. ev = make_node_from_constant(ev, self).optimize(compressor);
  15229. return best_of(compressor, ev, self);
  15230. }
  15231. return self;
  15232. function return_value(stat) {
  15233. if (!stat) return make_node(AST_Undefined, self);
  15234. if (stat instanceof AST_Return) {
  15235. if (!stat.value) return make_node(AST_Undefined, self);
  15236. return stat.value.clone(true);
  15237. }
  15238. if (stat instanceof AST_SimpleStatement) {
  15239. return make_node(AST_UnaryPrefix, stat, {
  15240. operator: "void",
  15241. expression: stat.body.clone(true)
  15242. });
  15243. }
  15244. }
  15245. function can_flatten_body(stat) {
  15246. var body = fn.body;
  15247. var len = body.length;
  15248. if (compressor.option("inline") < 3) {
  15249. return len == 1 && return_value(stat);
  15250. }
  15251. stat = null;
  15252. for (var i = 0; i < len; i++) {
  15253. var line = body[i];
  15254. if (line instanceof AST_Var) {
  15255. if (stat && !line.definitions.every((var_def) =>
  15256. !var_def.value
  15257. )) {
  15258. return false;
  15259. }
  15260. } else if (stat) {
  15261. return false;
  15262. } else if (!(line instanceof AST_EmptyStatement)) {
  15263. stat = line;
  15264. }
  15265. }
  15266. return return_value(stat);
  15267. }
  15268. function can_inject_args(block_scoped, safe_to_inject) {
  15269. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  15270. var arg = fn.argnames[i];
  15271. if (arg instanceof AST_DefaultAssign) {
  15272. if (has_flag(arg.left, UNUSED)) continue;
  15273. return false;
  15274. }
  15275. if (arg instanceof AST_Destructuring) return false;
  15276. if (arg instanceof AST_Expansion) {
  15277. if (has_flag(arg.expression, UNUSED)) continue;
  15278. return false;
  15279. }
  15280. if (has_flag(arg, UNUSED)) continue;
  15281. if (!safe_to_inject
  15282. || block_scoped.has(arg.name)
  15283. || identifier_atom.has(arg.name)
  15284. || scope.conflicting_def(arg.name)) {
  15285. return false;
  15286. }
  15287. if (in_loop) in_loop.push(arg.definition());
  15288. }
  15289. return true;
  15290. }
  15291. function can_inject_vars(block_scoped, safe_to_inject) {
  15292. var len = fn.body.length;
  15293. for (var i = 0; i < len; i++) {
  15294. var stat = fn.body[i];
  15295. if (!(stat instanceof AST_Var)) continue;
  15296. if (!safe_to_inject) return false;
  15297. for (var j = stat.definitions.length; --j >= 0;) {
  15298. var name = stat.definitions[j].name;
  15299. if (name instanceof AST_Destructuring
  15300. || block_scoped.has(name.name)
  15301. || identifier_atom.has(name.name)
  15302. || scope.conflicting_def(name.name)) {
  15303. return false;
  15304. }
  15305. if (in_loop) in_loop.push(name.definition());
  15306. }
  15307. }
  15308. return true;
  15309. }
  15310. function can_inject_symbols() {
  15311. var block_scoped = new Set();
  15312. do {
  15313. scope = compressor.parent(++level);
  15314. if (scope.is_block_scope() && scope.block_scope) {
  15315. // TODO this is sometimes undefined during compression.
  15316. // But it should always have a value!
  15317. scope.block_scope.variables.forEach(function (variable) {
  15318. block_scoped.add(variable.name);
  15319. });
  15320. }
  15321. if (scope instanceof AST_Catch) {
  15322. // TODO can we delete? AST_Catch is a block scope.
  15323. if (scope.argname) {
  15324. block_scoped.add(scope.argname.name);
  15325. }
  15326. } else if (scope instanceof AST_IterationStatement) {
  15327. in_loop = [];
  15328. } else if (scope instanceof AST_SymbolRef) {
  15329. if (scope.fixed_value() instanceof AST_Scope) return false;
  15330. }
  15331. } while (!(scope instanceof AST_Scope));
  15332. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  15333. var inline = compressor.option("inline");
  15334. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  15335. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  15336. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  15337. }
  15338. function append_var(decls, expressions, name, value) {
  15339. var def = name.definition();
  15340. // Name already exists, only when a function argument had the same name
  15341. const already_appended = scope.variables.has(name.name);
  15342. if (!already_appended) {
  15343. scope.variables.set(name.name, def);
  15344. scope.enclosed.push(def);
  15345. decls.push(make_node(AST_VarDef, name, {
  15346. name: name,
  15347. value: null
  15348. }));
  15349. }
  15350. var sym = make_node(AST_SymbolRef, name, name);
  15351. def.references.push(sym);
  15352. if (value) expressions.push(make_node(AST_Assign, self, {
  15353. operator: "=",
  15354. logical: false,
  15355. left: sym,
  15356. right: value.clone()
  15357. }));
  15358. }
  15359. function flatten_args(decls, expressions) {
  15360. var len = fn.argnames.length;
  15361. for (var i = self.args.length; --i >= len;) {
  15362. expressions.push(self.args[i]);
  15363. }
  15364. for (i = len; --i >= 0;) {
  15365. var name = fn.argnames[i];
  15366. var value = self.args[i];
  15367. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  15368. if (value) expressions.push(value);
  15369. } else {
  15370. var symbol = make_node(AST_SymbolVar, name, name);
  15371. name.definition().orig.push(symbol);
  15372. if (!value && in_loop) value = make_node(AST_Undefined, self);
  15373. append_var(decls, expressions, symbol, value);
  15374. }
  15375. }
  15376. decls.reverse();
  15377. expressions.reverse();
  15378. }
  15379. function flatten_vars(decls, expressions) {
  15380. var pos = expressions.length;
  15381. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  15382. var stat = fn.body[i];
  15383. if (!(stat instanceof AST_Var)) continue;
  15384. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  15385. var var_def = stat.definitions[j];
  15386. var name = var_def.name;
  15387. append_var(decls, expressions, name, var_def.value);
  15388. if (in_loop && fn.argnames.every((argname) =>
  15389. argname.name != name.name
  15390. )) {
  15391. var def = fn.variables.get(name.name);
  15392. var sym = make_node(AST_SymbolRef, name, name);
  15393. def.references.push(sym);
  15394. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  15395. operator: "=",
  15396. logical: false,
  15397. left: sym,
  15398. right: make_node(AST_Undefined, name)
  15399. }));
  15400. }
  15401. }
  15402. }
  15403. }
  15404. function flatten_fn(returned_value) {
  15405. var decls = [];
  15406. var expressions = [];
  15407. flatten_args(decls, expressions);
  15408. flatten_vars(decls, expressions);
  15409. expressions.push(returned_value);
  15410. if (decls.length) {
  15411. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  15412. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  15413. definitions: decls
  15414. }));
  15415. }
  15416. return expressions.map(exp => exp.clone(true));
  15417. }
  15418. }
  15419. /***********************************************************************
  15420. A JavaScript tokenizer / parser / beautifier / compressor.
  15421. https://github.com/mishoo/UglifyJS2
  15422. -------------------------------- (C) ---------------------------------
  15423. Author: Mihai Bazon
  15424. <mihai.bazon@gmail.com>
  15425. http://mihai.bazon.net/blog
  15426. Distributed under the BSD license:
  15427. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15428. Redistribution and use in source and binary forms, with or without
  15429. modification, are permitted provided that the following conditions
  15430. are met:
  15431. * Redistributions of source code must retain the above
  15432. copyright notice, this list of conditions and the following
  15433. disclaimer.
  15434. * Redistributions in binary form must reproduce the above
  15435. copyright notice, this list of conditions and the following
  15436. disclaimer in the documentation and/or other materials
  15437. provided with the distribution.
  15438. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15439. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15440. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15441. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15442. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15443. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15444. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15445. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15446. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15447. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15448. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15449. SUCH DAMAGE.
  15450. ***********************************************************************/
  15451. class Compressor extends TreeWalker {
  15452. constructor(options, { false_by_default = false, mangle_options = false }) {
  15453. super();
  15454. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  15455. this.options = defaults(options, {
  15456. arguments : false,
  15457. arrows : !false_by_default,
  15458. booleans : !false_by_default,
  15459. booleans_as_integers : false,
  15460. collapse_vars : !false_by_default,
  15461. comparisons : !false_by_default,
  15462. computed_props: !false_by_default,
  15463. conditionals : !false_by_default,
  15464. dead_code : !false_by_default,
  15465. defaults : true,
  15466. directives : !false_by_default,
  15467. drop_console : false,
  15468. drop_debugger : !false_by_default,
  15469. ecma : 5,
  15470. evaluate : !false_by_default,
  15471. expression : false,
  15472. global_defs : false,
  15473. hoist_funs : false,
  15474. hoist_props : !false_by_default,
  15475. hoist_vars : false,
  15476. ie8 : false,
  15477. if_return : !false_by_default,
  15478. inline : !false_by_default,
  15479. join_vars : !false_by_default,
  15480. keep_classnames: false,
  15481. keep_fargs : true,
  15482. keep_fnames : false,
  15483. keep_infinity : false,
  15484. loops : !false_by_default,
  15485. module : false,
  15486. negate_iife : !false_by_default,
  15487. passes : 1,
  15488. properties : !false_by_default,
  15489. pure_getters : !false_by_default && "strict",
  15490. pure_funcs : null,
  15491. reduce_funcs : !false_by_default,
  15492. reduce_vars : !false_by_default,
  15493. sequences : !false_by_default,
  15494. side_effects : !false_by_default,
  15495. switches : !false_by_default,
  15496. top_retain : null,
  15497. toplevel : !!(options && options["top_retain"]),
  15498. typeofs : !false_by_default,
  15499. unsafe : false,
  15500. unsafe_arrows : false,
  15501. unsafe_comps : false,
  15502. unsafe_Function: false,
  15503. unsafe_math : false,
  15504. unsafe_symbols: false,
  15505. unsafe_methods: false,
  15506. unsafe_proto : false,
  15507. unsafe_regexp : false,
  15508. unsafe_undefined: false,
  15509. unused : !false_by_default,
  15510. warnings : false // legacy
  15511. }, true);
  15512. var global_defs = this.options["global_defs"];
  15513. if (typeof global_defs == "object") for (var key in global_defs) {
  15514. if (key[0] === "@" && HOP(global_defs, key)) {
  15515. global_defs[key.slice(1)] = parse(global_defs[key], {
  15516. expression: true
  15517. });
  15518. }
  15519. }
  15520. if (this.options["inline"] === true) this.options["inline"] = 3;
  15521. var pure_funcs = this.options["pure_funcs"];
  15522. if (typeof pure_funcs == "function") {
  15523. this.pure_funcs = pure_funcs;
  15524. } else {
  15525. this.pure_funcs = pure_funcs ? function(node) {
  15526. return !pure_funcs.includes(node.expression.print_to_string());
  15527. } : return_true;
  15528. }
  15529. var top_retain = this.options["top_retain"];
  15530. if (top_retain instanceof RegExp) {
  15531. this.top_retain = function(def) {
  15532. return top_retain.test(def.name);
  15533. };
  15534. } else if (typeof top_retain == "function") {
  15535. this.top_retain = top_retain;
  15536. } else if (top_retain) {
  15537. if (typeof top_retain == "string") {
  15538. top_retain = top_retain.split(/,/);
  15539. }
  15540. this.top_retain = function(def) {
  15541. return top_retain.includes(def.name);
  15542. };
  15543. }
  15544. if (this.options["module"]) {
  15545. this.directives["use strict"] = true;
  15546. this.options["toplevel"] = true;
  15547. }
  15548. var toplevel = this.options["toplevel"];
  15549. this.toplevel = typeof toplevel == "string" ? {
  15550. funcs: /funcs/.test(toplevel),
  15551. vars: /vars/.test(toplevel)
  15552. } : {
  15553. funcs: toplevel,
  15554. vars: toplevel
  15555. };
  15556. var sequences = this.options["sequences"];
  15557. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  15558. this.evaluated_regexps = new Map();
  15559. this._toplevel = undefined;
  15560. this.mangle_options = mangle_options;
  15561. }
  15562. option(key) {
  15563. return this.options[key];
  15564. }
  15565. exposed(def) {
  15566. if (def.export) return true;
  15567. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  15568. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  15569. return true;
  15570. return false;
  15571. }
  15572. in_boolean_context() {
  15573. if (!this.option("booleans")) return false;
  15574. var self = this.self();
  15575. for (var i = 0, p; p = this.parent(i); i++) {
  15576. if (p instanceof AST_SimpleStatement
  15577. || p instanceof AST_Conditional && p.condition === self
  15578. || p instanceof AST_DWLoop && p.condition === self
  15579. || p instanceof AST_For && p.condition === self
  15580. || p instanceof AST_If && p.condition === self
  15581. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  15582. return true;
  15583. }
  15584. if (
  15585. p instanceof AST_Binary
  15586. && (
  15587. p.operator == "&&"
  15588. || p.operator == "||"
  15589. || p.operator == "??"
  15590. )
  15591. || p instanceof AST_Conditional
  15592. || p.tail_node() === self
  15593. ) {
  15594. self = p;
  15595. } else {
  15596. return false;
  15597. }
  15598. }
  15599. }
  15600. get_toplevel() {
  15601. return this._toplevel;
  15602. }
  15603. compress(toplevel) {
  15604. toplevel = toplevel.resolve_defines(this);
  15605. this._toplevel = toplevel;
  15606. if (this.option("expression")) {
  15607. this._toplevel.process_expression(true);
  15608. }
  15609. var passes = +this.options.passes || 1;
  15610. var min_count = 1 / 0;
  15611. var stopping = false;
  15612. var nth_identifier = this.mangle_options && this.mangle_options.nth_identifier || base54;
  15613. var mangle = { ie8: this.option("ie8"), nth_identifier: nth_identifier };
  15614. for (var pass = 0; pass < passes; pass++) {
  15615. this._toplevel.figure_out_scope(mangle);
  15616. if (pass === 0 && this.option("drop_console")) {
  15617. // must be run before reduce_vars and compress pass
  15618. this._toplevel = this._toplevel.drop_console();
  15619. }
  15620. if (pass > 0 || this.option("reduce_vars")) {
  15621. this._toplevel.reset_opt_flags(this);
  15622. }
  15623. this._toplevel = this._toplevel.transform(this);
  15624. if (passes > 1) {
  15625. let count = 0;
  15626. walk(this._toplevel, () => { count++; });
  15627. if (count < min_count) {
  15628. min_count = count;
  15629. stopping = false;
  15630. } else if (stopping) {
  15631. break;
  15632. } else {
  15633. stopping = true;
  15634. }
  15635. }
  15636. }
  15637. if (this.option("expression")) {
  15638. this._toplevel.process_expression(false);
  15639. }
  15640. toplevel = this._toplevel;
  15641. this._toplevel = undefined;
  15642. return toplevel;
  15643. }
  15644. before(node, descend) {
  15645. if (has_flag(node, SQUEEZED)) return node;
  15646. var was_scope = false;
  15647. if (node instanceof AST_Scope) {
  15648. node = node.hoist_properties(this);
  15649. node = node.hoist_declarations(this);
  15650. was_scope = true;
  15651. }
  15652. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  15653. // would call AST_Node.transform() if a different instance of AST_Node is
  15654. // produced after def_optimize().
  15655. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  15656. // Migrate and defer all children's AST_Node.transform() to below, which
  15657. // will now happen after this parent AST_Node has been properly substituted
  15658. // thus gives a consistent AST snapshot.
  15659. descend(node, this);
  15660. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  15661. // following replacement call would result in degraded efficiency of both
  15662. // output and performance.
  15663. descend(node, this);
  15664. var opt = node.optimize(this);
  15665. if (was_scope && opt instanceof AST_Scope) {
  15666. opt.drop_unused(this);
  15667. descend(opt, this);
  15668. }
  15669. if (opt === node) set_flag(opt, SQUEEZED);
  15670. return opt;
  15671. }
  15672. }
  15673. function def_optimize(node, optimizer) {
  15674. node.DEFMETHOD("optimize", function(compressor) {
  15675. var self = this;
  15676. if (has_flag(self, OPTIMIZED)) return self;
  15677. if (compressor.has_directive("use asm")) return self;
  15678. var opt = optimizer(self, compressor);
  15679. set_flag(opt, OPTIMIZED);
  15680. return opt;
  15681. });
  15682. }
  15683. def_optimize(AST_Node, function(self) {
  15684. return self;
  15685. });
  15686. AST_Toplevel.DEFMETHOD("drop_console", function() {
  15687. return this.transform(new TreeTransformer(function(self) {
  15688. if (self.TYPE == "Call") {
  15689. var exp = self.expression;
  15690. if (exp instanceof AST_PropAccess) {
  15691. var name = exp.expression;
  15692. while (name.expression) {
  15693. name = name.expression;
  15694. }
  15695. if (is_undeclared_ref(name) && name.name == "console") {
  15696. return make_node(AST_Undefined, self);
  15697. }
  15698. }
  15699. }
  15700. }));
  15701. });
  15702. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  15703. return equivalent_to(this, node);
  15704. });
  15705. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  15706. var self = this;
  15707. var tt = new TreeTransformer(function(node) {
  15708. if (insert && node instanceof AST_SimpleStatement) {
  15709. return make_node(AST_Return, node, {
  15710. value: node.body
  15711. });
  15712. }
  15713. if (!insert && node instanceof AST_Return) {
  15714. if (compressor) {
  15715. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  15716. return value
  15717. ? make_node(AST_SimpleStatement, node, { body: value })
  15718. : make_node(AST_EmptyStatement, node);
  15719. }
  15720. return make_node(AST_SimpleStatement, node, {
  15721. body: node.value || make_node(AST_UnaryPrefix, node, {
  15722. operator: "void",
  15723. expression: make_node(AST_Number, node, {
  15724. value: 0
  15725. })
  15726. })
  15727. });
  15728. }
  15729. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  15730. return node;
  15731. }
  15732. if (node instanceof AST_Block) {
  15733. var index = node.body.length - 1;
  15734. if (index >= 0) {
  15735. node.body[index] = node.body[index].transform(tt);
  15736. }
  15737. } else if (node instanceof AST_If) {
  15738. node.body = node.body.transform(tt);
  15739. if (node.alternative) {
  15740. node.alternative = node.alternative.transform(tt);
  15741. }
  15742. } else if (node instanceof AST_With) {
  15743. node.body = node.body.transform(tt);
  15744. }
  15745. return node;
  15746. });
  15747. self.transform(tt);
  15748. });
  15749. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  15750. const self = this;
  15751. const reduce_vars = compressor.option("reduce_vars");
  15752. const preparation = new TreeWalker(function(node, descend) {
  15753. clear_flag(node, CLEAR_BETWEEN_PASSES);
  15754. if (reduce_vars) {
  15755. if (compressor.top_retain
  15756. && node instanceof AST_Defun // Only functions are retained
  15757. && preparation.parent() === self
  15758. ) {
  15759. set_flag(node, TOP);
  15760. }
  15761. return node.reduce_vars(preparation, descend, compressor);
  15762. }
  15763. });
  15764. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  15765. // properly assigned before use:
  15766. // - `push()` & `pop()` when visiting conditional branches
  15767. preparation.safe_ids = Object.create(null);
  15768. preparation.in_loop = null;
  15769. preparation.loop_ids = new Map();
  15770. preparation.defs_to_safe_ids = new Map();
  15771. self.walk(preparation);
  15772. });
  15773. AST_Symbol.DEFMETHOD("fixed_value", function() {
  15774. var fixed = this.thedef.fixed;
  15775. if (!fixed || fixed instanceof AST_Node) return fixed;
  15776. return fixed();
  15777. });
  15778. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  15779. var orig = this.definition().orig;
  15780. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  15781. });
  15782. function find_variable(compressor, name) {
  15783. var scope, i = 0;
  15784. while (scope = compressor.parent(i++)) {
  15785. if (scope instanceof AST_Scope) break;
  15786. if (scope instanceof AST_Catch && scope.argname) {
  15787. scope = scope.argname.definition().scope;
  15788. break;
  15789. }
  15790. }
  15791. return scope.find_variable(name);
  15792. }
  15793. 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");
  15794. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  15795. return !this.definition().undeclared
  15796. || compressor.option("unsafe") && global_names.has(this.name);
  15797. });
  15798. /* -----[ optimizers ]----- */
  15799. var directives = new Set(["use asm", "use strict"]);
  15800. def_optimize(AST_Directive, function(self, compressor) {
  15801. if (compressor.option("directives")
  15802. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  15803. return make_node(AST_EmptyStatement, self);
  15804. }
  15805. return self;
  15806. });
  15807. def_optimize(AST_Debugger, function(self, compressor) {
  15808. if (compressor.option("drop_debugger"))
  15809. return make_node(AST_EmptyStatement, self);
  15810. return self;
  15811. });
  15812. def_optimize(AST_LabeledStatement, function(self, compressor) {
  15813. if (self.body instanceof AST_Break
  15814. && compressor.loopcontrol_target(self.body) === self.body) {
  15815. return make_node(AST_EmptyStatement, self);
  15816. }
  15817. return self.label.references.length == 0 ? self.body : self;
  15818. });
  15819. def_optimize(AST_Block, function(self, compressor) {
  15820. tighten_body(self.body, compressor);
  15821. return self;
  15822. });
  15823. function can_be_extracted_from_if_block(node) {
  15824. return !(
  15825. node instanceof AST_Const
  15826. || node instanceof AST_Let
  15827. || node instanceof AST_Class
  15828. );
  15829. }
  15830. def_optimize(AST_BlockStatement, function(self, compressor) {
  15831. tighten_body(self.body, compressor);
  15832. switch (self.body.length) {
  15833. case 1:
  15834. if (!compressor.has_directive("use strict")
  15835. && compressor.parent() instanceof AST_If
  15836. && can_be_extracted_from_if_block(self.body[0])
  15837. || can_be_evicted_from_block(self.body[0])) {
  15838. return self.body[0];
  15839. }
  15840. break;
  15841. case 0: return make_node(AST_EmptyStatement, self);
  15842. }
  15843. return self;
  15844. });
  15845. function opt_AST_Lambda(self, compressor) {
  15846. tighten_body(self.body, compressor);
  15847. if (compressor.option("side_effects")
  15848. && self.body.length == 1
  15849. && self.body[0] === compressor.has_directive("use strict")) {
  15850. self.body.length = 0;
  15851. }
  15852. return self;
  15853. }
  15854. def_optimize(AST_Lambda, opt_AST_Lambda);
  15855. const r_keep_assign = /keep_assign/;
  15856. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  15857. if (!compressor.option("unused")) return;
  15858. if (compressor.has_directive("use asm")) return;
  15859. var self = this;
  15860. if (self.pinned()) return;
  15861. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  15862. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  15863. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  15864. if (node instanceof AST_Assign
  15865. && !node.logical
  15866. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  15867. ) {
  15868. return node.left;
  15869. }
  15870. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  15871. return node.expression;
  15872. }
  15873. };
  15874. var in_use_ids = new Map();
  15875. var fixed_ids = new Map();
  15876. if (self instanceof AST_Toplevel && compressor.top_retain) {
  15877. self.variables.forEach(function(def) {
  15878. if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
  15879. in_use_ids.set(def.id, def);
  15880. }
  15881. });
  15882. }
  15883. var var_defs_by_id = new Map();
  15884. var initializations = new Map();
  15885. // pass 1: find out which symbols are directly used in
  15886. // this scope (not in nested scopes).
  15887. var scope = this;
  15888. var tw = new TreeWalker(function(node, descend) {
  15889. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  15890. node.argnames.forEach(function(argname) {
  15891. if (!(argname instanceof AST_SymbolDeclaration)) return;
  15892. var def = argname.definition();
  15893. if (!in_use_ids.has(def.id)) {
  15894. in_use_ids.set(def.id, def);
  15895. }
  15896. });
  15897. }
  15898. if (node === self) return;
  15899. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  15900. var node_def = node.name.definition();
  15901. const in_export = tw.parent() instanceof AST_Export;
  15902. if (in_export || !drop_funcs && scope === self) {
  15903. if (node_def.global && !in_use_ids.has(node_def.id)) {
  15904. in_use_ids.set(node_def.id, node_def);
  15905. }
  15906. }
  15907. if (node instanceof AST_DefClass) {
  15908. if (
  15909. node.extends
  15910. && (node.extends.has_side_effects(compressor)
  15911. || node.extends.may_throw(compressor))
  15912. ) {
  15913. node.extends.walk(tw);
  15914. }
  15915. for (const prop of node.properties) {
  15916. if (
  15917. prop.has_side_effects(compressor) ||
  15918. prop.may_throw(compressor)
  15919. ) {
  15920. prop.walk(tw);
  15921. }
  15922. }
  15923. }
  15924. map_add(initializations, node_def.id, node);
  15925. return true; // don't go in nested scopes
  15926. }
  15927. if (node instanceof AST_SymbolFunarg && scope === self) {
  15928. map_add(var_defs_by_id, node.definition().id, node);
  15929. }
  15930. if (node instanceof AST_Definitions && scope === self) {
  15931. const in_export = tw.parent() instanceof AST_Export;
  15932. node.definitions.forEach(function(def) {
  15933. if (def.name instanceof AST_SymbolVar) {
  15934. map_add(var_defs_by_id, def.name.definition().id, def);
  15935. }
  15936. if (in_export || !drop_vars) {
  15937. walk(def.name, node => {
  15938. if (node instanceof AST_SymbolDeclaration) {
  15939. const def = node.definition();
  15940. if (
  15941. (in_export || def.global)
  15942. && !in_use_ids.has(def.id)
  15943. ) {
  15944. in_use_ids.set(def.id, def);
  15945. }
  15946. }
  15947. });
  15948. }
  15949. if (def.value) {
  15950. if (def.name instanceof AST_Destructuring) {
  15951. def.walk(tw);
  15952. } else {
  15953. var node_def = def.name.definition();
  15954. map_add(initializations, node_def.id, def.value);
  15955. if (!node_def.chained && def.name.fixed_value() === def.value) {
  15956. fixed_ids.set(node_def.id, def);
  15957. }
  15958. }
  15959. if (def.value.has_side_effects(compressor)) {
  15960. def.value.walk(tw);
  15961. }
  15962. }
  15963. });
  15964. return true;
  15965. }
  15966. return scan_ref_scoped(node, descend);
  15967. });
  15968. self.walk(tw);
  15969. // pass 2: for every used symbol we need to walk its
  15970. // initialization code to figure out if it uses other
  15971. // symbols (that may not be in_use).
  15972. tw = new TreeWalker(scan_ref_scoped);
  15973. in_use_ids.forEach(function (def) {
  15974. var init = initializations.get(def.id);
  15975. if (init) init.forEach(function(init) {
  15976. init.walk(tw);
  15977. });
  15978. });
  15979. // pass 3: we should drop declarations not in_use
  15980. var tt = new TreeTransformer(
  15981. function before(node, descend, in_list) {
  15982. var parent = tt.parent();
  15983. if (drop_vars) {
  15984. const sym = assign_as_unused(node);
  15985. if (sym instanceof AST_SymbolRef) {
  15986. var def = sym.definition();
  15987. var in_use = in_use_ids.has(def.id);
  15988. if (node instanceof AST_Assign) {
  15989. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  15990. return maintain_this_binding(parent, node, node.right.transform(tt));
  15991. }
  15992. } else if (!in_use) return in_list ? MAP.skip : make_node(AST_Number, node, {
  15993. value: 0
  15994. });
  15995. }
  15996. }
  15997. if (scope !== self) return;
  15998. var def;
  15999. if (node.name
  16000. && (node instanceof AST_ClassExpression
  16001. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  16002. || node instanceof AST_Function
  16003. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  16004. // any declarations with same name will overshadow
  16005. // name of this anonymous function and can therefore
  16006. // never be used anywhere
  16007. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  16008. }
  16009. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  16010. var trim = !compressor.option("keep_fargs");
  16011. for (var a = node.argnames, i = a.length; --i >= 0;) {
  16012. var sym = a[i];
  16013. if (sym instanceof AST_Expansion) {
  16014. sym = sym.expression;
  16015. }
  16016. if (sym instanceof AST_DefaultAssign) {
  16017. sym = sym.left;
  16018. }
  16019. // Do not drop destructuring arguments.
  16020. // They constitute a type assertion, so dropping
  16021. // them would stop that TypeError which would happen
  16022. // if someone called it with an incorrectly formatted
  16023. // parameter.
  16024. if (!(sym instanceof AST_Destructuring) && !in_use_ids.has(sym.definition().id)) {
  16025. set_flag(sym, UNUSED);
  16026. if (trim) {
  16027. a.pop();
  16028. }
  16029. } else {
  16030. trim = false;
  16031. }
  16032. }
  16033. }
  16034. if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
  16035. const def = node.name.definition();
  16036. const keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  16037. // Class "extends" and static blocks may have side effects
  16038. const has_side_effects = !keep
  16039. && node instanceof AST_Class
  16040. && node.has_side_effects(compressor);
  16041. if (!keep && !has_side_effects) {
  16042. def.eliminated++;
  16043. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  16044. }
  16045. }
  16046. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  16047. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  16048. // place uninitialized names at the start
  16049. var body = [], head = [], tail = [];
  16050. // for unused names whose initialization has
  16051. // side effects, we can cascade the init. code
  16052. // into the next one, or next statement.
  16053. var side_effects = [];
  16054. node.definitions.forEach(function(def) {
  16055. if (def.value) def.value = def.value.transform(tt);
  16056. var is_destructure = def.name instanceof AST_Destructuring;
  16057. var sym = is_destructure
  16058. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  16059. : def.name.definition();
  16060. if (drop_block && sym.global) return tail.push(def);
  16061. if (!(drop_vars || drop_block)
  16062. || is_destructure
  16063. && (def.name.names.length
  16064. || def.name.is_array
  16065. || compressor.option("pure_getters") != true)
  16066. || in_use_ids.has(sym.id)
  16067. ) {
  16068. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  16069. def.value = def.value.drop_side_effect_free(compressor);
  16070. }
  16071. if (def.name instanceof AST_SymbolVar) {
  16072. var var_defs = var_defs_by_id.get(sym.id);
  16073. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  16074. if (def.value) {
  16075. var ref = make_node(AST_SymbolRef, def.name, def.name);
  16076. sym.references.push(ref);
  16077. var assign = make_node(AST_Assign, def, {
  16078. operator: "=",
  16079. logical: false,
  16080. left: ref,
  16081. right: def.value
  16082. });
  16083. if (fixed_ids.get(sym.id) === def) {
  16084. fixed_ids.set(sym.id, assign);
  16085. }
  16086. side_effects.push(assign.transform(tt));
  16087. }
  16088. remove(var_defs, def);
  16089. sym.eliminated++;
  16090. return;
  16091. }
  16092. }
  16093. if (def.value) {
  16094. if (side_effects.length > 0) {
  16095. if (tail.length > 0) {
  16096. side_effects.push(def.value);
  16097. def.value = make_sequence(def.value, side_effects);
  16098. } else {
  16099. body.push(make_node(AST_SimpleStatement, node, {
  16100. body: make_sequence(node, side_effects)
  16101. }));
  16102. }
  16103. side_effects = [];
  16104. }
  16105. tail.push(def);
  16106. } else {
  16107. head.push(def);
  16108. }
  16109. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  16110. var value = def.value && def.value.drop_side_effect_free(compressor);
  16111. if (value) side_effects.push(value);
  16112. def.value = null;
  16113. head.push(def);
  16114. } else {
  16115. var value = def.value && def.value.drop_side_effect_free(compressor);
  16116. if (value) {
  16117. side_effects.push(value);
  16118. }
  16119. sym.eliminated++;
  16120. }
  16121. });
  16122. if (head.length > 0 || tail.length > 0) {
  16123. node.definitions = head.concat(tail);
  16124. body.push(node);
  16125. }
  16126. if (side_effects.length > 0) {
  16127. body.push(make_node(AST_SimpleStatement, node, {
  16128. body: make_sequence(node, side_effects)
  16129. }));
  16130. }
  16131. switch (body.length) {
  16132. case 0:
  16133. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  16134. case 1:
  16135. return body[0];
  16136. default:
  16137. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  16138. body: body
  16139. });
  16140. }
  16141. }
  16142. // certain combination of unused name + side effect leads to:
  16143. // https://github.com/mishoo/UglifyJS2/issues/44
  16144. // https://github.com/mishoo/UglifyJS2/issues/1830
  16145. // https://github.com/mishoo/UglifyJS2/issues/1838
  16146. // that's an invalid AST.
  16147. // We fix it at this stage by moving the `var` outside the `for`.
  16148. if (node instanceof AST_For) {
  16149. descend(node, this);
  16150. var block;
  16151. if (node.init instanceof AST_BlockStatement) {
  16152. block = node.init;
  16153. node.init = block.body.pop();
  16154. block.body.push(node);
  16155. }
  16156. if (node.init instanceof AST_SimpleStatement) {
  16157. node.init = node.init.body;
  16158. } else if (is_empty(node.init)) {
  16159. node.init = null;
  16160. }
  16161. return !block ? node : in_list ? MAP.splice(block.body) : block;
  16162. }
  16163. if (node instanceof AST_LabeledStatement
  16164. && node.body instanceof AST_For
  16165. ) {
  16166. descend(node, this);
  16167. if (node.body instanceof AST_BlockStatement) {
  16168. var block = node.body;
  16169. node.body = block.body.pop();
  16170. block.body.push(node);
  16171. return in_list ? MAP.splice(block.body) : block;
  16172. }
  16173. return node;
  16174. }
  16175. if (node instanceof AST_BlockStatement) {
  16176. descend(node, this);
  16177. if (in_list && node.body.every(can_be_evicted_from_block)) {
  16178. return MAP.splice(node.body);
  16179. }
  16180. return node;
  16181. }
  16182. if (node instanceof AST_Scope) {
  16183. const save_scope = scope;
  16184. scope = node;
  16185. descend(node, this);
  16186. scope = save_scope;
  16187. return node;
  16188. }
  16189. }
  16190. );
  16191. self.transform(tt);
  16192. function scan_ref_scoped(node, descend) {
  16193. var node_def;
  16194. const sym = assign_as_unused(node);
  16195. if (sym instanceof AST_SymbolRef
  16196. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  16197. && self.variables.get(sym.name) === (node_def = sym.definition())
  16198. ) {
  16199. if (node instanceof AST_Assign) {
  16200. node.right.walk(tw);
  16201. if (!node_def.chained && node.left.fixed_value() === node.right) {
  16202. fixed_ids.set(node_def.id, node);
  16203. }
  16204. }
  16205. return true;
  16206. }
  16207. if (node instanceof AST_SymbolRef) {
  16208. node_def = node.definition();
  16209. if (!in_use_ids.has(node_def.id)) {
  16210. in_use_ids.set(node_def.id, node_def);
  16211. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  16212. const redef = node_def.scope.is_block_scope()
  16213. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  16214. if (redef) in_use_ids.set(redef.id, redef);
  16215. }
  16216. }
  16217. return true;
  16218. }
  16219. if (node instanceof AST_Scope) {
  16220. var save_scope = scope;
  16221. scope = node;
  16222. descend();
  16223. scope = save_scope;
  16224. return true;
  16225. }
  16226. }
  16227. });
  16228. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  16229. var self = this;
  16230. if (compressor.has_directive("use asm")) return self;
  16231. // Hoisting makes no sense in an arrow func
  16232. if (!Array.isArray(self.body)) return self;
  16233. var hoist_funs = compressor.option("hoist_funs");
  16234. var hoist_vars = compressor.option("hoist_vars");
  16235. if (hoist_funs || hoist_vars) {
  16236. var dirs = [];
  16237. var hoisted = [];
  16238. var vars = new Map(), vars_found = 0, var_decl = 0;
  16239. // let's count var_decl first, we seem to waste a lot of
  16240. // space if we hoist `var` when there's only one.
  16241. walk(self, node => {
  16242. if (node instanceof AST_Scope && node !== self)
  16243. return true;
  16244. if (node instanceof AST_Var) {
  16245. ++var_decl;
  16246. return true;
  16247. }
  16248. });
  16249. hoist_vars = hoist_vars && var_decl > 1;
  16250. var tt = new TreeTransformer(
  16251. function before(node) {
  16252. if (node !== self) {
  16253. if (node instanceof AST_Directive) {
  16254. dirs.push(node);
  16255. return make_node(AST_EmptyStatement, node);
  16256. }
  16257. if (hoist_funs && node instanceof AST_Defun
  16258. && !(tt.parent() instanceof AST_Export)
  16259. && tt.parent() === self) {
  16260. hoisted.push(node);
  16261. return make_node(AST_EmptyStatement, node);
  16262. }
  16263. if (
  16264. hoist_vars
  16265. && node instanceof AST_Var
  16266. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  16267. ) {
  16268. node.definitions.forEach(function(def) {
  16269. vars.set(def.name.name, def);
  16270. ++vars_found;
  16271. });
  16272. var seq = node.to_assignments(compressor);
  16273. var p = tt.parent();
  16274. if (p instanceof AST_ForIn && p.init === node) {
  16275. if (seq == null) {
  16276. var def = node.definitions[0].name;
  16277. return make_node(AST_SymbolRef, def, def);
  16278. }
  16279. return seq;
  16280. }
  16281. if (p instanceof AST_For && p.init === node) {
  16282. return seq;
  16283. }
  16284. if (!seq) return make_node(AST_EmptyStatement, node);
  16285. return make_node(AST_SimpleStatement, node, {
  16286. body: seq
  16287. });
  16288. }
  16289. if (node instanceof AST_Scope)
  16290. return node; // to avoid descending in nested scopes
  16291. }
  16292. }
  16293. );
  16294. self = self.transform(tt);
  16295. if (vars_found > 0) {
  16296. // collect only vars which don't show up in self's arguments list
  16297. var defs = [];
  16298. const is_lambda = self instanceof AST_Lambda;
  16299. const args_as_names = is_lambda ? self.args_as_names() : null;
  16300. vars.forEach((def, name) => {
  16301. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  16302. vars.delete(name);
  16303. } else {
  16304. def = def.clone();
  16305. def.value = null;
  16306. defs.push(def);
  16307. vars.set(name, def);
  16308. }
  16309. });
  16310. if (defs.length > 0) {
  16311. // try to merge in assignments
  16312. for (var i = 0; i < self.body.length;) {
  16313. if (self.body[i] instanceof AST_SimpleStatement) {
  16314. var expr = self.body[i].body, sym, assign;
  16315. if (expr instanceof AST_Assign
  16316. && expr.operator == "="
  16317. && (sym = expr.left) instanceof AST_Symbol
  16318. && vars.has(sym.name)
  16319. ) {
  16320. var def = vars.get(sym.name);
  16321. if (def.value) break;
  16322. def.value = expr.right;
  16323. remove(defs, def);
  16324. defs.push(def);
  16325. self.body.splice(i, 1);
  16326. continue;
  16327. }
  16328. if (expr instanceof AST_Sequence
  16329. && (assign = expr.expressions[0]) instanceof AST_Assign
  16330. && assign.operator == "="
  16331. && (sym = assign.left) instanceof AST_Symbol
  16332. && vars.has(sym.name)
  16333. ) {
  16334. var def = vars.get(sym.name);
  16335. if (def.value) break;
  16336. def.value = assign.right;
  16337. remove(defs, def);
  16338. defs.push(def);
  16339. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  16340. continue;
  16341. }
  16342. }
  16343. if (self.body[i] instanceof AST_EmptyStatement) {
  16344. self.body.splice(i, 1);
  16345. continue;
  16346. }
  16347. if (self.body[i] instanceof AST_BlockStatement) {
  16348. self.body.splice(i, 1, ...self.body[i].body);
  16349. continue;
  16350. }
  16351. break;
  16352. }
  16353. defs = make_node(AST_Var, self, {
  16354. definitions: defs
  16355. });
  16356. hoisted.push(defs);
  16357. }
  16358. }
  16359. self.body = dirs.concat(hoisted, self.body);
  16360. }
  16361. return self;
  16362. });
  16363. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  16364. var self = this;
  16365. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  16366. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  16367. var defs_by_id = new Map();
  16368. var hoister = new TreeTransformer(function(node, descend) {
  16369. if (node instanceof AST_Definitions
  16370. && hoister.parent() instanceof AST_Export) return node;
  16371. if (node instanceof AST_VarDef) {
  16372. const sym = node.name;
  16373. let def;
  16374. let value;
  16375. if (sym.scope === self
  16376. && (def = sym.definition()).escaped != 1
  16377. && !def.assignments
  16378. && !def.direct_access
  16379. && !def.single_use
  16380. && !compressor.exposed(def)
  16381. && !top_retain(def)
  16382. && (value = sym.fixed_value()) === node.value
  16383. && value instanceof AST_Object
  16384. && !value.properties.some(prop =>
  16385. prop instanceof AST_Expansion || prop.computed_key()
  16386. )
  16387. ) {
  16388. descend(node, this);
  16389. const defs = new Map();
  16390. const assignments = [];
  16391. value.properties.forEach(({ key, value }) => {
  16392. const scope = hoister.find_scope();
  16393. const symbol = self.create_symbol(sym.CTOR, {
  16394. source: sym,
  16395. scope,
  16396. conflict_scopes: new Set([
  16397. scope,
  16398. ...sym.definition().references.map(ref => ref.scope)
  16399. ]),
  16400. tentative_name: sym.name + "_" + key
  16401. });
  16402. defs.set(String(key), symbol.definition());
  16403. assignments.push(make_node(AST_VarDef, node, {
  16404. name: symbol,
  16405. value
  16406. }));
  16407. });
  16408. defs_by_id.set(def.id, defs);
  16409. return MAP.splice(assignments);
  16410. }
  16411. } else if (node instanceof AST_PropAccess
  16412. && node.expression instanceof AST_SymbolRef
  16413. ) {
  16414. const defs = defs_by_id.get(node.expression.definition().id);
  16415. if (defs) {
  16416. const def = defs.get(String(get_simple_key(node.property)));
  16417. const sym = make_node(AST_SymbolRef, node, {
  16418. name: def.name,
  16419. scope: node.expression.scope,
  16420. thedef: def
  16421. });
  16422. sym.reference({});
  16423. return sym;
  16424. }
  16425. }
  16426. });
  16427. return self.transform(hoister);
  16428. });
  16429. def_optimize(AST_SimpleStatement, function(self, compressor) {
  16430. if (compressor.option("side_effects")) {
  16431. var body = self.body;
  16432. var node = body.drop_side_effect_free(compressor, true);
  16433. if (!node) {
  16434. return make_node(AST_EmptyStatement, self);
  16435. }
  16436. if (node !== body) {
  16437. return make_node(AST_SimpleStatement, self, { body: node });
  16438. }
  16439. }
  16440. return self;
  16441. });
  16442. def_optimize(AST_While, function(self, compressor) {
  16443. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  16444. });
  16445. def_optimize(AST_Do, function(self, compressor) {
  16446. if (!compressor.option("loops")) return self;
  16447. var cond = self.condition.tail_node().evaluate(compressor);
  16448. if (!(cond instanceof AST_Node)) {
  16449. if (cond) return make_node(AST_For, self, {
  16450. body: make_node(AST_BlockStatement, self.body, {
  16451. body: [
  16452. self.body,
  16453. make_node(AST_SimpleStatement, self.condition, {
  16454. body: self.condition
  16455. })
  16456. ]
  16457. })
  16458. }).optimize(compressor);
  16459. if (!has_break_or_continue(self, compressor.parent())) {
  16460. return make_node(AST_BlockStatement, self.body, {
  16461. body: [
  16462. self.body,
  16463. make_node(AST_SimpleStatement, self.condition, {
  16464. body: self.condition
  16465. })
  16466. ]
  16467. }).optimize(compressor);
  16468. }
  16469. }
  16470. return self;
  16471. });
  16472. function if_break_in_loop(self, compressor) {
  16473. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  16474. if (compressor.option("dead_code") && is_break(first)) {
  16475. var body = [];
  16476. if (self.init instanceof AST_Statement) {
  16477. body.push(self.init);
  16478. } else if (self.init) {
  16479. body.push(make_node(AST_SimpleStatement, self.init, {
  16480. body: self.init
  16481. }));
  16482. }
  16483. if (self.condition) {
  16484. body.push(make_node(AST_SimpleStatement, self.condition, {
  16485. body: self.condition
  16486. }));
  16487. }
  16488. trim_unreachable_code(compressor, self.body, body);
  16489. return make_node(AST_BlockStatement, self, {
  16490. body: body
  16491. });
  16492. }
  16493. if (first instanceof AST_If) {
  16494. if (is_break(first.body)) {
  16495. if (self.condition) {
  16496. self.condition = make_node(AST_Binary, self.condition, {
  16497. left: self.condition,
  16498. operator: "&&",
  16499. right: first.condition.negate(compressor),
  16500. });
  16501. } else {
  16502. self.condition = first.condition.negate(compressor);
  16503. }
  16504. drop_it(first.alternative);
  16505. } else if (is_break(first.alternative)) {
  16506. if (self.condition) {
  16507. self.condition = make_node(AST_Binary, self.condition, {
  16508. left: self.condition,
  16509. operator: "&&",
  16510. right: first.condition,
  16511. });
  16512. } else {
  16513. self.condition = first.condition;
  16514. }
  16515. drop_it(first.body);
  16516. }
  16517. }
  16518. return self;
  16519. function is_break(node) {
  16520. return node instanceof AST_Break
  16521. && compressor.loopcontrol_target(node) === compressor.self();
  16522. }
  16523. function drop_it(rest) {
  16524. rest = as_statement_array(rest);
  16525. if (self.body instanceof AST_BlockStatement) {
  16526. self.body = self.body.clone();
  16527. self.body.body = rest.concat(self.body.body.slice(1));
  16528. self.body = self.body.transform(compressor);
  16529. } else {
  16530. self.body = make_node(AST_BlockStatement, self.body, {
  16531. body: rest
  16532. }).transform(compressor);
  16533. }
  16534. self = if_break_in_loop(self, compressor);
  16535. }
  16536. }
  16537. def_optimize(AST_For, function(self, compressor) {
  16538. if (!compressor.option("loops")) return self;
  16539. if (compressor.option("side_effects") && self.init) {
  16540. self.init = self.init.drop_side_effect_free(compressor);
  16541. }
  16542. if (self.condition) {
  16543. var cond = self.condition.evaluate(compressor);
  16544. if (!(cond instanceof AST_Node)) {
  16545. if (cond) self.condition = null;
  16546. else if (!compressor.option("dead_code")) {
  16547. var orig = self.condition;
  16548. self.condition = make_node_from_constant(cond, self.condition);
  16549. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  16550. }
  16551. }
  16552. if (compressor.option("dead_code")) {
  16553. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  16554. if (!cond) {
  16555. var body = [];
  16556. trim_unreachable_code(compressor, self.body, body);
  16557. if (self.init instanceof AST_Statement) {
  16558. body.push(self.init);
  16559. } else if (self.init) {
  16560. body.push(make_node(AST_SimpleStatement, self.init, {
  16561. body: self.init
  16562. }));
  16563. }
  16564. body.push(make_node(AST_SimpleStatement, self.condition, {
  16565. body: self.condition
  16566. }));
  16567. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  16568. }
  16569. }
  16570. }
  16571. return if_break_in_loop(self, compressor);
  16572. });
  16573. def_optimize(AST_If, function(self, compressor) {
  16574. if (is_empty(self.alternative)) self.alternative = null;
  16575. if (!compressor.option("conditionals")) return self;
  16576. // if condition can be statically determined, drop
  16577. // one of the blocks. note, statically determined implies
  16578. // “has no side effects”; also it doesn't work for cases like
  16579. // `x && true`, though it probably should.
  16580. var cond = self.condition.evaluate(compressor);
  16581. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  16582. var orig = self.condition;
  16583. self.condition = make_node_from_constant(cond, orig);
  16584. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  16585. }
  16586. if (compressor.option("dead_code")) {
  16587. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  16588. if (!cond) {
  16589. var body = [];
  16590. trim_unreachable_code(compressor, self.body, body);
  16591. body.push(make_node(AST_SimpleStatement, self.condition, {
  16592. body: self.condition
  16593. }));
  16594. if (self.alternative) body.push(self.alternative);
  16595. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  16596. } else if (!(cond instanceof AST_Node)) {
  16597. var body = [];
  16598. body.push(make_node(AST_SimpleStatement, self.condition, {
  16599. body: self.condition
  16600. }));
  16601. body.push(self.body);
  16602. if (self.alternative) {
  16603. trim_unreachable_code(compressor, self.alternative, body);
  16604. }
  16605. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  16606. }
  16607. }
  16608. var negated = self.condition.negate(compressor);
  16609. var self_condition_length = self.condition.size();
  16610. var negated_length = negated.size();
  16611. var negated_is_best = negated_length < self_condition_length;
  16612. if (self.alternative && negated_is_best) {
  16613. negated_is_best = false; // because we already do the switch here.
  16614. // no need to swap values of self_condition_length and negated_length
  16615. // here because they are only used in an equality comparison later on.
  16616. self.condition = negated;
  16617. var tmp = self.body;
  16618. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  16619. self.alternative = tmp;
  16620. }
  16621. if (is_empty(self.body) && is_empty(self.alternative)) {
  16622. return make_node(AST_SimpleStatement, self.condition, {
  16623. body: self.condition.clone()
  16624. }).optimize(compressor);
  16625. }
  16626. if (self.body instanceof AST_SimpleStatement
  16627. && self.alternative instanceof AST_SimpleStatement) {
  16628. return make_node(AST_SimpleStatement, self, {
  16629. body: make_node(AST_Conditional, self, {
  16630. condition : self.condition,
  16631. consequent : self.body.body,
  16632. alternative : self.alternative.body
  16633. })
  16634. }).optimize(compressor);
  16635. }
  16636. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  16637. if (self_condition_length === negated_length && !negated_is_best
  16638. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  16639. // although the code length of self.condition and negated are the same,
  16640. // negated does not require additional surrounding parentheses.
  16641. // see https://github.com/mishoo/UglifyJS2/issues/979
  16642. negated_is_best = true;
  16643. }
  16644. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  16645. body: make_node(AST_Binary, self, {
  16646. operator : "||",
  16647. left : negated,
  16648. right : self.body.body
  16649. })
  16650. }).optimize(compressor);
  16651. return make_node(AST_SimpleStatement, self, {
  16652. body: make_node(AST_Binary, self, {
  16653. operator : "&&",
  16654. left : self.condition,
  16655. right : self.body.body
  16656. })
  16657. }).optimize(compressor);
  16658. }
  16659. if (self.body instanceof AST_EmptyStatement
  16660. && self.alternative instanceof AST_SimpleStatement) {
  16661. return make_node(AST_SimpleStatement, self, {
  16662. body: make_node(AST_Binary, self, {
  16663. operator : "||",
  16664. left : self.condition,
  16665. right : self.alternative.body
  16666. })
  16667. }).optimize(compressor);
  16668. }
  16669. if (self.body instanceof AST_Exit
  16670. && self.alternative instanceof AST_Exit
  16671. && self.body.TYPE == self.alternative.TYPE) {
  16672. return make_node(self.body.CTOR, self, {
  16673. value: make_node(AST_Conditional, self, {
  16674. condition : self.condition,
  16675. consequent : self.body.value || make_node(AST_Undefined, self.body),
  16676. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  16677. }).transform(compressor)
  16678. }).optimize(compressor);
  16679. }
  16680. if (self.body instanceof AST_If
  16681. && !self.body.alternative
  16682. && !self.alternative) {
  16683. self = make_node(AST_If, self, {
  16684. condition: make_node(AST_Binary, self.condition, {
  16685. operator: "&&",
  16686. left: self.condition,
  16687. right: self.body.condition
  16688. }),
  16689. body: self.body.body,
  16690. alternative: null
  16691. });
  16692. }
  16693. if (aborts(self.body)) {
  16694. if (self.alternative) {
  16695. var alt = self.alternative;
  16696. self.alternative = null;
  16697. return make_node(AST_BlockStatement, self, {
  16698. body: [ self, alt ]
  16699. }).optimize(compressor);
  16700. }
  16701. }
  16702. if (aborts(self.alternative)) {
  16703. var body = self.body;
  16704. self.body = self.alternative;
  16705. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  16706. self.alternative = null;
  16707. return make_node(AST_BlockStatement, self, {
  16708. body: [ self, body ]
  16709. }).optimize(compressor);
  16710. }
  16711. return self;
  16712. });
  16713. def_optimize(AST_Switch, function(self, compressor) {
  16714. if (!compressor.option("switches")) return self;
  16715. var branch;
  16716. var value = self.expression.evaluate(compressor);
  16717. if (!(value instanceof AST_Node)) {
  16718. var orig = self.expression;
  16719. self.expression = make_node_from_constant(value, orig);
  16720. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  16721. }
  16722. if (!compressor.option("dead_code")) return self;
  16723. if (value instanceof AST_Node) {
  16724. value = self.expression.tail_node().evaluate(compressor);
  16725. }
  16726. var decl = [];
  16727. var body = [];
  16728. var default_branch;
  16729. var exact_match;
  16730. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  16731. branch = self.body[i];
  16732. if (branch instanceof AST_Default) {
  16733. if (!default_branch) {
  16734. default_branch = branch;
  16735. } else {
  16736. eliminate_branch(branch, body[body.length - 1]);
  16737. }
  16738. } else if (!(value instanceof AST_Node)) {
  16739. var exp = branch.expression.evaluate(compressor);
  16740. if (!(exp instanceof AST_Node) && exp !== value) {
  16741. eliminate_branch(branch, body[body.length - 1]);
  16742. continue;
  16743. }
  16744. if (exp instanceof AST_Node) exp = branch.expression.tail_node().evaluate(compressor);
  16745. if (exp === value) {
  16746. exact_match = branch;
  16747. if (default_branch) {
  16748. var default_index = body.indexOf(default_branch);
  16749. body.splice(default_index, 1);
  16750. eliminate_branch(default_branch, body[default_index - 1]);
  16751. default_branch = null;
  16752. }
  16753. }
  16754. }
  16755. body.push(branch);
  16756. }
  16757. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  16758. self.body = body;
  16759. let default_or_exact = default_branch || exact_match;
  16760. default_branch = null;
  16761. exact_match = null;
  16762. // group equivalent branches so they will be located next to each other,
  16763. // that way the next micro-optimization will merge them.
  16764. // ** bail micro-optimization if not a simple switch case with breaks
  16765. if (body.every((branch, i) =>
  16766. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  16767. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  16768. ) {
  16769. for (let i = 0; i < body.length; i++) {
  16770. const branch = body[i];
  16771. for (let j = i + 1; j < body.length; j++) {
  16772. const next = body[j];
  16773. if (next.body.length === 0) continue;
  16774. const last_branch = j === (body.length - 1);
  16775. const equivalentBranch = branches_equivalent(next, branch, false);
  16776. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  16777. if (!equivalentBranch && last_branch) {
  16778. next.body.push(make_node(AST_Break));
  16779. }
  16780. // let's find previous siblings with inert fallthrough...
  16781. let x = j - 1;
  16782. let fallthroughDepth = 0;
  16783. while (x > i) {
  16784. if (is_inert_body(body[x--])) {
  16785. fallthroughDepth++;
  16786. } else {
  16787. break;
  16788. }
  16789. }
  16790. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  16791. body.splice(i + 1, 0, ...plucked);
  16792. i += plucked.length;
  16793. }
  16794. }
  16795. }
  16796. }
  16797. // merge equivalent branches in a row
  16798. for (let i = 0; i < body.length; i++) {
  16799. let branch = body[i];
  16800. if (branch.body.length === 0) continue;
  16801. if (!aborts(branch)) continue;
  16802. for (let j = i + 1; j < body.length; i++, j++) {
  16803. let next = body[j];
  16804. if (next.body.length === 0) continue;
  16805. if (
  16806. branches_equivalent(next, branch, false)
  16807. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  16808. ) {
  16809. branch.body = [];
  16810. branch = next;
  16811. continue;
  16812. }
  16813. break;
  16814. }
  16815. }
  16816. // Prune any empty branches at the end of the switch statement.
  16817. {
  16818. let i = body.length - 1;
  16819. for (; i >= 0; i--) {
  16820. let bbody = body[i].body;
  16821. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  16822. if (!is_inert_body(body[i])) break;
  16823. }
  16824. // i now points to the index of a branch that contains a body. By incrementing, it's
  16825. // pointing to the first branch that's empty.
  16826. i++;
  16827. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  16828. // The default behavior is to do nothing. We can take advantage of that to
  16829. // remove all case expressions that are side-effect free that also do
  16830. // nothing, since they'll default to doing nothing. But we can't remove any
  16831. // case expressions before one that would side-effect, since they may cause
  16832. // the side-effect to be skipped.
  16833. for (let j = body.length - 1; j >= i; j--) {
  16834. let branch = body[j];
  16835. if (branch === default_or_exact) {
  16836. default_or_exact = null;
  16837. body.pop();
  16838. } else if (!branch.expression.has_side_effects(compressor)) {
  16839. body.pop();
  16840. } else {
  16841. break;
  16842. }
  16843. }
  16844. }
  16845. }
  16846. // Prune side-effect free branches that fall into default.
  16847. DEFAULT: if (default_or_exact) {
  16848. let default_index = body.indexOf(default_or_exact);
  16849. let default_body_index = default_index;
  16850. for (; default_body_index < body.length - 1; default_body_index++) {
  16851. if (!is_inert_body(body[default_body_index])) break;
  16852. }
  16853. if (default_body_index < body.length - 1) {
  16854. break DEFAULT;
  16855. }
  16856. let side_effect_index = body.length - 1;
  16857. for (; side_effect_index >= 0; side_effect_index--) {
  16858. let branch = body[side_effect_index];
  16859. if (branch === default_or_exact) continue;
  16860. if (branch.expression.has_side_effects(compressor)) break;
  16861. }
  16862. // If the default behavior comes after any side-effect case expressions,
  16863. // then we can fold all side-effect free cases into the default branch.
  16864. // If the side-effect case is after the default, then any side-effect
  16865. // free cases could prevent the side-effect from occurring.
  16866. if (default_body_index > side_effect_index) {
  16867. let prev_body_index = default_index - 1;
  16868. for (; prev_body_index >= 0; prev_body_index--) {
  16869. if (!is_inert_body(body[prev_body_index])) break;
  16870. }
  16871. let before = Math.max(side_effect_index, prev_body_index) + 1;
  16872. let after = default_index;
  16873. if (side_effect_index > default_index) {
  16874. // If the default falls into the same body as a side-effect
  16875. // case, then we need preserve that case and only prune the
  16876. // cases after it.
  16877. after = side_effect_index;
  16878. body[side_effect_index].body = body[default_body_index].body;
  16879. } else {
  16880. // The default will be the last branch.
  16881. default_or_exact.body = body[default_body_index].body;
  16882. }
  16883. // Prune everything after the default (or last side-effect case)
  16884. // until the next case with a body.
  16885. body.splice(after + 1, default_body_index - after);
  16886. // Prune everything before the default that falls into it.
  16887. body.splice(before, default_index - before);
  16888. }
  16889. }
  16890. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  16891. DEFAULT: if (default_or_exact) {
  16892. let i = body.findIndex(branch => !is_inert_body(branch));
  16893. let caseBody;
  16894. // `i` is equal to one of the following:
  16895. // - `-1`, there is no body in the switch statement.
  16896. // - `body.length - 1`, all cases fall into the same body.
  16897. // - anything else, there are multiple bodies in the switch.
  16898. if (i === body.length - 1) {
  16899. // All cases fall into the case body.
  16900. let branch = body[i];
  16901. if (has_nested_break(self)) break DEFAULT;
  16902. // This is the last case body, and we've already pruned any breaks, so it's
  16903. // safe to hoist.
  16904. caseBody = make_node(AST_BlockStatement, branch, {
  16905. body: branch.body
  16906. });
  16907. branch.body = [];
  16908. } else if (i !== -1) {
  16909. // If there are multiple bodies, then we cannot optimize anything.
  16910. break DEFAULT;
  16911. }
  16912. let sideEffect = body.find(branch => {
  16913. return (
  16914. branch !== default_or_exact
  16915. && branch.expression.has_side_effects(compressor)
  16916. );
  16917. });
  16918. // If no cases cause a side-effect, we can eliminate the switch entirely.
  16919. if (!sideEffect) {
  16920. return make_node(AST_BlockStatement, self, {
  16921. body: decl.concat(
  16922. statement(self.expression),
  16923. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  16924. caseBody || []
  16925. )
  16926. }).optimize(compressor);
  16927. }
  16928. // If we're this far, either there was no body or all cases fell into the same body.
  16929. // If there was no body, then we don't need a default branch (because the default is
  16930. // do nothing). If there was a body, we'll extract it to after the switch, so the
  16931. // switch's new default is to do nothing and we can still prune it.
  16932. const default_index = body.indexOf(default_or_exact);
  16933. body.splice(default_index, 1);
  16934. default_or_exact = null;
  16935. if (caseBody) {
  16936. // Recurse into switch statement one more time so that we can append the case body
  16937. // outside of the switch. This recursion will only happen once since we've pruned
  16938. // the default case.
  16939. return make_node(AST_BlockStatement, self, {
  16940. body: decl.concat(self, caseBody)
  16941. }).optimize(compressor);
  16942. }
  16943. // If we fall here, there is a default branch somewhere, there are no case bodies,
  16944. // and there's a side-effect somewhere. Just let the below paths take care of it.
  16945. }
  16946. if (body.length > 0) {
  16947. body[0].body = decl.concat(body[0].body);
  16948. }
  16949. if (body.length == 0) {
  16950. return make_node(AST_BlockStatement, self, {
  16951. body: decl.concat(statement(self.expression))
  16952. }).optimize(compressor);
  16953. }
  16954. if (body.length == 1 && !has_nested_break(self)) {
  16955. // This is the last case body, and we've already pruned any breaks, so it's
  16956. // safe to hoist.
  16957. let branch = body[0];
  16958. return make_node(AST_If, self, {
  16959. condition: make_node(AST_Binary, self, {
  16960. operator: "===",
  16961. left: self.expression,
  16962. right: branch.expression,
  16963. }),
  16964. body: make_node(AST_BlockStatement, branch, {
  16965. body: branch.body
  16966. }),
  16967. alternative: null
  16968. }).optimize(compressor);
  16969. }
  16970. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  16971. let branch = body[0] === default_or_exact ? body[1] : body[0];
  16972. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  16973. if (aborts(body[0])) {
  16974. // Only the first branch body could have a break (at the last statement)
  16975. let first = body[0];
  16976. if (is_break(first.body[first.body.length - 1], compressor)) {
  16977. first.body.pop();
  16978. }
  16979. return make_node(AST_If, self, {
  16980. condition: make_node(AST_Binary, self, {
  16981. operator: "===",
  16982. left: self.expression,
  16983. right: branch.expression,
  16984. }),
  16985. body: make_node(AST_BlockStatement, branch, {
  16986. body: branch.body
  16987. }),
  16988. alternative: make_node(AST_BlockStatement, default_or_exact, {
  16989. body: [].concat(
  16990. exact_exp || [],
  16991. default_or_exact.body
  16992. )
  16993. })
  16994. }).optimize(compressor);
  16995. }
  16996. let operator = "===";
  16997. let consequent = make_node(AST_BlockStatement, branch, {
  16998. body: branch.body,
  16999. });
  17000. let always = make_node(AST_BlockStatement, default_or_exact, {
  17001. body: [].concat(
  17002. exact_exp || [],
  17003. default_or_exact.body
  17004. )
  17005. });
  17006. if (body[0] === default_or_exact) {
  17007. operator = "!==";
  17008. let tmp = always;
  17009. always = consequent;
  17010. consequent = tmp;
  17011. }
  17012. return make_node(AST_BlockStatement, self, {
  17013. body: [
  17014. make_node(AST_If, self, {
  17015. condition: make_node(AST_Binary, self, {
  17016. operator: operator,
  17017. left: self.expression,
  17018. right: branch.expression,
  17019. }),
  17020. body: consequent,
  17021. alternative: null
  17022. })
  17023. ].concat(always)
  17024. }).optimize(compressor);
  17025. }
  17026. return self;
  17027. function eliminate_branch(branch, prev) {
  17028. if (prev && !aborts(prev)) {
  17029. prev.body = prev.body.concat(branch.body);
  17030. } else {
  17031. trim_unreachable_code(compressor, branch, decl);
  17032. }
  17033. }
  17034. function branches_equivalent(branch, prev, insertBreak) {
  17035. let bbody = branch.body;
  17036. let pbody = prev.body;
  17037. if (insertBreak) {
  17038. bbody = bbody.concat(make_node(AST_Break));
  17039. }
  17040. if (bbody.length !== pbody.length) return false;
  17041. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  17042. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  17043. return bblock.equivalent_to(pblock);
  17044. }
  17045. function statement(expression) {
  17046. return make_node(AST_SimpleStatement, expression, {
  17047. body: expression
  17048. });
  17049. }
  17050. function has_nested_break(root) {
  17051. let has_break = false;
  17052. let tw = new TreeWalker(node => {
  17053. if (has_break) return true;
  17054. if (node instanceof AST_Lambda) return true;
  17055. if (node instanceof AST_SimpleStatement) return true;
  17056. if (!is_break(node, tw)) return;
  17057. let parent = tw.parent();
  17058. if (
  17059. parent instanceof AST_SwitchBranch
  17060. && parent.body[parent.body.length - 1] === node
  17061. ) {
  17062. return;
  17063. }
  17064. has_break = true;
  17065. });
  17066. root.walk(tw);
  17067. return has_break;
  17068. }
  17069. function is_break(node, stack) {
  17070. return node instanceof AST_Break
  17071. && stack.loopcontrol_target(node) === self;
  17072. }
  17073. function is_inert_body(branch) {
  17074. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  17075. body: branch.body
  17076. }).has_side_effects(compressor);
  17077. }
  17078. });
  17079. def_optimize(AST_Try, function(self, compressor) {
  17080. tighten_body(self.body, compressor);
  17081. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  17082. if (compressor.option("dead_code") && self.body.every(is_empty)) {
  17083. var body = [];
  17084. if (self.bcatch) {
  17085. trim_unreachable_code(compressor, self.bcatch, body);
  17086. }
  17087. if (self.bfinally) body.push(...self.bfinally.body);
  17088. return make_node(AST_BlockStatement, self, {
  17089. body: body
  17090. }).optimize(compressor);
  17091. }
  17092. return self;
  17093. });
  17094. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  17095. var decls = [];
  17096. this.definitions.forEach(function(def) {
  17097. if (def.name instanceof AST_SymbolDeclaration) {
  17098. def.value = null;
  17099. decls.push(def);
  17100. } else {
  17101. walk(def.name, node => {
  17102. if (node instanceof AST_SymbolDeclaration) {
  17103. decls.push(make_node(AST_VarDef, def, {
  17104. name: node,
  17105. value: null
  17106. }));
  17107. }
  17108. });
  17109. }
  17110. });
  17111. this.definitions = decls;
  17112. });
  17113. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  17114. var reduce_vars = compressor.option("reduce_vars");
  17115. var assignments = [];
  17116. for (const def of this.definitions) {
  17117. if (def.value) {
  17118. var name = make_node(AST_SymbolRef, def.name, def.name);
  17119. assignments.push(make_node(AST_Assign, def, {
  17120. operator : "=",
  17121. logical: false,
  17122. left : name,
  17123. right : def.value
  17124. }));
  17125. if (reduce_vars) name.definition().fixed = false;
  17126. } else if (def.value) {
  17127. // Because it's a destructuring, do not turn into an assignment.
  17128. var varDef = make_node(AST_VarDef, def, {
  17129. name: def.name,
  17130. value: def.value
  17131. });
  17132. var var_ = make_node(AST_Var, def, {
  17133. definitions: [ varDef ]
  17134. });
  17135. assignments.push(var_);
  17136. }
  17137. const thedef = def.name.definition();
  17138. thedef.eliminated++;
  17139. thedef.replaced--;
  17140. }
  17141. if (assignments.length == 0) return null;
  17142. return make_sequence(this, assignments);
  17143. });
  17144. def_optimize(AST_Definitions, function(self) {
  17145. if (self.definitions.length == 0)
  17146. return make_node(AST_EmptyStatement, self);
  17147. return self;
  17148. });
  17149. def_optimize(AST_VarDef, function(self, compressor) {
  17150. if (
  17151. self.name instanceof AST_SymbolLet
  17152. && self.value != null
  17153. && is_undefined(self.value, compressor)
  17154. ) {
  17155. self.value = null;
  17156. }
  17157. return self;
  17158. });
  17159. def_optimize(AST_Import, function(self) {
  17160. return self;
  17161. });
  17162. def_optimize(AST_Call, function(self, compressor) {
  17163. var exp = self.expression;
  17164. var fn = exp;
  17165. inline_array_like_spread(self.args);
  17166. var simple_args = self.args.every((arg) =>
  17167. !(arg instanceof AST_Expansion)
  17168. );
  17169. if (compressor.option("reduce_vars")
  17170. && fn instanceof AST_SymbolRef
  17171. && !has_annotation(self, _NOINLINE)
  17172. ) {
  17173. const fixed = fn.fixed_value();
  17174. if (!retain_top_func(fixed, compressor)) {
  17175. fn = fixed;
  17176. }
  17177. }
  17178. var is_func = fn instanceof AST_Lambda;
  17179. if (is_func && fn.pinned()) return self;
  17180. if (compressor.option("unused")
  17181. && simple_args
  17182. && is_func
  17183. && !fn.uses_arguments) {
  17184. var pos = 0, last = 0;
  17185. for (var i = 0, len = self.args.length; i < len; i++) {
  17186. if (fn.argnames[i] instanceof AST_Expansion) {
  17187. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  17188. var node = self.args[i++].drop_side_effect_free(compressor);
  17189. if (node) {
  17190. self.args[pos++] = node;
  17191. }
  17192. } else while (i < len) {
  17193. self.args[pos++] = self.args[i++];
  17194. }
  17195. last = pos;
  17196. break;
  17197. }
  17198. var trim = i >= fn.argnames.length;
  17199. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  17200. var node = self.args[i].drop_side_effect_free(compressor);
  17201. if (node) {
  17202. self.args[pos++] = node;
  17203. } else if (!trim) {
  17204. self.args[pos++] = make_node(AST_Number, self.args[i], {
  17205. value: 0
  17206. });
  17207. continue;
  17208. }
  17209. } else {
  17210. self.args[pos++] = self.args[i];
  17211. }
  17212. last = pos;
  17213. }
  17214. self.args.length = last;
  17215. }
  17216. if (compressor.option("unsafe")) {
  17217. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  17218. const [argument] = self.args;
  17219. if (argument instanceof AST_Array) {
  17220. return make_node(AST_Array, argument, {
  17221. elements: argument.elements
  17222. }).optimize(compressor);
  17223. }
  17224. }
  17225. if (is_undeclared_ref(exp)) switch (exp.name) {
  17226. case "Array":
  17227. if (self.args.length != 1) {
  17228. return make_node(AST_Array, self, {
  17229. elements: self.args
  17230. }).optimize(compressor);
  17231. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  17232. const elements = [];
  17233. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  17234. return new AST_Array({ elements });
  17235. }
  17236. break;
  17237. case "Object":
  17238. if (self.args.length == 0) {
  17239. return make_node(AST_Object, self, {
  17240. properties: []
  17241. });
  17242. }
  17243. break;
  17244. case "String":
  17245. if (self.args.length == 0) return make_node(AST_String, self, {
  17246. value: ""
  17247. });
  17248. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  17249. left: self.args[0],
  17250. operator: "+",
  17251. right: make_node(AST_String, self, { value: "" })
  17252. }).optimize(compressor);
  17253. break;
  17254. case "Number":
  17255. if (self.args.length == 0) return make_node(AST_Number, self, {
  17256. value: 0
  17257. });
  17258. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  17259. return make_node(AST_UnaryPrefix, self, {
  17260. expression: self.args[0],
  17261. operator: "+"
  17262. }).optimize(compressor);
  17263. }
  17264. break;
  17265. case "Symbol":
  17266. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  17267. self.args.length = 0;
  17268. break;
  17269. case "Boolean":
  17270. if (self.args.length == 0) return make_node(AST_False, self);
  17271. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  17272. expression: make_node(AST_UnaryPrefix, self, {
  17273. expression: self.args[0],
  17274. operator: "!"
  17275. }),
  17276. operator: "!"
  17277. }).optimize(compressor);
  17278. break;
  17279. case "RegExp":
  17280. var params = [];
  17281. if (self.args.length >= 1
  17282. && self.args.length <= 2
  17283. && self.args.every((arg) => {
  17284. var value = arg.evaluate(compressor);
  17285. params.push(value);
  17286. return arg !== value;
  17287. })
  17288. && regexp_is_safe(params[0])
  17289. ) {
  17290. let [ source, flags ] = params;
  17291. source = regexp_source_fix(new RegExp(source).source);
  17292. const rx = make_node(AST_RegExp, self, {
  17293. value: { source, flags }
  17294. });
  17295. if (rx._eval(compressor) !== rx) {
  17296. return rx;
  17297. }
  17298. }
  17299. break;
  17300. } else if (exp instanceof AST_Dot) switch(exp.property) {
  17301. case "toString":
  17302. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  17303. return make_node(AST_Binary, self, {
  17304. left: make_node(AST_String, self, { value: "" }),
  17305. operator: "+",
  17306. right: exp.expression
  17307. }).optimize(compressor);
  17308. }
  17309. break;
  17310. case "join":
  17311. if (exp.expression instanceof AST_Array) EXIT: {
  17312. var separator;
  17313. if (self.args.length > 0) {
  17314. separator = self.args[0].evaluate(compressor);
  17315. if (separator === self.args[0]) break EXIT; // not a constant
  17316. }
  17317. var elements = [];
  17318. var consts = [];
  17319. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  17320. var el = exp.expression.elements[i];
  17321. if (el instanceof AST_Expansion) break EXIT;
  17322. var value = el.evaluate(compressor);
  17323. if (value !== el) {
  17324. consts.push(value);
  17325. } else {
  17326. if (consts.length > 0) {
  17327. elements.push(make_node(AST_String, self, {
  17328. value: consts.join(separator)
  17329. }));
  17330. consts.length = 0;
  17331. }
  17332. elements.push(el);
  17333. }
  17334. }
  17335. if (consts.length > 0) {
  17336. elements.push(make_node(AST_String, self, {
  17337. value: consts.join(separator)
  17338. }));
  17339. }
  17340. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  17341. if (elements.length == 1) {
  17342. if (elements[0].is_string(compressor)) {
  17343. return elements[0];
  17344. }
  17345. return make_node(AST_Binary, elements[0], {
  17346. operator : "+",
  17347. left : make_node(AST_String, self, { value: "" }),
  17348. right : elements[0]
  17349. });
  17350. }
  17351. if (separator == "") {
  17352. var first;
  17353. if (elements[0].is_string(compressor)
  17354. || elements[1].is_string(compressor)) {
  17355. first = elements.shift();
  17356. } else {
  17357. first = make_node(AST_String, self, { value: "" });
  17358. }
  17359. return elements.reduce(function(prev, el) {
  17360. return make_node(AST_Binary, el, {
  17361. operator : "+",
  17362. left : prev,
  17363. right : el
  17364. });
  17365. }, first).optimize(compressor);
  17366. }
  17367. // need this awkward cloning to not affect original element
  17368. // best_of will decide which one to get through.
  17369. var node = self.clone();
  17370. node.expression = node.expression.clone();
  17371. node.expression.expression = node.expression.expression.clone();
  17372. node.expression.expression.elements = elements;
  17373. return best_of(compressor, self, node);
  17374. }
  17375. break;
  17376. case "charAt":
  17377. if (exp.expression.is_string(compressor)) {
  17378. var arg = self.args[0];
  17379. var index = arg ? arg.evaluate(compressor) : 0;
  17380. if (index !== arg) {
  17381. return make_node(AST_Sub, exp, {
  17382. expression: exp.expression,
  17383. property: make_node_from_constant(index | 0, arg || exp)
  17384. }).optimize(compressor);
  17385. }
  17386. }
  17387. break;
  17388. case "apply":
  17389. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  17390. var args = self.args[1].elements.slice();
  17391. args.unshift(self.args[0]);
  17392. return make_node(AST_Call, self, {
  17393. expression: make_node(AST_Dot, exp, {
  17394. expression: exp.expression,
  17395. optional: false,
  17396. property: "call"
  17397. }),
  17398. args: args
  17399. }).optimize(compressor);
  17400. }
  17401. break;
  17402. case "call":
  17403. var func = exp.expression;
  17404. if (func instanceof AST_SymbolRef) {
  17405. func = func.fixed_value();
  17406. }
  17407. if (func instanceof AST_Lambda && !func.contains_this()) {
  17408. return (self.args.length ? make_sequence(this, [
  17409. self.args[0],
  17410. make_node(AST_Call, self, {
  17411. expression: exp.expression,
  17412. args: self.args.slice(1)
  17413. })
  17414. ]) : make_node(AST_Call, self, {
  17415. expression: exp.expression,
  17416. args: []
  17417. })).optimize(compressor);
  17418. }
  17419. break;
  17420. }
  17421. }
  17422. if (compressor.option("unsafe_Function")
  17423. && is_undeclared_ref(exp)
  17424. && exp.name == "Function") {
  17425. // new Function() => function(){}
  17426. if (self.args.length == 0) return make_node(AST_Function, self, {
  17427. argnames: [],
  17428. body: []
  17429. }).optimize(compressor);
  17430. var nth_identifier = compressor.mangle_options && compressor.mangle_options.nth_identifier || base54;
  17431. if (self.args.every((x) => x instanceof AST_String)) {
  17432. // quite a corner-case, but we can handle it:
  17433. // https://github.com/mishoo/UglifyJS2/issues/203
  17434. // if the code argument is a constant, then we can minify it.
  17435. try {
  17436. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  17437. return arg.value;
  17438. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  17439. var ast = parse(code);
  17440. var mangle = { ie8: compressor.option("ie8"), nth_identifier: nth_identifier };
  17441. ast.figure_out_scope(mangle);
  17442. var comp = new Compressor(compressor.options, {
  17443. mangle_options: compressor.mangle_options
  17444. });
  17445. ast = ast.transform(comp);
  17446. ast.figure_out_scope(mangle);
  17447. ast.compute_char_frequency(mangle);
  17448. ast.mangle_names(mangle);
  17449. var fun;
  17450. walk(ast, node => {
  17451. if (is_func_expr(node)) {
  17452. fun = node;
  17453. return walk_abort;
  17454. }
  17455. });
  17456. var code = OutputStream();
  17457. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  17458. self.args = [
  17459. make_node(AST_String, self, {
  17460. value: fun.argnames.map(function(arg) {
  17461. return arg.print_to_string();
  17462. }).join(",")
  17463. }),
  17464. make_node(AST_String, self.args[self.args.length - 1], {
  17465. value: code.get().replace(/^{|}$/g, "")
  17466. })
  17467. ];
  17468. return self;
  17469. } catch (ex) {
  17470. if (!(ex instanceof JS_Parse_Error)) {
  17471. throw ex;
  17472. }
  17473. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  17474. }
  17475. }
  17476. }
  17477. return inline_into_call(self, fn, compressor);
  17478. });
  17479. def_optimize(AST_New, function(self, compressor) {
  17480. if (
  17481. compressor.option("unsafe") &&
  17482. is_undeclared_ref(self.expression) &&
  17483. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  17484. ) return make_node(AST_Call, self, self).transform(compressor);
  17485. return self;
  17486. });
  17487. def_optimize(AST_Sequence, function(self, compressor) {
  17488. if (!compressor.option("side_effects")) return self;
  17489. var expressions = [];
  17490. filter_for_side_effects();
  17491. var end = expressions.length - 1;
  17492. trim_right_for_undefined();
  17493. if (end == 0) {
  17494. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  17495. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  17496. return self;
  17497. }
  17498. self.expressions = expressions;
  17499. return self;
  17500. function filter_for_side_effects() {
  17501. var first = first_in_statement(compressor);
  17502. var last = self.expressions.length - 1;
  17503. self.expressions.forEach(function(expr, index) {
  17504. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  17505. if (expr) {
  17506. merge_sequence(expressions, expr);
  17507. first = false;
  17508. }
  17509. });
  17510. }
  17511. function trim_right_for_undefined() {
  17512. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  17513. if (end < expressions.length - 1) {
  17514. expressions[end] = make_node(AST_UnaryPrefix, self, {
  17515. operator : "void",
  17516. expression : expressions[end]
  17517. });
  17518. expressions.length = end + 1;
  17519. }
  17520. }
  17521. });
  17522. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  17523. if (compressor.option("sequences")) {
  17524. if (this.expression instanceof AST_Sequence) {
  17525. var x = this.expression.expressions.slice();
  17526. var e = this.clone();
  17527. e.expression = x.pop();
  17528. x.push(e);
  17529. return make_sequence(this, x).optimize(compressor);
  17530. }
  17531. }
  17532. return this;
  17533. });
  17534. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  17535. return self.lift_sequences(compressor);
  17536. });
  17537. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  17538. var e = self.expression;
  17539. if (
  17540. self.operator == "delete" &&
  17541. !(
  17542. e instanceof AST_SymbolRef ||
  17543. e instanceof AST_PropAccess ||
  17544. e instanceof AST_Chain ||
  17545. is_identifier_atom(e)
  17546. )
  17547. ) {
  17548. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  17549. }
  17550. var seq = self.lift_sequences(compressor);
  17551. if (seq !== self) {
  17552. return seq;
  17553. }
  17554. if (compressor.option("side_effects") && self.operator == "void") {
  17555. e = e.drop_side_effect_free(compressor);
  17556. if (e) {
  17557. self.expression = e;
  17558. return self;
  17559. } else {
  17560. return make_node(AST_Undefined, self).optimize(compressor);
  17561. }
  17562. }
  17563. if (compressor.in_boolean_context()) {
  17564. switch (self.operator) {
  17565. case "!":
  17566. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  17567. // !!foo ==> foo, if we're in boolean context
  17568. return e.expression;
  17569. }
  17570. if (e instanceof AST_Binary) {
  17571. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  17572. }
  17573. break;
  17574. case "typeof":
  17575. // typeof always returns a non-empty string, thus it's
  17576. // always true in booleans
  17577. // And we don't need to check if it's undeclared, because in typeof, that's OK
  17578. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  17579. e,
  17580. make_node(AST_True, self)
  17581. ])).optimize(compressor);
  17582. }
  17583. }
  17584. if (self.operator == "-" && e instanceof AST_Infinity) {
  17585. e = e.transform(compressor);
  17586. }
  17587. if (e instanceof AST_Binary
  17588. && (self.operator == "+" || self.operator == "-")
  17589. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  17590. return make_node(AST_Binary, self, {
  17591. operator: e.operator,
  17592. left: make_node(AST_UnaryPrefix, e.left, {
  17593. operator: self.operator,
  17594. expression: e.left
  17595. }),
  17596. right: e.right
  17597. });
  17598. }
  17599. // avoids infinite recursion of numerals
  17600. if (self.operator != "-"
  17601. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)) {
  17602. var ev = self.evaluate(compressor);
  17603. if (ev !== self) {
  17604. ev = make_node_from_constant(ev, self).optimize(compressor);
  17605. return best_of(compressor, ev, self);
  17606. }
  17607. }
  17608. return self;
  17609. });
  17610. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  17611. if (compressor.option("sequences")) {
  17612. if (this.left instanceof AST_Sequence) {
  17613. var x = this.left.expressions.slice();
  17614. var e = this.clone();
  17615. e.left = x.pop();
  17616. x.push(e);
  17617. return make_sequence(this, x).optimize(compressor);
  17618. }
  17619. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  17620. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  17621. var x = this.right.expressions;
  17622. var last = x.length - 1;
  17623. for (var i = 0; i < last; i++) {
  17624. if (!assign && x[i].has_side_effects(compressor)) break;
  17625. }
  17626. if (i == last) {
  17627. x = x.slice();
  17628. var e = this.clone();
  17629. e.right = x.pop();
  17630. x.push(e);
  17631. return make_sequence(this, x).optimize(compressor);
  17632. } else if (i > 0) {
  17633. var e = this.clone();
  17634. e.right = make_sequence(this.right, x.slice(i));
  17635. x = x.slice(0, i);
  17636. x.push(e);
  17637. return make_sequence(this, x).optimize(compressor);
  17638. }
  17639. }
  17640. }
  17641. return this;
  17642. });
  17643. var commutativeOperators = makePredicate("== === != !== * & | ^");
  17644. function is_object(node) {
  17645. return node instanceof AST_Array
  17646. || node instanceof AST_Lambda
  17647. || node instanceof AST_Object
  17648. || node instanceof AST_Class;
  17649. }
  17650. def_optimize(AST_Binary, function(self, compressor) {
  17651. function reversible() {
  17652. return self.left.is_constant()
  17653. || self.right.is_constant()
  17654. || !self.left.has_side_effects(compressor)
  17655. && !self.right.has_side_effects(compressor);
  17656. }
  17657. function reverse(op) {
  17658. if (reversible()) {
  17659. if (op) self.operator = op;
  17660. var tmp = self.left;
  17661. self.left = self.right;
  17662. self.right = tmp;
  17663. }
  17664. }
  17665. if (commutativeOperators.has(self.operator)) {
  17666. if (self.right.is_constant()
  17667. && !self.left.is_constant()) {
  17668. // if right is a constant, whatever side effects the
  17669. // left side might have could not influence the
  17670. // result. hence, force switch.
  17671. if (!(self.left instanceof AST_Binary
  17672. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  17673. reverse();
  17674. }
  17675. }
  17676. }
  17677. self = self.lift_sequences(compressor);
  17678. if (compressor.option("comparisons")) switch (self.operator) {
  17679. case "===":
  17680. case "!==":
  17681. var is_strict_comparison = true;
  17682. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  17683. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  17684. (self.left.is_boolean() && self.right.is_boolean()) ||
  17685. self.left.equivalent_to(self.right)) {
  17686. self.operator = self.operator.substr(0, 2);
  17687. }
  17688. // XXX: intentionally falling down to the next case
  17689. case "==":
  17690. case "!=":
  17691. // void 0 == x => null == x
  17692. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  17693. self.left = make_node(AST_Null, self.left);
  17694. } else if (compressor.option("typeofs")
  17695. // "undefined" == typeof x => undefined === x
  17696. && self.left instanceof AST_String
  17697. && self.left.value == "undefined"
  17698. && self.right instanceof AST_UnaryPrefix
  17699. && self.right.operator == "typeof") {
  17700. var expr = self.right.expression;
  17701. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  17702. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  17703. self.right = expr;
  17704. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  17705. if (self.operator.length == 2) self.operator += "=";
  17706. }
  17707. } else if (self.left instanceof AST_SymbolRef
  17708. // obj !== obj => false
  17709. && self.right instanceof AST_SymbolRef
  17710. && self.left.definition() === self.right.definition()
  17711. && is_object(self.left.fixed_value())) {
  17712. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  17713. }
  17714. break;
  17715. case "&&":
  17716. case "||":
  17717. var lhs = self.left;
  17718. if (lhs.operator == self.operator) {
  17719. lhs = lhs.right;
  17720. }
  17721. if (lhs instanceof AST_Binary
  17722. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  17723. && self.right instanceof AST_Binary
  17724. && lhs.operator == self.right.operator
  17725. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  17726. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  17727. && !lhs.right.has_side_effects(compressor)
  17728. && lhs.right.equivalent_to(self.right.right)) {
  17729. var combined = make_node(AST_Binary, self, {
  17730. operator: lhs.operator.slice(0, -1),
  17731. left: make_node(AST_Null, self),
  17732. right: lhs.right
  17733. });
  17734. if (lhs !== self.left) {
  17735. combined = make_node(AST_Binary, self, {
  17736. operator: self.operator,
  17737. left: self.left.left,
  17738. right: combined
  17739. });
  17740. }
  17741. return combined;
  17742. }
  17743. break;
  17744. }
  17745. if (self.operator == "+" && compressor.in_boolean_context()) {
  17746. var ll = self.left.evaluate(compressor);
  17747. var rr = self.right.evaluate(compressor);
  17748. if (ll && typeof ll == "string") {
  17749. return make_sequence(self, [
  17750. self.right,
  17751. make_node(AST_True, self)
  17752. ]).optimize(compressor);
  17753. }
  17754. if (rr && typeof rr == "string") {
  17755. return make_sequence(self, [
  17756. self.left,
  17757. make_node(AST_True, self)
  17758. ]).optimize(compressor);
  17759. }
  17760. }
  17761. if (compressor.option("comparisons") && self.is_boolean()) {
  17762. if (!(compressor.parent() instanceof AST_Binary)
  17763. || compressor.parent() instanceof AST_Assign) {
  17764. var negated = make_node(AST_UnaryPrefix, self, {
  17765. operator: "!",
  17766. expression: self.negate(compressor, first_in_statement(compressor))
  17767. });
  17768. self = best_of(compressor, self, negated);
  17769. }
  17770. if (compressor.option("unsafe_comps")) {
  17771. switch (self.operator) {
  17772. case "<": reverse(">"); break;
  17773. case "<=": reverse(">="); break;
  17774. }
  17775. }
  17776. }
  17777. if (self.operator == "+") {
  17778. if (self.right instanceof AST_String
  17779. && self.right.getValue() == ""
  17780. && self.left.is_string(compressor)) {
  17781. return self.left;
  17782. }
  17783. if (self.left instanceof AST_String
  17784. && self.left.getValue() == ""
  17785. && self.right.is_string(compressor)) {
  17786. return self.right;
  17787. }
  17788. if (self.left instanceof AST_Binary
  17789. && self.left.operator == "+"
  17790. && self.left.left instanceof AST_String
  17791. && self.left.left.getValue() == ""
  17792. && self.right.is_string(compressor)) {
  17793. self.left = self.left.right;
  17794. return self;
  17795. }
  17796. }
  17797. if (compressor.option("evaluate")) {
  17798. switch (self.operator) {
  17799. case "&&":
  17800. var ll = has_flag(self.left, TRUTHY)
  17801. ? true
  17802. : has_flag(self.left, FALSY)
  17803. ? false
  17804. : self.left.evaluate(compressor);
  17805. if (!ll) {
  17806. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  17807. } else if (!(ll instanceof AST_Node)) {
  17808. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  17809. }
  17810. var rr = self.right.evaluate(compressor);
  17811. if (!rr) {
  17812. if (compressor.in_boolean_context()) {
  17813. return make_sequence(self, [
  17814. self.left,
  17815. make_node(AST_False, self)
  17816. ]).optimize(compressor);
  17817. } else {
  17818. set_flag(self, FALSY);
  17819. }
  17820. } else if (!(rr instanceof AST_Node)) {
  17821. var parent = compressor.parent();
  17822. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  17823. return self.left.optimize(compressor);
  17824. }
  17825. }
  17826. // x || false && y ---> x ? y : false
  17827. if (self.left.operator == "||") {
  17828. var lr = self.left.right.evaluate(compressor);
  17829. if (!lr) return make_node(AST_Conditional, self, {
  17830. condition: self.left.left,
  17831. consequent: self.right,
  17832. alternative: self.left.right
  17833. }).optimize(compressor);
  17834. }
  17835. break;
  17836. case "||":
  17837. var ll = has_flag(self.left, TRUTHY)
  17838. ? true
  17839. : has_flag(self.left, FALSY)
  17840. ? false
  17841. : self.left.evaluate(compressor);
  17842. if (!ll) {
  17843. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  17844. } else if (!(ll instanceof AST_Node)) {
  17845. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  17846. }
  17847. var rr = self.right.evaluate(compressor);
  17848. if (!rr) {
  17849. var parent = compressor.parent();
  17850. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  17851. return self.left.optimize(compressor);
  17852. }
  17853. } else if (!(rr instanceof AST_Node)) {
  17854. if (compressor.in_boolean_context()) {
  17855. return make_sequence(self, [
  17856. self.left,
  17857. make_node(AST_True, self)
  17858. ]).optimize(compressor);
  17859. } else {
  17860. set_flag(self, TRUTHY);
  17861. }
  17862. }
  17863. if (self.left.operator == "&&") {
  17864. var lr = self.left.right.evaluate(compressor);
  17865. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  17866. condition: self.left.left,
  17867. consequent: self.left.right,
  17868. alternative: self.right
  17869. }).optimize(compressor);
  17870. }
  17871. break;
  17872. case "??":
  17873. if (is_nullish(self.left, compressor)) {
  17874. return self.right;
  17875. }
  17876. var ll = self.left.evaluate(compressor);
  17877. if (!(ll instanceof AST_Node)) {
  17878. // if we know the value for sure we can simply compute right away.
  17879. return ll == null ? self.right : self.left;
  17880. }
  17881. if (compressor.in_boolean_context()) {
  17882. const rr = self.right.evaluate(compressor);
  17883. if (!(rr instanceof AST_Node) && !rr) {
  17884. return self.left;
  17885. }
  17886. }
  17887. }
  17888. var associative = true;
  17889. switch (self.operator) {
  17890. case "+":
  17891. // (x + "foo") + "bar" => x + "foobar"
  17892. if (self.right instanceof AST_Constant
  17893. && self.left instanceof AST_Binary
  17894. && self.left.operator == "+"
  17895. && self.left.is_string(compressor)) {
  17896. var binary = make_node(AST_Binary, self, {
  17897. operator: "+",
  17898. left: self.left.right,
  17899. right: self.right,
  17900. });
  17901. var r = binary.optimize(compressor);
  17902. if (binary !== r) {
  17903. self = make_node(AST_Binary, self, {
  17904. operator: "+",
  17905. left: self.left.left,
  17906. right: r
  17907. });
  17908. }
  17909. }
  17910. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  17911. if (self.left instanceof AST_Binary
  17912. && self.left.operator == "+"
  17913. && self.left.is_string(compressor)
  17914. && self.right instanceof AST_Binary
  17915. && self.right.operator == "+"
  17916. && self.right.is_string(compressor)) {
  17917. var binary = make_node(AST_Binary, self, {
  17918. operator: "+",
  17919. left: self.left.right,
  17920. right: self.right.left,
  17921. });
  17922. var m = binary.optimize(compressor);
  17923. if (binary !== m) {
  17924. self = make_node(AST_Binary, self, {
  17925. operator: "+",
  17926. left: make_node(AST_Binary, self.left, {
  17927. operator: "+",
  17928. left: self.left.left,
  17929. right: m
  17930. }),
  17931. right: self.right.right
  17932. });
  17933. }
  17934. }
  17935. // a + -b => a - b
  17936. if (self.right instanceof AST_UnaryPrefix
  17937. && self.right.operator == "-"
  17938. && self.left.is_number(compressor)) {
  17939. self = make_node(AST_Binary, self, {
  17940. operator: "-",
  17941. left: self.left,
  17942. right: self.right.expression
  17943. });
  17944. break;
  17945. }
  17946. // -a + b => b - a
  17947. if (self.left instanceof AST_UnaryPrefix
  17948. && self.left.operator == "-"
  17949. && reversible()
  17950. && self.right.is_number(compressor)) {
  17951. self = make_node(AST_Binary, self, {
  17952. operator: "-",
  17953. left: self.right,
  17954. right: self.left.expression
  17955. });
  17956. break;
  17957. }
  17958. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  17959. if (self.left instanceof AST_TemplateString) {
  17960. var l = self.left;
  17961. var r = self.right.evaluate(compressor);
  17962. if (r != self.right) {
  17963. l.segments[l.segments.length - 1].value += String(r);
  17964. return l;
  17965. }
  17966. }
  17967. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  17968. if (self.right instanceof AST_TemplateString) {
  17969. var r = self.right;
  17970. var l = self.left.evaluate(compressor);
  17971. if (l != self.left) {
  17972. r.segments[0].value = String(l) + r.segments[0].value;
  17973. return r;
  17974. }
  17975. }
  17976. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  17977. if (self.left instanceof AST_TemplateString
  17978. && self.right instanceof AST_TemplateString) {
  17979. var l = self.left;
  17980. var segments = l.segments;
  17981. var r = self.right;
  17982. segments[segments.length - 1].value += r.segments[0].value;
  17983. for (var i = 1; i < r.segments.length; i++) {
  17984. segments.push(r.segments[i]);
  17985. }
  17986. return l;
  17987. }
  17988. case "*":
  17989. associative = compressor.option("unsafe_math");
  17990. case "&":
  17991. case "|":
  17992. case "^":
  17993. // a + +b => +b + a
  17994. if (self.left.is_number(compressor)
  17995. && self.right.is_number(compressor)
  17996. && reversible()
  17997. && !(self.left instanceof AST_Binary
  17998. && self.left.operator != self.operator
  17999. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  18000. var reversed = make_node(AST_Binary, self, {
  18001. operator: self.operator,
  18002. left: self.right,
  18003. right: self.left
  18004. });
  18005. if (self.right instanceof AST_Constant
  18006. && !(self.left instanceof AST_Constant)) {
  18007. self = best_of(compressor, reversed, self);
  18008. } else {
  18009. self = best_of(compressor, self, reversed);
  18010. }
  18011. }
  18012. if (associative && self.is_number(compressor)) {
  18013. // a + (b + c) => (a + b) + c
  18014. if (self.right instanceof AST_Binary
  18015. && self.right.operator == self.operator) {
  18016. self = make_node(AST_Binary, self, {
  18017. operator: self.operator,
  18018. left: make_node(AST_Binary, self.left, {
  18019. operator: self.operator,
  18020. left: self.left,
  18021. right: self.right.left,
  18022. start: self.left.start,
  18023. end: self.right.left.end
  18024. }),
  18025. right: self.right.right
  18026. });
  18027. }
  18028. // (n + 2) + 3 => 5 + n
  18029. // (2 * n) * 3 => 6 + n
  18030. if (self.right instanceof AST_Constant
  18031. && self.left instanceof AST_Binary
  18032. && self.left.operator == self.operator) {
  18033. if (self.left.left instanceof AST_Constant) {
  18034. self = make_node(AST_Binary, self, {
  18035. operator: self.operator,
  18036. left: make_node(AST_Binary, self.left, {
  18037. operator: self.operator,
  18038. left: self.left.left,
  18039. right: self.right,
  18040. start: self.left.left.start,
  18041. end: self.right.end
  18042. }),
  18043. right: self.left.right
  18044. });
  18045. } else if (self.left.right instanceof AST_Constant) {
  18046. self = make_node(AST_Binary, self, {
  18047. operator: self.operator,
  18048. left: make_node(AST_Binary, self.left, {
  18049. operator: self.operator,
  18050. left: self.left.right,
  18051. right: self.right,
  18052. start: self.left.right.start,
  18053. end: self.right.end
  18054. }),
  18055. right: self.left.left
  18056. });
  18057. }
  18058. }
  18059. // (a | 1) | (2 | d) => (3 | a) | b
  18060. if (self.left instanceof AST_Binary
  18061. && self.left.operator == self.operator
  18062. && self.left.right instanceof AST_Constant
  18063. && self.right instanceof AST_Binary
  18064. && self.right.operator == self.operator
  18065. && self.right.left instanceof AST_Constant) {
  18066. self = make_node(AST_Binary, self, {
  18067. operator: self.operator,
  18068. left: make_node(AST_Binary, self.left, {
  18069. operator: self.operator,
  18070. left: make_node(AST_Binary, self.left.left, {
  18071. operator: self.operator,
  18072. left: self.left.right,
  18073. right: self.right.left,
  18074. start: self.left.right.start,
  18075. end: self.right.left.end
  18076. }),
  18077. right: self.left.left
  18078. }),
  18079. right: self.right.right
  18080. });
  18081. }
  18082. }
  18083. }
  18084. }
  18085. // x && (y && z) ==> x && y && z
  18086. // x || (y || z) ==> x || y || z
  18087. // x + ("y" + z) ==> x + "y" + z
  18088. // "x" + (y + "z")==> "x" + y + "z"
  18089. if (self.right instanceof AST_Binary
  18090. && self.right.operator == self.operator
  18091. && (lazy_op.has(self.operator)
  18092. || (self.operator == "+"
  18093. && (self.right.left.is_string(compressor)
  18094. || (self.left.is_string(compressor)
  18095. && self.right.right.is_string(compressor)))))
  18096. ) {
  18097. self.left = make_node(AST_Binary, self.left, {
  18098. operator : self.operator,
  18099. left : self.left.transform(compressor),
  18100. right : self.right.left.transform(compressor)
  18101. });
  18102. self.right = self.right.right.transform(compressor);
  18103. return self.transform(compressor);
  18104. }
  18105. var ev = self.evaluate(compressor);
  18106. if (ev !== self) {
  18107. ev = make_node_from_constant(ev, self).optimize(compressor);
  18108. return best_of(compressor, ev, self);
  18109. }
  18110. return self;
  18111. });
  18112. def_optimize(AST_SymbolExport, function(self) {
  18113. return self;
  18114. });
  18115. def_optimize(AST_SymbolRef, function(self, compressor) {
  18116. if (
  18117. !compressor.option("ie8")
  18118. && is_undeclared_ref(self)
  18119. && !compressor.find_parent(AST_With)
  18120. ) {
  18121. switch (self.name) {
  18122. case "undefined":
  18123. return make_node(AST_Undefined, self).optimize(compressor);
  18124. case "NaN":
  18125. return make_node(AST_NaN, self).optimize(compressor);
  18126. case "Infinity":
  18127. return make_node(AST_Infinity, self).optimize(compressor);
  18128. }
  18129. }
  18130. const parent = compressor.parent();
  18131. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  18132. return inline_into_symbolref(self, compressor);
  18133. } else {
  18134. return self;
  18135. }
  18136. });
  18137. function is_atomic(lhs, self) {
  18138. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  18139. }
  18140. def_optimize(AST_Undefined, function(self, compressor) {
  18141. if (compressor.option("unsafe_undefined")) {
  18142. var undef = find_variable(compressor, "undefined");
  18143. if (undef) {
  18144. var ref = make_node(AST_SymbolRef, self, {
  18145. name : "undefined",
  18146. scope : undef.scope,
  18147. thedef : undef
  18148. });
  18149. set_flag(ref, UNDEFINED);
  18150. return ref;
  18151. }
  18152. }
  18153. var lhs = is_lhs(compressor.self(), compressor.parent());
  18154. if (lhs && is_atomic(lhs, self)) return self;
  18155. return make_node(AST_UnaryPrefix, self, {
  18156. operator: "void",
  18157. expression: make_node(AST_Number, self, {
  18158. value: 0
  18159. })
  18160. });
  18161. });
  18162. def_optimize(AST_Infinity, function(self, compressor) {
  18163. var lhs = is_lhs(compressor.self(), compressor.parent());
  18164. if (lhs && is_atomic(lhs, self)) return self;
  18165. if (
  18166. compressor.option("keep_infinity")
  18167. && !(lhs && !is_atomic(lhs, self))
  18168. && !find_variable(compressor, "Infinity")
  18169. ) {
  18170. return self;
  18171. }
  18172. return make_node(AST_Binary, self, {
  18173. operator: "/",
  18174. left: make_node(AST_Number, self, {
  18175. value: 1
  18176. }),
  18177. right: make_node(AST_Number, self, {
  18178. value: 0
  18179. })
  18180. });
  18181. });
  18182. def_optimize(AST_NaN, function(self, compressor) {
  18183. var lhs = is_lhs(compressor.self(), compressor.parent());
  18184. if (lhs && !is_atomic(lhs, self)
  18185. || find_variable(compressor, "NaN")) {
  18186. return make_node(AST_Binary, self, {
  18187. operator: "/",
  18188. left: make_node(AST_Number, self, {
  18189. value: 0
  18190. }),
  18191. right: make_node(AST_Number, self, {
  18192. value: 0
  18193. })
  18194. });
  18195. }
  18196. return self;
  18197. });
  18198. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  18199. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  18200. def_optimize(AST_Assign, function(self, compressor) {
  18201. if (self.logical) {
  18202. return self.lift_sequences(compressor);
  18203. }
  18204. var def;
  18205. // x = x ---> x
  18206. if (
  18207. self.operator === "="
  18208. && self.left instanceof AST_SymbolRef
  18209. && self.left.name !== "arguments"
  18210. && !(def = self.left.definition()).undeclared
  18211. && self.right.equivalent_to(self.left)
  18212. ) {
  18213. return self.right;
  18214. }
  18215. if (compressor.option("dead_code")
  18216. && self.left instanceof AST_SymbolRef
  18217. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  18218. var level = 0, node, parent = self;
  18219. do {
  18220. node = parent;
  18221. parent = compressor.parent(level++);
  18222. if (parent instanceof AST_Exit) {
  18223. if (in_try(level, parent)) break;
  18224. if (is_reachable(def.scope, [ def ])) break;
  18225. if (self.operator == "=") return self.right;
  18226. def.fixed = false;
  18227. return make_node(AST_Binary, self, {
  18228. operator: self.operator.slice(0, -1),
  18229. left: self.left,
  18230. right: self.right
  18231. }).optimize(compressor);
  18232. }
  18233. } while (parent instanceof AST_Binary && parent.right === node
  18234. || parent instanceof AST_Sequence && parent.tail_node() === node);
  18235. }
  18236. self = self.lift_sequences(compressor);
  18237. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  18238. // x = expr1 OP expr2
  18239. if (self.right.left instanceof AST_SymbolRef
  18240. && self.right.left.name == self.left.name
  18241. && ASSIGN_OPS.has(self.right.operator)) {
  18242. // x = x - 2 ---> x -= 2
  18243. self.operator = self.right.operator + "=";
  18244. self.right = self.right.right;
  18245. } else if (self.right.right instanceof AST_SymbolRef
  18246. && self.right.right.name == self.left.name
  18247. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  18248. && !self.right.left.has_side_effects(compressor)) {
  18249. // x = 2 & x ---> x &= 2
  18250. self.operator = self.right.operator + "=";
  18251. self.right = self.right.left;
  18252. }
  18253. }
  18254. return self;
  18255. function in_try(level, node) {
  18256. var right = self.right;
  18257. self.right = make_node(AST_Null, right);
  18258. var may_throw = node.may_throw(compressor);
  18259. self.right = right;
  18260. var scope = self.left.definition().scope;
  18261. var parent;
  18262. while ((parent = compressor.parent(level++)) !== scope) {
  18263. if (parent instanceof AST_Try) {
  18264. if (parent.bfinally) return true;
  18265. if (may_throw && parent.bcatch) return true;
  18266. }
  18267. }
  18268. }
  18269. });
  18270. def_optimize(AST_DefaultAssign, function(self, compressor) {
  18271. if (!compressor.option("evaluate")) {
  18272. return self;
  18273. }
  18274. var evaluateRight = self.right.evaluate(compressor);
  18275. // `[x = undefined] = foo` ---> `[x] = foo`
  18276. if (evaluateRight === undefined) {
  18277. self = self.left;
  18278. } else if (evaluateRight !== self.right) {
  18279. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  18280. self.right = best_of_expression(evaluateRight, self.right);
  18281. }
  18282. return self;
  18283. });
  18284. function is_nullish_check(check, check_subject, compressor) {
  18285. if (check_subject.may_throw(compressor)) return false;
  18286. let nullish_side;
  18287. // foo == null
  18288. if (
  18289. check instanceof AST_Binary
  18290. && check.operator === "=="
  18291. // which side is nullish?
  18292. && (
  18293. (nullish_side = is_nullish(check.left, compressor) && check.left)
  18294. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  18295. )
  18296. // is the other side the same as the check_subject
  18297. && (
  18298. nullish_side === check.left
  18299. ? check.right
  18300. : check.left
  18301. ).equivalent_to(check_subject)
  18302. ) {
  18303. return true;
  18304. }
  18305. // foo === null || foo === undefined
  18306. if (check instanceof AST_Binary && check.operator === "||") {
  18307. let null_cmp;
  18308. let undefined_cmp;
  18309. const find_comparison = cmp => {
  18310. if (!(
  18311. cmp instanceof AST_Binary
  18312. && (cmp.operator === "===" || cmp.operator === "==")
  18313. )) {
  18314. return false;
  18315. }
  18316. let found = 0;
  18317. let defined_side;
  18318. if (cmp.left instanceof AST_Null) {
  18319. found++;
  18320. null_cmp = cmp;
  18321. defined_side = cmp.right;
  18322. }
  18323. if (cmp.right instanceof AST_Null) {
  18324. found++;
  18325. null_cmp = cmp;
  18326. defined_side = cmp.left;
  18327. }
  18328. if (is_undefined(cmp.left, compressor)) {
  18329. found++;
  18330. undefined_cmp = cmp;
  18331. defined_side = cmp.right;
  18332. }
  18333. if (is_undefined(cmp.right, compressor)) {
  18334. found++;
  18335. undefined_cmp = cmp;
  18336. defined_side = cmp.left;
  18337. }
  18338. if (found !== 1) {
  18339. return false;
  18340. }
  18341. if (!defined_side.equivalent_to(check_subject)) {
  18342. return false;
  18343. }
  18344. return true;
  18345. };
  18346. if (!find_comparison(check.left)) return false;
  18347. if (!find_comparison(check.right)) return false;
  18348. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  18349. return true;
  18350. }
  18351. }
  18352. return false;
  18353. }
  18354. def_optimize(AST_Conditional, function(self, compressor) {
  18355. if (!compressor.option("conditionals")) return self;
  18356. // This looks like lift_sequences(), should probably be under "sequences"
  18357. if (self.condition instanceof AST_Sequence) {
  18358. var expressions = self.condition.expressions.slice();
  18359. self.condition = expressions.pop();
  18360. expressions.push(self);
  18361. return make_sequence(self, expressions);
  18362. }
  18363. var cond = self.condition.evaluate(compressor);
  18364. if (cond !== self.condition) {
  18365. if (cond) {
  18366. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  18367. } else {
  18368. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  18369. }
  18370. }
  18371. var negated = cond.negate(compressor, first_in_statement(compressor));
  18372. if (best_of(compressor, cond, negated) === negated) {
  18373. self = make_node(AST_Conditional, self, {
  18374. condition: negated,
  18375. consequent: self.alternative,
  18376. alternative: self.consequent
  18377. });
  18378. }
  18379. var condition = self.condition;
  18380. var consequent = self.consequent;
  18381. var alternative = self.alternative;
  18382. // x?x:y --> x||y
  18383. if (condition instanceof AST_SymbolRef
  18384. && consequent instanceof AST_SymbolRef
  18385. && condition.definition() === consequent.definition()) {
  18386. return make_node(AST_Binary, self, {
  18387. operator: "||",
  18388. left: condition,
  18389. right: alternative
  18390. });
  18391. }
  18392. // if (foo) exp = something; else exp = something_else;
  18393. // |
  18394. // v
  18395. // exp = foo ? something : something_else;
  18396. if (
  18397. consequent instanceof AST_Assign
  18398. && alternative instanceof AST_Assign
  18399. && consequent.operator === alternative.operator
  18400. && consequent.logical === alternative.logical
  18401. && consequent.left.equivalent_to(alternative.left)
  18402. && (!self.condition.has_side_effects(compressor)
  18403. || consequent.operator == "="
  18404. && !consequent.left.has_side_effects(compressor))
  18405. ) {
  18406. return make_node(AST_Assign, self, {
  18407. operator: consequent.operator,
  18408. left: consequent.left,
  18409. logical: consequent.logical,
  18410. right: make_node(AST_Conditional, self, {
  18411. condition: self.condition,
  18412. consequent: consequent.right,
  18413. alternative: alternative.right
  18414. })
  18415. });
  18416. }
  18417. // x ? y(a) : y(b) --> y(x ? a : b)
  18418. var arg_index;
  18419. if (consequent instanceof AST_Call
  18420. && alternative.TYPE === consequent.TYPE
  18421. && consequent.args.length > 0
  18422. && consequent.args.length == alternative.args.length
  18423. && consequent.expression.equivalent_to(alternative.expression)
  18424. && !self.condition.has_side_effects(compressor)
  18425. && !consequent.expression.has_side_effects(compressor)
  18426. && typeof (arg_index = single_arg_diff()) == "number") {
  18427. var node = consequent.clone();
  18428. node.args[arg_index] = make_node(AST_Conditional, self, {
  18429. condition: self.condition,
  18430. consequent: consequent.args[arg_index],
  18431. alternative: alternative.args[arg_index]
  18432. });
  18433. return node;
  18434. }
  18435. // a ? b : c ? b : d --> (a || c) ? b : d
  18436. if (alternative instanceof AST_Conditional
  18437. && consequent.equivalent_to(alternative.consequent)) {
  18438. return make_node(AST_Conditional, self, {
  18439. condition: make_node(AST_Binary, self, {
  18440. operator: "||",
  18441. left: condition,
  18442. right: alternative.condition
  18443. }),
  18444. consequent: consequent,
  18445. alternative: alternative.alternative
  18446. }).optimize(compressor);
  18447. }
  18448. // a == null ? b : a -> a ?? b
  18449. if (
  18450. compressor.option("ecma") >= 2020 &&
  18451. is_nullish_check(condition, alternative, compressor)
  18452. ) {
  18453. return make_node(AST_Binary, self, {
  18454. operator: "??",
  18455. left: alternative,
  18456. right: consequent
  18457. }).optimize(compressor);
  18458. }
  18459. // a ? b : (c, b) --> (a || c), b
  18460. if (alternative instanceof AST_Sequence
  18461. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  18462. return make_sequence(self, [
  18463. make_node(AST_Binary, self, {
  18464. operator: "||",
  18465. left: condition,
  18466. right: make_sequence(self, alternative.expressions.slice(0, -1))
  18467. }),
  18468. consequent
  18469. ]).optimize(compressor);
  18470. }
  18471. // a ? b : (c && b) --> (a || c) && b
  18472. if (alternative instanceof AST_Binary
  18473. && alternative.operator == "&&"
  18474. && consequent.equivalent_to(alternative.right)) {
  18475. return make_node(AST_Binary, self, {
  18476. operator: "&&",
  18477. left: make_node(AST_Binary, self, {
  18478. operator: "||",
  18479. left: condition,
  18480. right: alternative.left
  18481. }),
  18482. right: consequent
  18483. }).optimize(compressor);
  18484. }
  18485. // x?y?z:a:a --> x&&y?z:a
  18486. if (consequent instanceof AST_Conditional
  18487. && consequent.alternative.equivalent_to(alternative)) {
  18488. return make_node(AST_Conditional, self, {
  18489. condition: make_node(AST_Binary, self, {
  18490. left: self.condition,
  18491. operator: "&&",
  18492. right: consequent.condition
  18493. }),
  18494. consequent: consequent.consequent,
  18495. alternative: alternative
  18496. });
  18497. }
  18498. // x ? y : y --> x, y
  18499. if (consequent.equivalent_to(alternative)) {
  18500. return make_sequence(self, [
  18501. self.condition,
  18502. consequent
  18503. ]).optimize(compressor);
  18504. }
  18505. // x ? y || z : z --> x && y || z
  18506. if (consequent instanceof AST_Binary
  18507. && consequent.operator == "||"
  18508. && consequent.right.equivalent_to(alternative)) {
  18509. return make_node(AST_Binary, self, {
  18510. operator: "||",
  18511. left: make_node(AST_Binary, self, {
  18512. operator: "&&",
  18513. left: self.condition,
  18514. right: consequent.left
  18515. }),
  18516. right: alternative
  18517. }).optimize(compressor);
  18518. }
  18519. const in_bool = compressor.in_boolean_context();
  18520. if (is_true(self.consequent)) {
  18521. if (is_false(self.alternative)) {
  18522. // c ? true : false ---> !!c
  18523. return booleanize(self.condition);
  18524. }
  18525. // c ? true : x ---> !!c || x
  18526. return make_node(AST_Binary, self, {
  18527. operator: "||",
  18528. left: booleanize(self.condition),
  18529. right: self.alternative
  18530. });
  18531. }
  18532. if (is_false(self.consequent)) {
  18533. if (is_true(self.alternative)) {
  18534. // c ? false : true ---> !c
  18535. return booleanize(self.condition.negate(compressor));
  18536. }
  18537. // c ? false : x ---> !c && x
  18538. return make_node(AST_Binary, self, {
  18539. operator: "&&",
  18540. left: booleanize(self.condition.negate(compressor)),
  18541. right: self.alternative
  18542. });
  18543. }
  18544. if (is_true(self.alternative)) {
  18545. // c ? x : true ---> !c || x
  18546. return make_node(AST_Binary, self, {
  18547. operator: "||",
  18548. left: booleanize(self.condition.negate(compressor)),
  18549. right: self.consequent
  18550. });
  18551. }
  18552. if (is_false(self.alternative)) {
  18553. // c ? x : false ---> !!c && x
  18554. return make_node(AST_Binary, self, {
  18555. operator: "&&",
  18556. left: booleanize(self.condition),
  18557. right: self.consequent
  18558. });
  18559. }
  18560. return self;
  18561. function booleanize(node) {
  18562. if (node.is_boolean()) return node;
  18563. // !!expression
  18564. return make_node(AST_UnaryPrefix, node, {
  18565. operator: "!",
  18566. expression: node.negate(compressor)
  18567. });
  18568. }
  18569. // AST_True or !0
  18570. function is_true(node) {
  18571. return node instanceof AST_True
  18572. || in_bool
  18573. && node instanceof AST_Constant
  18574. && node.getValue()
  18575. || (node instanceof AST_UnaryPrefix
  18576. && node.operator == "!"
  18577. && node.expression instanceof AST_Constant
  18578. && !node.expression.getValue());
  18579. }
  18580. // AST_False or !1
  18581. function is_false(node) {
  18582. return node instanceof AST_False
  18583. || in_bool
  18584. && node instanceof AST_Constant
  18585. && !node.getValue()
  18586. || (node instanceof AST_UnaryPrefix
  18587. && node.operator == "!"
  18588. && node.expression instanceof AST_Constant
  18589. && node.expression.getValue());
  18590. }
  18591. function single_arg_diff() {
  18592. var a = consequent.args;
  18593. var b = alternative.args;
  18594. for (var i = 0, len = a.length; i < len; i++) {
  18595. if (a[i] instanceof AST_Expansion) return;
  18596. if (!a[i].equivalent_to(b[i])) {
  18597. if (b[i] instanceof AST_Expansion) return;
  18598. for (var j = i + 1; j < len; j++) {
  18599. if (a[j] instanceof AST_Expansion) return;
  18600. if (!a[j].equivalent_to(b[j])) return;
  18601. }
  18602. return i;
  18603. }
  18604. }
  18605. }
  18606. });
  18607. def_optimize(AST_Boolean, function(self, compressor) {
  18608. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  18609. value: +self.value
  18610. });
  18611. var p = compressor.parent();
  18612. if (compressor.option("booleans_as_integers")) {
  18613. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  18614. p.operator = p.operator.replace(/=$/, "");
  18615. }
  18616. return make_node(AST_Number, self, {
  18617. value: +self.value
  18618. });
  18619. }
  18620. if (compressor.option("booleans")) {
  18621. if (p instanceof AST_Binary && (p.operator == "=="
  18622. || p.operator == "!=")) {
  18623. return make_node(AST_Number, self, {
  18624. value: +self.value
  18625. });
  18626. }
  18627. return make_node(AST_UnaryPrefix, self, {
  18628. operator: "!",
  18629. expression: make_node(AST_Number, self, {
  18630. value: 1 - self.value
  18631. })
  18632. });
  18633. }
  18634. return self;
  18635. });
  18636. function safe_to_flatten(value, compressor) {
  18637. if (value instanceof AST_SymbolRef) {
  18638. value = value.fixed_value();
  18639. }
  18640. if (!value) return false;
  18641. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  18642. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  18643. return compressor.parent() instanceof AST_New;
  18644. }
  18645. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  18646. if (!compressor.option("properties")) return;
  18647. if (key === "__proto__") return;
  18648. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  18649. var expr = this.expression;
  18650. if (expr instanceof AST_Object) {
  18651. var props = expr.properties;
  18652. for (var i = props.length; --i >= 0;) {
  18653. var prop = props[i];
  18654. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  18655. const all_props_flattenable = props.every((p) =>
  18656. (p instanceof AST_ObjectKeyVal
  18657. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  18658. )
  18659. && !p.computed_key()
  18660. );
  18661. if (!all_props_flattenable) return;
  18662. if (!safe_to_flatten(prop.value, compressor)) return;
  18663. return make_node(AST_Sub, this, {
  18664. expression: make_node(AST_Array, expr, {
  18665. elements: props.map(function(prop) {
  18666. var v = prop.value;
  18667. if (v instanceof AST_Accessor) {
  18668. v = make_node(AST_Function, v, v);
  18669. }
  18670. var k = prop.key;
  18671. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  18672. return make_sequence(prop, [ k, v ]);
  18673. }
  18674. return v;
  18675. })
  18676. }),
  18677. property: make_node(AST_Number, this, {
  18678. value: i
  18679. })
  18680. });
  18681. }
  18682. }
  18683. }
  18684. });
  18685. def_optimize(AST_Sub, function(self, compressor) {
  18686. var expr = self.expression;
  18687. var prop = self.property;
  18688. if (compressor.option("properties")) {
  18689. var key = prop.evaluate(compressor);
  18690. if (key !== prop) {
  18691. if (typeof key == "string") {
  18692. if (key == "undefined") {
  18693. key = undefined;
  18694. } else {
  18695. var value = parseFloat(key);
  18696. if (value.toString() == key) {
  18697. key = value;
  18698. }
  18699. }
  18700. }
  18701. prop = self.property = best_of_expression(prop, make_node_from_constant(key, prop).transform(compressor));
  18702. var property = "" + key;
  18703. if (is_basic_identifier_string(property)
  18704. && property.length <= prop.size() + 1) {
  18705. return make_node(AST_Dot, self, {
  18706. expression: expr,
  18707. optional: self.optional,
  18708. property: property,
  18709. quote: prop.quote,
  18710. }).optimize(compressor);
  18711. }
  18712. }
  18713. }
  18714. var fn;
  18715. OPT_ARGUMENTS: if (compressor.option("arguments")
  18716. && expr instanceof AST_SymbolRef
  18717. && expr.name == "arguments"
  18718. && expr.definition().orig.length == 1
  18719. && (fn = expr.scope) instanceof AST_Lambda
  18720. && fn.uses_arguments
  18721. && !(fn instanceof AST_Arrow)
  18722. && prop instanceof AST_Number) {
  18723. var index = prop.getValue();
  18724. var params = new Set();
  18725. var argnames = fn.argnames;
  18726. for (var n = 0; n < argnames.length; n++) {
  18727. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  18728. break OPT_ARGUMENTS; // destructuring parameter - bail
  18729. }
  18730. var param = argnames[n].name;
  18731. if (params.has(param)) {
  18732. break OPT_ARGUMENTS; // duplicate parameter - bail
  18733. }
  18734. params.add(param);
  18735. }
  18736. var argname = fn.argnames[index];
  18737. if (argname && compressor.has_directive("use strict")) {
  18738. var def = argname.definition();
  18739. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  18740. argname = null;
  18741. }
  18742. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  18743. while (index >= fn.argnames.length) {
  18744. argname = fn.create_symbol(AST_SymbolFunarg, {
  18745. source: fn,
  18746. scope: fn,
  18747. tentative_name: "argument_" + fn.argnames.length,
  18748. });
  18749. fn.argnames.push(argname);
  18750. }
  18751. }
  18752. if (argname) {
  18753. var sym = make_node(AST_SymbolRef, self, argname);
  18754. sym.reference({});
  18755. clear_flag(argname, UNUSED);
  18756. return sym;
  18757. }
  18758. }
  18759. if (is_lhs(self, compressor.parent())) return self;
  18760. if (key !== prop) {
  18761. var sub = self.flatten_object(property, compressor);
  18762. if (sub) {
  18763. expr = self.expression = sub.expression;
  18764. prop = self.property = sub.property;
  18765. }
  18766. }
  18767. if (compressor.option("properties") && compressor.option("side_effects")
  18768. && prop instanceof AST_Number && expr instanceof AST_Array) {
  18769. var index = prop.getValue();
  18770. var elements = expr.elements;
  18771. var retValue = elements[index];
  18772. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  18773. var flatten = true;
  18774. var values = [];
  18775. for (var i = elements.length; --i > index;) {
  18776. var value = elements[i].drop_side_effect_free(compressor);
  18777. if (value) {
  18778. values.unshift(value);
  18779. if (flatten && value.has_side_effects(compressor)) flatten = false;
  18780. }
  18781. }
  18782. if (retValue instanceof AST_Expansion) break FLATTEN;
  18783. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  18784. if (!flatten) values.unshift(retValue);
  18785. while (--i >= 0) {
  18786. var value = elements[i];
  18787. if (value instanceof AST_Expansion) break FLATTEN;
  18788. value = value.drop_side_effect_free(compressor);
  18789. if (value) values.unshift(value);
  18790. else index--;
  18791. }
  18792. if (flatten) {
  18793. values.push(retValue);
  18794. return make_sequence(self, values).optimize(compressor);
  18795. } else return make_node(AST_Sub, self, {
  18796. expression: make_node(AST_Array, expr, {
  18797. elements: values
  18798. }),
  18799. property: make_node(AST_Number, prop, {
  18800. value: index
  18801. })
  18802. });
  18803. }
  18804. }
  18805. var ev = self.evaluate(compressor);
  18806. if (ev !== self) {
  18807. ev = make_node_from_constant(ev, self).optimize(compressor);
  18808. return best_of(compressor, ev, self);
  18809. }
  18810. return self;
  18811. });
  18812. def_optimize(AST_Chain, function (self, compressor) {
  18813. if (is_nullish(self.expression, compressor)) {
  18814. let parent = compressor.parent();
  18815. // It's valid to delete a nullish optional chain, but if we optimized
  18816. // this to `delete undefined` then it would appear to be a syntax error
  18817. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  18818. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  18819. return make_node_from_constant(0, self);
  18820. }
  18821. return make_node(AST_Undefined, self);
  18822. }
  18823. return self;
  18824. });
  18825. AST_Lambda.DEFMETHOD("contains_this", function() {
  18826. return walk(this, node => {
  18827. if (node instanceof AST_This) return walk_abort;
  18828. if (
  18829. node !== this
  18830. && node instanceof AST_Scope
  18831. && !(node instanceof AST_Arrow)
  18832. ) {
  18833. return true;
  18834. }
  18835. });
  18836. });
  18837. def_optimize(AST_Dot, function(self, compressor) {
  18838. const parent = compressor.parent();
  18839. if (is_lhs(self, parent)) return self;
  18840. if (compressor.option("unsafe_proto")
  18841. && self.expression instanceof AST_Dot
  18842. && self.expression.property == "prototype") {
  18843. var exp = self.expression.expression;
  18844. if (is_undeclared_ref(exp)) switch (exp.name) {
  18845. case "Array":
  18846. self.expression = make_node(AST_Array, self.expression, {
  18847. elements: []
  18848. });
  18849. break;
  18850. case "Function":
  18851. self.expression = make_node(AST_Function, self.expression, {
  18852. argnames: [],
  18853. body: []
  18854. });
  18855. break;
  18856. case "Number":
  18857. self.expression = make_node(AST_Number, self.expression, {
  18858. value: 0
  18859. });
  18860. break;
  18861. case "Object":
  18862. self.expression = make_node(AST_Object, self.expression, {
  18863. properties: []
  18864. });
  18865. break;
  18866. case "RegExp":
  18867. self.expression = make_node(AST_RegExp, self.expression, {
  18868. value: { source: "t", flags: "" }
  18869. });
  18870. break;
  18871. case "String":
  18872. self.expression = make_node(AST_String, self.expression, {
  18873. value: ""
  18874. });
  18875. break;
  18876. }
  18877. }
  18878. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  18879. const sub = self.flatten_object(self.property, compressor);
  18880. if (sub) return sub.optimize(compressor);
  18881. }
  18882. if (self.expression instanceof AST_PropAccess
  18883. && parent instanceof AST_PropAccess) {
  18884. return self;
  18885. }
  18886. let ev = self.evaluate(compressor);
  18887. if (ev !== self) {
  18888. ev = make_node_from_constant(ev, self).optimize(compressor);
  18889. return best_of(compressor, ev, self);
  18890. }
  18891. return self;
  18892. });
  18893. function literals_in_boolean_context(self, compressor) {
  18894. if (compressor.in_boolean_context()) {
  18895. return best_of(compressor, self, make_sequence(self, [
  18896. self,
  18897. make_node(AST_True, self)
  18898. ]).optimize(compressor));
  18899. }
  18900. return self;
  18901. }
  18902. function inline_array_like_spread(elements) {
  18903. for (var i = 0; i < elements.length; i++) {
  18904. var el = elements[i];
  18905. if (el instanceof AST_Expansion) {
  18906. var expr = el.expression;
  18907. if (
  18908. expr instanceof AST_Array
  18909. && !expr.elements.some(elm => elm instanceof AST_Hole)
  18910. ) {
  18911. elements.splice(i, 1, ...expr.elements);
  18912. // Step back one, as the element at i is now new.
  18913. i--;
  18914. }
  18915. // In array-like spread, spreading a non-iterable value is TypeError.
  18916. // We therefore can’t optimize anything else, unlike with object spread.
  18917. }
  18918. }
  18919. }
  18920. def_optimize(AST_Array, function(self, compressor) {
  18921. var optimized = literals_in_boolean_context(self, compressor);
  18922. if (optimized !== self) {
  18923. return optimized;
  18924. }
  18925. inline_array_like_spread(self.elements);
  18926. return self;
  18927. });
  18928. function inline_object_prop_spread(props, compressor) {
  18929. for (var i = 0; i < props.length; i++) {
  18930. var prop = props[i];
  18931. if (prop instanceof AST_Expansion) {
  18932. const expr = prop.expression;
  18933. if (
  18934. expr instanceof AST_Object
  18935. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  18936. ) {
  18937. props.splice(i, 1, ...expr.properties);
  18938. // Step back one, as the property at i is now new.
  18939. i--;
  18940. } else if (expr instanceof AST_Constant
  18941. && !(expr instanceof AST_String)) {
  18942. // Unlike array-like spread, in object spread, spreading a
  18943. // non-iterable value silently does nothing; it is thus safe
  18944. // to remove. AST_String is the only iterable AST_Constant.
  18945. props.splice(i, 1);
  18946. i--;
  18947. } else if (is_nullish(expr, compressor)) {
  18948. // Likewise, null and undefined can be silently removed.
  18949. props.splice(i, 1);
  18950. i--;
  18951. }
  18952. }
  18953. }
  18954. }
  18955. def_optimize(AST_Object, function(self, compressor) {
  18956. var optimized = literals_in_boolean_context(self, compressor);
  18957. if (optimized !== self) {
  18958. return optimized;
  18959. }
  18960. inline_object_prop_spread(self.properties, compressor);
  18961. return self;
  18962. });
  18963. def_optimize(AST_RegExp, literals_in_boolean_context);
  18964. def_optimize(AST_Return, function(self, compressor) {
  18965. if (self.value && is_undefined(self.value, compressor)) {
  18966. self.value = null;
  18967. }
  18968. return self;
  18969. });
  18970. def_optimize(AST_Arrow, opt_AST_Lambda);
  18971. def_optimize(AST_Function, function(self, compressor) {
  18972. self = opt_AST_Lambda(self, compressor);
  18973. if (compressor.option("unsafe_arrows")
  18974. && compressor.option("ecma") >= 2015
  18975. && !self.name
  18976. && !self.is_generator
  18977. && !self.uses_arguments
  18978. && !self.pinned()) {
  18979. const uses_this = walk(self, node => {
  18980. if (node instanceof AST_This) return walk_abort;
  18981. });
  18982. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  18983. }
  18984. return self;
  18985. });
  18986. def_optimize(AST_Class, function(self) {
  18987. // HACK to avoid compress failure.
  18988. // AST_Class is not really an AST_Scope/AST_Block as it lacks a body.
  18989. return self;
  18990. });
  18991. def_optimize(AST_ClassStaticBlock, function(self, compressor) {
  18992. tighten_body(self.body, compressor);
  18993. return self;
  18994. });
  18995. def_optimize(AST_Yield, function(self, compressor) {
  18996. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  18997. self.expression = null;
  18998. }
  18999. return self;
  19000. });
  19001. def_optimize(AST_TemplateString, function(self, compressor) {
  19002. if (
  19003. !compressor.option("evaluate")
  19004. || compressor.parent() instanceof AST_PrefixedTemplateString
  19005. ) {
  19006. return self;
  19007. }
  19008. var segments = [];
  19009. for (var i = 0; i < self.segments.length; i++) {
  19010. var segment = self.segments[i];
  19011. if (segment instanceof AST_Node) {
  19012. var result = segment.evaluate(compressor);
  19013. // Evaluate to constant value
  19014. // Constant value shorter than ${segment}
  19015. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  19016. // There should always be a previous and next segment if segment is a node
  19017. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  19018. continue;
  19019. }
  19020. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  19021. // TODO:
  19022. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  19023. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  19024. if (segment instanceof AST_TemplateString) {
  19025. var inners = segment.segments;
  19026. segments[segments.length - 1].value += inners[0].value;
  19027. for (var j = 1; j < inners.length; j++) {
  19028. segment = inners[j];
  19029. segments.push(segment);
  19030. }
  19031. continue;
  19032. }
  19033. }
  19034. segments.push(segment);
  19035. }
  19036. self.segments = segments;
  19037. // `foo` => "foo"
  19038. if (segments.length == 1) {
  19039. return make_node(AST_String, self, segments[0]);
  19040. }
  19041. if (
  19042. segments.length === 3
  19043. && segments[1] instanceof AST_Node
  19044. && (
  19045. segments[1].is_string(compressor)
  19046. || segments[1].is_number(compressor)
  19047. || is_nullish(segments[1], compressor)
  19048. || compressor.option("unsafe")
  19049. )
  19050. ) {
  19051. // `foo${bar}` => "foo" + bar
  19052. if (segments[2].value === "") {
  19053. return make_node(AST_Binary, self, {
  19054. operator: "+",
  19055. left: make_node(AST_String, self, {
  19056. value: segments[0].value,
  19057. }),
  19058. right: segments[1],
  19059. });
  19060. }
  19061. // `${bar}baz` => bar + "baz"
  19062. if (segments[0].value === "") {
  19063. return make_node(AST_Binary, self, {
  19064. operator: "+",
  19065. left: segments[1],
  19066. right: make_node(AST_String, self, {
  19067. value: segments[2].value,
  19068. }),
  19069. });
  19070. }
  19071. }
  19072. return self;
  19073. });
  19074. def_optimize(AST_PrefixedTemplateString, function(self) {
  19075. return self;
  19076. });
  19077. // ["p"]:1 ---> p:1
  19078. // [42]:1 ---> 42:1
  19079. function lift_key(self, compressor) {
  19080. if (!compressor.option("computed_props")) return self;
  19081. // save a comparison in the typical case
  19082. if (!(self.key instanceof AST_Constant)) return self;
  19083. // allow certain acceptable props as not all AST_Constants are true constants
  19084. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  19085. if (self.key.value === "__proto__") return self;
  19086. if (self.key.value == "constructor"
  19087. && compressor.parent() instanceof AST_Class) return self;
  19088. if (self instanceof AST_ObjectKeyVal) {
  19089. self.quote = self.key.quote;
  19090. self.key = self.key.value;
  19091. } else if (self instanceof AST_ClassProperty) {
  19092. self.quote = self.key.quote;
  19093. self.key = make_node(AST_SymbolClassProperty, self.key, {
  19094. name: self.key.value
  19095. });
  19096. } else {
  19097. self.quote = self.key.quote;
  19098. self.key = make_node(AST_SymbolMethod, self.key, {
  19099. name: self.key.value
  19100. });
  19101. }
  19102. }
  19103. return self;
  19104. }
  19105. def_optimize(AST_ObjectProperty, lift_key);
  19106. def_optimize(AST_ConciseMethod, function(self, compressor) {
  19107. lift_key(self, compressor);
  19108. // p(){return x;} ---> p:()=>x
  19109. if (compressor.option("arrows")
  19110. && compressor.parent() instanceof AST_Object
  19111. && !self.is_generator
  19112. && !self.value.uses_arguments
  19113. && !self.value.pinned()
  19114. && self.value.body.length == 1
  19115. && self.value.body[0] instanceof AST_Return
  19116. && self.value.body[0].value
  19117. && !self.value.contains_this()) {
  19118. var arrow = make_node(AST_Arrow, self.value, self.value);
  19119. arrow.async = self.async;
  19120. arrow.is_generator = self.is_generator;
  19121. return make_node(AST_ObjectKeyVal, self, {
  19122. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  19123. value: arrow,
  19124. quote: self.quote,
  19125. });
  19126. }
  19127. return self;
  19128. });
  19129. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  19130. lift_key(self, compressor);
  19131. // p:function(){} ---> p(){}
  19132. // p:function*(){} ---> *p(){}
  19133. // p:async function(){} ---> async p(){}
  19134. // p:()=>{} ---> p(){}
  19135. // p:async()=>{} ---> async p(){}
  19136. var unsafe_methods = compressor.option("unsafe_methods");
  19137. if (unsafe_methods
  19138. && compressor.option("ecma") >= 2015
  19139. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  19140. var key = self.key;
  19141. var value = self.value;
  19142. var is_arrow_with_block = value instanceof AST_Arrow
  19143. && Array.isArray(value.body)
  19144. && !value.contains_this();
  19145. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  19146. return make_node(AST_ConciseMethod, self, {
  19147. async: value.async,
  19148. is_generator: value.is_generator,
  19149. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  19150. name: key,
  19151. }),
  19152. value: make_node(AST_Accessor, value, value),
  19153. quote: self.quote,
  19154. });
  19155. }
  19156. }
  19157. return self;
  19158. });
  19159. def_optimize(AST_Destructuring, function(self, compressor) {
  19160. if (compressor.option("pure_getters") == true
  19161. && compressor.option("unused")
  19162. && !self.is_array
  19163. && Array.isArray(self.names)
  19164. && !is_destructuring_export_decl(compressor)
  19165. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  19166. var keep = [];
  19167. for (var i = 0; i < self.names.length; i++) {
  19168. var elem = self.names[i];
  19169. if (!(elem instanceof AST_ObjectKeyVal
  19170. && typeof elem.key == "string"
  19171. && elem.value instanceof AST_SymbolDeclaration
  19172. && !should_retain(compressor, elem.value.definition()))) {
  19173. keep.push(elem);
  19174. }
  19175. }
  19176. if (keep.length != self.names.length) {
  19177. self.names = keep;
  19178. }
  19179. }
  19180. return self;
  19181. function is_destructuring_export_decl(compressor) {
  19182. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  19183. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  19184. var parent = compressor.parent(p);
  19185. if (!parent) return false;
  19186. if (a === 0 && parent.TYPE == "Destructuring") continue;
  19187. if (!ancestors[a].test(parent.TYPE)) {
  19188. return false;
  19189. }
  19190. a++;
  19191. }
  19192. return true;
  19193. }
  19194. function should_retain(compressor, def) {
  19195. if (def.references.length) return true;
  19196. if (!def.global) return false;
  19197. if (compressor.toplevel.vars) {
  19198. if (compressor.top_retain) {
  19199. return compressor.top_retain(def);
  19200. }
  19201. return false;
  19202. }
  19203. return true;
  19204. }
  19205. });
  19206. /***********************************************************************
  19207. A JavaScript tokenizer / parser / beautifier / compressor.
  19208. https://github.com/mishoo/UglifyJS2
  19209. -------------------------------- (C) ---------------------------------
  19210. Author: Mihai Bazon
  19211. <mihai.bazon@gmail.com>
  19212. http://mihai.bazon.net/blog
  19213. Distributed under the BSD license:
  19214. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  19215. Redistribution and use in source and binary forms, with or without
  19216. modification, are permitted provided that the following conditions
  19217. are met:
  19218. * Redistributions of source code must retain the above
  19219. copyright notice, this list of conditions and the following
  19220. disclaimer.
  19221. * Redistributions in binary form must reproduce the above
  19222. copyright notice, this list of conditions and the following
  19223. disclaimer in the documentation and/or other materials
  19224. provided with the distribution.
  19225. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  19226. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19227. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19228. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  19229. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  19230. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19231. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19232. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19233. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  19234. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  19235. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  19236. SUCH DAMAGE.
  19237. ***********************************************************************/
  19238. // a small wrapper around source-map and @jridgewell/source-map
  19239. async function SourceMap(options) {
  19240. options = defaults(options, {
  19241. file : null,
  19242. root : null,
  19243. orig : null,
  19244. files: {},
  19245. });
  19246. var orig_map;
  19247. var generator = new sourceMap.SourceMapGenerator({
  19248. file : options.file,
  19249. sourceRoot : options.root
  19250. });
  19251. let sourcesContent = {__proto__: null};
  19252. let files = options.files;
  19253. for (var name in files) if (HOP(files, name)) {
  19254. sourcesContent[name] = files[name];
  19255. }
  19256. if (options.orig) {
  19257. // We support both @jridgewell/source-map (which has a sync
  19258. // SourceMapConsumer) and source-map (which has an async
  19259. // SourceMapConsumer).
  19260. orig_map = await new sourceMap.SourceMapConsumer(options.orig);
  19261. if (orig_map.sourcesContent) {
  19262. orig_map.sources.forEach(function(source, i) {
  19263. var content = orig_map.sourcesContent[i];
  19264. if (content) {
  19265. sourcesContent[source] = content;
  19266. }
  19267. });
  19268. }
  19269. }
  19270. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  19271. let generatedPos = { line: gen_line, column: gen_col };
  19272. if (orig_map) {
  19273. var info = orig_map.originalPositionFor({
  19274. line: orig_line,
  19275. column: orig_col
  19276. });
  19277. if (info.source === null) {
  19278. generator.addMapping({
  19279. generated: generatedPos,
  19280. original: null,
  19281. source: null,
  19282. name: null
  19283. });
  19284. return;
  19285. }
  19286. source = info.source;
  19287. orig_line = info.line;
  19288. orig_col = info.column;
  19289. name = info.name || name;
  19290. }
  19291. generator.addMapping({
  19292. generated : generatedPos,
  19293. original : { line: orig_line, column: orig_col },
  19294. source : source,
  19295. name : name
  19296. });
  19297. generator.setSourceContent(source, sourcesContent[source]);
  19298. }
  19299. function clean(map) {
  19300. const allNull = map.sourcesContent && map.sourcesContent.every(c => c == null);
  19301. if (allNull) delete map.sourcesContent;
  19302. if (map.file === undefined) delete map.file;
  19303. if (map.sourceRoot === undefined) delete map.sourceRoot;
  19304. return map;
  19305. }
  19306. function getDecoded() {
  19307. if (!generator.toDecodedMap) return null;
  19308. return clean(generator.toDecodedMap());
  19309. }
  19310. function getEncoded() {
  19311. return clean(generator.toJSON());
  19312. }
  19313. function destroy() {
  19314. // @jridgewell/source-map's SourceMapConsumer does not need to be
  19315. // manually freed.
  19316. if (orig_map && orig_map.destroy) orig_map.destroy();
  19317. }
  19318. return {
  19319. add,
  19320. getDecoded,
  19321. getEncoded,
  19322. destroy,
  19323. };
  19324. }
  19325. var domprops = [
  19326. "$&",
  19327. "$'",
  19328. "$*",
  19329. "$+",
  19330. "$1",
  19331. "$2",
  19332. "$3",
  19333. "$4",
  19334. "$5",
  19335. "$6",
  19336. "$7",
  19337. "$8",
  19338. "$9",
  19339. "$_",
  19340. "$`",
  19341. "$input",
  19342. "-moz-animation",
  19343. "-moz-animation-delay",
  19344. "-moz-animation-direction",
  19345. "-moz-animation-duration",
  19346. "-moz-animation-fill-mode",
  19347. "-moz-animation-iteration-count",
  19348. "-moz-animation-name",
  19349. "-moz-animation-play-state",
  19350. "-moz-animation-timing-function",
  19351. "-moz-appearance",
  19352. "-moz-backface-visibility",
  19353. "-moz-border-end",
  19354. "-moz-border-end-color",
  19355. "-moz-border-end-style",
  19356. "-moz-border-end-width",
  19357. "-moz-border-image",
  19358. "-moz-border-start",
  19359. "-moz-border-start-color",
  19360. "-moz-border-start-style",
  19361. "-moz-border-start-width",
  19362. "-moz-box-align",
  19363. "-moz-box-direction",
  19364. "-moz-box-flex",
  19365. "-moz-box-ordinal-group",
  19366. "-moz-box-orient",
  19367. "-moz-box-pack",
  19368. "-moz-box-sizing",
  19369. "-moz-float-edge",
  19370. "-moz-font-feature-settings",
  19371. "-moz-font-language-override",
  19372. "-moz-force-broken-image-icon",
  19373. "-moz-hyphens",
  19374. "-moz-image-region",
  19375. "-moz-margin-end",
  19376. "-moz-margin-start",
  19377. "-moz-orient",
  19378. "-moz-osx-font-smoothing",
  19379. "-moz-outline-radius",
  19380. "-moz-outline-radius-bottomleft",
  19381. "-moz-outline-radius-bottomright",
  19382. "-moz-outline-radius-topleft",
  19383. "-moz-outline-radius-topright",
  19384. "-moz-padding-end",
  19385. "-moz-padding-start",
  19386. "-moz-perspective",
  19387. "-moz-perspective-origin",
  19388. "-moz-tab-size",
  19389. "-moz-text-size-adjust",
  19390. "-moz-transform",
  19391. "-moz-transform-origin",
  19392. "-moz-transform-style",
  19393. "-moz-transition",
  19394. "-moz-transition-delay",
  19395. "-moz-transition-duration",
  19396. "-moz-transition-property",
  19397. "-moz-transition-timing-function",
  19398. "-moz-user-focus",
  19399. "-moz-user-input",
  19400. "-moz-user-modify",
  19401. "-moz-user-select",
  19402. "-moz-window-dragging",
  19403. "-webkit-align-content",
  19404. "-webkit-align-items",
  19405. "-webkit-align-self",
  19406. "-webkit-animation",
  19407. "-webkit-animation-delay",
  19408. "-webkit-animation-direction",
  19409. "-webkit-animation-duration",
  19410. "-webkit-animation-fill-mode",
  19411. "-webkit-animation-iteration-count",
  19412. "-webkit-animation-name",
  19413. "-webkit-animation-play-state",
  19414. "-webkit-animation-timing-function",
  19415. "-webkit-appearance",
  19416. "-webkit-backface-visibility",
  19417. "-webkit-background-clip",
  19418. "-webkit-background-origin",
  19419. "-webkit-background-size",
  19420. "-webkit-border-bottom-left-radius",
  19421. "-webkit-border-bottom-right-radius",
  19422. "-webkit-border-image",
  19423. "-webkit-border-radius",
  19424. "-webkit-border-top-left-radius",
  19425. "-webkit-border-top-right-radius",
  19426. "-webkit-box-align",
  19427. "-webkit-box-direction",
  19428. "-webkit-box-flex",
  19429. "-webkit-box-ordinal-group",
  19430. "-webkit-box-orient",
  19431. "-webkit-box-pack",
  19432. "-webkit-box-shadow",
  19433. "-webkit-box-sizing",
  19434. "-webkit-filter",
  19435. "-webkit-flex",
  19436. "-webkit-flex-basis",
  19437. "-webkit-flex-direction",
  19438. "-webkit-flex-flow",
  19439. "-webkit-flex-grow",
  19440. "-webkit-flex-shrink",
  19441. "-webkit-flex-wrap",
  19442. "-webkit-justify-content",
  19443. "-webkit-line-clamp",
  19444. "-webkit-mask",
  19445. "-webkit-mask-clip",
  19446. "-webkit-mask-composite",
  19447. "-webkit-mask-image",
  19448. "-webkit-mask-origin",
  19449. "-webkit-mask-position",
  19450. "-webkit-mask-position-x",
  19451. "-webkit-mask-position-y",
  19452. "-webkit-mask-repeat",
  19453. "-webkit-mask-size",
  19454. "-webkit-order",
  19455. "-webkit-perspective",
  19456. "-webkit-perspective-origin",
  19457. "-webkit-text-fill-color",
  19458. "-webkit-text-size-adjust",
  19459. "-webkit-text-stroke",
  19460. "-webkit-text-stroke-color",
  19461. "-webkit-text-stroke-width",
  19462. "-webkit-transform",
  19463. "-webkit-transform-origin",
  19464. "-webkit-transform-style",
  19465. "-webkit-transition",
  19466. "-webkit-transition-delay",
  19467. "-webkit-transition-duration",
  19468. "-webkit-transition-property",
  19469. "-webkit-transition-timing-function",
  19470. "-webkit-user-select",
  19471. "0",
  19472. "1",
  19473. "10",
  19474. "11",
  19475. "12",
  19476. "13",
  19477. "14",
  19478. "15",
  19479. "16",
  19480. "17",
  19481. "18",
  19482. "19",
  19483. "2",
  19484. "20",
  19485. "3",
  19486. "4",
  19487. "5",
  19488. "6",
  19489. "7",
  19490. "8",
  19491. "9",
  19492. "@@iterator",
  19493. "ABORT_ERR",
  19494. "ACTIVE",
  19495. "ACTIVE_ATTRIBUTES",
  19496. "ACTIVE_TEXTURE",
  19497. "ACTIVE_UNIFORMS",
  19498. "ACTIVE_UNIFORM_BLOCKS",
  19499. "ADDITION",
  19500. "ALIASED_LINE_WIDTH_RANGE",
  19501. "ALIASED_POINT_SIZE_RANGE",
  19502. "ALLOW_KEYBOARD_INPUT",
  19503. "ALLPASS",
  19504. "ALPHA",
  19505. "ALPHA_BITS",
  19506. "ALREADY_SIGNALED",
  19507. "ALT_MASK",
  19508. "ALWAYS",
  19509. "ANY_SAMPLES_PASSED",
  19510. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  19511. "ANY_TYPE",
  19512. "ANY_UNORDERED_NODE_TYPE",
  19513. "ARRAY_BUFFER",
  19514. "ARRAY_BUFFER_BINDING",
  19515. "ATTACHED_SHADERS",
  19516. "ATTRIBUTE_NODE",
  19517. "AT_TARGET",
  19518. "AbortController",
  19519. "AbortSignal",
  19520. "AbsoluteOrientationSensor",
  19521. "AbstractRange",
  19522. "Accelerometer",
  19523. "AddSearchProvider",
  19524. "AggregateError",
  19525. "AnalyserNode",
  19526. "Animation",
  19527. "AnimationEffect",
  19528. "AnimationEvent",
  19529. "AnimationPlaybackEvent",
  19530. "AnimationTimeline",
  19531. "AnonXMLHttpRequest",
  19532. "Any",
  19533. "ApplicationCache",
  19534. "ApplicationCacheErrorEvent",
  19535. "Array",
  19536. "ArrayBuffer",
  19537. "ArrayType",
  19538. "Atomics",
  19539. "Attr",
  19540. "Audio",
  19541. "AudioBuffer",
  19542. "AudioBufferSourceNode",
  19543. "AudioContext",
  19544. "AudioDestinationNode",
  19545. "AudioListener",
  19546. "AudioNode",
  19547. "AudioParam",
  19548. "AudioParamMap",
  19549. "AudioProcessingEvent",
  19550. "AudioScheduledSourceNode",
  19551. "AudioStreamTrack",
  19552. "AudioWorklet",
  19553. "AudioWorkletNode",
  19554. "AuthenticatorAssertionResponse",
  19555. "AuthenticatorAttestationResponse",
  19556. "AuthenticatorResponse",
  19557. "AutocompleteErrorEvent",
  19558. "BACK",
  19559. "BAD_BOUNDARYPOINTS_ERR",
  19560. "BAD_REQUEST",
  19561. "BANDPASS",
  19562. "BLEND",
  19563. "BLEND_COLOR",
  19564. "BLEND_DST_ALPHA",
  19565. "BLEND_DST_RGB",
  19566. "BLEND_EQUATION",
  19567. "BLEND_EQUATION_ALPHA",
  19568. "BLEND_EQUATION_RGB",
  19569. "BLEND_SRC_ALPHA",
  19570. "BLEND_SRC_RGB",
  19571. "BLUE_BITS",
  19572. "BLUR",
  19573. "BOOL",
  19574. "BOOLEAN_TYPE",
  19575. "BOOL_VEC2",
  19576. "BOOL_VEC3",
  19577. "BOOL_VEC4",
  19578. "BOTH",
  19579. "BROWSER_DEFAULT_WEBGL",
  19580. "BUBBLING_PHASE",
  19581. "BUFFER_SIZE",
  19582. "BUFFER_USAGE",
  19583. "BYTE",
  19584. "BYTES_PER_ELEMENT",
  19585. "BackgroundFetchManager",
  19586. "BackgroundFetchRecord",
  19587. "BackgroundFetchRegistration",
  19588. "BarProp",
  19589. "BarcodeDetector",
  19590. "BaseAudioContext",
  19591. "BaseHref",
  19592. "BatteryManager",
  19593. "BeforeInstallPromptEvent",
  19594. "BeforeLoadEvent",
  19595. "BeforeUnloadEvent",
  19596. "BigInt",
  19597. "BigInt64Array",
  19598. "BigUint64Array",
  19599. "BiquadFilterNode",
  19600. "Blob",
  19601. "BlobEvent",
  19602. "Bluetooth",
  19603. "BluetoothCharacteristicProperties",
  19604. "BluetoothDevice",
  19605. "BluetoothRemoteGATTCharacteristic",
  19606. "BluetoothRemoteGATTDescriptor",
  19607. "BluetoothRemoteGATTServer",
  19608. "BluetoothRemoteGATTService",
  19609. "BluetoothUUID",
  19610. "Boolean",
  19611. "BroadcastChannel",
  19612. "ByteLengthQueuingStrategy",
  19613. "CAPTURING_PHASE",
  19614. "CCW",
  19615. "CDATASection",
  19616. "CDATA_SECTION_NODE",
  19617. "CHANGE",
  19618. "CHARSET_RULE",
  19619. "CHECKING",
  19620. "CLAMP_TO_EDGE",
  19621. "CLICK",
  19622. "CLOSED",
  19623. "CLOSING",
  19624. "COLOR",
  19625. "COLOR_ATTACHMENT0",
  19626. "COLOR_ATTACHMENT1",
  19627. "COLOR_ATTACHMENT10",
  19628. "COLOR_ATTACHMENT11",
  19629. "COLOR_ATTACHMENT12",
  19630. "COLOR_ATTACHMENT13",
  19631. "COLOR_ATTACHMENT14",
  19632. "COLOR_ATTACHMENT15",
  19633. "COLOR_ATTACHMENT2",
  19634. "COLOR_ATTACHMENT3",
  19635. "COLOR_ATTACHMENT4",
  19636. "COLOR_ATTACHMENT5",
  19637. "COLOR_ATTACHMENT6",
  19638. "COLOR_ATTACHMENT7",
  19639. "COLOR_ATTACHMENT8",
  19640. "COLOR_ATTACHMENT9",
  19641. "COLOR_BUFFER_BIT",
  19642. "COLOR_CLEAR_VALUE",
  19643. "COLOR_WRITEMASK",
  19644. "COMMENT_NODE",
  19645. "COMPARE_REF_TO_TEXTURE",
  19646. "COMPILE_STATUS",
  19647. "COMPLETION_STATUS_KHR",
  19648. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  19649. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  19650. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  19651. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  19652. "COMPRESSED_TEXTURE_FORMATS",
  19653. "CONDITION_SATISFIED",
  19654. "CONFIGURATION_UNSUPPORTED",
  19655. "CONNECTING",
  19656. "CONSTANT_ALPHA",
  19657. "CONSTANT_COLOR",
  19658. "CONSTRAINT_ERR",
  19659. "CONTEXT_LOST_WEBGL",
  19660. "CONTROL_MASK",
  19661. "COPY_READ_BUFFER",
  19662. "COPY_READ_BUFFER_BINDING",
  19663. "COPY_WRITE_BUFFER",
  19664. "COPY_WRITE_BUFFER_BINDING",
  19665. "COUNTER_STYLE_RULE",
  19666. "CSS",
  19667. "CSS2Properties",
  19668. "CSSAnimation",
  19669. "CSSCharsetRule",
  19670. "CSSConditionRule",
  19671. "CSSCounterStyleRule",
  19672. "CSSFontFaceRule",
  19673. "CSSFontFeatureValuesRule",
  19674. "CSSGroupingRule",
  19675. "CSSImageValue",
  19676. "CSSImportRule",
  19677. "CSSKeyframeRule",
  19678. "CSSKeyframesRule",
  19679. "CSSKeywordValue",
  19680. "CSSMathInvert",
  19681. "CSSMathMax",
  19682. "CSSMathMin",
  19683. "CSSMathNegate",
  19684. "CSSMathProduct",
  19685. "CSSMathSum",
  19686. "CSSMathValue",
  19687. "CSSMatrixComponent",
  19688. "CSSMediaRule",
  19689. "CSSMozDocumentRule",
  19690. "CSSNameSpaceRule",
  19691. "CSSNamespaceRule",
  19692. "CSSNumericArray",
  19693. "CSSNumericValue",
  19694. "CSSPageRule",
  19695. "CSSPerspective",
  19696. "CSSPositionValue",
  19697. "CSSPrimitiveValue",
  19698. "CSSRotate",
  19699. "CSSRule",
  19700. "CSSRuleList",
  19701. "CSSScale",
  19702. "CSSSkew",
  19703. "CSSSkewX",
  19704. "CSSSkewY",
  19705. "CSSStyleDeclaration",
  19706. "CSSStyleRule",
  19707. "CSSStyleSheet",
  19708. "CSSStyleValue",
  19709. "CSSSupportsRule",
  19710. "CSSTransformComponent",
  19711. "CSSTransformValue",
  19712. "CSSTransition",
  19713. "CSSTranslate",
  19714. "CSSUnitValue",
  19715. "CSSUnknownRule",
  19716. "CSSUnparsedValue",
  19717. "CSSValue",
  19718. "CSSValueList",
  19719. "CSSVariableReferenceValue",
  19720. "CSSVariablesDeclaration",
  19721. "CSSVariablesRule",
  19722. "CSSViewportRule",
  19723. "CSS_ATTR",
  19724. "CSS_CM",
  19725. "CSS_COUNTER",
  19726. "CSS_CUSTOM",
  19727. "CSS_DEG",
  19728. "CSS_DIMENSION",
  19729. "CSS_EMS",
  19730. "CSS_EXS",
  19731. "CSS_FILTER_BLUR",
  19732. "CSS_FILTER_BRIGHTNESS",
  19733. "CSS_FILTER_CONTRAST",
  19734. "CSS_FILTER_CUSTOM",
  19735. "CSS_FILTER_DROP_SHADOW",
  19736. "CSS_FILTER_GRAYSCALE",
  19737. "CSS_FILTER_HUE_ROTATE",
  19738. "CSS_FILTER_INVERT",
  19739. "CSS_FILTER_OPACITY",
  19740. "CSS_FILTER_REFERENCE",
  19741. "CSS_FILTER_SATURATE",
  19742. "CSS_FILTER_SEPIA",
  19743. "CSS_GRAD",
  19744. "CSS_HZ",
  19745. "CSS_IDENT",
  19746. "CSS_IN",
  19747. "CSS_INHERIT",
  19748. "CSS_KHZ",
  19749. "CSS_MATRIX",
  19750. "CSS_MATRIX3D",
  19751. "CSS_MM",
  19752. "CSS_MS",
  19753. "CSS_NUMBER",
  19754. "CSS_PC",
  19755. "CSS_PERCENTAGE",
  19756. "CSS_PERSPECTIVE",
  19757. "CSS_PRIMITIVE_VALUE",
  19758. "CSS_PT",
  19759. "CSS_PX",
  19760. "CSS_RAD",
  19761. "CSS_RECT",
  19762. "CSS_RGBCOLOR",
  19763. "CSS_ROTATE",
  19764. "CSS_ROTATE3D",
  19765. "CSS_ROTATEX",
  19766. "CSS_ROTATEY",
  19767. "CSS_ROTATEZ",
  19768. "CSS_S",
  19769. "CSS_SCALE",
  19770. "CSS_SCALE3D",
  19771. "CSS_SCALEX",
  19772. "CSS_SCALEY",
  19773. "CSS_SCALEZ",
  19774. "CSS_SKEW",
  19775. "CSS_SKEWX",
  19776. "CSS_SKEWY",
  19777. "CSS_STRING",
  19778. "CSS_TRANSLATE",
  19779. "CSS_TRANSLATE3D",
  19780. "CSS_TRANSLATEX",
  19781. "CSS_TRANSLATEY",
  19782. "CSS_TRANSLATEZ",
  19783. "CSS_UNKNOWN",
  19784. "CSS_URI",
  19785. "CSS_VALUE_LIST",
  19786. "CSS_VH",
  19787. "CSS_VMAX",
  19788. "CSS_VMIN",
  19789. "CSS_VW",
  19790. "CULL_FACE",
  19791. "CULL_FACE_MODE",
  19792. "CURRENT_PROGRAM",
  19793. "CURRENT_QUERY",
  19794. "CURRENT_VERTEX_ATTRIB",
  19795. "CUSTOM",
  19796. "CW",
  19797. "Cache",
  19798. "CacheStorage",
  19799. "CanvasCaptureMediaStream",
  19800. "CanvasCaptureMediaStreamTrack",
  19801. "CanvasGradient",
  19802. "CanvasPattern",
  19803. "CanvasRenderingContext2D",
  19804. "CaretPosition",
  19805. "ChannelMergerNode",
  19806. "ChannelSplitterNode",
  19807. "CharacterData",
  19808. "ClientRect",
  19809. "ClientRectList",
  19810. "Clipboard",
  19811. "ClipboardEvent",
  19812. "ClipboardItem",
  19813. "CloseEvent",
  19814. "Collator",
  19815. "CommandEvent",
  19816. "Comment",
  19817. "CompileError",
  19818. "CompositionEvent",
  19819. "CompressionStream",
  19820. "Console",
  19821. "ConstantSourceNode",
  19822. "Controllers",
  19823. "ConvolverNode",
  19824. "CountQueuingStrategy",
  19825. "Counter",
  19826. "Credential",
  19827. "CredentialsContainer",
  19828. "Crypto",
  19829. "CryptoKey",
  19830. "CustomElementRegistry",
  19831. "CustomEvent",
  19832. "DATABASE_ERR",
  19833. "DATA_CLONE_ERR",
  19834. "DATA_ERR",
  19835. "DBLCLICK",
  19836. "DECR",
  19837. "DECR_WRAP",
  19838. "DELETE_STATUS",
  19839. "DEPTH",
  19840. "DEPTH24_STENCIL8",
  19841. "DEPTH32F_STENCIL8",
  19842. "DEPTH_ATTACHMENT",
  19843. "DEPTH_BITS",
  19844. "DEPTH_BUFFER_BIT",
  19845. "DEPTH_CLEAR_VALUE",
  19846. "DEPTH_COMPONENT",
  19847. "DEPTH_COMPONENT16",
  19848. "DEPTH_COMPONENT24",
  19849. "DEPTH_COMPONENT32F",
  19850. "DEPTH_FUNC",
  19851. "DEPTH_RANGE",
  19852. "DEPTH_STENCIL",
  19853. "DEPTH_STENCIL_ATTACHMENT",
  19854. "DEPTH_TEST",
  19855. "DEPTH_WRITEMASK",
  19856. "DEVICE_INELIGIBLE",
  19857. "DIRECTION_DOWN",
  19858. "DIRECTION_LEFT",
  19859. "DIRECTION_RIGHT",
  19860. "DIRECTION_UP",
  19861. "DISABLED",
  19862. "DISPATCH_REQUEST_ERR",
  19863. "DITHER",
  19864. "DOCUMENT_FRAGMENT_NODE",
  19865. "DOCUMENT_NODE",
  19866. "DOCUMENT_POSITION_CONTAINED_BY",
  19867. "DOCUMENT_POSITION_CONTAINS",
  19868. "DOCUMENT_POSITION_DISCONNECTED",
  19869. "DOCUMENT_POSITION_FOLLOWING",
  19870. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  19871. "DOCUMENT_POSITION_PRECEDING",
  19872. "DOCUMENT_TYPE_NODE",
  19873. "DOMCursor",
  19874. "DOMError",
  19875. "DOMException",
  19876. "DOMImplementation",
  19877. "DOMImplementationLS",
  19878. "DOMMatrix",
  19879. "DOMMatrixReadOnly",
  19880. "DOMParser",
  19881. "DOMPoint",
  19882. "DOMPointReadOnly",
  19883. "DOMQuad",
  19884. "DOMRect",
  19885. "DOMRectList",
  19886. "DOMRectReadOnly",
  19887. "DOMRequest",
  19888. "DOMSTRING_SIZE_ERR",
  19889. "DOMSettableTokenList",
  19890. "DOMStringList",
  19891. "DOMStringMap",
  19892. "DOMTokenList",
  19893. "DOMTransactionEvent",
  19894. "DOM_DELTA_LINE",
  19895. "DOM_DELTA_PAGE",
  19896. "DOM_DELTA_PIXEL",
  19897. "DOM_INPUT_METHOD_DROP",
  19898. "DOM_INPUT_METHOD_HANDWRITING",
  19899. "DOM_INPUT_METHOD_IME",
  19900. "DOM_INPUT_METHOD_KEYBOARD",
  19901. "DOM_INPUT_METHOD_MULTIMODAL",
  19902. "DOM_INPUT_METHOD_OPTION",
  19903. "DOM_INPUT_METHOD_PASTE",
  19904. "DOM_INPUT_METHOD_SCRIPT",
  19905. "DOM_INPUT_METHOD_UNKNOWN",
  19906. "DOM_INPUT_METHOD_VOICE",
  19907. "DOM_KEY_LOCATION_JOYSTICK",
  19908. "DOM_KEY_LOCATION_LEFT",
  19909. "DOM_KEY_LOCATION_MOBILE",
  19910. "DOM_KEY_LOCATION_NUMPAD",
  19911. "DOM_KEY_LOCATION_RIGHT",
  19912. "DOM_KEY_LOCATION_STANDARD",
  19913. "DOM_VK_0",
  19914. "DOM_VK_1",
  19915. "DOM_VK_2",
  19916. "DOM_VK_3",
  19917. "DOM_VK_4",
  19918. "DOM_VK_5",
  19919. "DOM_VK_6",
  19920. "DOM_VK_7",
  19921. "DOM_VK_8",
  19922. "DOM_VK_9",
  19923. "DOM_VK_A",
  19924. "DOM_VK_ACCEPT",
  19925. "DOM_VK_ADD",
  19926. "DOM_VK_ALT",
  19927. "DOM_VK_ALTGR",
  19928. "DOM_VK_AMPERSAND",
  19929. "DOM_VK_ASTERISK",
  19930. "DOM_VK_AT",
  19931. "DOM_VK_ATTN",
  19932. "DOM_VK_B",
  19933. "DOM_VK_BACKSPACE",
  19934. "DOM_VK_BACK_QUOTE",
  19935. "DOM_VK_BACK_SLASH",
  19936. "DOM_VK_BACK_SPACE",
  19937. "DOM_VK_C",
  19938. "DOM_VK_CANCEL",
  19939. "DOM_VK_CAPS_LOCK",
  19940. "DOM_VK_CIRCUMFLEX",
  19941. "DOM_VK_CLEAR",
  19942. "DOM_VK_CLOSE_BRACKET",
  19943. "DOM_VK_CLOSE_CURLY_BRACKET",
  19944. "DOM_VK_CLOSE_PAREN",
  19945. "DOM_VK_COLON",
  19946. "DOM_VK_COMMA",
  19947. "DOM_VK_CONTEXT_MENU",
  19948. "DOM_VK_CONTROL",
  19949. "DOM_VK_CONVERT",
  19950. "DOM_VK_CRSEL",
  19951. "DOM_VK_CTRL",
  19952. "DOM_VK_D",
  19953. "DOM_VK_DECIMAL",
  19954. "DOM_VK_DELETE",
  19955. "DOM_VK_DIVIDE",
  19956. "DOM_VK_DOLLAR",
  19957. "DOM_VK_DOUBLE_QUOTE",
  19958. "DOM_VK_DOWN",
  19959. "DOM_VK_E",
  19960. "DOM_VK_EISU",
  19961. "DOM_VK_END",
  19962. "DOM_VK_ENTER",
  19963. "DOM_VK_EQUALS",
  19964. "DOM_VK_EREOF",
  19965. "DOM_VK_ESCAPE",
  19966. "DOM_VK_EXCLAMATION",
  19967. "DOM_VK_EXECUTE",
  19968. "DOM_VK_EXSEL",
  19969. "DOM_VK_F",
  19970. "DOM_VK_F1",
  19971. "DOM_VK_F10",
  19972. "DOM_VK_F11",
  19973. "DOM_VK_F12",
  19974. "DOM_VK_F13",
  19975. "DOM_VK_F14",
  19976. "DOM_VK_F15",
  19977. "DOM_VK_F16",
  19978. "DOM_VK_F17",
  19979. "DOM_VK_F18",
  19980. "DOM_VK_F19",
  19981. "DOM_VK_F2",
  19982. "DOM_VK_F20",
  19983. "DOM_VK_F21",
  19984. "DOM_VK_F22",
  19985. "DOM_VK_F23",
  19986. "DOM_VK_F24",
  19987. "DOM_VK_F25",
  19988. "DOM_VK_F26",
  19989. "DOM_VK_F27",
  19990. "DOM_VK_F28",
  19991. "DOM_VK_F29",
  19992. "DOM_VK_F3",
  19993. "DOM_VK_F30",
  19994. "DOM_VK_F31",
  19995. "DOM_VK_F32",
  19996. "DOM_VK_F33",
  19997. "DOM_VK_F34",
  19998. "DOM_VK_F35",
  19999. "DOM_VK_F36",
  20000. "DOM_VK_F4",
  20001. "DOM_VK_F5",
  20002. "DOM_VK_F6",
  20003. "DOM_VK_F7",
  20004. "DOM_VK_F8",
  20005. "DOM_VK_F9",
  20006. "DOM_VK_FINAL",
  20007. "DOM_VK_FRONT",
  20008. "DOM_VK_G",
  20009. "DOM_VK_GREATER_THAN",
  20010. "DOM_VK_H",
  20011. "DOM_VK_HANGUL",
  20012. "DOM_VK_HANJA",
  20013. "DOM_VK_HASH",
  20014. "DOM_VK_HELP",
  20015. "DOM_VK_HK_TOGGLE",
  20016. "DOM_VK_HOME",
  20017. "DOM_VK_HYPHEN_MINUS",
  20018. "DOM_VK_I",
  20019. "DOM_VK_INSERT",
  20020. "DOM_VK_J",
  20021. "DOM_VK_JUNJA",
  20022. "DOM_VK_K",
  20023. "DOM_VK_KANA",
  20024. "DOM_VK_KANJI",
  20025. "DOM_VK_L",
  20026. "DOM_VK_LEFT",
  20027. "DOM_VK_LEFT_TAB",
  20028. "DOM_VK_LESS_THAN",
  20029. "DOM_VK_M",
  20030. "DOM_VK_META",
  20031. "DOM_VK_MODECHANGE",
  20032. "DOM_VK_MULTIPLY",
  20033. "DOM_VK_N",
  20034. "DOM_VK_NONCONVERT",
  20035. "DOM_VK_NUMPAD0",
  20036. "DOM_VK_NUMPAD1",
  20037. "DOM_VK_NUMPAD2",
  20038. "DOM_VK_NUMPAD3",
  20039. "DOM_VK_NUMPAD4",
  20040. "DOM_VK_NUMPAD5",
  20041. "DOM_VK_NUMPAD6",
  20042. "DOM_VK_NUMPAD7",
  20043. "DOM_VK_NUMPAD8",
  20044. "DOM_VK_NUMPAD9",
  20045. "DOM_VK_NUM_LOCK",
  20046. "DOM_VK_O",
  20047. "DOM_VK_OEM_1",
  20048. "DOM_VK_OEM_102",
  20049. "DOM_VK_OEM_2",
  20050. "DOM_VK_OEM_3",
  20051. "DOM_VK_OEM_4",
  20052. "DOM_VK_OEM_5",
  20053. "DOM_VK_OEM_6",
  20054. "DOM_VK_OEM_7",
  20055. "DOM_VK_OEM_8",
  20056. "DOM_VK_OEM_COMMA",
  20057. "DOM_VK_OEM_MINUS",
  20058. "DOM_VK_OEM_PERIOD",
  20059. "DOM_VK_OEM_PLUS",
  20060. "DOM_VK_OPEN_BRACKET",
  20061. "DOM_VK_OPEN_CURLY_BRACKET",
  20062. "DOM_VK_OPEN_PAREN",
  20063. "DOM_VK_P",
  20064. "DOM_VK_PA1",
  20065. "DOM_VK_PAGEDOWN",
  20066. "DOM_VK_PAGEUP",
  20067. "DOM_VK_PAGE_DOWN",
  20068. "DOM_VK_PAGE_UP",
  20069. "DOM_VK_PAUSE",
  20070. "DOM_VK_PERCENT",
  20071. "DOM_VK_PERIOD",
  20072. "DOM_VK_PIPE",
  20073. "DOM_VK_PLAY",
  20074. "DOM_VK_PLUS",
  20075. "DOM_VK_PRINT",
  20076. "DOM_VK_PRINTSCREEN",
  20077. "DOM_VK_PROCESSKEY",
  20078. "DOM_VK_PROPERITES",
  20079. "DOM_VK_Q",
  20080. "DOM_VK_QUESTION_MARK",
  20081. "DOM_VK_QUOTE",
  20082. "DOM_VK_R",
  20083. "DOM_VK_REDO",
  20084. "DOM_VK_RETURN",
  20085. "DOM_VK_RIGHT",
  20086. "DOM_VK_S",
  20087. "DOM_VK_SCROLL_LOCK",
  20088. "DOM_VK_SELECT",
  20089. "DOM_VK_SEMICOLON",
  20090. "DOM_VK_SEPARATOR",
  20091. "DOM_VK_SHIFT",
  20092. "DOM_VK_SLASH",
  20093. "DOM_VK_SLEEP",
  20094. "DOM_VK_SPACE",
  20095. "DOM_VK_SUBTRACT",
  20096. "DOM_VK_T",
  20097. "DOM_VK_TAB",
  20098. "DOM_VK_TILDE",
  20099. "DOM_VK_U",
  20100. "DOM_VK_UNDERSCORE",
  20101. "DOM_VK_UNDO",
  20102. "DOM_VK_UNICODE",
  20103. "DOM_VK_UP",
  20104. "DOM_VK_V",
  20105. "DOM_VK_VOLUME_DOWN",
  20106. "DOM_VK_VOLUME_MUTE",
  20107. "DOM_VK_VOLUME_UP",
  20108. "DOM_VK_W",
  20109. "DOM_VK_WIN",
  20110. "DOM_VK_WINDOW",
  20111. "DOM_VK_WIN_ICO_00",
  20112. "DOM_VK_WIN_ICO_CLEAR",
  20113. "DOM_VK_WIN_ICO_HELP",
  20114. "DOM_VK_WIN_OEM_ATTN",
  20115. "DOM_VK_WIN_OEM_AUTO",
  20116. "DOM_VK_WIN_OEM_BACKTAB",
  20117. "DOM_VK_WIN_OEM_CLEAR",
  20118. "DOM_VK_WIN_OEM_COPY",
  20119. "DOM_VK_WIN_OEM_CUSEL",
  20120. "DOM_VK_WIN_OEM_ENLW",
  20121. "DOM_VK_WIN_OEM_FINISH",
  20122. "DOM_VK_WIN_OEM_FJ_JISHO",
  20123. "DOM_VK_WIN_OEM_FJ_LOYA",
  20124. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  20125. "DOM_VK_WIN_OEM_FJ_ROYA",
  20126. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  20127. "DOM_VK_WIN_OEM_JUMP",
  20128. "DOM_VK_WIN_OEM_PA1",
  20129. "DOM_VK_WIN_OEM_PA2",
  20130. "DOM_VK_WIN_OEM_PA3",
  20131. "DOM_VK_WIN_OEM_RESET",
  20132. "DOM_VK_WIN_OEM_WSCTRL",
  20133. "DOM_VK_X",
  20134. "DOM_VK_XF86XK_ADD_FAVORITE",
  20135. "DOM_VK_XF86XK_APPLICATION_LEFT",
  20136. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  20137. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  20138. "DOM_VK_XF86XK_AUDIO_FORWARD",
  20139. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  20140. "DOM_VK_XF86XK_AUDIO_MEDIA",
  20141. "DOM_VK_XF86XK_AUDIO_MUTE",
  20142. "DOM_VK_XF86XK_AUDIO_NEXT",
  20143. "DOM_VK_XF86XK_AUDIO_PAUSE",
  20144. "DOM_VK_XF86XK_AUDIO_PLAY",
  20145. "DOM_VK_XF86XK_AUDIO_PREV",
  20146. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  20147. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  20148. "DOM_VK_XF86XK_AUDIO_RECORD",
  20149. "DOM_VK_XF86XK_AUDIO_REPEAT",
  20150. "DOM_VK_XF86XK_AUDIO_REWIND",
  20151. "DOM_VK_XF86XK_AUDIO_STOP",
  20152. "DOM_VK_XF86XK_AWAY",
  20153. "DOM_VK_XF86XK_BACK",
  20154. "DOM_VK_XF86XK_BACK_FORWARD",
  20155. "DOM_VK_XF86XK_BATTERY",
  20156. "DOM_VK_XF86XK_BLUE",
  20157. "DOM_VK_XF86XK_BLUETOOTH",
  20158. "DOM_VK_XF86XK_BOOK",
  20159. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  20160. "DOM_VK_XF86XK_CALCULATOR",
  20161. "DOM_VK_XF86XK_CALENDAR",
  20162. "DOM_VK_XF86XK_CD",
  20163. "DOM_VK_XF86XK_CLOSE",
  20164. "DOM_VK_XF86XK_COMMUNITY",
  20165. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  20166. "DOM_VK_XF86XK_COPY",
  20167. "DOM_VK_XF86XK_CUT",
  20168. "DOM_VK_XF86XK_CYCLE_ANGLE",
  20169. "DOM_VK_XF86XK_DISPLAY",
  20170. "DOM_VK_XF86XK_DOCUMENTS",
  20171. "DOM_VK_XF86XK_DOS",
  20172. "DOM_VK_XF86XK_EJECT",
  20173. "DOM_VK_XF86XK_EXCEL",
  20174. "DOM_VK_XF86XK_EXPLORER",
  20175. "DOM_VK_XF86XK_FAVORITES",
  20176. "DOM_VK_XF86XK_FINANCE",
  20177. "DOM_VK_XF86XK_FORWARD",
  20178. "DOM_VK_XF86XK_FRAME_BACK",
  20179. "DOM_VK_XF86XK_FRAME_FORWARD",
  20180. "DOM_VK_XF86XK_GAME",
  20181. "DOM_VK_XF86XK_GO",
  20182. "DOM_VK_XF86XK_GREEN",
  20183. "DOM_VK_XF86XK_HIBERNATE",
  20184. "DOM_VK_XF86XK_HISTORY",
  20185. "DOM_VK_XF86XK_HOME_PAGE",
  20186. "DOM_VK_XF86XK_HOT_LINKS",
  20187. "DOM_VK_XF86XK_I_TOUCH",
  20188. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  20189. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  20190. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  20191. "DOM_VK_XF86XK_LAUNCH0",
  20192. "DOM_VK_XF86XK_LAUNCH1",
  20193. "DOM_VK_XF86XK_LAUNCH2",
  20194. "DOM_VK_XF86XK_LAUNCH3",
  20195. "DOM_VK_XF86XK_LAUNCH4",
  20196. "DOM_VK_XF86XK_LAUNCH5",
  20197. "DOM_VK_XF86XK_LAUNCH6",
  20198. "DOM_VK_XF86XK_LAUNCH7",
  20199. "DOM_VK_XF86XK_LAUNCH8",
  20200. "DOM_VK_XF86XK_LAUNCH9",
  20201. "DOM_VK_XF86XK_LAUNCH_A",
  20202. "DOM_VK_XF86XK_LAUNCH_B",
  20203. "DOM_VK_XF86XK_LAUNCH_C",
  20204. "DOM_VK_XF86XK_LAUNCH_D",
  20205. "DOM_VK_XF86XK_LAUNCH_E",
  20206. "DOM_VK_XF86XK_LAUNCH_F",
  20207. "DOM_VK_XF86XK_LIGHT_BULB",
  20208. "DOM_VK_XF86XK_LOG_OFF",
  20209. "DOM_VK_XF86XK_MAIL",
  20210. "DOM_VK_XF86XK_MAIL_FORWARD",
  20211. "DOM_VK_XF86XK_MARKET",
  20212. "DOM_VK_XF86XK_MEETING",
  20213. "DOM_VK_XF86XK_MEMO",
  20214. "DOM_VK_XF86XK_MENU_KB",
  20215. "DOM_VK_XF86XK_MENU_PB",
  20216. "DOM_VK_XF86XK_MESSENGER",
  20217. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  20218. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  20219. "DOM_VK_XF86XK_MUSIC",
  20220. "DOM_VK_XF86XK_MY_COMPUTER",
  20221. "DOM_VK_XF86XK_MY_SITES",
  20222. "DOM_VK_XF86XK_NEW",
  20223. "DOM_VK_XF86XK_NEWS",
  20224. "DOM_VK_XF86XK_OFFICE_HOME",
  20225. "DOM_VK_XF86XK_OPEN",
  20226. "DOM_VK_XF86XK_OPEN_URL",
  20227. "DOM_VK_XF86XK_OPTION",
  20228. "DOM_VK_XF86XK_PASTE",
  20229. "DOM_VK_XF86XK_PHONE",
  20230. "DOM_VK_XF86XK_PICTURES",
  20231. "DOM_VK_XF86XK_POWER_DOWN",
  20232. "DOM_VK_XF86XK_POWER_OFF",
  20233. "DOM_VK_XF86XK_RED",
  20234. "DOM_VK_XF86XK_REFRESH",
  20235. "DOM_VK_XF86XK_RELOAD",
  20236. "DOM_VK_XF86XK_REPLY",
  20237. "DOM_VK_XF86XK_ROCKER_DOWN",
  20238. "DOM_VK_XF86XK_ROCKER_ENTER",
  20239. "DOM_VK_XF86XK_ROCKER_UP",
  20240. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  20241. "DOM_VK_XF86XK_ROTATION_KB",
  20242. "DOM_VK_XF86XK_ROTATION_PB",
  20243. "DOM_VK_XF86XK_SAVE",
  20244. "DOM_VK_XF86XK_SCREEN_SAVER",
  20245. "DOM_VK_XF86XK_SCROLL_CLICK",
  20246. "DOM_VK_XF86XK_SCROLL_DOWN",
  20247. "DOM_VK_XF86XK_SCROLL_UP",
  20248. "DOM_VK_XF86XK_SEARCH",
  20249. "DOM_VK_XF86XK_SEND",
  20250. "DOM_VK_XF86XK_SHOP",
  20251. "DOM_VK_XF86XK_SPELL",
  20252. "DOM_VK_XF86XK_SPLIT_SCREEN",
  20253. "DOM_VK_XF86XK_STANDBY",
  20254. "DOM_VK_XF86XK_START",
  20255. "DOM_VK_XF86XK_STOP",
  20256. "DOM_VK_XF86XK_SUBTITLE",
  20257. "DOM_VK_XF86XK_SUPPORT",
  20258. "DOM_VK_XF86XK_SUSPEND",
  20259. "DOM_VK_XF86XK_TASK_PANE",
  20260. "DOM_VK_XF86XK_TERMINAL",
  20261. "DOM_VK_XF86XK_TIME",
  20262. "DOM_VK_XF86XK_TOOLS",
  20263. "DOM_VK_XF86XK_TOP_MENU",
  20264. "DOM_VK_XF86XK_TO_DO_LIST",
  20265. "DOM_VK_XF86XK_TRAVEL",
  20266. "DOM_VK_XF86XK_USER1KB",
  20267. "DOM_VK_XF86XK_USER2KB",
  20268. "DOM_VK_XF86XK_USER_PB",
  20269. "DOM_VK_XF86XK_UWB",
  20270. "DOM_VK_XF86XK_VENDOR_HOME",
  20271. "DOM_VK_XF86XK_VIDEO",
  20272. "DOM_VK_XF86XK_VIEW",
  20273. "DOM_VK_XF86XK_WAKE_UP",
  20274. "DOM_VK_XF86XK_WEB_CAM",
  20275. "DOM_VK_XF86XK_WHEEL_BUTTON",
  20276. "DOM_VK_XF86XK_WLAN",
  20277. "DOM_VK_XF86XK_WORD",
  20278. "DOM_VK_XF86XK_WWW",
  20279. "DOM_VK_XF86XK_XFER",
  20280. "DOM_VK_XF86XK_YELLOW",
  20281. "DOM_VK_XF86XK_ZOOM_IN",
  20282. "DOM_VK_XF86XK_ZOOM_OUT",
  20283. "DOM_VK_Y",
  20284. "DOM_VK_Z",
  20285. "DOM_VK_ZOOM",
  20286. "DONE",
  20287. "DONT_CARE",
  20288. "DOWNLOADING",
  20289. "DRAGDROP",
  20290. "DRAW_BUFFER0",
  20291. "DRAW_BUFFER1",
  20292. "DRAW_BUFFER10",
  20293. "DRAW_BUFFER11",
  20294. "DRAW_BUFFER12",
  20295. "DRAW_BUFFER13",
  20296. "DRAW_BUFFER14",
  20297. "DRAW_BUFFER15",
  20298. "DRAW_BUFFER2",
  20299. "DRAW_BUFFER3",
  20300. "DRAW_BUFFER4",
  20301. "DRAW_BUFFER5",
  20302. "DRAW_BUFFER6",
  20303. "DRAW_BUFFER7",
  20304. "DRAW_BUFFER8",
  20305. "DRAW_BUFFER9",
  20306. "DRAW_FRAMEBUFFER",
  20307. "DRAW_FRAMEBUFFER_BINDING",
  20308. "DST_ALPHA",
  20309. "DST_COLOR",
  20310. "DYNAMIC_COPY",
  20311. "DYNAMIC_DRAW",
  20312. "DYNAMIC_READ",
  20313. "DataChannel",
  20314. "DataTransfer",
  20315. "DataTransferItem",
  20316. "DataTransferItemList",
  20317. "DataView",
  20318. "Date",
  20319. "DateTimeFormat",
  20320. "DecompressionStream",
  20321. "DelayNode",
  20322. "DeprecationReportBody",
  20323. "DesktopNotification",
  20324. "DesktopNotificationCenter",
  20325. "DeviceLightEvent",
  20326. "DeviceMotionEvent",
  20327. "DeviceMotionEventAcceleration",
  20328. "DeviceMotionEventRotationRate",
  20329. "DeviceOrientationEvent",
  20330. "DeviceProximityEvent",
  20331. "DeviceStorage",
  20332. "DeviceStorageChangeEvent",
  20333. "Directory",
  20334. "DisplayNames",
  20335. "Document",
  20336. "DocumentFragment",
  20337. "DocumentTimeline",
  20338. "DocumentType",
  20339. "DragEvent",
  20340. "DynamicsCompressorNode",
  20341. "E",
  20342. "ELEMENT_ARRAY_BUFFER",
  20343. "ELEMENT_ARRAY_BUFFER_BINDING",
  20344. "ELEMENT_NODE",
  20345. "EMPTY",
  20346. "ENCODING_ERR",
  20347. "ENDED",
  20348. "END_TO_END",
  20349. "END_TO_START",
  20350. "ENTITY_NODE",
  20351. "ENTITY_REFERENCE_NODE",
  20352. "EPSILON",
  20353. "EQUAL",
  20354. "EQUALPOWER",
  20355. "ERROR",
  20356. "EXPONENTIAL_DISTANCE",
  20357. "Element",
  20358. "ElementInternals",
  20359. "ElementQuery",
  20360. "EnterPictureInPictureEvent",
  20361. "Entity",
  20362. "EntityReference",
  20363. "Error",
  20364. "ErrorEvent",
  20365. "EvalError",
  20366. "Event",
  20367. "EventException",
  20368. "EventSource",
  20369. "EventTarget",
  20370. "External",
  20371. "FASTEST",
  20372. "FIDOSDK",
  20373. "FILTER_ACCEPT",
  20374. "FILTER_INTERRUPT",
  20375. "FILTER_REJECT",
  20376. "FILTER_SKIP",
  20377. "FINISHED_STATE",
  20378. "FIRST_ORDERED_NODE_TYPE",
  20379. "FLOAT",
  20380. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  20381. "FLOAT_MAT2",
  20382. "FLOAT_MAT2x3",
  20383. "FLOAT_MAT2x4",
  20384. "FLOAT_MAT3",
  20385. "FLOAT_MAT3x2",
  20386. "FLOAT_MAT3x4",
  20387. "FLOAT_MAT4",
  20388. "FLOAT_MAT4x2",
  20389. "FLOAT_MAT4x3",
  20390. "FLOAT_VEC2",
  20391. "FLOAT_VEC3",
  20392. "FLOAT_VEC4",
  20393. "FOCUS",
  20394. "FONT_FACE_RULE",
  20395. "FONT_FEATURE_VALUES_RULE",
  20396. "FRAGMENT_SHADER",
  20397. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  20398. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  20399. "FRAMEBUFFER",
  20400. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  20401. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  20402. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  20403. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  20404. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  20405. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  20406. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  20407. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  20408. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  20409. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  20410. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  20411. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  20412. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  20413. "FRAMEBUFFER_BINDING",
  20414. "FRAMEBUFFER_COMPLETE",
  20415. "FRAMEBUFFER_DEFAULT",
  20416. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  20417. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  20418. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  20419. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  20420. "FRAMEBUFFER_UNSUPPORTED",
  20421. "FRONT",
  20422. "FRONT_AND_BACK",
  20423. "FRONT_FACE",
  20424. "FUNC_ADD",
  20425. "FUNC_REVERSE_SUBTRACT",
  20426. "FUNC_SUBTRACT",
  20427. "FeaturePolicy",
  20428. "FeaturePolicyViolationReportBody",
  20429. "FederatedCredential",
  20430. "Feed",
  20431. "FeedEntry",
  20432. "File",
  20433. "FileError",
  20434. "FileList",
  20435. "FileReader",
  20436. "FileSystem",
  20437. "FileSystemDirectoryEntry",
  20438. "FileSystemDirectoryReader",
  20439. "FileSystemEntry",
  20440. "FileSystemFileEntry",
  20441. "FinalizationRegistry",
  20442. "FindInPage",
  20443. "Float32Array",
  20444. "Float64Array",
  20445. "FocusEvent",
  20446. "FontFace",
  20447. "FontFaceSet",
  20448. "FontFaceSetLoadEvent",
  20449. "FormData",
  20450. "FormDataEvent",
  20451. "FragmentDirective",
  20452. "Function",
  20453. "GENERATE_MIPMAP_HINT",
  20454. "GEQUAL",
  20455. "GREATER",
  20456. "GREEN_BITS",
  20457. "GainNode",
  20458. "Gamepad",
  20459. "GamepadAxisMoveEvent",
  20460. "GamepadButton",
  20461. "GamepadButtonEvent",
  20462. "GamepadEvent",
  20463. "GamepadHapticActuator",
  20464. "GamepadPose",
  20465. "Geolocation",
  20466. "GeolocationCoordinates",
  20467. "GeolocationPosition",
  20468. "GeolocationPositionError",
  20469. "GestureEvent",
  20470. "Global",
  20471. "Gyroscope",
  20472. "HALF_FLOAT",
  20473. "HAVE_CURRENT_DATA",
  20474. "HAVE_ENOUGH_DATA",
  20475. "HAVE_FUTURE_DATA",
  20476. "HAVE_METADATA",
  20477. "HAVE_NOTHING",
  20478. "HEADERS_RECEIVED",
  20479. "HIDDEN",
  20480. "HIERARCHY_REQUEST_ERR",
  20481. "HIGHPASS",
  20482. "HIGHSHELF",
  20483. "HIGH_FLOAT",
  20484. "HIGH_INT",
  20485. "HORIZONTAL",
  20486. "HORIZONTAL_AXIS",
  20487. "HRTF",
  20488. "HTMLAllCollection",
  20489. "HTMLAnchorElement",
  20490. "HTMLAppletElement",
  20491. "HTMLAreaElement",
  20492. "HTMLAudioElement",
  20493. "HTMLBRElement",
  20494. "HTMLBaseElement",
  20495. "HTMLBaseFontElement",
  20496. "HTMLBlockquoteElement",
  20497. "HTMLBodyElement",
  20498. "HTMLButtonElement",
  20499. "HTMLCanvasElement",
  20500. "HTMLCollection",
  20501. "HTMLCommandElement",
  20502. "HTMLContentElement",
  20503. "HTMLDListElement",
  20504. "HTMLDataElement",
  20505. "HTMLDataListElement",
  20506. "HTMLDetailsElement",
  20507. "HTMLDialogElement",
  20508. "HTMLDirectoryElement",
  20509. "HTMLDivElement",
  20510. "HTMLDocument",
  20511. "HTMLElement",
  20512. "HTMLEmbedElement",
  20513. "HTMLFieldSetElement",
  20514. "HTMLFontElement",
  20515. "HTMLFormControlsCollection",
  20516. "HTMLFormElement",
  20517. "HTMLFrameElement",
  20518. "HTMLFrameSetElement",
  20519. "HTMLHRElement",
  20520. "HTMLHeadElement",
  20521. "HTMLHeadingElement",
  20522. "HTMLHtmlElement",
  20523. "HTMLIFrameElement",
  20524. "HTMLImageElement",
  20525. "HTMLInputElement",
  20526. "HTMLIsIndexElement",
  20527. "HTMLKeygenElement",
  20528. "HTMLLIElement",
  20529. "HTMLLabelElement",
  20530. "HTMLLegendElement",
  20531. "HTMLLinkElement",
  20532. "HTMLMapElement",
  20533. "HTMLMarqueeElement",
  20534. "HTMLMediaElement",
  20535. "HTMLMenuElement",
  20536. "HTMLMenuItemElement",
  20537. "HTMLMetaElement",
  20538. "HTMLMeterElement",
  20539. "HTMLModElement",
  20540. "HTMLOListElement",
  20541. "HTMLObjectElement",
  20542. "HTMLOptGroupElement",
  20543. "HTMLOptionElement",
  20544. "HTMLOptionsCollection",
  20545. "HTMLOutputElement",
  20546. "HTMLParagraphElement",
  20547. "HTMLParamElement",
  20548. "HTMLPictureElement",
  20549. "HTMLPreElement",
  20550. "HTMLProgressElement",
  20551. "HTMLPropertiesCollection",
  20552. "HTMLQuoteElement",
  20553. "HTMLScriptElement",
  20554. "HTMLSelectElement",
  20555. "HTMLShadowElement",
  20556. "HTMLSlotElement",
  20557. "HTMLSourceElement",
  20558. "HTMLSpanElement",
  20559. "HTMLStyleElement",
  20560. "HTMLTableCaptionElement",
  20561. "HTMLTableCellElement",
  20562. "HTMLTableColElement",
  20563. "HTMLTableElement",
  20564. "HTMLTableRowElement",
  20565. "HTMLTableSectionElement",
  20566. "HTMLTemplateElement",
  20567. "HTMLTextAreaElement",
  20568. "HTMLTimeElement",
  20569. "HTMLTitleElement",
  20570. "HTMLTrackElement",
  20571. "HTMLUListElement",
  20572. "HTMLUnknownElement",
  20573. "HTMLVideoElement",
  20574. "HashChangeEvent",
  20575. "Headers",
  20576. "History",
  20577. "Hz",
  20578. "ICE_CHECKING",
  20579. "ICE_CLOSED",
  20580. "ICE_COMPLETED",
  20581. "ICE_CONNECTED",
  20582. "ICE_FAILED",
  20583. "ICE_GATHERING",
  20584. "ICE_WAITING",
  20585. "IDBCursor",
  20586. "IDBCursorWithValue",
  20587. "IDBDatabase",
  20588. "IDBDatabaseException",
  20589. "IDBFactory",
  20590. "IDBFileHandle",
  20591. "IDBFileRequest",
  20592. "IDBIndex",
  20593. "IDBKeyRange",
  20594. "IDBMutableFile",
  20595. "IDBObjectStore",
  20596. "IDBOpenDBRequest",
  20597. "IDBRequest",
  20598. "IDBTransaction",
  20599. "IDBVersionChangeEvent",
  20600. "IDLE",
  20601. "IIRFilterNode",
  20602. "IMPLEMENTATION_COLOR_READ_FORMAT",
  20603. "IMPLEMENTATION_COLOR_READ_TYPE",
  20604. "IMPORT_RULE",
  20605. "INCR",
  20606. "INCR_WRAP",
  20607. "INDEX_SIZE_ERR",
  20608. "INT",
  20609. "INTERLEAVED_ATTRIBS",
  20610. "INT_2_10_10_10_REV",
  20611. "INT_SAMPLER_2D",
  20612. "INT_SAMPLER_2D_ARRAY",
  20613. "INT_SAMPLER_3D",
  20614. "INT_SAMPLER_CUBE",
  20615. "INT_VEC2",
  20616. "INT_VEC3",
  20617. "INT_VEC4",
  20618. "INUSE_ATTRIBUTE_ERR",
  20619. "INVALID_ACCESS_ERR",
  20620. "INVALID_CHARACTER_ERR",
  20621. "INVALID_ENUM",
  20622. "INVALID_EXPRESSION_ERR",
  20623. "INVALID_FRAMEBUFFER_OPERATION",
  20624. "INVALID_INDEX",
  20625. "INVALID_MODIFICATION_ERR",
  20626. "INVALID_NODE_TYPE_ERR",
  20627. "INVALID_OPERATION",
  20628. "INVALID_STATE_ERR",
  20629. "INVALID_VALUE",
  20630. "INVERSE_DISTANCE",
  20631. "INVERT",
  20632. "IceCandidate",
  20633. "IdleDeadline",
  20634. "Image",
  20635. "ImageBitmap",
  20636. "ImageBitmapRenderingContext",
  20637. "ImageCapture",
  20638. "ImageData",
  20639. "Infinity",
  20640. "InputDeviceCapabilities",
  20641. "InputDeviceInfo",
  20642. "InputEvent",
  20643. "InputMethodContext",
  20644. "InstallTrigger",
  20645. "InstallTriggerImpl",
  20646. "Instance",
  20647. "Int16Array",
  20648. "Int32Array",
  20649. "Int8Array",
  20650. "Intent",
  20651. "InternalError",
  20652. "IntersectionObserver",
  20653. "IntersectionObserverEntry",
  20654. "Intl",
  20655. "IsSearchProviderInstalled",
  20656. "Iterator",
  20657. "JSON",
  20658. "KEEP",
  20659. "KEYDOWN",
  20660. "KEYFRAMES_RULE",
  20661. "KEYFRAME_RULE",
  20662. "KEYPRESS",
  20663. "KEYUP",
  20664. "KeyEvent",
  20665. "Keyboard",
  20666. "KeyboardEvent",
  20667. "KeyboardLayoutMap",
  20668. "KeyframeEffect",
  20669. "LENGTHADJUST_SPACING",
  20670. "LENGTHADJUST_SPACINGANDGLYPHS",
  20671. "LENGTHADJUST_UNKNOWN",
  20672. "LEQUAL",
  20673. "LESS",
  20674. "LINEAR",
  20675. "LINEAR_DISTANCE",
  20676. "LINEAR_MIPMAP_LINEAR",
  20677. "LINEAR_MIPMAP_NEAREST",
  20678. "LINES",
  20679. "LINE_LOOP",
  20680. "LINE_STRIP",
  20681. "LINE_WIDTH",
  20682. "LINK_STATUS",
  20683. "LIVE",
  20684. "LN10",
  20685. "LN2",
  20686. "LOADED",
  20687. "LOADING",
  20688. "LOG10E",
  20689. "LOG2E",
  20690. "LOWPASS",
  20691. "LOWSHELF",
  20692. "LOW_FLOAT",
  20693. "LOW_INT",
  20694. "LSException",
  20695. "LSParserFilter",
  20696. "LUMINANCE",
  20697. "LUMINANCE_ALPHA",
  20698. "LargestContentfulPaint",
  20699. "LayoutShift",
  20700. "LayoutShiftAttribution",
  20701. "LinearAccelerationSensor",
  20702. "LinkError",
  20703. "ListFormat",
  20704. "LocalMediaStream",
  20705. "Locale",
  20706. "Location",
  20707. "Lock",
  20708. "LockManager",
  20709. "MAX",
  20710. "MAX_3D_TEXTURE_SIZE",
  20711. "MAX_ARRAY_TEXTURE_LAYERS",
  20712. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  20713. "MAX_COLOR_ATTACHMENTS",
  20714. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  20715. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  20716. "MAX_COMBINED_UNIFORM_BLOCKS",
  20717. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  20718. "MAX_CUBE_MAP_TEXTURE_SIZE",
  20719. "MAX_DRAW_BUFFERS",
  20720. "MAX_ELEMENTS_INDICES",
  20721. "MAX_ELEMENTS_VERTICES",
  20722. "MAX_ELEMENT_INDEX",
  20723. "MAX_FRAGMENT_INPUT_COMPONENTS",
  20724. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  20725. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  20726. "MAX_FRAGMENT_UNIFORM_VECTORS",
  20727. "MAX_PROGRAM_TEXEL_OFFSET",
  20728. "MAX_RENDERBUFFER_SIZE",
  20729. "MAX_SAFE_INTEGER",
  20730. "MAX_SAMPLES",
  20731. "MAX_SERVER_WAIT_TIMEOUT",
  20732. "MAX_TEXTURE_IMAGE_UNITS",
  20733. "MAX_TEXTURE_LOD_BIAS",
  20734. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  20735. "MAX_TEXTURE_SIZE",
  20736. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  20737. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  20738. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  20739. "MAX_UNIFORM_BLOCK_SIZE",
  20740. "MAX_UNIFORM_BUFFER_BINDINGS",
  20741. "MAX_VALUE",
  20742. "MAX_VARYING_COMPONENTS",
  20743. "MAX_VARYING_VECTORS",
  20744. "MAX_VERTEX_ATTRIBS",
  20745. "MAX_VERTEX_OUTPUT_COMPONENTS",
  20746. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  20747. "MAX_VERTEX_UNIFORM_BLOCKS",
  20748. "MAX_VERTEX_UNIFORM_COMPONENTS",
  20749. "MAX_VERTEX_UNIFORM_VECTORS",
  20750. "MAX_VIEWPORT_DIMS",
  20751. "MEDIA_ERR_ABORTED",
  20752. "MEDIA_ERR_DECODE",
  20753. "MEDIA_ERR_ENCRYPTED",
  20754. "MEDIA_ERR_NETWORK",
  20755. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  20756. "MEDIA_KEYERR_CLIENT",
  20757. "MEDIA_KEYERR_DOMAIN",
  20758. "MEDIA_KEYERR_HARDWARECHANGE",
  20759. "MEDIA_KEYERR_OUTPUT",
  20760. "MEDIA_KEYERR_SERVICE",
  20761. "MEDIA_KEYERR_UNKNOWN",
  20762. "MEDIA_RULE",
  20763. "MEDIUM_FLOAT",
  20764. "MEDIUM_INT",
  20765. "META_MASK",
  20766. "MIDIAccess",
  20767. "MIDIConnectionEvent",
  20768. "MIDIInput",
  20769. "MIDIInputMap",
  20770. "MIDIMessageEvent",
  20771. "MIDIOutput",
  20772. "MIDIOutputMap",
  20773. "MIDIPort",
  20774. "MIN",
  20775. "MIN_PROGRAM_TEXEL_OFFSET",
  20776. "MIN_SAFE_INTEGER",
  20777. "MIN_VALUE",
  20778. "MIRRORED_REPEAT",
  20779. "MODE_ASYNCHRONOUS",
  20780. "MODE_SYNCHRONOUS",
  20781. "MODIFICATION",
  20782. "MOUSEDOWN",
  20783. "MOUSEDRAG",
  20784. "MOUSEMOVE",
  20785. "MOUSEOUT",
  20786. "MOUSEOVER",
  20787. "MOUSEUP",
  20788. "MOZ_KEYFRAMES_RULE",
  20789. "MOZ_KEYFRAME_RULE",
  20790. "MOZ_SOURCE_CURSOR",
  20791. "MOZ_SOURCE_ERASER",
  20792. "MOZ_SOURCE_KEYBOARD",
  20793. "MOZ_SOURCE_MOUSE",
  20794. "MOZ_SOURCE_PEN",
  20795. "MOZ_SOURCE_TOUCH",
  20796. "MOZ_SOURCE_UNKNOWN",
  20797. "MSGESTURE_FLAG_BEGIN",
  20798. "MSGESTURE_FLAG_CANCEL",
  20799. "MSGESTURE_FLAG_END",
  20800. "MSGESTURE_FLAG_INERTIA",
  20801. "MSGESTURE_FLAG_NONE",
  20802. "MSPOINTER_TYPE_MOUSE",
  20803. "MSPOINTER_TYPE_PEN",
  20804. "MSPOINTER_TYPE_TOUCH",
  20805. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  20806. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  20807. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  20808. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  20809. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  20810. "MS_ASYNC_OP_STATUS_CANCELED",
  20811. "MS_ASYNC_OP_STATUS_ERROR",
  20812. "MS_ASYNC_OP_STATUS_SUCCESS",
  20813. "MS_MANIPULATION_STATE_ACTIVE",
  20814. "MS_MANIPULATION_STATE_CANCELLED",
  20815. "MS_MANIPULATION_STATE_COMMITTED",
  20816. "MS_MANIPULATION_STATE_DRAGGING",
  20817. "MS_MANIPULATION_STATE_INERTIA",
  20818. "MS_MANIPULATION_STATE_PRESELECT",
  20819. "MS_MANIPULATION_STATE_SELECTING",
  20820. "MS_MANIPULATION_STATE_STOPPED",
  20821. "MS_MEDIA_ERR_ENCRYPTED",
  20822. "MS_MEDIA_KEYERR_CLIENT",
  20823. "MS_MEDIA_KEYERR_DOMAIN",
  20824. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  20825. "MS_MEDIA_KEYERR_OUTPUT",
  20826. "MS_MEDIA_KEYERR_SERVICE",
  20827. "MS_MEDIA_KEYERR_UNKNOWN",
  20828. "Map",
  20829. "Math",
  20830. "MathMLElement",
  20831. "MediaCapabilities",
  20832. "MediaCapabilitiesInfo",
  20833. "MediaController",
  20834. "MediaDeviceInfo",
  20835. "MediaDevices",
  20836. "MediaElementAudioSourceNode",
  20837. "MediaEncryptedEvent",
  20838. "MediaError",
  20839. "MediaKeyError",
  20840. "MediaKeyEvent",
  20841. "MediaKeyMessageEvent",
  20842. "MediaKeyNeededEvent",
  20843. "MediaKeySession",
  20844. "MediaKeyStatusMap",
  20845. "MediaKeySystemAccess",
  20846. "MediaKeys",
  20847. "MediaList",
  20848. "MediaMetadata",
  20849. "MediaQueryList",
  20850. "MediaQueryListEvent",
  20851. "MediaRecorder",
  20852. "MediaRecorderErrorEvent",
  20853. "MediaSession",
  20854. "MediaSettingsRange",
  20855. "MediaSource",
  20856. "MediaStream",
  20857. "MediaStreamAudioDestinationNode",
  20858. "MediaStreamAudioSourceNode",
  20859. "MediaStreamEvent",
  20860. "MediaStreamTrack",
  20861. "MediaStreamTrackAudioSourceNode",
  20862. "MediaStreamTrackEvent",
  20863. "Memory",
  20864. "MessageChannel",
  20865. "MessageEvent",
  20866. "MessagePort",
  20867. "Methods",
  20868. "MimeType",
  20869. "MimeTypeArray",
  20870. "Module",
  20871. "MouseEvent",
  20872. "MouseScrollEvent",
  20873. "MozAnimation",
  20874. "MozAnimationDelay",
  20875. "MozAnimationDirection",
  20876. "MozAnimationDuration",
  20877. "MozAnimationFillMode",
  20878. "MozAnimationIterationCount",
  20879. "MozAnimationName",
  20880. "MozAnimationPlayState",
  20881. "MozAnimationTimingFunction",
  20882. "MozAppearance",
  20883. "MozBackfaceVisibility",
  20884. "MozBinding",
  20885. "MozBorderBottomColors",
  20886. "MozBorderEnd",
  20887. "MozBorderEndColor",
  20888. "MozBorderEndStyle",
  20889. "MozBorderEndWidth",
  20890. "MozBorderImage",
  20891. "MozBorderLeftColors",
  20892. "MozBorderRightColors",
  20893. "MozBorderStart",
  20894. "MozBorderStartColor",
  20895. "MozBorderStartStyle",
  20896. "MozBorderStartWidth",
  20897. "MozBorderTopColors",
  20898. "MozBoxAlign",
  20899. "MozBoxDirection",
  20900. "MozBoxFlex",
  20901. "MozBoxOrdinalGroup",
  20902. "MozBoxOrient",
  20903. "MozBoxPack",
  20904. "MozBoxSizing",
  20905. "MozCSSKeyframeRule",
  20906. "MozCSSKeyframesRule",
  20907. "MozColumnCount",
  20908. "MozColumnFill",
  20909. "MozColumnGap",
  20910. "MozColumnRule",
  20911. "MozColumnRuleColor",
  20912. "MozColumnRuleStyle",
  20913. "MozColumnRuleWidth",
  20914. "MozColumnWidth",
  20915. "MozColumns",
  20916. "MozContactChangeEvent",
  20917. "MozFloatEdge",
  20918. "MozFontFeatureSettings",
  20919. "MozFontLanguageOverride",
  20920. "MozForceBrokenImageIcon",
  20921. "MozHyphens",
  20922. "MozImageRegion",
  20923. "MozMarginEnd",
  20924. "MozMarginStart",
  20925. "MozMmsEvent",
  20926. "MozMmsMessage",
  20927. "MozMobileMessageThread",
  20928. "MozOSXFontSmoothing",
  20929. "MozOrient",
  20930. "MozOsxFontSmoothing",
  20931. "MozOutlineRadius",
  20932. "MozOutlineRadiusBottomleft",
  20933. "MozOutlineRadiusBottomright",
  20934. "MozOutlineRadiusTopleft",
  20935. "MozOutlineRadiusTopright",
  20936. "MozPaddingEnd",
  20937. "MozPaddingStart",
  20938. "MozPerspective",
  20939. "MozPerspectiveOrigin",
  20940. "MozPowerManager",
  20941. "MozSettingsEvent",
  20942. "MozSmsEvent",
  20943. "MozSmsMessage",
  20944. "MozStackSizing",
  20945. "MozTabSize",
  20946. "MozTextAlignLast",
  20947. "MozTextDecorationColor",
  20948. "MozTextDecorationLine",
  20949. "MozTextDecorationStyle",
  20950. "MozTextSizeAdjust",
  20951. "MozTransform",
  20952. "MozTransformOrigin",
  20953. "MozTransformStyle",
  20954. "MozTransition",
  20955. "MozTransitionDelay",
  20956. "MozTransitionDuration",
  20957. "MozTransitionProperty",
  20958. "MozTransitionTimingFunction",
  20959. "MozUserFocus",
  20960. "MozUserInput",
  20961. "MozUserModify",
  20962. "MozUserSelect",
  20963. "MozWindowDragging",
  20964. "MozWindowShadow",
  20965. "MutationEvent",
  20966. "MutationObserver",
  20967. "MutationRecord",
  20968. "NAMESPACE_ERR",
  20969. "NAMESPACE_RULE",
  20970. "NEAREST",
  20971. "NEAREST_MIPMAP_LINEAR",
  20972. "NEAREST_MIPMAP_NEAREST",
  20973. "NEGATIVE_INFINITY",
  20974. "NETWORK_EMPTY",
  20975. "NETWORK_ERR",
  20976. "NETWORK_IDLE",
  20977. "NETWORK_LOADED",
  20978. "NETWORK_LOADING",
  20979. "NETWORK_NO_SOURCE",
  20980. "NEVER",
  20981. "NEW",
  20982. "NEXT",
  20983. "NEXT_NO_DUPLICATE",
  20984. "NICEST",
  20985. "NODE_AFTER",
  20986. "NODE_BEFORE",
  20987. "NODE_BEFORE_AND_AFTER",
  20988. "NODE_INSIDE",
  20989. "NONE",
  20990. "NON_TRANSIENT_ERR",
  20991. "NOTATION_NODE",
  20992. "NOTCH",
  20993. "NOTEQUAL",
  20994. "NOT_ALLOWED_ERR",
  20995. "NOT_FOUND_ERR",
  20996. "NOT_READABLE_ERR",
  20997. "NOT_SUPPORTED_ERR",
  20998. "NO_DATA_ALLOWED_ERR",
  20999. "NO_ERR",
  21000. "NO_ERROR",
  21001. "NO_MODIFICATION_ALLOWED_ERR",
  21002. "NUMBER_TYPE",
  21003. "NUM_COMPRESSED_TEXTURE_FORMATS",
  21004. "NaN",
  21005. "NamedNodeMap",
  21006. "NavigationPreloadManager",
  21007. "Navigator",
  21008. "NearbyLinks",
  21009. "NetworkInformation",
  21010. "Node",
  21011. "NodeFilter",
  21012. "NodeIterator",
  21013. "NodeList",
  21014. "Notation",
  21015. "Notification",
  21016. "NotifyPaintEvent",
  21017. "Number",
  21018. "NumberFormat",
  21019. "OBJECT_TYPE",
  21020. "OBSOLETE",
  21021. "OK",
  21022. "ONE",
  21023. "ONE_MINUS_CONSTANT_ALPHA",
  21024. "ONE_MINUS_CONSTANT_COLOR",
  21025. "ONE_MINUS_DST_ALPHA",
  21026. "ONE_MINUS_DST_COLOR",
  21027. "ONE_MINUS_SRC_ALPHA",
  21028. "ONE_MINUS_SRC_COLOR",
  21029. "OPEN",
  21030. "OPENED",
  21031. "OPENING",
  21032. "ORDERED_NODE_ITERATOR_TYPE",
  21033. "ORDERED_NODE_SNAPSHOT_TYPE",
  21034. "OTHER_ERROR",
  21035. "OUT_OF_MEMORY",
  21036. "Object",
  21037. "OfflineAudioCompletionEvent",
  21038. "OfflineAudioContext",
  21039. "OfflineResourceList",
  21040. "OffscreenCanvas",
  21041. "OffscreenCanvasRenderingContext2D",
  21042. "Option",
  21043. "OrientationSensor",
  21044. "OscillatorNode",
  21045. "OverconstrainedError",
  21046. "OverflowEvent",
  21047. "PACK_ALIGNMENT",
  21048. "PACK_ROW_LENGTH",
  21049. "PACK_SKIP_PIXELS",
  21050. "PACK_SKIP_ROWS",
  21051. "PAGE_RULE",
  21052. "PARSE_ERR",
  21053. "PATHSEG_ARC_ABS",
  21054. "PATHSEG_ARC_REL",
  21055. "PATHSEG_CLOSEPATH",
  21056. "PATHSEG_CURVETO_CUBIC_ABS",
  21057. "PATHSEG_CURVETO_CUBIC_REL",
  21058. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  21059. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  21060. "PATHSEG_CURVETO_QUADRATIC_ABS",
  21061. "PATHSEG_CURVETO_QUADRATIC_REL",
  21062. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  21063. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  21064. "PATHSEG_LINETO_ABS",
  21065. "PATHSEG_LINETO_HORIZONTAL_ABS",
  21066. "PATHSEG_LINETO_HORIZONTAL_REL",
  21067. "PATHSEG_LINETO_REL",
  21068. "PATHSEG_LINETO_VERTICAL_ABS",
  21069. "PATHSEG_LINETO_VERTICAL_REL",
  21070. "PATHSEG_MOVETO_ABS",
  21071. "PATHSEG_MOVETO_REL",
  21072. "PATHSEG_UNKNOWN",
  21073. "PATH_EXISTS_ERR",
  21074. "PEAKING",
  21075. "PERMISSION_DENIED",
  21076. "PERSISTENT",
  21077. "PI",
  21078. "PIXEL_PACK_BUFFER",
  21079. "PIXEL_PACK_BUFFER_BINDING",
  21080. "PIXEL_UNPACK_BUFFER",
  21081. "PIXEL_UNPACK_BUFFER_BINDING",
  21082. "PLAYING_STATE",
  21083. "POINTS",
  21084. "POLYGON_OFFSET_FACTOR",
  21085. "POLYGON_OFFSET_FILL",
  21086. "POLYGON_OFFSET_UNITS",
  21087. "POSITION_UNAVAILABLE",
  21088. "POSITIVE_INFINITY",
  21089. "PREV",
  21090. "PREV_NO_DUPLICATE",
  21091. "PROCESSING_INSTRUCTION_NODE",
  21092. "PageChangeEvent",
  21093. "PageTransitionEvent",
  21094. "PaintRequest",
  21095. "PaintRequestList",
  21096. "PannerNode",
  21097. "PasswordCredential",
  21098. "Path2D",
  21099. "PaymentAddress",
  21100. "PaymentInstruments",
  21101. "PaymentManager",
  21102. "PaymentMethodChangeEvent",
  21103. "PaymentRequest",
  21104. "PaymentRequestUpdateEvent",
  21105. "PaymentResponse",
  21106. "Performance",
  21107. "PerformanceElementTiming",
  21108. "PerformanceEntry",
  21109. "PerformanceEventTiming",
  21110. "PerformanceLongTaskTiming",
  21111. "PerformanceMark",
  21112. "PerformanceMeasure",
  21113. "PerformanceNavigation",
  21114. "PerformanceNavigationTiming",
  21115. "PerformanceObserver",
  21116. "PerformanceObserverEntryList",
  21117. "PerformancePaintTiming",
  21118. "PerformanceResourceTiming",
  21119. "PerformanceServerTiming",
  21120. "PerformanceTiming",
  21121. "PeriodicSyncManager",
  21122. "PeriodicWave",
  21123. "PermissionStatus",
  21124. "Permissions",
  21125. "PhotoCapabilities",
  21126. "PictureInPictureWindow",
  21127. "Plugin",
  21128. "PluginArray",
  21129. "PluralRules",
  21130. "PointerEvent",
  21131. "PopStateEvent",
  21132. "PopupBlockedEvent",
  21133. "Presentation",
  21134. "PresentationAvailability",
  21135. "PresentationConnection",
  21136. "PresentationConnectionAvailableEvent",
  21137. "PresentationConnectionCloseEvent",
  21138. "PresentationConnectionList",
  21139. "PresentationReceiver",
  21140. "PresentationRequest",
  21141. "ProcessingInstruction",
  21142. "ProgressEvent",
  21143. "Promise",
  21144. "PromiseRejectionEvent",
  21145. "PropertyNodeList",
  21146. "Proxy",
  21147. "PublicKeyCredential",
  21148. "PushManager",
  21149. "PushSubscription",
  21150. "PushSubscriptionOptions",
  21151. "Q",
  21152. "QUERY_RESULT",
  21153. "QUERY_RESULT_AVAILABLE",
  21154. "QUOTA_ERR",
  21155. "QUOTA_EXCEEDED_ERR",
  21156. "QueryInterface",
  21157. "R11F_G11F_B10F",
  21158. "R16F",
  21159. "R16I",
  21160. "R16UI",
  21161. "R32F",
  21162. "R32I",
  21163. "R32UI",
  21164. "R8",
  21165. "R8I",
  21166. "R8UI",
  21167. "R8_SNORM",
  21168. "RASTERIZER_DISCARD",
  21169. "READ_BUFFER",
  21170. "READ_FRAMEBUFFER",
  21171. "READ_FRAMEBUFFER_BINDING",
  21172. "READ_ONLY",
  21173. "READ_ONLY_ERR",
  21174. "READ_WRITE",
  21175. "RED",
  21176. "RED_BITS",
  21177. "RED_INTEGER",
  21178. "REMOVAL",
  21179. "RENDERBUFFER",
  21180. "RENDERBUFFER_ALPHA_SIZE",
  21181. "RENDERBUFFER_BINDING",
  21182. "RENDERBUFFER_BLUE_SIZE",
  21183. "RENDERBUFFER_DEPTH_SIZE",
  21184. "RENDERBUFFER_GREEN_SIZE",
  21185. "RENDERBUFFER_HEIGHT",
  21186. "RENDERBUFFER_INTERNAL_FORMAT",
  21187. "RENDERBUFFER_RED_SIZE",
  21188. "RENDERBUFFER_SAMPLES",
  21189. "RENDERBUFFER_STENCIL_SIZE",
  21190. "RENDERBUFFER_WIDTH",
  21191. "RENDERER",
  21192. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  21193. "RENDERING_INTENT_AUTO",
  21194. "RENDERING_INTENT_PERCEPTUAL",
  21195. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  21196. "RENDERING_INTENT_SATURATION",
  21197. "RENDERING_INTENT_UNKNOWN",
  21198. "REPEAT",
  21199. "REPLACE",
  21200. "RG",
  21201. "RG16F",
  21202. "RG16I",
  21203. "RG16UI",
  21204. "RG32F",
  21205. "RG32I",
  21206. "RG32UI",
  21207. "RG8",
  21208. "RG8I",
  21209. "RG8UI",
  21210. "RG8_SNORM",
  21211. "RGB",
  21212. "RGB10_A2",
  21213. "RGB10_A2UI",
  21214. "RGB16F",
  21215. "RGB16I",
  21216. "RGB16UI",
  21217. "RGB32F",
  21218. "RGB32I",
  21219. "RGB32UI",
  21220. "RGB565",
  21221. "RGB5_A1",
  21222. "RGB8",
  21223. "RGB8I",
  21224. "RGB8UI",
  21225. "RGB8_SNORM",
  21226. "RGB9_E5",
  21227. "RGBA",
  21228. "RGBA16F",
  21229. "RGBA16I",
  21230. "RGBA16UI",
  21231. "RGBA32F",
  21232. "RGBA32I",
  21233. "RGBA32UI",
  21234. "RGBA4",
  21235. "RGBA8",
  21236. "RGBA8I",
  21237. "RGBA8UI",
  21238. "RGBA8_SNORM",
  21239. "RGBA_INTEGER",
  21240. "RGBColor",
  21241. "RGB_INTEGER",
  21242. "RG_INTEGER",
  21243. "ROTATION_CLOCKWISE",
  21244. "ROTATION_COUNTERCLOCKWISE",
  21245. "RTCCertificate",
  21246. "RTCDTMFSender",
  21247. "RTCDTMFToneChangeEvent",
  21248. "RTCDataChannel",
  21249. "RTCDataChannelEvent",
  21250. "RTCDtlsTransport",
  21251. "RTCError",
  21252. "RTCErrorEvent",
  21253. "RTCIceCandidate",
  21254. "RTCIceTransport",
  21255. "RTCPeerConnection",
  21256. "RTCPeerConnectionIceErrorEvent",
  21257. "RTCPeerConnectionIceEvent",
  21258. "RTCRtpReceiver",
  21259. "RTCRtpSender",
  21260. "RTCRtpTransceiver",
  21261. "RTCSctpTransport",
  21262. "RTCSessionDescription",
  21263. "RTCStatsReport",
  21264. "RTCTrackEvent",
  21265. "RadioNodeList",
  21266. "Range",
  21267. "RangeError",
  21268. "RangeException",
  21269. "ReadableStream",
  21270. "ReadableStreamDefaultReader",
  21271. "RecordErrorEvent",
  21272. "Rect",
  21273. "ReferenceError",
  21274. "Reflect",
  21275. "RegExp",
  21276. "RelativeOrientationSensor",
  21277. "RelativeTimeFormat",
  21278. "RemotePlayback",
  21279. "Report",
  21280. "ReportBody",
  21281. "ReportingObserver",
  21282. "Request",
  21283. "ResizeObserver",
  21284. "ResizeObserverEntry",
  21285. "ResizeObserverSize",
  21286. "Response",
  21287. "RuntimeError",
  21288. "SAMPLER_2D",
  21289. "SAMPLER_2D_ARRAY",
  21290. "SAMPLER_2D_ARRAY_SHADOW",
  21291. "SAMPLER_2D_SHADOW",
  21292. "SAMPLER_3D",
  21293. "SAMPLER_BINDING",
  21294. "SAMPLER_CUBE",
  21295. "SAMPLER_CUBE_SHADOW",
  21296. "SAMPLES",
  21297. "SAMPLE_ALPHA_TO_COVERAGE",
  21298. "SAMPLE_BUFFERS",
  21299. "SAMPLE_COVERAGE",
  21300. "SAMPLE_COVERAGE_INVERT",
  21301. "SAMPLE_COVERAGE_VALUE",
  21302. "SAWTOOTH",
  21303. "SCHEDULED_STATE",
  21304. "SCISSOR_BOX",
  21305. "SCISSOR_TEST",
  21306. "SCROLL_PAGE_DOWN",
  21307. "SCROLL_PAGE_UP",
  21308. "SDP_ANSWER",
  21309. "SDP_OFFER",
  21310. "SDP_PRANSWER",
  21311. "SECURITY_ERR",
  21312. "SELECT",
  21313. "SEPARATE_ATTRIBS",
  21314. "SERIALIZE_ERR",
  21315. "SEVERITY_ERROR",
  21316. "SEVERITY_FATAL_ERROR",
  21317. "SEVERITY_WARNING",
  21318. "SHADER_COMPILER",
  21319. "SHADER_TYPE",
  21320. "SHADING_LANGUAGE_VERSION",
  21321. "SHIFT_MASK",
  21322. "SHORT",
  21323. "SHOWING",
  21324. "SHOW_ALL",
  21325. "SHOW_ATTRIBUTE",
  21326. "SHOW_CDATA_SECTION",
  21327. "SHOW_COMMENT",
  21328. "SHOW_DOCUMENT",
  21329. "SHOW_DOCUMENT_FRAGMENT",
  21330. "SHOW_DOCUMENT_TYPE",
  21331. "SHOW_ELEMENT",
  21332. "SHOW_ENTITY",
  21333. "SHOW_ENTITY_REFERENCE",
  21334. "SHOW_NOTATION",
  21335. "SHOW_PROCESSING_INSTRUCTION",
  21336. "SHOW_TEXT",
  21337. "SIGNALED",
  21338. "SIGNED_NORMALIZED",
  21339. "SINE",
  21340. "SOUNDFIELD",
  21341. "SQLException",
  21342. "SQRT1_2",
  21343. "SQRT2",
  21344. "SQUARE",
  21345. "SRC_ALPHA",
  21346. "SRC_ALPHA_SATURATE",
  21347. "SRC_COLOR",
  21348. "SRGB",
  21349. "SRGB8",
  21350. "SRGB8_ALPHA8",
  21351. "START_TO_END",
  21352. "START_TO_START",
  21353. "STATIC_COPY",
  21354. "STATIC_DRAW",
  21355. "STATIC_READ",
  21356. "STENCIL",
  21357. "STENCIL_ATTACHMENT",
  21358. "STENCIL_BACK_FAIL",
  21359. "STENCIL_BACK_FUNC",
  21360. "STENCIL_BACK_PASS_DEPTH_FAIL",
  21361. "STENCIL_BACK_PASS_DEPTH_PASS",
  21362. "STENCIL_BACK_REF",
  21363. "STENCIL_BACK_VALUE_MASK",
  21364. "STENCIL_BACK_WRITEMASK",
  21365. "STENCIL_BITS",
  21366. "STENCIL_BUFFER_BIT",
  21367. "STENCIL_CLEAR_VALUE",
  21368. "STENCIL_FAIL",
  21369. "STENCIL_FUNC",
  21370. "STENCIL_INDEX",
  21371. "STENCIL_INDEX8",
  21372. "STENCIL_PASS_DEPTH_FAIL",
  21373. "STENCIL_PASS_DEPTH_PASS",
  21374. "STENCIL_REF",
  21375. "STENCIL_TEST",
  21376. "STENCIL_VALUE_MASK",
  21377. "STENCIL_WRITEMASK",
  21378. "STREAM_COPY",
  21379. "STREAM_DRAW",
  21380. "STREAM_READ",
  21381. "STRING_TYPE",
  21382. "STYLE_RULE",
  21383. "SUBPIXEL_BITS",
  21384. "SUPPORTS_RULE",
  21385. "SVGAElement",
  21386. "SVGAltGlyphDefElement",
  21387. "SVGAltGlyphElement",
  21388. "SVGAltGlyphItemElement",
  21389. "SVGAngle",
  21390. "SVGAnimateColorElement",
  21391. "SVGAnimateElement",
  21392. "SVGAnimateMotionElement",
  21393. "SVGAnimateTransformElement",
  21394. "SVGAnimatedAngle",
  21395. "SVGAnimatedBoolean",
  21396. "SVGAnimatedEnumeration",
  21397. "SVGAnimatedInteger",
  21398. "SVGAnimatedLength",
  21399. "SVGAnimatedLengthList",
  21400. "SVGAnimatedNumber",
  21401. "SVGAnimatedNumberList",
  21402. "SVGAnimatedPreserveAspectRatio",
  21403. "SVGAnimatedRect",
  21404. "SVGAnimatedString",
  21405. "SVGAnimatedTransformList",
  21406. "SVGAnimationElement",
  21407. "SVGCircleElement",
  21408. "SVGClipPathElement",
  21409. "SVGColor",
  21410. "SVGComponentTransferFunctionElement",
  21411. "SVGCursorElement",
  21412. "SVGDefsElement",
  21413. "SVGDescElement",
  21414. "SVGDiscardElement",
  21415. "SVGDocument",
  21416. "SVGElement",
  21417. "SVGElementInstance",
  21418. "SVGElementInstanceList",
  21419. "SVGEllipseElement",
  21420. "SVGException",
  21421. "SVGFEBlendElement",
  21422. "SVGFEColorMatrixElement",
  21423. "SVGFEComponentTransferElement",
  21424. "SVGFECompositeElement",
  21425. "SVGFEConvolveMatrixElement",
  21426. "SVGFEDiffuseLightingElement",
  21427. "SVGFEDisplacementMapElement",
  21428. "SVGFEDistantLightElement",
  21429. "SVGFEDropShadowElement",
  21430. "SVGFEFloodElement",
  21431. "SVGFEFuncAElement",
  21432. "SVGFEFuncBElement",
  21433. "SVGFEFuncGElement",
  21434. "SVGFEFuncRElement",
  21435. "SVGFEGaussianBlurElement",
  21436. "SVGFEImageElement",
  21437. "SVGFEMergeElement",
  21438. "SVGFEMergeNodeElement",
  21439. "SVGFEMorphologyElement",
  21440. "SVGFEOffsetElement",
  21441. "SVGFEPointLightElement",
  21442. "SVGFESpecularLightingElement",
  21443. "SVGFESpotLightElement",
  21444. "SVGFETileElement",
  21445. "SVGFETurbulenceElement",
  21446. "SVGFilterElement",
  21447. "SVGFontElement",
  21448. "SVGFontFaceElement",
  21449. "SVGFontFaceFormatElement",
  21450. "SVGFontFaceNameElement",
  21451. "SVGFontFaceSrcElement",
  21452. "SVGFontFaceUriElement",
  21453. "SVGForeignObjectElement",
  21454. "SVGGElement",
  21455. "SVGGeometryElement",
  21456. "SVGGlyphElement",
  21457. "SVGGlyphRefElement",
  21458. "SVGGradientElement",
  21459. "SVGGraphicsElement",
  21460. "SVGHKernElement",
  21461. "SVGImageElement",
  21462. "SVGLength",
  21463. "SVGLengthList",
  21464. "SVGLineElement",
  21465. "SVGLinearGradientElement",
  21466. "SVGMPathElement",
  21467. "SVGMarkerElement",
  21468. "SVGMaskElement",
  21469. "SVGMatrix",
  21470. "SVGMetadataElement",
  21471. "SVGMissingGlyphElement",
  21472. "SVGNumber",
  21473. "SVGNumberList",
  21474. "SVGPaint",
  21475. "SVGPathElement",
  21476. "SVGPathSeg",
  21477. "SVGPathSegArcAbs",
  21478. "SVGPathSegArcRel",
  21479. "SVGPathSegClosePath",
  21480. "SVGPathSegCurvetoCubicAbs",
  21481. "SVGPathSegCurvetoCubicRel",
  21482. "SVGPathSegCurvetoCubicSmoothAbs",
  21483. "SVGPathSegCurvetoCubicSmoothRel",
  21484. "SVGPathSegCurvetoQuadraticAbs",
  21485. "SVGPathSegCurvetoQuadraticRel",
  21486. "SVGPathSegCurvetoQuadraticSmoothAbs",
  21487. "SVGPathSegCurvetoQuadraticSmoothRel",
  21488. "SVGPathSegLinetoAbs",
  21489. "SVGPathSegLinetoHorizontalAbs",
  21490. "SVGPathSegLinetoHorizontalRel",
  21491. "SVGPathSegLinetoRel",
  21492. "SVGPathSegLinetoVerticalAbs",
  21493. "SVGPathSegLinetoVerticalRel",
  21494. "SVGPathSegList",
  21495. "SVGPathSegMovetoAbs",
  21496. "SVGPathSegMovetoRel",
  21497. "SVGPatternElement",
  21498. "SVGPoint",
  21499. "SVGPointList",
  21500. "SVGPolygonElement",
  21501. "SVGPolylineElement",
  21502. "SVGPreserveAspectRatio",
  21503. "SVGRadialGradientElement",
  21504. "SVGRect",
  21505. "SVGRectElement",
  21506. "SVGRenderingIntent",
  21507. "SVGSVGElement",
  21508. "SVGScriptElement",
  21509. "SVGSetElement",
  21510. "SVGStopElement",
  21511. "SVGStringList",
  21512. "SVGStyleElement",
  21513. "SVGSwitchElement",
  21514. "SVGSymbolElement",
  21515. "SVGTRefElement",
  21516. "SVGTSpanElement",
  21517. "SVGTextContentElement",
  21518. "SVGTextElement",
  21519. "SVGTextPathElement",
  21520. "SVGTextPositioningElement",
  21521. "SVGTitleElement",
  21522. "SVGTransform",
  21523. "SVGTransformList",
  21524. "SVGUnitTypes",
  21525. "SVGUseElement",
  21526. "SVGVKernElement",
  21527. "SVGViewElement",
  21528. "SVGViewSpec",
  21529. "SVGZoomAndPan",
  21530. "SVGZoomEvent",
  21531. "SVG_ANGLETYPE_DEG",
  21532. "SVG_ANGLETYPE_GRAD",
  21533. "SVG_ANGLETYPE_RAD",
  21534. "SVG_ANGLETYPE_UNKNOWN",
  21535. "SVG_ANGLETYPE_UNSPECIFIED",
  21536. "SVG_CHANNEL_A",
  21537. "SVG_CHANNEL_B",
  21538. "SVG_CHANNEL_G",
  21539. "SVG_CHANNEL_R",
  21540. "SVG_CHANNEL_UNKNOWN",
  21541. "SVG_COLORTYPE_CURRENTCOLOR",
  21542. "SVG_COLORTYPE_RGBCOLOR",
  21543. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  21544. "SVG_COLORTYPE_UNKNOWN",
  21545. "SVG_EDGEMODE_DUPLICATE",
  21546. "SVG_EDGEMODE_NONE",
  21547. "SVG_EDGEMODE_UNKNOWN",
  21548. "SVG_EDGEMODE_WRAP",
  21549. "SVG_FEBLEND_MODE_COLOR",
  21550. "SVG_FEBLEND_MODE_COLOR_BURN",
  21551. "SVG_FEBLEND_MODE_COLOR_DODGE",
  21552. "SVG_FEBLEND_MODE_DARKEN",
  21553. "SVG_FEBLEND_MODE_DIFFERENCE",
  21554. "SVG_FEBLEND_MODE_EXCLUSION",
  21555. "SVG_FEBLEND_MODE_HARD_LIGHT",
  21556. "SVG_FEBLEND_MODE_HUE",
  21557. "SVG_FEBLEND_MODE_LIGHTEN",
  21558. "SVG_FEBLEND_MODE_LUMINOSITY",
  21559. "SVG_FEBLEND_MODE_MULTIPLY",
  21560. "SVG_FEBLEND_MODE_NORMAL",
  21561. "SVG_FEBLEND_MODE_OVERLAY",
  21562. "SVG_FEBLEND_MODE_SATURATION",
  21563. "SVG_FEBLEND_MODE_SCREEN",
  21564. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  21565. "SVG_FEBLEND_MODE_UNKNOWN",
  21566. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  21567. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  21568. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  21569. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  21570. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  21571. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  21572. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  21573. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  21574. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  21575. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  21576. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  21577. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  21578. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  21579. "SVG_FECOMPOSITE_OPERATOR_IN",
  21580. "SVG_FECOMPOSITE_OPERATOR_OUT",
  21581. "SVG_FECOMPOSITE_OPERATOR_OVER",
  21582. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  21583. "SVG_FECOMPOSITE_OPERATOR_XOR",
  21584. "SVG_INVALID_VALUE_ERR",
  21585. "SVG_LENGTHTYPE_CM",
  21586. "SVG_LENGTHTYPE_EMS",
  21587. "SVG_LENGTHTYPE_EXS",
  21588. "SVG_LENGTHTYPE_IN",
  21589. "SVG_LENGTHTYPE_MM",
  21590. "SVG_LENGTHTYPE_NUMBER",
  21591. "SVG_LENGTHTYPE_PC",
  21592. "SVG_LENGTHTYPE_PERCENTAGE",
  21593. "SVG_LENGTHTYPE_PT",
  21594. "SVG_LENGTHTYPE_PX",
  21595. "SVG_LENGTHTYPE_UNKNOWN",
  21596. "SVG_MARKERUNITS_STROKEWIDTH",
  21597. "SVG_MARKERUNITS_UNKNOWN",
  21598. "SVG_MARKERUNITS_USERSPACEONUSE",
  21599. "SVG_MARKER_ORIENT_ANGLE",
  21600. "SVG_MARKER_ORIENT_AUTO",
  21601. "SVG_MARKER_ORIENT_UNKNOWN",
  21602. "SVG_MASKTYPE_ALPHA",
  21603. "SVG_MASKTYPE_LUMINANCE",
  21604. "SVG_MATRIX_NOT_INVERTABLE",
  21605. "SVG_MEETORSLICE_MEET",
  21606. "SVG_MEETORSLICE_SLICE",
  21607. "SVG_MEETORSLICE_UNKNOWN",
  21608. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  21609. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  21610. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  21611. "SVG_PAINTTYPE_CURRENTCOLOR",
  21612. "SVG_PAINTTYPE_NONE",
  21613. "SVG_PAINTTYPE_RGBCOLOR",
  21614. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  21615. "SVG_PAINTTYPE_UNKNOWN",
  21616. "SVG_PAINTTYPE_URI",
  21617. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  21618. "SVG_PAINTTYPE_URI_NONE",
  21619. "SVG_PAINTTYPE_URI_RGBCOLOR",
  21620. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  21621. "SVG_PRESERVEASPECTRATIO_NONE",
  21622. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  21623. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  21624. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  21625. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  21626. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  21627. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  21628. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  21629. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  21630. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  21631. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  21632. "SVG_SPREADMETHOD_PAD",
  21633. "SVG_SPREADMETHOD_REFLECT",
  21634. "SVG_SPREADMETHOD_REPEAT",
  21635. "SVG_SPREADMETHOD_UNKNOWN",
  21636. "SVG_STITCHTYPE_NOSTITCH",
  21637. "SVG_STITCHTYPE_STITCH",
  21638. "SVG_STITCHTYPE_UNKNOWN",
  21639. "SVG_TRANSFORM_MATRIX",
  21640. "SVG_TRANSFORM_ROTATE",
  21641. "SVG_TRANSFORM_SCALE",
  21642. "SVG_TRANSFORM_SKEWX",
  21643. "SVG_TRANSFORM_SKEWY",
  21644. "SVG_TRANSFORM_TRANSLATE",
  21645. "SVG_TRANSFORM_UNKNOWN",
  21646. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  21647. "SVG_TURBULENCE_TYPE_TURBULENCE",
  21648. "SVG_TURBULENCE_TYPE_UNKNOWN",
  21649. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  21650. "SVG_UNIT_TYPE_UNKNOWN",
  21651. "SVG_UNIT_TYPE_USERSPACEONUSE",
  21652. "SVG_WRONG_TYPE_ERR",
  21653. "SVG_ZOOMANDPAN_DISABLE",
  21654. "SVG_ZOOMANDPAN_MAGNIFY",
  21655. "SVG_ZOOMANDPAN_UNKNOWN",
  21656. "SYNC_CONDITION",
  21657. "SYNC_FENCE",
  21658. "SYNC_FLAGS",
  21659. "SYNC_FLUSH_COMMANDS_BIT",
  21660. "SYNC_GPU_COMMANDS_COMPLETE",
  21661. "SYNC_STATUS",
  21662. "SYNTAX_ERR",
  21663. "SavedPages",
  21664. "Screen",
  21665. "ScreenOrientation",
  21666. "Script",
  21667. "ScriptProcessorNode",
  21668. "ScrollAreaEvent",
  21669. "SecurityPolicyViolationEvent",
  21670. "Selection",
  21671. "Sensor",
  21672. "SensorErrorEvent",
  21673. "ServiceWorker",
  21674. "ServiceWorkerContainer",
  21675. "ServiceWorkerRegistration",
  21676. "SessionDescription",
  21677. "Set",
  21678. "ShadowRoot",
  21679. "SharedArrayBuffer",
  21680. "SharedWorker",
  21681. "SimpleGestureEvent",
  21682. "SourceBuffer",
  21683. "SourceBufferList",
  21684. "SpeechSynthesis",
  21685. "SpeechSynthesisErrorEvent",
  21686. "SpeechSynthesisEvent",
  21687. "SpeechSynthesisUtterance",
  21688. "SpeechSynthesisVoice",
  21689. "StaticRange",
  21690. "StereoPannerNode",
  21691. "StopIteration",
  21692. "Storage",
  21693. "StorageEvent",
  21694. "StorageManager",
  21695. "String",
  21696. "StructType",
  21697. "StylePropertyMap",
  21698. "StylePropertyMapReadOnly",
  21699. "StyleSheet",
  21700. "StyleSheetList",
  21701. "SubmitEvent",
  21702. "SubtleCrypto",
  21703. "Symbol",
  21704. "SyncManager",
  21705. "SyntaxError",
  21706. "TEMPORARY",
  21707. "TEXTPATH_METHODTYPE_ALIGN",
  21708. "TEXTPATH_METHODTYPE_STRETCH",
  21709. "TEXTPATH_METHODTYPE_UNKNOWN",
  21710. "TEXTPATH_SPACINGTYPE_AUTO",
  21711. "TEXTPATH_SPACINGTYPE_EXACT",
  21712. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  21713. "TEXTURE",
  21714. "TEXTURE0",
  21715. "TEXTURE1",
  21716. "TEXTURE10",
  21717. "TEXTURE11",
  21718. "TEXTURE12",
  21719. "TEXTURE13",
  21720. "TEXTURE14",
  21721. "TEXTURE15",
  21722. "TEXTURE16",
  21723. "TEXTURE17",
  21724. "TEXTURE18",
  21725. "TEXTURE19",
  21726. "TEXTURE2",
  21727. "TEXTURE20",
  21728. "TEXTURE21",
  21729. "TEXTURE22",
  21730. "TEXTURE23",
  21731. "TEXTURE24",
  21732. "TEXTURE25",
  21733. "TEXTURE26",
  21734. "TEXTURE27",
  21735. "TEXTURE28",
  21736. "TEXTURE29",
  21737. "TEXTURE3",
  21738. "TEXTURE30",
  21739. "TEXTURE31",
  21740. "TEXTURE4",
  21741. "TEXTURE5",
  21742. "TEXTURE6",
  21743. "TEXTURE7",
  21744. "TEXTURE8",
  21745. "TEXTURE9",
  21746. "TEXTURE_2D",
  21747. "TEXTURE_2D_ARRAY",
  21748. "TEXTURE_3D",
  21749. "TEXTURE_BASE_LEVEL",
  21750. "TEXTURE_BINDING_2D",
  21751. "TEXTURE_BINDING_2D_ARRAY",
  21752. "TEXTURE_BINDING_3D",
  21753. "TEXTURE_BINDING_CUBE_MAP",
  21754. "TEXTURE_COMPARE_FUNC",
  21755. "TEXTURE_COMPARE_MODE",
  21756. "TEXTURE_CUBE_MAP",
  21757. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  21758. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  21759. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  21760. "TEXTURE_CUBE_MAP_POSITIVE_X",
  21761. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  21762. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  21763. "TEXTURE_IMMUTABLE_FORMAT",
  21764. "TEXTURE_IMMUTABLE_LEVELS",
  21765. "TEXTURE_MAG_FILTER",
  21766. "TEXTURE_MAX_ANISOTROPY_EXT",
  21767. "TEXTURE_MAX_LEVEL",
  21768. "TEXTURE_MAX_LOD",
  21769. "TEXTURE_MIN_FILTER",
  21770. "TEXTURE_MIN_LOD",
  21771. "TEXTURE_WRAP_R",
  21772. "TEXTURE_WRAP_S",
  21773. "TEXTURE_WRAP_T",
  21774. "TEXT_NODE",
  21775. "TIMEOUT",
  21776. "TIMEOUT_ERR",
  21777. "TIMEOUT_EXPIRED",
  21778. "TIMEOUT_IGNORED",
  21779. "TOO_LARGE_ERR",
  21780. "TRANSACTION_INACTIVE_ERR",
  21781. "TRANSFORM_FEEDBACK",
  21782. "TRANSFORM_FEEDBACK_ACTIVE",
  21783. "TRANSFORM_FEEDBACK_BINDING",
  21784. "TRANSFORM_FEEDBACK_BUFFER",
  21785. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  21786. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  21787. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  21788. "TRANSFORM_FEEDBACK_BUFFER_START",
  21789. "TRANSFORM_FEEDBACK_PAUSED",
  21790. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  21791. "TRANSFORM_FEEDBACK_VARYINGS",
  21792. "TRIANGLE",
  21793. "TRIANGLES",
  21794. "TRIANGLE_FAN",
  21795. "TRIANGLE_STRIP",
  21796. "TYPE_BACK_FORWARD",
  21797. "TYPE_ERR",
  21798. "TYPE_MISMATCH_ERR",
  21799. "TYPE_NAVIGATE",
  21800. "TYPE_RELOAD",
  21801. "TYPE_RESERVED",
  21802. "Table",
  21803. "TaskAttributionTiming",
  21804. "Text",
  21805. "TextDecoder",
  21806. "TextDecoderStream",
  21807. "TextEncoder",
  21808. "TextEncoderStream",
  21809. "TextEvent",
  21810. "TextMetrics",
  21811. "TextTrack",
  21812. "TextTrackCue",
  21813. "TextTrackCueList",
  21814. "TextTrackList",
  21815. "TimeEvent",
  21816. "TimeRanges",
  21817. "Touch",
  21818. "TouchEvent",
  21819. "TouchList",
  21820. "TrackEvent",
  21821. "TransformStream",
  21822. "TransitionEvent",
  21823. "TreeWalker",
  21824. "TrustedHTML",
  21825. "TrustedScript",
  21826. "TrustedScriptURL",
  21827. "TrustedTypePolicy",
  21828. "TrustedTypePolicyFactory",
  21829. "TypeError",
  21830. "TypedObject",
  21831. "U2F",
  21832. "UIEvent",
  21833. "UNCACHED",
  21834. "UNIFORM_ARRAY_STRIDE",
  21835. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  21836. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  21837. "UNIFORM_BLOCK_BINDING",
  21838. "UNIFORM_BLOCK_DATA_SIZE",
  21839. "UNIFORM_BLOCK_INDEX",
  21840. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  21841. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  21842. "UNIFORM_BUFFER",
  21843. "UNIFORM_BUFFER_BINDING",
  21844. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  21845. "UNIFORM_BUFFER_SIZE",
  21846. "UNIFORM_BUFFER_START",
  21847. "UNIFORM_IS_ROW_MAJOR",
  21848. "UNIFORM_MATRIX_STRIDE",
  21849. "UNIFORM_OFFSET",
  21850. "UNIFORM_SIZE",
  21851. "UNIFORM_TYPE",
  21852. "UNKNOWN_ERR",
  21853. "UNKNOWN_RULE",
  21854. "UNMASKED_RENDERER_WEBGL",
  21855. "UNMASKED_VENDOR_WEBGL",
  21856. "UNORDERED_NODE_ITERATOR_TYPE",
  21857. "UNORDERED_NODE_SNAPSHOT_TYPE",
  21858. "UNPACK_ALIGNMENT",
  21859. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  21860. "UNPACK_FLIP_Y_WEBGL",
  21861. "UNPACK_IMAGE_HEIGHT",
  21862. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  21863. "UNPACK_ROW_LENGTH",
  21864. "UNPACK_SKIP_IMAGES",
  21865. "UNPACK_SKIP_PIXELS",
  21866. "UNPACK_SKIP_ROWS",
  21867. "UNSCHEDULED_STATE",
  21868. "UNSENT",
  21869. "UNSIGNALED",
  21870. "UNSIGNED_BYTE",
  21871. "UNSIGNED_INT",
  21872. "UNSIGNED_INT_10F_11F_11F_REV",
  21873. "UNSIGNED_INT_24_8",
  21874. "UNSIGNED_INT_2_10_10_10_REV",
  21875. "UNSIGNED_INT_5_9_9_9_REV",
  21876. "UNSIGNED_INT_SAMPLER_2D",
  21877. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  21878. "UNSIGNED_INT_SAMPLER_3D",
  21879. "UNSIGNED_INT_SAMPLER_CUBE",
  21880. "UNSIGNED_INT_VEC2",
  21881. "UNSIGNED_INT_VEC3",
  21882. "UNSIGNED_INT_VEC4",
  21883. "UNSIGNED_NORMALIZED",
  21884. "UNSIGNED_SHORT",
  21885. "UNSIGNED_SHORT_4_4_4_4",
  21886. "UNSIGNED_SHORT_5_5_5_1",
  21887. "UNSIGNED_SHORT_5_6_5",
  21888. "UNSPECIFIED_EVENT_TYPE_ERR",
  21889. "UPDATEREADY",
  21890. "URIError",
  21891. "URL",
  21892. "URLSearchParams",
  21893. "URLUnencoded",
  21894. "URL_MISMATCH_ERR",
  21895. "USB",
  21896. "USBAlternateInterface",
  21897. "USBConfiguration",
  21898. "USBConnectionEvent",
  21899. "USBDevice",
  21900. "USBEndpoint",
  21901. "USBInTransferResult",
  21902. "USBInterface",
  21903. "USBIsochronousInTransferPacket",
  21904. "USBIsochronousInTransferResult",
  21905. "USBIsochronousOutTransferPacket",
  21906. "USBIsochronousOutTransferResult",
  21907. "USBOutTransferResult",
  21908. "UTC",
  21909. "Uint16Array",
  21910. "Uint32Array",
  21911. "Uint8Array",
  21912. "Uint8ClampedArray",
  21913. "UserActivation",
  21914. "UserMessageHandler",
  21915. "UserMessageHandlersNamespace",
  21916. "UserProximityEvent",
  21917. "VALIDATE_STATUS",
  21918. "VALIDATION_ERR",
  21919. "VARIABLES_RULE",
  21920. "VENDOR",
  21921. "VERSION",
  21922. "VERSION_CHANGE",
  21923. "VERSION_ERR",
  21924. "VERTEX_ARRAY_BINDING",
  21925. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  21926. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  21927. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  21928. "VERTEX_ATTRIB_ARRAY_ENABLED",
  21929. "VERTEX_ATTRIB_ARRAY_INTEGER",
  21930. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  21931. "VERTEX_ATTRIB_ARRAY_POINTER",
  21932. "VERTEX_ATTRIB_ARRAY_SIZE",
  21933. "VERTEX_ATTRIB_ARRAY_STRIDE",
  21934. "VERTEX_ATTRIB_ARRAY_TYPE",
  21935. "VERTEX_SHADER",
  21936. "VERTICAL",
  21937. "VERTICAL_AXIS",
  21938. "VER_ERR",
  21939. "VIEWPORT",
  21940. "VIEWPORT_RULE",
  21941. "VRDisplay",
  21942. "VRDisplayCapabilities",
  21943. "VRDisplayEvent",
  21944. "VREyeParameters",
  21945. "VRFieldOfView",
  21946. "VRFrameData",
  21947. "VRPose",
  21948. "VRStageParameters",
  21949. "VTTCue",
  21950. "VTTRegion",
  21951. "ValidityState",
  21952. "VideoPlaybackQuality",
  21953. "VideoStreamTrack",
  21954. "VisualViewport",
  21955. "WAIT_FAILED",
  21956. "WEBKIT_FILTER_RULE",
  21957. "WEBKIT_KEYFRAMES_RULE",
  21958. "WEBKIT_KEYFRAME_RULE",
  21959. "WEBKIT_REGION_RULE",
  21960. "WRONG_DOCUMENT_ERR",
  21961. "WakeLock",
  21962. "WakeLockSentinel",
  21963. "WasmAnyRef",
  21964. "WaveShaperNode",
  21965. "WeakMap",
  21966. "WeakRef",
  21967. "WeakSet",
  21968. "WebAssembly",
  21969. "WebGL2RenderingContext",
  21970. "WebGLActiveInfo",
  21971. "WebGLBuffer",
  21972. "WebGLContextEvent",
  21973. "WebGLFramebuffer",
  21974. "WebGLProgram",
  21975. "WebGLQuery",
  21976. "WebGLRenderbuffer",
  21977. "WebGLRenderingContext",
  21978. "WebGLSampler",
  21979. "WebGLShader",
  21980. "WebGLShaderPrecisionFormat",
  21981. "WebGLSync",
  21982. "WebGLTexture",
  21983. "WebGLTransformFeedback",
  21984. "WebGLUniformLocation",
  21985. "WebGLVertexArray",
  21986. "WebGLVertexArrayObject",
  21987. "WebKitAnimationEvent",
  21988. "WebKitBlobBuilder",
  21989. "WebKitCSSFilterRule",
  21990. "WebKitCSSFilterValue",
  21991. "WebKitCSSKeyframeRule",
  21992. "WebKitCSSKeyframesRule",
  21993. "WebKitCSSMatrix",
  21994. "WebKitCSSRegionRule",
  21995. "WebKitCSSTransformValue",
  21996. "WebKitDataCue",
  21997. "WebKitGamepad",
  21998. "WebKitMediaKeyError",
  21999. "WebKitMediaKeyMessageEvent",
  22000. "WebKitMediaKeySession",
  22001. "WebKitMediaKeys",
  22002. "WebKitMediaSource",
  22003. "WebKitMutationObserver",
  22004. "WebKitNamespace",
  22005. "WebKitPlaybackTargetAvailabilityEvent",
  22006. "WebKitPoint",
  22007. "WebKitShadowRoot",
  22008. "WebKitSourceBuffer",
  22009. "WebKitSourceBufferList",
  22010. "WebKitTransitionEvent",
  22011. "WebSocket",
  22012. "WebkitAlignContent",
  22013. "WebkitAlignItems",
  22014. "WebkitAlignSelf",
  22015. "WebkitAnimation",
  22016. "WebkitAnimationDelay",
  22017. "WebkitAnimationDirection",
  22018. "WebkitAnimationDuration",
  22019. "WebkitAnimationFillMode",
  22020. "WebkitAnimationIterationCount",
  22021. "WebkitAnimationName",
  22022. "WebkitAnimationPlayState",
  22023. "WebkitAnimationTimingFunction",
  22024. "WebkitAppearance",
  22025. "WebkitBackfaceVisibility",
  22026. "WebkitBackgroundClip",
  22027. "WebkitBackgroundOrigin",
  22028. "WebkitBackgroundSize",
  22029. "WebkitBorderBottomLeftRadius",
  22030. "WebkitBorderBottomRightRadius",
  22031. "WebkitBorderImage",
  22032. "WebkitBorderRadius",
  22033. "WebkitBorderTopLeftRadius",
  22034. "WebkitBorderTopRightRadius",
  22035. "WebkitBoxAlign",
  22036. "WebkitBoxDirection",
  22037. "WebkitBoxFlex",
  22038. "WebkitBoxOrdinalGroup",
  22039. "WebkitBoxOrient",
  22040. "WebkitBoxPack",
  22041. "WebkitBoxShadow",
  22042. "WebkitBoxSizing",
  22043. "WebkitFilter",
  22044. "WebkitFlex",
  22045. "WebkitFlexBasis",
  22046. "WebkitFlexDirection",
  22047. "WebkitFlexFlow",
  22048. "WebkitFlexGrow",
  22049. "WebkitFlexShrink",
  22050. "WebkitFlexWrap",
  22051. "WebkitJustifyContent",
  22052. "WebkitLineClamp",
  22053. "WebkitMask",
  22054. "WebkitMaskClip",
  22055. "WebkitMaskComposite",
  22056. "WebkitMaskImage",
  22057. "WebkitMaskOrigin",
  22058. "WebkitMaskPosition",
  22059. "WebkitMaskPositionX",
  22060. "WebkitMaskPositionY",
  22061. "WebkitMaskRepeat",
  22062. "WebkitMaskSize",
  22063. "WebkitOrder",
  22064. "WebkitPerspective",
  22065. "WebkitPerspectiveOrigin",
  22066. "WebkitTextFillColor",
  22067. "WebkitTextSizeAdjust",
  22068. "WebkitTextStroke",
  22069. "WebkitTextStrokeColor",
  22070. "WebkitTextStrokeWidth",
  22071. "WebkitTransform",
  22072. "WebkitTransformOrigin",
  22073. "WebkitTransformStyle",
  22074. "WebkitTransition",
  22075. "WebkitTransitionDelay",
  22076. "WebkitTransitionDuration",
  22077. "WebkitTransitionProperty",
  22078. "WebkitTransitionTimingFunction",
  22079. "WebkitUserSelect",
  22080. "WheelEvent",
  22081. "Window",
  22082. "Worker",
  22083. "Worklet",
  22084. "WritableStream",
  22085. "WritableStreamDefaultWriter",
  22086. "XMLDocument",
  22087. "XMLHttpRequest",
  22088. "XMLHttpRequestEventTarget",
  22089. "XMLHttpRequestException",
  22090. "XMLHttpRequestProgressEvent",
  22091. "XMLHttpRequestUpload",
  22092. "XMLSerializer",
  22093. "XMLStylesheetProcessingInstruction",
  22094. "XPathEvaluator",
  22095. "XPathException",
  22096. "XPathExpression",
  22097. "XPathNSResolver",
  22098. "XPathResult",
  22099. "XRBoundedReferenceSpace",
  22100. "XRDOMOverlayState",
  22101. "XRFrame",
  22102. "XRHitTestResult",
  22103. "XRHitTestSource",
  22104. "XRInputSource",
  22105. "XRInputSourceArray",
  22106. "XRInputSourceEvent",
  22107. "XRInputSourcesChangeEvent",
  22108. "XRLayer",
  22109. "XRPose",
  22110. "XRRay",
  22111. "XRReferenceSpace",
  22112. "XRReferenceSpaceEvent",
  22113. "XRRenderState",
  22114. "XRRigidTransform",
  22115. "XRSession",
  22116. "XRSessionEvent",
  22117. "XRSpace",
  22118. "XRSystem",
  22119. "XRTransientInputHitTestResult",
  22120. "XRTransientInputHitTestSource",
  22121. "XRView",
  22122. "XRViewerPose",
  22123. "XRViewport",
  22124. "XRWebGLLayer",
  22125. "XSLTProcessor",
  22126. "ZERO",
  22127. "_XD0M_",
  22128. "_YD0M_",
  22129. "__defineGetter__",
  22130. "__defineSetter__",
  22131. "__lookupGetter__",
  22132. "__lookupSetter__",
  22133. "__opera",
  22134. "__proto__",
  22135. "_browserjsran",
  22136. "a",
  22137. "aLink",
  22138. "abbr",
  22139. "abort",
  22140. "aborted",
  22141. "abs",
  22142. "absolute",
  22143. "acceleration",
  22144. "accelerationIncludingGravity",
  22145. "accelerator",
  22146. "accept",
  22147. "acceptCharset",
  22148. "acceptNode",
  22149. "accessKey",
  22150. "accessKeyLabel",
  22151. "accuracy",
  22152. "acos",
  22153. "acosh",
  22154. "action",
  22155. "actionURL",
  22156. "actions",
  22157. "activated",
  22158. "active",
  22159. "activeCues",
  22160. "activeElement",
  22161. "activeSourceBuffers",
  22162. "activeSourceCount",
  22163. "activeTexture",
  22164. "activeVRDisplays",
  22165. "actualBoundingBoxAscent",
  22166. "actualBoundingBoxDescent",
  22167. "actualBoundingBoxLeft",
  22168. "actualBoundingBoxRight",
  22169. "add",
  22170. "addAll",
  22171. "addBehavior",
  22172. "addCandidate",
  22173. "addColorStop",
  22174. "addCue",
  22175. "addElement",
  22176. "addEventListener",
  22177. "addFilter",
  22178. "addFromString",
  22179. "addFromUri",
  22180. "addIceCandidate",
  22181. "addImport",
  22182. "addListener",
  22183. "addModule",
  22184. "addNamed",
  22185. "addPageRule",
  22186. "addPath",
  22187. "addPointer",
  22188. "addRange",
  22189. "addRegion",
  22190. "addRule",
  22191. "addSearchEngine",
  22192. "addSourceBuffer",
  22193. "addStream",
  22194. "addTextTrack",
  22195. "addTrack",
  22196. "addTransceiver",
  22197. "addWakeLockListener",
  22198. "added",
  22199. "addedNodes",
  22200. "additionalName",
  22201. "additiveSymbols",
  22202. "addons",
  22203. "address",
  22204. "addressLine",
  22205. "adoptNode",
  22206. "adoptedStyleSheets",
  22207. "adr",
  22208. "advance",
  22209. "after",
  22210. "album",
  22211. "alert",
  22212. "algorithm",
  22213. "align",
  22214. "align-content",
  22215. "align-items",
  22216. "align-self",
  22217. "alignContent",
  22218. "alignItems",
  22219. "alignSelf",
  22220. "alignmentBaseline",
  22221. "alinkColor",
  22222. "all",
  22223. "allSettled",
  22224. "allow",
  22225. "allowFullscreen",
  22226. "allowPaymentRequest",
  22227. "allowedDirections",
  22228. "allowedFeatures",
  22229. "allowedToPlay",
  22230. "allowsFeature",
  22231. "alpha",
  22232. "alt",
  22233. "altGraphKey",
  22234. "altHtml",
  22235. "altKey",
  22236. "altLeft",
  22237. "alternate",
  22238. "alternateSetting",
  22239. "alternates",
  22240. "altitude",
  22241. "altitudeAccuracy",
  22242. "amplitude",
  22243. "ancestorOrigins",
  22244. "anchor",
  22245. "anchorNode",
  22246. "anchorOffset",
  22247. "anchors",
  22248. "and",
  22249. "angle",
  22250. "angularAcceleration",
  22251. "angularVelocity",
  22252. "animVal",
  22253. "animate",
  22254. "animatedInstanceRoot",
  22255. "animatedNormalizedPathSegList",
  22256. "animatedPathSegList",
  22257. "animatedPoints",
  22258. "animation",
  22259. "animation-delay",
  22260. "animation-direction",
  22261. "animation-duration",
  22262. "animation-fill-mode",
  22263. "animation-iteration-count",
  22264. "animation-name",
  22265. "animation-play-state",
  22266. "animation-timing-function",
  22267. "animationDelay",
  22268. "animationDirection",
  22269. "animationDuration",
  22270. "animationFillMode",
  22271. "animationIterationCount",
  22272. "animationName",
  22273. "animationPlayState",
  22274. "animationStartTime",
  22275. "animationTimingFunction",
  22276. "animationsPaused",
  22277. "anniversary",
  22278. "antialias",
  22279. "anticipatedRemoval",
  22280. "any",
  22281. "app",
  22282. "appCodeName",
  22283. "appMinorVersion",
  22284. "appName",
  22285. "appNotifications",
  22286. "appVersion",
  22287. "appearance",
  22288. "append",
  22289. "appendBuffer",
  22290. "appendChild",
  22291. "appendData",
  22292. "appendItem",
  22293. "appendMedium",
  22294. "appendNamed",
  22295. "appendRule",
  22296. "appendStream",
  22297. "appendWindowEnd",
  22298. "appendWindowStart",
  22299. "applets",
  22300. "applicationCache",
  22301. "applicationServerKey",
  22302. "apply",
  22303. "applyConstraints",
  22304. "applyElement",
  22305. "arc",
  22306. "arcTo",
  22307. "architecture",
  22308. "archive",
  22309. "areas",
  22310. "arguments",
  22311. "ariaAtomic",
  22312. "ariaAutoComplete",
  22313. "ariaBusy",
  22314. "ariaChecked",
  22315. "ariaColCount",
  22316. "ariaColIndex",
  22317. "ariaColSpan",
  22318. "ariaCurrent",
  22319. "ariaDescription",
  22320. "ariaDisabled",
  22321. "ariaExpanded",
  22322. "ariaHasPopup",
  22323. "ariaHidden",
  22324. "ariaKeyShortcuts",
  22325. "ariaLabel",
  22326. "ariaLevel",
  22327. "ariaLive",
  22328. "ariaModal",
  22329. "ariaMultiLine",
  22330. "ariaMultiSelectable",
  22331. "ariaOrientation",
  22332. "ariaPlaceholder",
  22333. "ariaPosInSet",
  22334. "ariaPressed",
  22335. "ariaReadOnly",
  22336. "ariaRelevant",
  22337. "ariaRequired",
  22338. "ariaRoleDescription",
  22339. "ariaRowCount",
  22340. "ariaRowIndex",
  22341. "ariaRowSpan",
  22342. "ariaSelected",
  22343. "ariaSetSize",
  22344. "ariaSort",
  22345. "ariaValueMax",
  22346. "ariaValueMin",
  22347. "ariaValueNow",
  22348. "ariaValueText",
  22349. "arrayBuffer",
  22350. "artist",
  22351. "artwork",
  22352. "as",
  22353. "asIntN",
  22354. "asUintN",
  22355. "asin",
  22356. "asinh",
  22357. "assert",
  22358. "assign",
  22359. "assignedElements",
  22360. "assignedNodes",
  22361. "assignedSlot",
  22362. "async",
  22363. "asyncIterator",
  22364. "atEnd",
  22365. "atan",
  22366. "atan2",
  22367. "atanh",
  22368. "atob",
  22369. "attachEvent",
  22370. "attachInternals",
  22371. "attachShader",
  22372. "attachShadow",
  22373. "attachments",
  22374. "attack",
  22375. "attestationObject",
  22376. "attrChange",
  22377. "attrName",
  22378. "attributeFilter",
  22379. "attributeName",
  22380. "attributeNamespace",
  22381. "attributeOldValue",
  22382. "attributeStyleMap",
  22383. "attributes",
  22384. "attribution",
  22385. "audioBitsPerSecond",
  22386. "audioTracks",
  22387. "audioWorklet",
  22388. "authenticatedSignedWrites",
  22389. "authenticatorData",
  22390. "autoIncrement",
  22391. "autobuffer",
  22392. "autocapitalize",
  22393. "autocomplete",
  22394. "autocorrect",
  22395. "autofocus",
  22396. "automationRate",
  22397. "autoplay",
  22398. "availHeight",
  22399. "availLeft",
  22400. "availTop",
  22401. "availWidth",
  22402. "availability",
  22403. "available",
  22404. "aversion",
  22405. "ax",
  22406. "axes",
  22407. "axis",
  22408. "ay",
  22409. "azimuth",
  22410. "b",
  22411. "back",
  22412. "backface-visibility",
  22413. "backfaceVisibility",
  22414. "background",
  22415. "background-attachment",
  22416. "background-blend-mode",
  22417. "background-clip",
  22418. "background-color",
  22419. "background-image",
  22420. "background-origin",
  22421. "background-position",
  22422. "background-position-x",
  22423. "background-position-y",
  22424. "background-repeat",
  22425. "background-size",
  22426. "backgroundAttachment",
  22427. "backgroundBlendMode",
  22428. "backgroundClip",
  22429. "backgroundColor",
  22430. "backgroundFetch",
  22431. "backgroundImage",
  22432. "backgroundOrigin",
  22433. "backgroundPosition",
  22434. "backgroundPositionX",
  22435. "backgroundPositionY",
  22436. "backgroundRepeat",
  22437. "backgroundSize",
  22438. "badInput",
  22439. "badge",
  22440. "balance",
  22441. "baseFrequencyX",
  22442. "baseFrequencyY",
  22443. "baseLatency",
  22444. "baseLayer",
  22445. "baseNode",
  22446. "baseOffset",
  22447. "baseURI",
  22448. "baseVal",
  22449. "baselineShift",
  22450. "battery",
  22451. "bday",
  22452. "before",
  22453. "beginElement",
  22454. "beginElementAt",
  22455. "beginPath",
  22456. "beginQuery",
  22457. "beginTransformFeedback",
  22458. "behavior",
  22459. "behaviorCookie",
  22460. "behaviorPart",
  22461. "behaviorUrns",
  22462. "beta",
  22463. "bezierCurveTo",
  22464. "bgColor",
  22465. "bgProperties",
  22466. "bias",
  22467. "big",
  22468. "bigint64",
  22469. "biguint64",
  22470. "binaryType",
  22471. "bind",
  22472. "bindAttribLocation",
  22473. "bindBuffer",
  22474. "bindBufferBase",
  22475. "bindBufferRange",
  22476. "bindFramebuffer",
  22477. "bindRenderbuffer",
  22478. "bindSampler",
  22479. "bindTexture",
  22480. "bindTransformFeedback",
  22481. "bindVertexArray",
  22482. "bitness",
  22483. "blendColor",
  22484. "blendEquation",
  22485. "blendEquationSeparate",
  22486. "blendFunc",
  22487. "blendFuncSeparate",
  22488. "blink",
  22489. "blitFramebuffer",
  22490. "blob",
  22491. "block-size",
  22492. "blockDirection",
  22493. "blockSize",
  22494. "blockedURI",
  22495. "blue",
  22496. "bluetooth",
  22497. "blur",
  22498. "body",
  22499. "bodyUsed",
  22500. "bold",
  22501. "bookmarks",
  22502. "booleanValue",
  22503. "border",
  22504. "border-block",
  22505. "border-block-color",
  22506. "border-block-end",
  22507. "border-block-end-color",
  22508. "border-block-end-style",
  22509. "border-block-end-width",
  22510. "border-block-start",
  22511. "border-block-start-color",
  22512. "border-block-start-style",
  22513. "border-block-start-width",
  22514. "border-block-style",
  22515. "border-block-width",
  22516. "border-bottom",
  22517. "border-bottom-color",
  22518. "border-bottom-left-radius",
  22519. "border-bottom-right-radius",
  22520. "border-bottom-style",
  22521. "border-bottom-width",
  22522. "border-collapse",
  22523. "border-color",
  22524. "border-end-end-radius",
  22525. "border-end-start-radius",
  22526. "border-image",
  22527. "border-image-outset",
  22528. "border-image-repeat",
  22529. "border-image-slice",
  22530. "border-image-source",
  22531. "border-image-width",
  22532. "border-inline",
  22533. "border-inline-color",
  22534. "border-inline-end",
  22535. "border-inline-end-color",
  22536. "border-inline-end-style",
  22537. "border-inline-end-width",
  22538. "border-inline-start",
  22539. "border-inline-start-color",
  22540. "border-inline-start-style",
  22541. "border-inline-start-width",
  22542. "border-inline-style",
  22543. "border-inline-width",
  22544. "border-left",
  22545. "border-left-color",
  22546. "border-left-style",
  22547. "border-left-width",
  22548. "border-radius",
  22549. "border-right",
  22550. "border-right-color",
  22551. "border-right-style",
  22552. "border-right-width",
  22553. "border-spacing",
  22554. "border-start-end-radius",
  22555. "border-start-start-radius",
  22556. "border-style",
  22557. "border-top",
  22558. "border-top-color",
  22559. "border-top-left-radius",
  22560. "border-top-right-radius",
  22561. "border-top-style",
  22562. "border-top-width",
  22563. "border-width",
  22564. "borderBlock",
  22565. "borderBlockColor",
  22566. "borderBlockEnd",
  22567. "borderBlockEndColor",
  22568. "borderBlockEndStyle",
  22569. "borderBlockEndWidth",
  22570. "borderBlockStart",
  22571. "borderBlockStartColor",
  22572. "borderBlockStartStyle",
  22573. "borderBlockStartWidth",
  22574. "borderBlockStyle",
  22575. "borderBlockWidth",
  22576. "borderBottom",
  22577. "borderBottomColor",
  22578. "borderBottomLeftRadius",
  22579. "borderBottomRightRadius",
  22580. "borderBottomStyle",
  22581. "borderBottomWidth",
  22582. "borderBoxSize",
  22583. "borderCollapse",
  22584. "borderColor",
  22585. "borderColorDark",
  22586. "borderColorLight",
  22587. "borderEndEndRadius",
  22588. "borderEndStartRadius",
  22589. "borderImage",
  22590. "borderImageOutset",
  22591. "borderImageRepeat",
  22592. "borderImageSlice",
  22593. "borderImageSource",
  22594. "borderImageWidth",
  22595. "borderInline",
  22596. "borderInlineColor",
  22597. "borderInlineEnd",
  22598. "borderInlineEndColor",
  22599. "borderInlineEndStyle",
  22600. "borderInlineEndWidth",
  22601. "borderInlineStart",
  22602. "borderInlineStartColor",
  22603. "borderInlineStartStyle",
  22604. "borderInlineStartWidth",
  22605. "borderInlineStyle",
  22606. "borderInlineWidth",
  22607. "borderLeft",
  22608. "borderLeftColor",
  22609. "borderLeftStyle",
  22610. "borderLeftWidth",
  22611. "borderRadius",
  22612. "borderRight",
  22613. "borderRightColor",
  22614. "borderRightStyle",
  22615. "borderRightWidth",
  22616. "borderSpacing",
  22617. "borderStartEndRadius",
  22618. "borderStartStartRadius",
  22619. "borderStyle",
  22620. "borderTop",
  22621. "borderTopColor",
  22622. "borderTopLeftRadius",
  22623. "borderTopRightRadius",
  22624. "borderTopStyle",
  22625. "borderTopWidth",
  22626. "borderWidth",
  22627. "bottom",
  22628. "bottomMargin",
  22629. "bound",
  22630. "boundElements",
  22631. "boundingClientRect",
  22632. "boundingHeight",
  22633. "boundingLeft",
  22634. "boundingTop",
  22635. "boundingWidth",
  22636. "bounds",
  22637. "boundsGeometry",
  22638. "box-decoration-break",
  22639. "box-shadow",
  22640. "box-sizing",
  22641. "boxDecorationBreak",
  22642. "boxShadow",
  22643. "boxSizing",
  22644. "brand",
  22645. "brands",
  22646. "break-after",
  22647. "break-before",
  22648. "break-inside",
  22649. "breakAfter",
  22650. "breakBefore",
  22651. "breakInside",
  22652. "broadcast",
  22653. "browserLanguage",
  22654. "btoa",
  22655. "bubbles",
  22656. "buffer",
  22657. "bufferData",
  22658. "bufferDepth",
  22659. "bufferSize",
  22660. "bufferSubData",
  22661. "buffered",
  22662. "bufferedAmount",
  22663. "bufferedAmountLowThreshold",
  22664. "buildID",
  22665. "buildNumber",
  22666. "button",
  22667. "buttonID",
  22668. "buttons",
  22669. "byteLength",
  22670. "byteOffset",
  22671. "bytesWritten",
  22672. "c",
  22673. "cache",
  22674. "caches",
  22675. "call",
  22676. "caller",
  22677. "canBeFormatted",
  22678. "canBeMounted",
  22679. "canBeShared",
  22680. "canHaveChildren",
  22681. "canHaveHTML",
  22682. "canInsertDTMF",
  22683. "canMakePayment",
  22684. "canPlayType",
  22685. "canPresent",
  22686. "canTrickleIceCandidates",
  22687. "cancel",
  22688. "cancelAndHoldAtTime",
  22689. "cancelAnimationFrame",
  22690. "cancelBubble",
  22691. "cancelIdleCallback",
  22692. "cancelScheduledValues",
  22693. "cancelVideoFrameCallback",
  22694. "cancelWatchAvailability",
  22695. "cancelable",
  22696. "candidate",
  22697. "canonicalUUID",
  22698. "canvas",
  22699. "capabilities",
  22700. "caption",
  22701. "caption-side",
  22702. "captionSide",
  22703. "capture",
  22704. "captureEvents",
  22705. "captureStackTrace",
  22706. "captureStream",
  22707. "caret-color",
  22708. "caretBidiLevel",
  22709. "caretColor",
  22710. "caretPositionFromPoint",
  22711. "caretRangeFromPoint",
  22712. "cast",
  22713. "catch",
  22714. "category",
  22715. "cbrt",
  22716. "cd",
  22717. "ceil",
  22718. "cellIndex",
  22719. "cellPadding",
  22720. "cellSpacing",
  22721. "cells",
  22722. "ch",
  22723. "chOff",
  22724. "chain",
  22725. "challenge",
  22726. "changeType",
  22727. "changedTouches",
  22728. "channel",
  22729. "channelCount",
  22730. "channelCountMode",
  22731. "channelInterpretation",
  22732. "char",
  22733. "charAt",
  22734. "charCode",
  22735. "charCodeAt",
  22736. "charIndex",
  22737. "charLength",
  22738. "characterData",
  22739. "characterDataOldValue",
  22740. "characterSet",
  22741. "characteristic",
  22742. "charging",
  22743. "chargingTime",
  22744. "charset",
  22745. "check",
  22746. "checkEnclosure",
  22747. "checkFramebufferStatus",
  22748. "checkIntersection",
  22749. "checkValidity",
  22750. "checked",
  22751. "childElementCount",
  22752. "childList",
  22753. "childNodes",
  22754. "children",
  22755. "chrome",
  22756. "ciphertext",
  22757. "cite",
  22758. "city",
  22759. "claimInterface",
  22760. "claimed",
  22761. "classList",
  22762. "className",
  22763. "classid",
  22764. "clear",
  22765. "clearAppBadge",
  22766. "clearAttributes",
  22767. "clearBufferfi",
  22768. "clearBufferfv",
  22769. "clearBufferiv",
  22770. "clearBufferuiv",
  22771. "clearColor",
  22772. "clearData",
  22773. "clearDepth",
  22774. "clearHalt",
  22775. "clearImmediate",
  22776. "clearInterval",
  22777. "clearLiveSeekableRange",
  22778. "clearMarks",
  22779. "clearMaxGCPauseAccumulator",
  22780. "clearMeasures",
  22781. "clearParameters",
  22782. "clearRect",
  22783. "clearResourceTimings",
  22784. "clearShadow",
  22785. "clearStencil",
  22786. "clearTimeout",
  22787. "clearWatch",
  22788. "click",
  22789. "clickCount",
  22790. "clientDataJSON",
  22791. "clientHeight",
  22792. "clientInformation",
  22793. "clientLeft",
  22794. "clientRect",
  22795. "clientRects",
  22796. "clientTop",
  22797. "clientWaitSync",
  22798. "clientWidth",
  22799. "clientX",
  22800. "clientY",
  22801. "clip",
  22802. "clip-path",
  22803. "clip-rule",
  22804. "clipBottom",
  22805. "clipLeft",
  22806. "clipPath",
  22807. "clipPathUnits",
  22808. "clipRight",
  22809. "clipRule",
  22810. "clipTop",
  22811. "clipboard",
  22812. "clipboardData",
  22813. "clone",
  22814. "cloneContents",
  22815. "cloneNode",
  22816. "cloneRange",
  22817. "close",
  22818. "closePath",
  22819. "closed",
  22820. "closest",
  22821. "clz",
  22822. "clz32",
  22823. "cm",
  22824. "cmp",
  22825. "code",
  22826. "codeBase",
  22827. "codePointAt",
  22828. "codeType",
  22829. "colSpan",
  22830. "collapse",
  22831. "collapseToEnd",
  22832. "collapseToStart",
  22833. "collapsed",
  22834. "collect",
  22835. "colno",
  22836. "color",
  22837. "color-adjust",
  22838. "color-interpolation",
  22839. "color-interpolation-filters",
  22840. "colorAdjust",
  22841. "colorDepth",
  22842. "colorInterpolation",
  22843. "colorInterpolationFilters",
  22844. "colorMask",
  22845. "colorType",
  22846. "cols",
  22847. "column-count",
  22848. "column-fill",
  22849. "column-gap",
  22850. "column-rule",
  22851. "column-rule-color",
  22852. "column-rule-style",
  22853. "column-rule-width",
  22854. "column-span",
  22855. "column-width",
  22856. "columnCount",
  22857. "columnFill",
  22858. "columnGap",
  22859. "columnNumber",
  22860. "columnRule",
  22861. "columnRuleColor",
  22862. "columnRuleStyle",
  22863. "columnRuleWidth",
  22864. "columnSpan",
  22865. "columnWidth",
  22866. "columns",
  22867. "command",
  22868. "commit",
  22869. "commitPreferences",
  22870. "commitStyles",
  22871. "commonAncestorContainer",
  22872. "compact",
  22873. "compareBoundaryPoints",
  22874. "compareDocumentPosition",
  22875. "compareEndPoints",
  22876. "compareExchange",
  22877. "compareNode",
  22878. "comparePoint",
  22879. "compatMode",
  22880. "compatible",
  22881. "compile",
  22882. "compileShader",
  22883. "compileStreaming",
  22884. "complete",
  22885. "component",
  22886. "componentFromPoint",
  22887. "composed",
  22888. "composedPath",
  22889. "composite",
  22890. "compositionEndOffset",
  22891. "compositionStartOffset",
  22892. "compressedTexImage2D",
  22893. "compressedTexImage3D",
  22894. "compressedTexSubImage2D",
  22895. "compressedTexSubImage3D",
  22896. "computedStyleMap",
  22897. "concat",
  22898. "conditionText",
  22899. "coneInnerAngle",
  22900. "coneOuterAngle",
  22901. "coneOuterGain",
  22902. "configuration",
  22903. "configurationName",
  22904. "configurationValue",
  22905. "configurations",
  22906. "confirm",
  22907. "confirmComposition",
  22908. "confirmSiteSpecificTrackingException",
  22909. "confirmWebWideTrackingException",
  22910. "connect",
  22911. "connectEnd",
  22912. "connectShark",
  22913. "connectStart",
  22914. "connected",
  22915. "connection",
  22916. "connectionList",
  22917. "connectionSpeed",
  22918. "connectionState",
  22919. "connections",
  22920. "console",
  22921. "consolidate",
  22922. "constraint",
  22923. "constrictionActive",
  22924. "construct",
  22925. "constructor",
  22926. "contactID",
  22927. "contain",
  22928. "containerId",
  22929. "containerName",
  22930. "containerSrc",
  22931. "containerType",
  22932. "contains",
  22933. "containsNode",
  22934. "content",
  22935. "contentBoxSize",
  22936. "contentDocument",
  22937. "contentEditable",
  22938. "contentHint",
  22939. "contentOverflow",
  22940. "contentRect",
  22941. "contentScriptType",
  22942. "contentStyleType",
  22943. "contentType",
  22944. "contentWindow",
  22945. "context",
  22946. "contextMenu",
  22947. "contextmenu",
  22948. "continue",
  22949. "continuePrimaryKey",
  22950. "continuous",
  22951. "control",
  22952. "controlTransferIn",
  22953. "controlTransferOut",
  22954. "controller",
  22955. "controls",
  22956. "controlsList",
  22957. "convertPointFromNode",
  22958. "convertQuadFromNode",
  22959. "convertRectFromNode",
  22960. "convertToBlob",
  22961. "convertToSpecifiedUnits",
  22962. "cookie",
  22963. "cookieEnabled",
  22964. "coords",
  22965. "copyBufferSubData",
  22966. "copyFromChannel",
  22967. "copyTexImage2D",
  22968. "copyTexSubImage2D",
  22969. "copyTexSubImage3D",
  22970. "copyToChannel",
  22971. "copyWithin",
  22972. "correspondingElement",
  22973. "correspondingUseElement",
  22974. "corruptedVideoFrames",
  22975. "cos",
  22976. "cosh",
  22977. "count",
  22978. "countReset",
  22979. "counter-increment",
  22980. "counter-reset",
  22981. "counter-set",
  22982. "counterIncrement",
  22983. "counterReset",
  22984. "counterSet",
  22985. "country",
  22986. "cpuClass",
  22987. "cpuSleepAllowed",
  22988. "create",
  22989. "createAnalyser",
  22990. "createAnswer",
  22991. "createAttribute",
  22992. "createAttributeNS",
  22993. "createBiquadFilter",
  22994. "createBuffer",
  22995. "createBufferSource",
  22996. "createCDATASection",
  22997. "createCSSStyleSheet",
  22998. "createCaption",
  22999. "createChannelMerger",
  23000. "createChannelSplitter",
  23001. "createComment",
  23002. "createConstantSource",
  23003. "createContextualFragment",
  23004. "createControlRange",
  23005. "createConvolver",
  23006. "createDTMFSender",
  23007. "createDataChannel",
  23008. "createDelay",
  23009. "createDelayNode",
  23010. "createDocument",
  23011. "createDocumentFragment",
  23012. "createDocumentType",
  23013. "createDynamicsCompressor",
  23014. "createElement",
  23015. "createElementNS",
  23016. "createEntityReference",
  23017. "createEvent",
  23018. "createEventObject",
  23019. "createExpression",
  23020. "createFramebuffer",
  23021. "createFunction",
  23022. "createGain",
  23023. "createGainNode",
  23024. "createHTML",
  23025. "createHTMLDocument",
  23026. "createIIRFilter",
  23027. "createImageBitmap",
  23028. "createImageData",
  23029. "createIndex",
  23030. "createJavaScriptNode",
  23031. "createLinearGradient",
  23032. "createMediaElementSource",
  23033. "createMediaKeys",
  23034. "createMediaStreamDestination",
  23035. "createMediaStreamSource",
  23036. "createMediaStreamTrackSource",
  23037. "createMutableFile",
  23038. "createNSResolver",
  23039. "createNodeIterator",
  23040. "createNotification",
  23041. "createObjectStore",
  23042. "createObjectURL",
  23043. "createOffer",
  23044. "createOscillator",
  23045. "createPanner",
  23046. "createPattern",
  23047. "createPeriodicWave",
  23048. "createPolicy",
  23049. "createPopup",
  23050. "createProcessingInstruction",
  23051. "createProgram",
  23052. "createQuery",
  23053. "createRadialGradient",
  23054. "createRange",
  23055. "createRangeCollection",
  23056. "createReader",
  23057. "createRenderbuffer",
  23058. "createSVGAngle",
  23059. "createSVGLength",
  23060. "createSVGMatrix",
  23061. "createSVGNumber",
  23062. "createSVGPathSegArcAbs",
  23063. "createSVGPathSegArcRel",
  23064. "createSVGPathSegClosePath",
  23065. "createSVGPathSegCurvetoCubicAbs",
  23066. "createSVGPathSegCurvetoCubicRel",
  23067. "createSVGPathSegCurvetoCubicSmoothAbs",
  23068. "createSVGPathSegCurvetoCubicSmoothRel",
  23069. "createSVGPathSegCurvetoQuadraticAbs",
  23070. "createSVGPathSegCurvetoQuadraticRel",
  23071. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  23072. "createSVGPathSegCurvetoQuadraticSmoothRel",
  23073. "createSVGPathSegLinetoAbs",
  23074. "createSVGPathSegLinetoHorizontalAbs",
  23075. "createSVGPathSegLinetoHorizontalRel",
  23076. "createSVGPathSegLinetoRel",
  23077. "createSVGPathSegLinetoVerticalAbs",
  23078. "createSVGPathSegLinetoVerticalRel",
  23079. "createSVGPathSegMovetoAbs",
  23080. "createSVGPathSegMovetoRel",
  23081. "createSVGPoint",
  23082. "createSVGRect",
  23083. "createSVGTransform",
  23084. "createSVGTransformFromMatrix",
  23085. "createSampler",
  23086. "createScript",
  23087. "createScriptProcessor",
  23088. "createScriptURL",
  23089. "createSession",
  23090. "createShader",
  23091. "createShadowRoot",
  23092. "createStereoPanner",
  23093. "createStyleSheet",
  23094. "createTBody",
  23095. "createTFoot",
  23096. "createTHead",
  23097. "createTextNode",
  23098. "createTextRange",
  23099. "createTexture",
  23100. "createTouch",
  23101. "createTouchList",
  23102. "createTransformFeedback",
  23103. "createTreeWalker",
  23104. "createVertexArray",
  23105. "createWaveShaper",
  23106. "creationTime",
  23107. "credentials",
  23108. "crossOrigin",
  23109. "crossOriginIsolated",
  23110. "crypto",
  23111. "csi",
  23112. "csp",
  23113. "cssFloat",
  23114. "cssRules",
  23115. "cssText",
  23116. "cssValueType",
  23117. "ctrlKey",
  23118. "ctrlLeft",
  23119. "cues",
  23120. "cullFace",
  23121. "currentDirection",
  23122. "currentLocalDescription",
  23123. "currentNode",
  23124. "currentPage",
  23125. "currentRect",
  23126. "currentRemoteDescription",
  23127. "currentScale",
  23128. "currentScript",
  23129. "currentSrc",
  23130. "currentState",
  23131. "currentStyle",
  23132. "currentTarget",
  23133. "currentTime",
  23134. "currentTranslate",
  23135. "currentView",
  23136. "cursor",
  23137. "curve",
  23138. "customElements",
  23139. "customError",
  23140. "cx",
  23141. "cy",
  23142. "d",
  23143. "data",
  23144. "dataFld",
  23145. "dataFormatAs",
  23146. "dataLoss",
  23147. "dataLossMessage",
  23148. "dataPageSize",
  23149. "dataSrc",
  23150. "dataTransfer",
  23151. "database",
  23152. "databases",
  23153. "dataset",
  23154. "dateTime",
  23155. "db",
  23156. "debug",
  23157. "debuggerEnabled",
  23158. "declare",
  23159. "decode",
  23160. "decodeAudioData",
  23161. "decodeURI",
  23162. "decodeURIComponent",
  23163. "decodedBodySize",
  23164. "decoding",
  23165. "decodingInfo",
  23166. "decrypt",
  23167. "default",
  23168. "defaultCharset",
  23169. "defaultChecked",
  23170. "defaultMuted",
  23171. "defaultPlaybackRate",
  23172. "defaultPolicy",
  23173. "defaultPrevented",
  23174. "defaultRequest",
  23175. "defaultSelected",
  23176. "defaultStatus",
  23177. "defaultURL",
  23178. "defaultValue",
  23179. "defaultView",
  23180. "defaultstatus",
  23181. "defer",
  23182. "define",
  23183. "defineMagicFunction",
  23184. "defineMagicVariable",
  23185. "defineProperties",
  23186. "defineProperty",
  23187. "deg",
  23188. "delay",
  23189. "delayTime",
  23190. "delegatesFocus",
  23191. "delete",
  23192. "deleteBuffer",
  23193. "deleteCaption",
  23194. "deleteCell",
  23195. "deleteContents",
  23196. "deleteData",
  23197. "deleteDatabase",
  23198. "deleteFramebuffer",
  23199. "deleteFromDocument",
  23200. "deleteIndex",
  23201. "deleteMedium",
  23202. "deleteObjectStore",
  23203. "deleteProgram",
  23204. "deleteProperty",
  23205. "deleteQuery",
  23206. "deleteRenderbuffer",
  23207. "deleteRow",
  23208. "deleteRule",
  23209. "deleteSampler",
  23210. "deleteShader",
  23211. "deleteSync",
  23212. "deleteTFoot",
  23213. "deleteTHead",
  23214. "deleteTexture",
  23215. "deleteTransformFeedback",
  23216. "deleteVertexArray",
  23217. "deliverChangeRecords",
  23218. "delivery",
  23219. "deliveryInfo",
  23220. "deliveryStatus",
  23221. "deliveryTimestamp",
  23222. "delta",
  23223. "deltaMode",
  23224. "deltaX",
  23225. "deltaY",
  23226. "deltaZ",
  23227. "dependentLocality",
  23228. "depthFar",
  23229. "depthFunc",
  23230. "depthMask",
  23231. "depthNear",
  23232. "depthRange",
  23233. "deref",
  23234. "deriveBits",
  23235. "deriveKey",
  23236. "description",
  23237. "deselectAll",
  23238. "designMode",
  23239. "desiredSize",
  23240. "destination",
  23241. "destinationURL",
  23242. "detach",
  23243. "detachEvent",
  23244. "detachShader",
  23245. "detail",
  23246. "details",
  23247. "detect",
  23248. "detune",
  23249. "device",
  23250. "deviceClass",
  23251. "deviceId",
  23252. "deviceMemory",
  23253. "devicePixelContentBoxSize",
  23254. "devicePixelRatio",
  23255. "deviceProtocol",
  23256. "deviceSubclass",
  23257. "deviceVersionMajor",
  23258. "deviceVersionMinor",
  23259. "deviceVersionSubminor",
  23260. "deviceXDPI",
  23261. "deviceYDPI",
  23262. "didTimeout",
  23263. "diffuseConstant",
  23264. "digest",
  23265. "dimensions",
  23266. "dir",
  23267. "dirName",
  23268. "direction",
  23269. "dirxml",
  23270. "disable",
  23271. "disablePictureInPicture",
  23272. "disableRemotePlayback",
  23273. "disableVertexAttribArray",
  23274. "disabled",
  23275. "dischargingTime",
  23276. "disconnect",
  23277. "disconnectShark",
  23278. "dispatchEvent",
  23279. "display",
  23280. "displayId",
  23281. "displayName",
  23282. "disposition",
  23283. "distanceModel",
  23284. "div",
  23285. "divisor",
  23286. "djsapi",
  23287. "djsproxy",
  23288. "doImport",
  23289. "doNotTrack",
  23290. "doScroll",
  23291. "doctype",
  23292. "document",
  23293. "documentElement",
  23294. "documentMode",
  23295. "documentURI",
  23296. "dolphin",
  23297. "dolphinGameCenter",
  23298. "dolphininfo",
  23299. "dolphinmeta",
  23300. "domComplete",
  23301. "domContentLoadedEventEnd",
  23302. "domContentLoadedEventStart",
  23303. "domInteractive",
  23304. "domLoading",
  23305. "domOverlayState",
  23306. "domain",
  23307. "domainLookupEnd",
  23308. "domainLookupStart",
  23309. "dominant-baseline",
  23310. "dominantBaseline",
  23311. "done",
  23312. "dopplerFactor",
  23313. "dotAll",
  23314. "downDegrees",
  23315. "downlink",
  23316. "download",
  23317. "downloadTotal",
  23318. "downloaded",
  23319. "dpcm",
  23320. "dpi",
  23321. "dppx",
  23322. "dragDrop",
  23323. "draggable",
  23324. "drawArrays",
  23325. "drawArraysInstanced",
  23326. "drawArraysInstancedANGLE",
  23327. "drawBuffers",
  23328. "drawCustomFocusRing",
  23329. "drawElements",
  23330. "drawElementsInstanced",
  23331. "drawElementsInstancedANGLE",
  23332. "drawFocusIfNeeded",
  23333. "drawImage",
  23334. "drawImageFromRect",
  23335. "drawRangeElements",
  23336. "drawSystemFocusRing",
  23337. "drawingBufferHeight",
  23338. "drawingBufferWidth",
  23339. "dropEffect",
  23340. "droppedVideoFrames",
  23341. "dropzone",
  23342. "dtmf",
  23343. "dump",
  23344. "dumpProfile",
  23345. "duplicate",
  23346. "durability",
  23347. "duration",
  23348. "dvname",
  23349. "dvnum",
  23350. "dx",
  23351. "dy",
  23352. "dynsrc",
  23353. "e",
  23354. "edgeMode",
  23355. "effect",
  23356. "effectAllowed",
  23357. "effectiveDirective",
  23358. "effectiveType",
  23359. "elapsedTime",
  23360. "element",
  23361. "elementFromPoint",
  23362. "elementTiming",
  23363. "elements",
  23364. "elementsFromPoint",
  23365. "elevation",
  23366. "ellipse",
  23367. "em",
  23368. "email",
  23369. "embeds",
  23370. "emma",
  23371. "empty",
  23372. "empty-cells",
  23373. "emptyCells",
  23374. "emptyHTML",
  23375. "emptyScript",
  23376. "emulatedPosition",
  23377. "enable",
  23378. "enableBackground",
  23379. "enableDelegations",
  23380. "enableStyleSheetsForSet",
  23381. "enableVertexAttribArray",
  23382. "enabled",
  23383. "enabledPlugin",
  23384. "encode",
  23385. "encodeInto",
  23386. "encodeURI",
  23387. "encodeURIComponent",
  23388. "encodedBodySize",
  23389. "encoding",
  23390. "encodingInfo",
  23391. "encrypt",
  23392. "enctype",
  23393. "end",
  23394. "endContainer",
  23395. "endElement",
  23396. "endElementAt",
  23397. "endOfStream",
  23398. "endOffset",
  23399. "endQuery",
  23400. "endTime",
  23401. "endTransformFeedback",
  23402. "ended",
  23403. "endpoint",
  23404. "endpointNumber",
  23405. "endpoints",
  23406. "endsWith",
  23407. "enterKeyHint",
  23408. "entities",
  23409. "entries",
  23410. "entryType",
  23411. "enumerate",
  23412. "enumerateDevices",
  23413. "enumerateEditable",
  23414. "environmentBlendMode",
  23415. "equals",
  23416. "error",
  23417. "errorCode",
  23418. "errorDetail",
  23419. "errorText",
  23420. "escape",
  23421. "estimate",
  23422. "eval",
  23423. "evaluate",
  23424. "event",
  23425. "eventPhase",
  23426. "every",
  23427. "ex",
  23428. "exception",
  23429. "exchange",
  23430. "exec",
  23431. "execCommand",
  23432. "execCommandShowHelp",
  23433. "execScript",
  23434. "exitFullscreen",
  23435. "exitPictureInPicture",
  23436. "exitPointerLock",
  23437. "exitPresent",
  23438. "exp",
  23439. "expand",
  23440. "expandEntityReferences",
  23441. "expando",
  23442. "expansion",
  23443. "expiration",
  23444. "expirationTime",
  23445. "expires",
  23446. "expiryDate",
  23447. "explicitOriginalTarget",
  23448. "expm1",
  23449. "exponent",
  23450. "exponentialRampToValueAtTime",
  23451. "exportKey",
  23452. "exports",
  23453. "extend",
  23454. "extensions",
  23455. "extentNode",
  23456. "extentOffset",
  23457. "external",
  23458. "externalResourcesRequired",
  23459. "extractContents",
  23460. "extractable",
  23461. "eye",
  23462. "f",
  23463. "face",
  23464. "factoryReset",
  23465. "failureReason",
  23466. "fallback",
  23467. "family",
  23468. "familyName",
  23469. "farthestViewportElement",
  23470. "fastSeek",
  23471. "fatal",
  23472. "featureId",
  23473. "featurePolicy",
  23474. "featureSettings",
  23475. "features",
  23476. "fenceSync",
  23477. "fetch",
  23478. "fetchStart",
  23479. "fftSize",
  23480. "fgColor",
  23481. "fieldOfView",
  23482. "file",
  23483. "fileCreatedDate",
  23484. "fileHandle",
  23485. "fileModifiedDate",
  23486. "fileName",
  23487. "fileSize",
  23488. "fileUpdatedDate",
  23489. "filename",
  23490. "files",
  23491. "filesystem",
  23492. "fill",
  23493. "fill-opacity",
  23494. "fill-rule",
  23495. "fillLightMode",
  23496. "fillOpacity",
  23497. "fillRect",
  23498. "fillRule",
  23499. "fillStyle",
  23500. "fillText",
  23501. "filter",
  23502. "filterResX",
  23503. "filterResY",
  23504. "filterUnits",
  23505. "filters",
  23506. "finally",
  23507. "find",
  23508. "findIndex",
  23509. "findRule",
  23510. "findText",
  23511. "finish",
  23512. "finished",
  23513. "fireEvent",
  23514. "firesTouchEvents",
  23515. "firstChild",
  23516. "firstElementChild",
  23517. "firstPage",
  23518. "fixed",
  23519. "flags",
  23520. "flat",
  23521. "flatMap",
  23522. "flex",
  23523. "flex-basis",
  23524. "flex-direction",
  23525. "flex-flow",
  23526. "flex-grow",
  23527. "flex-shrink",
  23528. "flex-wrap",
  23529. "flexBasis",
  23530. "flexDirection",
  23531. "flexFlow",
  23532. "flexGrow",
  23533. "flexShrink",
  23534. "flexWrap",
  23535. "flipX",
  23536. "flipY",
  23537. "float",
  23538. "float32",
  23539. "float64",
  23540. "flood-color",
  23541. "flood-opacity",
  23542. "floodColor",
  23543. "floodOpacity",
  23544. "floor",
  23545. "flush",
  23546. "focus",
  23547. "focusNode",
  23548. "focusOffset",
  23549. "font",
  23550. "font-family",
  23551. "font-feature-settings",
  23552. "font-kerning",
  23553. "font-language-override",
  23554. "font-optical-sizing",
  23555. "font-size",
  23556. "font-size-adjust",
  23557. "font-stretch",
  23558. "font-style",
  23559. "font-synthesis",
  23560. "font-variant",
  23561. "font-variant-alternates",
  23562. "font-variant-caps",
  23563. "font-variant-east-asian",
  23564. "font-variant-ligatures",
  23565. "font-variant-numeric",
  23566. "font-variant-position",
  23567. "font-variation-settings",
  23568. "font-weight",
  23569. "fontFamily",
  23570. "fontFeatureSettings",
  23571. "fontKerning",
  23572. "fontLanguageOverride",
  23573. "fontOpticalSizing",
  23574. "fontSize",
  23575. "fontSizeAdjust",
  23576. "fontSmoothingEnabled",
  23577. "fontStretch",
  23578. "fontStyle",
  23579. "fontSynthesis",
  23580. "fontVariant",
  23581. "fontVariantAlternates",
  23582. "fontVariantCaps",
  23583. "fontVariantEastAsian",
  23584. "fontVariantLigatures",
  23585. "fontVariantNumeric",
  23586. "fontVariantPosition",
  23587. "fontVariationSettings",
  23588. "fontWeight",
  23589. "fontcolor",
  23590. "fontfaces",
  23591. "fonts",
  23592. "fontsize",
  23593. "for",
  23594. "forEach",
  23595. "force",
  23596. "forceRedraw",
  23597. "form",
  23598. "formAction",
  23599. "formData",
  23600. "formEnctype",
  23601. "formMethod",
  23602. "formNoValidate",
  23603. "formTarget",
  23604. "format",
  23605. "formatToParts",
  23606. "forms",
  23607. "forward",
  23608. "forwardX",
  23609. "forwardY",
  23610. "forwardZ",
  23611. "foundation",
  23612. "fr",
  23613. "fragmentDirective",
  23614. "frame",
  23615. "frameBorder",
  23616. "frameElement",
  23617. "frameSpacing",
  23618. "framebuffer",
  23619. "framebufferHeight",
  23620. "framebufferRenderbuffer",
  23621. "framebufferTexture2D",
  23622. "framebufferTextureLayer",
  23623. "framebufferWidth",
  23624. "frames",
  23625. "freeSpace",
  23626. "freeze",
  23627. "frequency",
  23628. "frequencyBinCount",
  23629. "from",
  23630. "fromCharCode",
  23631. "fromCodePoint",
  23632. "fromElement",
  23633. "fromEntries",
  23634. "fromFloat32Array",
  23635. "fromFloat64Array",
  23636. "fromMatrix",
  23637. "fromPoint",
  23638. "fromQuad",
  23639. "fromRect",
  23640. "frontFace",
  23641. "fround",
  23642. "fullPath",
  23643. "fullScreen",
  23644. "fullVersionList",
  23645. "fullscreen",
  23646. "fullscreenElement",
  23647. "fullscreenEnabled",
  23648. "fx",
  23649. "fy",
  23650. "gain",
  23651. "gamepad",
  23652. "gamma",
  23653. "gap",
  23654. "gatheringState",
  23655. "gatt",
  23656. "genderIdentity",
  23657. "generateCertificate",
  23658. "generateKey",
  23659. "generateMipmap",
  23660. "generateRequest",
  23661. "geolocation",
  23662. "gestureObject",
  23663. "get",
  23664. "getActiveAttrib",
  23665. "getActiveUniform",
  23666. "getActiveUniformBlockName",
  23667. "getActiveUniformBlockParameter",
  23668. "getActiveUniforms",
  23669. "getAdjacentText",
  23670. "getAll",
  23671. "getAllKeys",
  23672. "getAllResponseHeaders",
  23673. "getAllowlistForFeature",
  23674. "getAnimations",
  23675. "getAsFile",
  23676. "getAsString",
  23677. "getAttachedShaders",
  23678. "getAttribLocation",
  23679. "getAttribute",
  23680. "getAttributeNS",
  23681. "getAttributeNames",
  23682. "getAttributeNode",
  23683. "getAttributeNodeNS",
  23684. "getAttributeType",
  23685. "getAudioTracks",
  23686. "getAvailability",
  23687. "getBBox",
  23688. "getBattery",
  23689. "getBigInt64",
  23690. "getBigUint64",
  23691. "getBlob",
  23692. "getBookmark",
  23693. "getBoundingClientRect",
  23694. "getBounds",
  23695. "getBoxQuads",
  23696. "getBufferParameter",
  23697. "getBufferSubData",
  23698. "getByteFrequencyData",
  23699. "getByteTimeDomainData",
  23700. "getCSSCanvasContext",
  23701. "getCTM",
  23702. "getCandidateWindowClientRect",
  23703. "getCanonicalLocales",
  23704. "getCapabilities",
  23705. "getChannelData",
  23706. "getCharNumAtPosition",
  23707. "getCharacteristic",
  23708. "getCharacteristics",
  23709. "getClientExtensionResults",
  23710. "getClientRect",
  23711. "getClientRects",
  23712. "getCoalescedEvents",
  23713. "getCompositionAlternatives",
  23714. "getComputedStyle",
  23715. "getComputedTextLength",
  23716. "getComputedTiming",
  23717. "getConfiguration",
  23718. "getConstraints",
  23719. "getContext",
  23720. "getContextAttributes",
  23721. "getContributingSources",
  23722. "getCounterValue",
  23723. "getCueAsHTML",
  23724. "getCueById",
  23725. "getCurrentPosition",
  23726. "getCurrentTime",
  23727. "getData",
  23728. "getDatabaseNames",
  23729. "getDate",
  23730. "getDay",
  23731. "getDefaultComputedStyle",
  23732. "getDescriptor",
  23733. "getDescriptors",
  23734. "getDestinationInsertionPoints",
  23735. "getDevices",
  23736. "getDirectory",
  23737. "getDisplayMedia",
  23738. "getDistributedNodes",
  23739. "getEditable",
  23740. "getElementById",
  23741. "getElementsByClassName",
  23742. "getElementsByName",
  23743. "getElementsByTagName",
  23744. "getElementsByTagNameNS",
  23745. "getEnclosureList",
  23746. "getEndPositionOfChar",
  23747. "getEntries",
  23748. "getEntriesByName",
  23749. "getEntriesByType",
  23750. "getError",
  23751. "getExtension",
  23752. "getExtentOfChar",
  23753. "getEyeParameters",
  23754. "getFeature",
  23755. "getFile",
  23756. "getFiles",
  23757. "getFilesAndDirectories",
  23758. "getFingerprints",
  23759. "getFloat32",
  23760. "getFloat64",
  23761. "getFloatFrequencyData",
  23762. "getFloatTimeDomainData",
  23763. "getFloatValue",
  23764. "getFragDataLocation",
  23765. "getFrameData",
  23766. "getFramebufferAttachmentParameter",
  23767. "getFrequencyResponse",
  23768. "getFullYear",
  23769. "getGamepads",
  23770. "getHighEntropyValues",
  23771. "getHitTestResults",
  23772. "getHitTestResultsForTransientInput",
  23773. "getHours",
  23774. "getIdentityAssertion",
  23775. "getIds",
  23776. "getImageData",
  23777. "getIndexedParameter",
  23778. "getInstalledRelatedApps",
  23779. "getInt16",
  23780. "getInt32",
  23781. "getInt8",
  23782. "getInternalformatParameter",
  23783. "getIntersectionList",
  23784. "getItem",
  23785. "getItems",
  23786. "getKey",
  23787. "getKeyframes",
  23788. "getLayers",
  23789. "getLayoutMap",
  23790. "getLineDash",
  23791. "getLocalCandidates",
  23792. "getLocalParameters",
  23793. "getLocalStreams",
  23794. "getMarks",
  23795. "getMatchedCSSRules",
  23796. "getMaxGCPauseSinceClear",
  23797. "getMeasures",
  23798. "getMetadata",
  23799. "getMilliseconds",
  23800. "getMinutes",
  23801. "getModifierState",
  23802. "getMonth",
  23803. "getNamedItem",
  23804. "getNamedItemNS",
  23805. "getNativeFramebufferScaleFactor",
  23806. "getNotifications",
  23807. "getNotifier",
  23808. "getNumberOfChars",
  23809. "getOffsetReferenceSpace",
  23810. "getOutputTimestamp",
  23811. "getOverrideHistoryNavigationMode",
  23812. "getOverrideStyle",
  23813. "getOwnPropertyDescriptor",
  23814. "getOwnPropertyDescriptors",
  23815. "getOwnPropertyNames",
  23816. "getOwnPropertySymbols",
  23817. "getParameter",
  23818. "getParameters",
  23819. "getParent",
  23820. "getPathSegAtLength",
  23821. "getPhotoCapabilities",
  23822. "getPhotoSettings",
  23823. "getPointAtLength",
  23824. "getPose",
  23825. "getPredictedEvents",
  23826. "getPreference",
  23827. "getPreferenceDefault",
  23828. "getPresentationAttribute",
  23829. "getPreventDefault",
  23830. "getPrimaryService",
  23831. "getPrimaryServices",
  23832. "getProgramInfoLog",
  23833. "getProgramParameter",
  23834. "getPropertyCSSValue",
  23835. "getPropertyPriority",
  23836. "getPropertyShorthand",
  23837. "getPropertyType",
  23838. "getPropertyValue",
  23839. "getPrototypeOf",
  23840. "getQuery",
  23841. "getQueryParameter",
  23842. "getRGBColorValue",
  23843. "getRandomValues",
  23844. "getRangeAt",
  23845. "getReader",
  23846. "getReceivers",
  23847. "getRectValue",
  23848. "getRegistration",
  23849. "getRegistrations",
  23850. "getRemoteCandidates",
  23851. "getRemoteCertificates",
  23852. "getRemoteParameters",
  23853. "getRemoteStreams",
  23854. "getRenderbufferParameter",
  23855. "getResponseHeader",
  23856. "getRoot",
  23857. "getRootNode",
  23858. "getRotationOfChar",
  23859. "getSVGDocument",
  23860. "getSamplerParameter",
  23861. "getScreenCTM",
  23862. "getSeconds",
  23863. "getSelectedCandidatePair",
  23864. "getSelection",
  23865. "getSenders",
  23866. "getService",
  23867. "getSettings",
  23868. "getShaderInfoLog",
  23869. "getShaderParameter",
  23870. "getShaderPrecisionFormat",
  23871. "getShaderSource",
  23872. "getSimpleDuration",
  23873. "getSiteIcons",
  23874. "getSources",
  23875. "getSpeculativeParserUrls",
  23876. "getStartPositionOfChar",
  23877. "getStartTime",
  23878. "getState",
  23879. "getStats",
  23880. "getStatusForPolicy",
  23881. "getStorageUpdates",
  23882. "getStreamById",
  23883. "getStringValue",
  23884. "getSubStringLength",
  23885. "getSubscription",
  23886. "getSupportedConstraints",
  23887. "getSupportedExtensions",
  23888. "getSupportedFormats",
  23889. "getSyncParameter",
  23890. "getSynchronizationSources",
  23891. "getTags",
  23892. "getTargetRanges",
  23893. "getTexParameter",
  23894. "getTime",
  23895. "getTimezoneOffset",
  23896. "getTiming",
  23897. "getTotalLength",
  23898. "getTrackById",
  23899. "getTracks",
  23900. "getTransceivers",
  23901. "getTransform",
  23902. "getTransformFeedbackVarying",
  23903. "getTransformToElement",
  23904. "getTransports",
  23905. "getType",
  23906. "getTypeMapping",
  23907. "getUTCDate",
  23908. "getUTCDay",
  23909. "getUTCFullYear",
  23910. "getUTCHours",
  23911. "getUTCMilliseconds",
  23912. "getUTCMinutes",
  23913. "getUTCMonth",
  23914. "getUTCSeconds",
  23915. "getUint16",
  23916. "getUint32",
  23917. "getUint8",
  23918. "getUniform",
  23919. "getUniformBlockIndex",
  23920. "getUniformIndices",
  23921. "getUniformLocation",
  23922. "getUserMedia",
  23923. "getVRDisplays",
  23924. "getValues",
  23925. "getVarDate",
  23926. "getVariableValue",
  23927. "getVertexAttrib",
  23928. "getVertexAttribOffset",
  23929. "getVideoPlaybackQuality",
  23930. "getVideoTracks",
  23931. "getViewerPose",
  23932. "getViewport",
  23933. "getVoices",
  23934. "getWakeLockState",
  23935. "getWriter",
  23936. "getYear",
  23937. "givenName",
  23938. "global",
  23939. "globalAlpha",
  23940. "globalCompositeOperation",
  23941. "globalThis",
  23942. "glyphOrientationHorizontal",
  23943. "glyphOrientationVertical",
  23944. "glyphRef",
  23945. "go",
  23946. "grabFrame",
  23947. "grad",
  23948. "gradientTransform",
  23949. "gradientUnits",
  23950. "grammars",
  23951. "green",
  23952. "grid",
  23953. "grid-area",
  23954. "grid-auto-columns",
  23955. "grid-auto-flow",
  23956. "grid-auto-rows",
  23957. "grid-column",
  23958. "grid-column-end",
  23959. "grid-column-gap",
  23960. "grid-column-start",
  23961. "grid-gap",
  23962. "grid-row",
  23963. "grid-row-end",
  23964. "grid-row-gap",
  23965. "grid-row-start",
  23966. "grid-template",
  23967. "grid-template-areas",
  23968. "grid-template-columns",
  23969. "grid-template-rows",
  23970. "gridArea",
  23971. "gridAutoColumns",
  23972. "gridAutoFlow",
  23973. "gridAutoRows",
  23974. "gridColumn",
  23975. "gridColumnEnd",
  23976. "gridColumnGap",
  23977. "gridColumnStart",
  23978. "gridGap",
  23979. "gridRow",
  23980. "gridRowEnd",
  23981. "gridRowGap",
  23982. "gridRowStart",
  23983. "gridTemplate",
  23984. "gridTemplateAreas",
  23985. "gridTemplateColumns",
  23986. "gridTemplateRows",
  23987. "gripSpace",
  23988. "group",
  23989. "groupCollapsed",
  23990. "groupEnd",
  23991. "groupId",
  23992. "hadRecentInput",
  23993. "hand",
  23994. "handedness",
  23995. "hapticActuators",
  23996. "hardwareConcurrency",
  23997. "has",
  23998. "hasAttribute",
  23999. "hasAttributeNS",
  24000. "hasAttributes",
  24001. "hasBeenActive",
  24002. "hasChildNodes",
  24003. "hasComposition",
  24004. "hasEnrolledInstrument",
  24005. "hasExtension",
  24006. "hasExternalDisplay",
  24007. "hasFeature",
  24008. "hasFocus",
  24009. "hasInstance",
  24010. "hasLayout",
  24011. "hasOrientation",
  24012. "hasOwnProperty",
  24013. "hasPointerCapture",
  24014. "hasPosition",
  24015. "hasReading",
  24016. "hasStorageAccess",
  24017. "hash",
  24018. "head",
  24019. "headers",
  24020. "heading",
  24021. "height",
  24022. "hidden",
  24023. "hide",
  24024. "hideFocus",
  24025. "high",
  24026. "highWaterMark",
  24027. "hint",
  24028. "history",
  24029. "honorificPrefix",
  24030. "honorificSuffix",
  24031. "horizontalOverflow",
  24032. "host",
  24033. "hostCandidate",
  24034. "hostname",
  24035. "href",
  24036. "hrefTranslate",
  24037. "hreflang",
  24038. "hspace",
  24039. "html5TagCheckInerface",
  24040. "htmlFor",
  24041. "htmlText",
  24042. "httpEquiv",
  24043. "httpRequestStatusCode",
  24044. "hwTimestamp",
  24045. "hyphens",
  24046. "hypot",
  24047. "iccId",
  24048. "iceConnectionState",
  24049. "iceGatheringState",
  24050. "iceTransport",
  24051. "icon",
  24052. "iconURL",
  24053. "id",
  24054. "identifier",
  24055. "identity",
  24056. "idpLoginUrl",
  24057. "ignoreBOM",
  24058. "ignoreCase",
  24059. "ignoreDepthValues",
  24060. "image-orientation",
  24061. "image-rendering",
  24062. "imageHeight",
  24063. "imageOrientation",
  24064. "imageRendering",
  24065. "imageSizes",
  24066. "imageSmoothingEnabled",
  24067. "imageSmoothingQuality",
  24068. "imageSrcset",
  24069. "imageWidth",
  24070. "images",
  24071. "ime-mode",
  24072. "imeMode",
  24073. "implementation",
  24074. "importKey",
  24075. "importNode",
  24076. "importStylesheet",
  24077. "imports",
  24078. "impp",
  24079. "imul",
  24080. "in",
  24081. "in1",
  24082. "in2",
  24083. "inBandMetadataTrackDispatchType",
  24084. "inRange",
  24085. "includes",
  24086. "incremental",
  24087. "indeterminate",
  24088. "index",
  24089. "indexNames",
  24090. "indexOf",
  24091. "indexedDB",
  24092. "indicate",
  24093. "inertiaDestinationX",
  24094. "inertiaDestinationY",
  24095. "info",
  24096. "init",
  24097. "initAnimationEvent",
  24098. "initBeforeLoadEvent",
  24099. "initClipboardEvent",
  24100. "initCloseEvent",
  24101. "initCommandEvent",
  24102. "initCompositionEvent",
  24103. "initCustomEvent",
  24104. "initData",
  24105. "initDataType",
  24106. "initDeviceMotionEvent",
  24107. "initDeviceOrientationEvent",
  24108. "initDragEvent",
  24109. "initErrorEvent",
  24110. "initEvent",
  24111. "initFocusEvent",
  24112. "initGestureEvent",
  24113. "initHashChangeEvent",
  24114. "initKeyEvent",
  24115. "initKeyboardEvent",
  24116. "initMSManipulationEvent",
  24117. "initMessageEvent",
  24118. "initMouseEvent",
  24119. "initMouseScrollEvent",
  24120. "initMouseWheelEvent",
  24121. "initMutationEvent",
  24122. "initNSMouseEvent",
  24123. "initOverflowEvent",
  24124. "initPageEvent",
  24125. "initPageTransitionEvent",
  24126. "initPointerEvent",
  24127. "initPopStateEvent",
  24128. "initProgressEvent",
  24129. "initScrollAreaEvent",
  24130. "initSimpleGestureEvent",
  24131. "initStorageEvent",
  24132. "initTextEvent",
  24133. "initTimeEvent",
  24134. "initTouchEvent",
  24135. "initTransitionEvent",
  24136. "initUIEvent",
  24137. "initWebKitAnimationEvent",
  24138. "initWebKitTransitionEvent",
  24139. "initWebKitWheelEvent",
  24140. "initWheelEvent",
  24141. "initialTime",
  24142. "initialize",
  24143. "initiatorType",
  24144. "inline-size",
  24145. "inlineSize",
  24146. "inlineVerticalFieldOfView",
  24147. "inner",
  24148. "innerHTML",
  24149. "innerHeight",
  24150. "innerText",
  24151. "innerWidth",
  24152. "input",
  24153. "inputBuffer",
  24154. "inputEncoding",
  24155. "inputMethod",
  24156. "inputMode",
  24157. "inputSource",
  24158. "inputSources",
  24159. "inputType",
  24160. "inputs",
  24161. "insertAdjacentElement",
  24162. "insertAdjacentHTML",
  24163. "insertAdjacentText",
  24164. "insertBefore",
  24165. "insertCell",
  24166. "insertDTMF",
  24167. "insertData",
  24168. "insertItemBefore",
  24169. "insertNode",
  24170. "insertRow",
  24171. "insertRule",
  24172. "inset",
  24173. "inset-block",
  24174. "inset-block-end",
  24175. "inset-block-start",
  24176. "inset-inline",
  24177. "inset-inline-end",
  24178. "inset-inline-start",
  24179. "insetBlock",
  24180. "insetBlockEnd",
  24181. "insetBlockStart",
  24182. "insetInline",
  24183. "insetInlineEnd",
  24184. "insetInlineStart",
  24185. "installing",
  24186. "instanceRoot",
  24187. "instantiate",
  24188. "instantiateStreaming",
  24189. "instruments",
  24190. "int16",
  24191. "int32",
  24192. "int8",
  24193. "integrity",
  24194. "interactionMode",
  24195. "intercept",
  24196. "interfaceClass",
  24197. "interfaceName",
  24198. "interfaceNumber",
  24199. "interfaceProtocol",
  24200. "interfaceSubclass",
  24201. "interfaces",
  24202. "interimResults",
  24203. "internalSubset",
  24204. "interpretation",
  24205. "intersectionRatio",
  24206. "intersectionRect",
  24207. "intersectsNode",
  24208. "interval",
  24209. "invalidIteratorState",
  24210. "invalidateFramebuffer",
  24211. "invalidateSubFramebuffer",
  24212. "inverse",
  24213. "invertSelf",
  24214. "is",
  24215. "is2D",
  24216. "isActive",
  24217. "isAlternate",
  24218. "isArray",
  24219. "isBingCurrentSearchDefault",
  24220. "isBuffer",
  24221. "isCandidateWindowVisible",
  24222. "isChar",
  24223. "isCollapsed",
  24224. "isComposing",
  24225. "isConcatSpreadable",
  24226. "isConnected",
  24227. "isContentEditable",
  24228. "isContentHandlerRegistered",
  24229. "isContextLost",
  24230. "isDefaultNamespace",
  24231. "isDirectory",
  24232. "isDisabled",
  24233. "isEnabled",
  24234. "isEqual",
  24235. "isEqualNode",
  24236. "isExtensible",
  24237. "isExternalCTAP2SecurityKeySupported",
  24238. "isFile",
  24239. "isFinite",
  24240. "isFramebuffer",
  24241. "isFrozen",
  24242. "isGenerator",
  24243. "isHTML",
  24244. "isHistoryNavigation",
  24245. "isId",
  24246. "isIdentity",
  24247. "isInjected",
  24248. "isInteger",
  24249. "isIntersecting",
  24250. "isLockFree",
  24251. "isMap",
  24252. "isMultiLine",
  24253. "isNaN",
  24254. "isOpen",
  24255. "isPointInFill",
  24256. "isPointInPath",
  24257. "isPointInRange",
  24258. "isPointInStroke",
  24259. "isPrefAlternate",
  24260. "isPresenting",
  24261. "isPrimary",
  24262. "isProgram",
  24263. "isPropertyImplicit",
  24264. "isProtocolHandlerRegistered",
  24265. "isPrototypeOf",
  24266. "isQuery",
  24267. "isRenderbuffer",
  24268. "isSafeInteger",
  24269. "isSameNode",
  24270. "isSampler",
  24271. "isScript",
  24272. "isScriptURL",
  24273. "isSealed",
  24274. "isSecureContext",
  24275. "isSessionSupported",
  24276. "isShader",
  24277. "isSupported",
  24278. "isSync",
  24279. "isTextEdit",
  24280. "isTexture",
  24281. "isTransformFeedback",
  24282. "isTrusted",
  24283. "isTypeSupported",
  24284. "isUserVerifyingPlatformAuthenticatorAvailable",
  24285. "isVertexArray",
  24286. "isView",
  24287. "isVisible",
  24288. "isochronousTransferIn",
  24289. "isochronousTransferOut",
  24290. "isolation",
  24291. "italics",
  24292. "item",
  24293. "itemId",
  24294. "itemProp",
  24295. "itemRef",
  24296. "itemScope",
  24297. "itemType",
  24298. "itemValue",
  24299. "items",
  24300. "iterateNext",
  24301. "iterationComposite",
  24302. "iterator",
  24303. "javaEnabled",
  24304. "jobTitle",
  24305. "join",
  24306. "json",
  24307. "justify-content",
  24308. "justify-items",
  24309. "justify-self",
  24310. "justifyContent",
  24311. "justifyItems",
  24312. "justifySelf",
  24313. "k1",
  24314. "k2",
  24315. "k3",
  24316. "k4",
  24317. "kHz",
  24318. "keepalive",
  24319. "kernelMatrix",
  24320. "kernelUnitLengthX",
  24321. "kernelUnitLengthY",
  24322. "kerning",
  24323. "key",
  24324. "keyCode",
  24325. "keyFor",
  24326. "keyIdentifier",
  24327. "keyLightEnabled",
  24328. "keyLocation",
  24329. "keyPath",
  24330. "keyStatuses",
  24331. "keySystem",
  24332. "keyText",
  24333. "keyUsage",
  24334. "keyboard",
  24335. "keys",
  24336. "keytype",
  24337. "kind",
  24338. "knee",
  24339. "label",
  24340. "labels",
  24341. "lang",
  24342. "language",
  24343. "languages",
  24344. "largeArcFlag",
  24345. "lastChild",
  24346. "lastElementChild",
  24347. "lastEventId",
  24348. "lastIndex",
  24349. "lastIndexOf",
  24350. "lastInputTime",
  24351. "lastMatch",
  24352. "lastMessageSubject",
  24353. "lastMessageType",
  24354. "lastModified",
  24355. "lastModifiedDate",
  24356. "lastPage",
  24357. "lastParen",
  24358. "lastState",
  24359. "lastStyleSheetSet",
  24360. "latitude",
  24361. "layerX",
  24362. "layerY",
  24363. "layoutFlow",
  24364. "layoutGrid",
  24365. "layoutGridChar",
  24366. "layoutGridLine",
  24367. "layoutGridMode",
  24368. "layoutGridType",
  24369. "lbound",
  24370. "left",
  24371. "leftContext",
  24372. "leftDegrees",
  24373. "leftMargin",
  24374. "leftProjectionMatrix",
  24375. "leftViewMatrix",
  24376. "length",
  24377. "lengthAdjust",
  24378. "lengthComputable",
  24379. "letter-spacing",
  24380. "letterSpacing",
  24381. "level",
  24382. "lighting-color",
  24383. "lightingColor",
  24384. "limitingConeAngle",
  24385. "line",
  24386. "line-break",
  24387. "line-height",
  24388. "lineAlign",
  24389. "lineBreak",
  24390. "lineCap",
  24391. "lineDashOffset",
  24392. "lineHeight",
  24393. "lineJoin",
  24394. "lineNumber",
  24395. "lineTo",
  24396. "lineWidth",
  24397. "linearAcceleration",
  24398. "linearRampToValueAtTime",
  24399. "linearVelocity",
  24400. "lineno",
  24401. "lines",
  24402. "link",
  24403. "linkColor",
  24404. "linkProgram",
  24405. "links",
  24406. "list",
  24407. "list-style",
  24408. "list-style-image",
  24409. "list-style-position",
  24410. "list-style-type",
  24411. "listStyle",
  24412. "listStyleImage",
  24413. "listStylePosition",
  24414. "listStyleType",
  24415. "listener",
  24416. "load",
  24417. "loadEventEnd",
  24418. "loadEventStart",
  24419. "loadTime",
  24420. "loadTimes",
  24421. "loaded",
  24422. "loading",
  24423. "localDescription",
  24424. "localName",
  24425. "localService",
  24426. "localStorage",
  24427. "locale",
  24428. "localeCompare",
  24429. "location",
  24430. "locationbar",
  24431. "lock",
  24432. "locked",
  24433. "lockedFile",
  24434. "locks",
  24435. "log",
  24436. "log10",
  24437. "log1p",
  24438. "log2",
  24439. "logicalXDPI",
  24440. "logicalYDPI",
  24441. "longDesc",
  24442. "longitude",
  24443. "lookupNamespaceURI",
  24444. "lookupPrefix",
  24445. "loop",
  24446. "loopEnd",
  24447. "loopStart",
  24448. "looping",
  24449. "low",
  24450. "lower",
  24451. "lowerBound",
  24452. "lowerOpen",
  24453. "lowsrc",
  24454. "m11",
  24455. "m12",
  24456. "m13",
  24457. "m14",
  24458. "m21",
  24459. "m22",
  24460. "m23",
  24461. "m24",
  24462. "m31",
  24463. "m32",
  24464. "m33",
  24465. "m34",
  24466. "m41",
  24467. "m42",
  24468. "m43",
  24469. "m44",
  24470. "makeXRCompatible",
  24471. "manifest",
  24472. "manufacturer",
  24473. "manufacturerName",
  24474. "map",
  24475. "mapping",
  24476. "margin",
  24477. "margin-block",
  24478. "margin-block-end",
  24479. "margin-block-start",
  24480. "margin-bottom",
  24481. "margin-inline",
  24482. "margin-inline-end",
  24483. "margin-inline-start",
  24484. "margin-left",
  24485. "margin-right",
  24486. "margin-top",
  24487. "marginBlock",
  24488. "marginBlockEnd",
  24489. "marginBlockStart",
  24490. "marginBottom",
  24491. "marginHeight",
  24492. "marginInline",
  24493. "marginInlineEnd",
  24494. "marginInlineStart",
  24495. "marginLeft",
  24496. "marginRight",
  24497. "marginTop",
  24498. "marginWidth",
  24499. "mark",
  24500. "marker",
  24501. "marker-end",
  24502. "marker-mid",
  24503. "marker-offset",
  24504. "marker-start",
  24505. "markerEnd",
  24506. "markerHeight",
  24507. "markerMid",
  24508. "markerOffset",
  24509. "markerStart",
  24510. "markerUnits",
  24511. "markerWidth",
  24512. "marks",
  24513. "mask",
  24514. "mask-clip",
  24515. "mask-composite",
  24516. "mask-image",
  24517. "mask-mode",
  24518. "mask-origin",
  24519. "mask-position",
  24520. "mask-position-x",
  24521. "mask-position-y",
  24522. "mask-repeat",
  24523. "mask-size",
  24524. "mask-type",
  24525. "maskClip",
  24526. "maskComposite",
  24527. "maskContentUnits",
  24528. "maskImage",
  24529. "maskMode",
  24530. "maskOrigin",
  24531. "maskPosition",
  24532. "maskPositionX",
  24533. "maskPositionY",
  24534. "maskRepeat",
  24535. "maskSize",
  24536. "maskType",
  24537. "maskUnits",
  24538. "match",
  24539. "matchAll",
  24540. "matchMedia",
  24541. "matchMedium",
  24542. "matches",
  24543. "matrix",
  24544. "matrixTransform",
  24545. "max",
  24546. "max-block-size",
  24547. "max-height",
  24548. "max-inline-size",
  24549. "max-width",
  24550. "maxActions",
  24551. "maxAlternatives",
  24552. "maxBlockSize",
  24553. "maxChannelCount",
  24554. "maxChannels",
  24555. "maxConnectionsPerServer",
  24556. "maxDecibels",
  24557. "maxDistance",
  24558. "maxHeight",
  24559. "maxInlineSize",
  24560. "maxLayers",
  24561. "maxLength",
  24562. "maxMessageSize",
  24563. "maxPacketLifeTime",
  24564. "maxRetransmits",
  24565. "maxTouchPoints",
  24566. "maxValue",
  24567. "maxWidth",
  24568. "measure",
  24569. "measureText",
  24570. "media",
  24571. "mediaCapabilities",
  24572. "mediaDevices",
  24573. "mediaElement",
  24574. "mediaGroup",
  24575. "mediaKeys",
  24576. "mediaSession",
  24577. "mediaStream",
  24578. "mediaText",
  24579. "meetOrSlice",
  24580. "memory",
  24581. "menubar",
  24582. "mergeAttributes",
  24583. "message",
  24584. "messageClass",
  24585. "messageHandlers",
  24586. "messageType",
  24587. "metaKey",
  24588. "metadata",
  24589. "method",
  24590. "methodDetails",
  24591. "methodName",
  24592. "mid",
  24593. "mimeType",
  24594. "mimeTypes",
  24595. "min",
  24596. "min-block-size",
  24597. "min-height",
  24598. "min-inline-size",
  24599. "min-width",
  24600. "minBlockSize",
  24601. "minDecibels",
  24602. "minHeight",
  24603. "minInlineSize",
  24604. "minLength",
  24605. "minValue",
  24606. "minWidth",
  24607. "miterLimit",
  24608. "mix-blend-mode",
  24609. "mixBlendMode",
  24610. "mm",
  24611. "mobile",
  24612. "mode",
  24613. "model",
  24614. "modify",
  24615. "mount",
  24616. "move",
  24617. "moveBy",
  24618. "moveEnd",
  24619. "moveFirst",
  24620. "moveFocusDown",
  24621. "moveFocusLeft",
  24622. "moveFocusRight",
  24623. "moveFocusUp",
  24624. "moveNext",
  24625. "moveRow",
  24626. "moveStart",
  24627. "moveTo",
  24628. "moveToBookmark",
  24629. "moveToElementText",
  24630. "moveToPoint",
  24631. "movementX",
  24632. "movementY",
  24633. "mozAdd",
  24634. "mozAnimationStartTime",
  24635. "mozAnon",
  24636. "mozApps",
  24637. "mozAudioCaptured",
  24638. "mozAudioChannelType",
  24639. "mozAutoplayEnabled",
  24640. "mozCancelAnimationFrame",
  24641. "mozCancelFullScreen",
  24642. "mozCancelRequestAnimationFrame",
  24643. "mozCaptureStream",
  24644. "mozCaptureStreamUntilEnded",
  24645. "mozClearDataAt",
  24646. "mozContact",
  24647. "mozContacts",
  24648. "mozCreateFileHandle",
  24649. "mozCurrentTransform",
  24650. "mozCurrentTransformInverse",
  24651. "mozCursor",
  24652. "mozDash",
  24653. "mozDashOffset",
  24654. "mozDecodedFrames",
  24655. "mozExitPointerLock",
  24656. "mozFillRule",
  24657. "mozFragmentEnd",
  24658. "mozFrameDelay",
  24659. "mozFullScreen",
  24660. "mozFullScreenElement",
  24661. "mozFullScreenEnabled",
  24662. "mozGetAll",
  24663. "mozGetAllKeys",
  24664. "mozGetAsFile",
  24665. "mozGetDataAt",
  24666. "mozGetMetadata",
  24667. "mozGetUserMedia",
  24668. "mozHasAudio",
  24669. "mozHasItem",
  24670. "mozHidden",
  24671. "mozImageSmoothingEnabled",
  24672. "mozIndexedDB",
  24673. "mozInnerScreenX",
  24674. "mozInnerScreenY",
  24675. "mozInputSource",
  24676. "mozIsTextField",
  24677. "mozItem",
  24678. "mozItemCount",
  24679. "mozItems",
  24680. "mozLength",
  24681. "mozLockOrientation",
  24682. "mozMatchesSelector",
  24683. "mozMovementX",
  24684. "mozMovementY",
  24685. "mozOpaque",
  24686. "mozOrientation",
  24687. "mozPaintCount",
  24688. "mozPaintedFrames",
  24689. "mozParsedFrames",
  24690. "mozPay",
  24691. "mozPointerLockElement",
  24692. "mozPresentedFrames",
  24693. "mozPreservesPitch",
  24694. "mozPressure",
  24695. "mozPrintCallback",
  24696. "mozRTCIceCandidate",
  24697. "mozRTCPeerConnection",
  24698. "mozRTCSessionDescription",
  24699. "mozRemove",
  24700. "mozRequestAnimationFrame",
  24701. "mozRequestFullScreen",
  24702. "mozRequestPointerLock",
  24703. "mozSetDataAt",
  24704. "mozSetImageElement",
  24705. "mozSourceNode",
  24706. "mozSrcObject",
  24707. "mozSystem",
  24708. "mozTCPSocket",
  24709. "mozTextStyle",
  24710. "mozTypesAt",
  24711. "mozUnlockOrientation",
  24712. "mozUserCancelled",
  24713. "mozVisibilityState",
  24714. "ms",
  24715. "msAnimation",
  24716. "msAnimationDelay",
  24717. "msAnimationDirection",
  24718. "msAnimationDuration",
  24719. "msAnimationFillMode",
  24720. "msAnimationIterationCount",
  24721. "msAnimationName",
  24722. "msAnimationPlayState",
  24723. "msAnimationStartTime",
  24724. "msAnimationTimingFunction",
  24725. "msBackfaceVisibility",
  24726. "msBlockProgression",
  24727. "msCSSOMElementFloatMetrics",
  24728. "msCaching",
  24729. "msCachingEnabled",
  24730. "msCancelRequestAnimationFrame",
  24731. "msCapsLockWarningOff",
  24732. "msClearImmediate",
  24733. "msClose",
  24734. "msContentZoomChaining",
  24735. "msContentZoomFactor",
  24736. "msContentZoomLimit",
  24737. "msContentZoomLimitMax",
  24738. "msContentZoomLimitMin",
  24739. "msContentZoomSnap",
  24740. "msContentZoomSnapPoints",
  24741. "msContentZoomSnapType",
  24742. "msContentZooming",
  24743. "msConvertURL",
  24744. "msCrypto",
  24745. "msDoNotTrack",
  24746. "msElementsFromPoint",
  24747. "msElementsFromRect",
  24748. "msExitFullscreen",
  24749. "msExtendedCode",
  24750. "msFillRule",
  24751. "msFirstPaint",
  24752. "msFlex",
  24753. "msFlexAlign",
  24754. "msFlexDirection",
  24755. "msFlexFlow",
  24756. "msFlexItemAlign",
  24757. "msFlexLinePack",
  24758. "msFlexNegative",
  24759. "msFlexOrder",
  24760. "msFlexPack",
  24761. "msFlexPositive",
  24762. "msFlexPreferredSize",
  24763. "msFlexWrap",
  24764. "msFlowFrom",
  24765. "msFlowInto",
  24766. "msFontFeatureSettings",
  24767. "msFullscreenElement",
  24768. "msFullscreenEnabled",
  24769. "msGetInputContext",
  24770. "msGetRegionContent",
  24771. "msGetUntransformedBounds",
  24772. "msGraphicsTrustStatus",
  24773. "msGridColumn",
  24774. "msGridColumnAlign",
  24775. "msGridColumnSpan",
  24776. "msGridColumns",
  24777. "msGridRow",
  24778. "msGridRowAlign",
  24779. "msGridRowSpan",
  24780. "msGridRows",
  24781. "msHidden",
  24782. "msHighContrastAdjust",
  24783. "msHyphenateLimitChars",
  24784. "msHyphenateLimitLines",
  24785. "msHyphenateLimitZone",
  24786. "msHyphens",
  24787. "msImageSmoothingEnabled",
  24788. "msImeAlign",
  24789. "msIndexedDB",
  24790. "msInterpolationMode",
  24791. "msIsStaticHTML",
  24792. "msKeySystem",
  24793. "msKeys",
  24794. "msLaunchUri",
  24795. "msLockOrientation",
  24796. "msManipulationViewsEnabled",
  24797. "msMatchMedia",
  24798. "msMatchesSelector",
  24799. "msMaxTouchPoints",
  24800. "msOrientation",
  24801. "msOverflowStyle",
  24802. "msPerspective",
  24803. "msPerspectiveOrigin",
  24804. "msPlayToDisabled",
  24805. "msPlayToPreferredSourceUri",
  24806. "msPlayToPrimary",
  24807. "msPointerEnabled",
  24808. "msRegionOverflow",
  24809. "msReleasePointerCapture",
  24810. "msRequestAnimationFrame",
  24811. "msRequestFullscreen",
  24812. "msSaveBlob",
  24813. "msSaveOrOpenBlob",
  24814. "msScrollChaining",
  24815. "msScrollLimit",
  24816. "msScrollLimitXMax",
  24817. "msScrollLimitXMin",
  24818. "msScrollLimitYMax",
  24819. "msScrollLimitYMin",
  24820. "msScrollRails",
  24821. "msScrollSnapPointsX",
  24822. "msScrollSnapPointsY",
  24823. "msScrollSnapType",
  24824. "msScrollSnapX",
  24825. "msScrollSnapY",
  24826. "msScrollTranslation",
  24827. "msSetImmediate",
  24828. "msSetMediaKeys",
  24829. "msSetPointerCapture",
  24830. "msTextCombineHorizontal",
  24831. "msTextSizeAdjust",
  24832. "msToBlob",
  24833. "msTouchAction",
  24834. "msTouchSelect",
  24835. "msTraceAsyncCallbackCompleted",
  24836. "msTraceAsyncCallbackStarting",
  24837. "msTraceAsyncOperationCompleted",
  24838. "msTraceAsyncOperationStarting",
  24839. "msTransform",
  24840. "msTransformOrigin",
  24841. "msTransformStyle",
  24842. "msTransition",
  24843. "msTransitionDelay",
  24844. "msTransitionDuration",
  24845. "msTransitionProperty",
  24846. "msTransitionTimingFunction",
  24847. "msUnlockOrientation",
  24848. "msUpdateAsyncCallbackRelation",
  24849. "msUserSelect",
  24850. "msVisibilityState",
  24851. "msWrapFlow",
  24852. "msWrapMargin",
  24853. "msWrapThrough",
  24854. "msWriteProfilerMark",
  24855. "msZoom",
  24856. "msZoomTo",
  24857. "mt",
  24858. "mul",
  24859. "multiEntry",
  24860. "multiSelectionObj",
  24861. "multiline",
  24862. "multiple",
  24863. "multiply",
  24864. "multiplySelf",
  24865. "mutableFile",
  24866. "muted",
  24867. "n",
  24868. "name",
  24869. "nameProp",
  24870. "namedItem",
  24871. "namedRecordset",
  24872. "names",
  24873. "namespaceURI",
  24874. "namespaces",
  24875. "naturalHeight",
  24876. "naturalWidth",
  24877. "navigate",
  24878. "navigation",
  24879. "navigationMode",
  24880. "navigationPreload",
  24881. "navigationStart",
  24882. "navigator",
  24883. "near",
  24884. "nearestViewportElement",
  24885. "negative",
  24886. "negotiated",
  24887. "netscape",
  24888. "networkState",
  24889. "newScale",
  24890. "newTranslate",
  24891. "newURL",
  24892. "newValue",
  24893. "newValueSpecifiedUnits",
  24894. "newVersion",
  24895. "newhome",
  24896. "next",
  24897. "nextElementSibling",
  24898. "nextHopProtocol",
  24899. "nextNode",
  24900. "nextPage",
  24901. "nextSibling",
  24902. "nickname",
  24903. "noHref",
  24904. "noModule",
  24905. "noResize",
  24906. "noShade",
  24907. "noValidate",
  24908. "noWrap",
  24909. "node",
  24910. "nodeName",
  24911. "nodeType",
  24912. "nodeValue",
  24913. "nonce",
  24914. "normalize",
  24915. "normalizedPathSegList",
  24916. "notationName",
  24917. "notations",
  24918. "note",
  24919. "noteGrainOn",
  24920. "noteOff",
  24921. "noteOn",
  24922. "notify",
  24923. "now",
  24924. "numOctaves",
  24925. "number",
  24926. "numberOfChannels",
  24927. "numberOfInputs",
  24928. "numberOfItems",
  24929. "numberOfOutputs",
  24930. "numberValue",
  24931. "oMatchesSelector",
  24932. "object",
  24933. "object-fit",
  24934. "object-position",
  24935. "objectFit",
  24936. "objectPosition",
  24937. "objectStore",
  24938. "objectStoreNames",
  24939. "objectType",
  24940. "observe",
  24941. "of",
  24942. "offscreenBuffering",
  24943. "offset",
  24944. "offset-anchor",
  24945. "offset-distance",
  24946. "offset-path",
  24947. "offset-rotate",
  24948. "offsetAnchor",
  24949. "offsetDistance",
  24950. "offsetHeight",
  24951. "offsetLeft",
  24952. "offsetNode",
  24953. "offsetParent",
  24954. "offsetPath",
  24955. "offsetRotate",
  24956. "offsetTop",
  24957. "offsetWidth",
  24958. "offsetX",
  24959. "offsetY",
  24960. "ok",
  24961. "oldURL",
  24962. "oldValue",
  24963. "oldVersion",
  24964. "olderShadowRoot",
  24965. "onLine",
  24966. "onabort",
  24967. "onabsolutedeviceorientation",
  24968. "onactivate",
  24969. "onactive",
  24970. "onaddsourcebuffer",
  24971. "onaddstream",
  24972. "onaddtrack",
  24973. "onafterprint",
  24974. "onafterscriptexecute",
  24975. "onafterupdate",
  24976. "onanimationcancel",
  24977. "onanimationend",
  24978. "onanimationiteration",
  24979. "onanimationstart",
  24980. "onappinstalled",
  24981. "onaudioend",
  24982. "onaudioprocess",
  24983. "onaudiostart",
  24984. "onautocomplete",
  24985. "onautocompleteerror",
  24986. "onauxclick",
  24987. "onbeforeactivate",
  24988. "onbeforecopy",
  24989. "onbeforecut",
  24990. "onbeforedeactivate",
  24991. "onbeforeeditfocus",
  24992. "onbeforeinstallprompt",
  24993. "onbeforepaste",
  24994. "onbeforeprint",
  24995. "onbeforescriptexecute",
  24996. "onbeforeunload",
  24997. "onbeforeupdate",
  24998. "onbeforexrselect",
  24999. "onbegin",
  25000. "onblocked",
  25001. "onblur",
  25002. "onbounce",
  25003. "onboundary",
  25004. "onbufferedamountlow",
  25005. "oncached",
  25006. "oncancel",
  25007. "oncandidatewindowhide",
  25008. "oncandidatewindowshow",
  25009. "oncandidatewindowupdate",
  25010. "oncanplay",
  25011. "oncanplaythrough",
  25012. "once",
  25013. "oncellchange",
  25014. "onchange",
  25015. "oncharacteristicvaluechanged",
  25016. "onchargingchange",
  25017. "onchargingtimechange",
  25018. "onchecking",
  25019. "onclick",
  25020. "onclose",
  25021. "onclosing",
  25022. "oncompassneedscalibration",
  25023. "oncomplete",
  25024. "onconnect",
  25025. "onconnecting",
  25026. "onconnectionavailable",
  25027. "onconnectionstatechange",
  25028. "oncontextmenu",
  25029. "oncontrollerchange",
  25030. "oncontrolselect",
  25031. "oncopy",
  25032. "oncuechange",
  25033. "oncut",
  25034. "ondataavailable",
  25035. "ondatachannel",
  25036. "ondatasetchanged",
  25037. "ondatasetcomplete",
  25038. "ondblclick",
  25039. "ondeactivate",
  25040. "ondevicechange",
  25041. "ondevicelight",
  25042. "ondevicemotion",
  25043. "ondeviceorientation",
  25044. "ondeviceorientationabsolute",
  25045. "ondeviceproximity",
  25046. "ondischargingtimechange",
  25047. "ondisconnect",
  25048. "ondisplay",
  25049. "ondownloading",
  25050. "ondrag",
  25051. "ondragend",
  25052. "ondragenter",
  25053. "ondragexit",
  25054. "ondragleave",
  25055. "ondragover",
  25056. "ondragstart",
  25057. "ondrop",
  25058. "ondurationchange",
  25059. "onemptied",
  25060. "onencrypted",
  25061. "onend",
  25062. "onended",
  25063. "onenter",
  25064. "onenterpictureinpicture",
  25065. "onerror",
  25066. "onerrorupdate",
  25067. "onexit",
  25068. "onfilterchange",
  25069. "onfinish",
  25070. "onfocus",
  25071. "onfocusin",
  25072. "onfocusout",
  25073. "onformdata",
  25074. "onfreeze",
  25075. "onfullscreenchange",
  25076. "onfullscreenerror",
  25077. "ongatheringstatechange",
  25078. "ongattserverdisconnected",
  25079. "ongesturechange",
  25080. "ongestureend",
  25081. "ongesturestart",
  25082. "ongotpointercapture",
  25083. "onhashchange",
  25084. "onhelp",
  25085. "onicecandidate",
  25086. "onicecandidateerror",
  25087. "oniceconnectionstatechange",
  25088. "onicegatheringstatechange",
  25089. "oninactive",
  25090. "oninput",
  25091. "oninputsourceschange",
  25092. "oninvalid",
  25093. "onkeydown",
  25094. "onkeypress",
  25095. "onkeystatuseschange",
  25096. "onkeyup",
  25097. "onlanguagechange",
  25098. "onlayoutcomplete",
  25099. "onleavepictureinpicture",
  25100. "onlevelchange",
  25101. "onload",
  25102. "onloadeddata",
  25103. "onloadedmetadata",
  25104. "onloadend",
  25105. "onloading",
  25106. "onloadingdone",
  25107. "onloadingerror",
  25108. "onloadstart",
  25109. "onlosecapture",
  25110. "onlostpointercapture",
  25111. "only",
  25112. "onmark",
  25113. "onmessage",
  25114. "onmessageerror",
  25115. "onmidimessage",
  25116. "onmousedown",
  25117. "onmouseenter",
  25118. "onmouseleave",
  25119. "onmousemove",
  25120. "onmouseout",
  25121. "onmouseover",
  25122. "onmouseup",
  25123. "onmousewheel",
  25124. "onmove",
  25125. "onmoveend",
  25126. "onmovestart",
  25127. "onmozfullscreenchange",
  25128. "onmozfullscreenerror",
  25129. "onmozorientationchange",
  25130. "onmozpointerlockchange",
  25131. "onmozpointerlockerror",
  25132. "onmscontentzoom",
  25133. "onmsfullscreenchange",
  25134. "onmsfullscreenerror",
  25135. "onmsgesturechange",
  25136. "onmsgesturedoubletap",
  25137. "onmsgestureend",
  25138. "onmsgesturehold",
  25139. "onmsgesturestart",
  25140. "onmsgesturetap",
  25141. "onmsgotpointercapture",
  25142. "onmsinertiastart",
  25143. "onmslostpointercapture",
  25144. "onmsmanipulationstatechanged",
  25145. "onmsneedkey",
  25146. "onmsorientationchange",
  25147. "onmspointercancel",
  25148. "onmspointerdown",
  25149. "onmspointerenter",
  25150. "onmspointerhover",
  25151. "onmspointerleave",
  25152. "onmspointermove",
  25153. "onmspointerout",
  25154. "onmspointerover",
  25155. "onmspointerup",
  25156. "onmssitemodejumplistitemremoved",
  25157. "onmsthumbnailclick",
  25158. "onmute",
  25159. "onnegotiationneeded",
  25160. "onnomatch",
  25161. "onnoupdate",
  25162. "onobsolete",
  25163. "onoffline",
  25164. "ononline",
  25165. "onopen",
  25166. "onorientationchange",
  25167. "onpagechange",
  25168. "onpagehide",
  25169. "onpageshow",
  25170. "onpaste",
  25171. "onpause",
  25172. "onpayerdetailchange",
  25173. "onpaymentmethodchange",
  25174. "onplay",
  25175. "onplaying",
  25176. "onpluginstreamstart",
  25177. "onpointercancel",
  25178. "onpointerdown",
  25179. "onpointerenter",
  25180. "onpointerleave",
  25181. "onpointerlockchange",
  25182. "onpointerlockerror",
  25183. "onpointermove",
  25184. "onpointerout",
  25185. "onpointerover",
  25186. "onpointerrawupdate",
  25187. "onpointerup",
  25188. "onpopstate",
  25189. "onprocessorerror",
  25190. "onprogress",
  25191. "onpropertychange",
  25192. "onratechange",
  25193. "onreading",
  25194. "onreadystatechange",
  25195. "onrejectionhandled",
  25196. "onrelease",
  25197. "onremove",
  25198. "onremovesourcebuffer",
  25199. "onremovestream",
  25200. "onremovetrack",
  25201. "onrepeat",
  25202. "onreset",
  25203. "onresize",
  25204. "onresizeend",
  25205. "onresizestart",
  25206. "onresourcetimingbufferfull",
  25207. "onresult",
  25208. "onresume",
  25209. "onrowenter",
  25210. "onrowexit",
  25211. "onrowsdelete",
  25212. "onrowsinserted",
  25213. "onscroll",
  25214. "onsearch",
  25215. "onsecuritypolicyviolation",
  25216. "onseeked",
  25217. "onseeking",
  25218. "onselect",
  25219. "onselectedcandidatepairchange",
  25220. "onselectend",
  25221. "onselectionchange",
  25222. "onselectstart",
  25223. "onshippingaddresschange",
  25224. "onshippingoptionchange",
  25225. "onshow",
  25226. "onsignalingstatechange",
  25227. "onsoundend",
  25228. "onsoundstart",
  25229. "onsourceclose",
  25230. "onsourceclosed",
  25231. "onsourceended",
  25232. "onsourceopen",
  25233. "onspeechend",
  25234. "onspeechstart",
  25235. "onsqueeze",
  25236. "onsqueezeend",
  25237. "onsqueezestart",
  25238. "onstalled",
  25239. "onstart",
  25240. "onstatechange",
  25241. "onstop",
  25242. "onstorage",
  25243. "onstoragecommit",
  25244. "onsubmit",
  25245. "onsuccess",
  25246. "onsuspend",
  25247. "onterminate",
  25248. "ontextinput",
  25249. "ontimeout",
  25250. "ontimeupdate",
  25251. "ontoggle",
  25252. "ontonechange",
  25253. "ontouchcancel",
  25254. "ontouchend",
  25255. "ontouchmove",
  25256. "ontouchstart",
  25257. "ontrack",
  25258. "ontransitioncancel",
  25259. "ontransitionend",
  25260. "ontransitionrun",
  25261. "ontransitionstart",
  25262. "onunhandledrejection",
  25263. "onunload",
  25264. "onunmute",
  25265. "onupdate",
  25266. "onupdateend",
  25267. "onupdatefound",
  25268. "onupdateready",
  25269. "onupdatestart",
  25270. "onupgradeneeded",
  25271. "onuserproximity",
  25272. "onversionchange",
  25273. "onvisibilitychange",
  25274. "onvoiceschanged",
  25275. "onvolumechange",
  25276. "onvrdisplayactivate",
  25277. "onvrdisplayconnect",
  25278. "onvrdisplaydeactivate",
  25279. "onvrdisplaydisconnect",
  25280. "onvrdisplaypresentchange",
  25281. "onwaiting",
  25282. "onwaitingforkey",
  25283. "onwarning",
  25284. "onwebkitanimationend",
  25285. "onwebkitanimationiteration",
  25286. "onwebkitanimationstart",
  25287. "onwebkitcurrentplaybacktargetiswirelesschanged",
  25288. "onwebkitfullscreenchange",
  25289. "onwebkitfullscreenerror",
  25290. "onwebkitkeyadded",
  25291. "onwebkitkeyerror",
  25292. "onwebkitkeymessage",
  25293. "onwebkitneedkey",
  25294. "onwebkitorientationchange",
  25295. "onwebkitplaybacktargetavailabilitychanged",
  25296. "onwebkitpointerlockchange",
  25297. "onwebkitpointerlockerror",
  25298. "onwebkitresourcetimingbufferfull",
  25299. "onwebkittransitionend",
  25300. "onwheel",
  25301. "onzoom",
  25302. "opacity",
  25303. "open",
  25304. "openCursor",
  25305. "openDatabase",
  25306. "openKeyCursor",
  25307. "opened",
  25308. "opener",
  25309. "opera",
  25310. "operationType",
  25311. "operator",
  25312. "opr",
  25313. "optimum",
  25314. "options",
  25315. "or",
  25316. "order",
  25317. "orderX",
  25318. "orderY",
  25319. "ordered",
  25320. "org",
  25321. "organization",
  25322. "orient",
  25323. "orientAngle",
  25324. "orientType",
  25325. "orientation",
  25326. "orientationX",
  25327. "orientationY",
  25328. "orientationZ",
  25329. "origin",
  25330. "originalPolicy",
  25331. "originalTarget",
  25332. "orphans",
  25333. "oscpu",
  25334. "outerHTML",
  25335. "outerHeight",
  25336. "outerText",
  25337. "outerWidth",
  25338. "outline",
  25339. "outline-color",
  25340. "outline-offset",
  25341. "outline-style",
  25342. "outline-width",
  25343. "outlineColor",
  25344. "outlineOffset",
  25345. "outlineStyle",
  25346. "outlineWidth",
  25347. "outputBuffer",
  25348. "outputChannelCount",
  25349. "outputLatency",
  25350. "outputs",
  25351. "overflow",
  25352. "overflow-anchor",
  25353. "overflow-block",
  25354. "overflow-inline",
  25355. "overflow-wrap",
  25356. "overflow-x",
  25357. "overflow-y",
  25358. "overflowAnchor",
  25359. "overflowBlock",
  25360. "overflowInline",
  25361. "overflowWrap",
  25362. "overflowX",
  25363. "overflowY",
  25364. "overrideMimeType",
  25365. "oversample",
  25366. "overscroll-behavior",
  25367. "overscroll-behavior-block",
  25368. "overscroll-behavior-inline",
  25369. "overscroll-behavior-x",
  25370. "overscroll-behavior-y",
  25371. "overscrollBehavior",
  25372. "overscrollBehaviorBlock",
  25373. "overscrollBehaviorInline",
  25374. "overscrollBehaviorX",
  25375. "overscrollBehaviorY",
  25376. "ownKeys",
  25377. "ownerDocument",
  25378. "ownerElement",
  25379. "ownerNode",
  25380. "ownerRule",
  25381. "ownerSVGElement",
  25382. "owningElement",
  25383. "p1",
  25384. "p2",
  25385. "p3",
  25386. "p4",
  25387. "packetSize",
  25388. "packets",
  25389. "pad",
  25390. "padEnd",
  25391. "padStart",
  25392. "padding",
  25393. "padding-block",
  25394. "padding-block-end",
  25395. "padding-block-start",
  25396. "padding-bottom",
  25397. "padding-inline",
  25398. "padding-inline-end",
  25399. "padding-inline-start",
  25400. "padding-left",
  25401. "padding-right",
  25402. "padding-top",
  25403. "paddingBlock",
  25404. "paddingBlockEnd",
  25405. "paddingBlockStart",
  25406. "paddingBottom",
  25407. "paddingInline",
  25408. "paddingInlineEnd",
  25409. "paddingInlineStart",
  25410. "paddingLeft",
  25411. "paddingRight",
  25412. "paddingTop",
  25413. "page",
  25414. "page-break-after",
  25415. "page-break-before",
  25416. "page-break-inside",
  25417. "pageBreakAfter",
  25418. "pageBreakBefore",
  25419. "pageBreakInside",
  25420. "pageCount",
  25421. "pageLeft",
  25422. "pageTop",
  25423. "pageX",
  25424. "pageXOffset",
  25425. "pageY",
  25426. "pageYOffset",
  25427. "pages",
  25428. "paint-order",
  25429. "paintOrder",
  25430. "paintRequests",
  25431. "paintType",
  25432. "paintWorklet",
  25433. "palette",
  25434. "pan",
  25435. "panningModel",
  25436. "parameterData",
  25437. "parameters",
  25438. "parent",
  25439. "parentElement",
  25440. "parentNode",
  25441. "parentRule",
  25442. "parentStyleSheet",
  25443. "parentTextEdit",
  25444. "parentWindow",
  25445. "parse",
  25446. "parseAll",
  25447. "parseFloat",
  25448. "parseFromString",
  25449. "parseInt",
  25450. "part",
  25451. "participants",
  25452. "passive",
  25453. "password",
  25454. "pasteHTML",
  25455. "path",
  25456. "pathLength",
  25457. "pathSegList",
  25458. "pathSegType",
  25459. "pathSegTypeAsLetter",
  25460. "pathname",
  25461. "pattern",
  25462. "patternContentUnits",
  25463. "patternMismatch",
  25464. "patternTransform",
  25465. "patternUnits",
  25466. "pause",
  25467. "pauseAnimations",
  25468. "pauseOnExit",
  25469. "pauseProfilers",
  25470. "pauseTransformFeedback",
  25471. "paused",
  25472. "payerEmail",
  25473. "payerName",
  25474. "payerPhone",
  25475. "paymentManager",
  25476. "pc",
  25477. "peerIdentity",
  25478. "pending",
  25479. "pendingLocalDescription",
  25480. "pendingRemoteDescription",
  25481. "percent",
  25482. "performance",
  25483. "periodicSync",
  25484. "permission",
  25485. "permissionState",
  25486. "permissions",
  25487. "persist",
  25488. "persisted",
  25489. "personalbar",
  25490. "perspective",
  25491. "perspective-origin",
  25492. "perspectiveOrigin",
  25493. "phone",
  25494. "phoneticFamilyName",
  25495. "phoneticGivenName",
  25496. "photo",
  25497. "pictureInPictureElement",
  25498. "pictureInPictureEnabled",
  25499. "pictureInPictureWindow",
  25500. "ping",
  25501. "pipeThrough",
  25502. "pipeTo",
  25503. "pitch",
  25504. "pixelBottom",
  25505. "pixelDepth",
  25506. "pixelHeight",
  25507. "pixelLeft",
  25508. "pixelRight",
  25509. "pixelStorei",
  25510. "pixelTop",
  25511. "pixelUnitToMillimeterX",
  25512. "pixelUnitToMillimeterY",
  25513. "pixelWidth",
  25514. "place-content",
  25515. "place-items",
  25516. "place-self",
  25517. "placeContent",
  25518. "placeItems",
  25519. "placeSelf",
  25520. "placeholder",
  25521. "platformVersion",
  25522. "platform",
  25523. "platforms",
  25524. "play",
  25525. "playEffect",
  25526. "playState",
  25527. "playbackRate",
  25528. "playbackState",
  25529. "playbackTime",
  25530. "played",
  25531. "playoutDelayHint",
  25532. "playsInline",
  25533. "plugins",
  25534. "pluginspage",
  25535. "pname",
  25536. "pointer-events",
  25537. "pointerBeforeReferenceNode",
  25538. "pointerEnabled",
  25539. "pointerEvents",
  25540. "pointerId",
  25541. "pointerLockElement",
  25542. "pointerType",
  25543. "points",
  25544. "pointsAtX",
  25545. "pointsAtY",
  25546. "pointsAtZ",
  25547. "polygonOffset",
  25548. "pop",
  25549. "populateMatrix",
  25550. "popupWindowFeatures",
  25551. "popupWindowName",
  25552. "popupWindowURI",
  25553. "port",
  25554. "port1",
  25555. "port2",
  25556. "ports",
  25557. "posBottom",
  25558. "posHeight",
  25559. "posLeft",
  25560. "posRight",
  25561. "posTop",
  25562. "posWidth",
  25563. "pose",
  25564. "position",
  25565. "positionAlign",
  25566. "positionX",
  25567. "positionY",
  25568. "positionZ",
  25569. "postError",
  25570. "postMessage",
  25571. "postalCode",
  25572. "poster",
  25573. "pow",
  25574. "powerEfficient",
  25575. "powerOff",
  25576. "preMultiplySelf",
  25577. "precision",
  25578. "preferredStyleSheetSet",
  25579. "preferredStylesheetSet",
  25580. "prefix",
  25581. "preload",
  25582. "prepend",
  25583. "presentation",
  25584. "preserveAlpha",
  25585. "preserveAspectRatio",
  25586. "preserveAspectRatioString",
  25587. "pressed",
  25588. "pressure",
  25589. "prevValue",
  25590. "preventDefault",
  25591. "preventExtensions",
  25592. "preventSilentAccess",
  25593. "previousElementSibling",
  25594. "previousNode",
  25595. "previousPage",
  25596. "previousRect",
  25597. "previousScale",
  25598. "previousSibling",
  25599. "previousTranslate",
  25600. "primaryKey",
  25601. "primitiveType",
  25602. "primitiveUnits",
  25603. "principals",
  25604. "print",
  25605. "priority",
  25606. "privateKey",
  25607. "probablySupportsContext",
  25608. "process",
  25609. "processIceMessage",
  25610. "processingEnd",
  25611. "processingStart",
  25612. "processorOptions",
  25613. "product",
  25614. "productId",
  25615. "productName",
  25616. "productSub",
  25617. "profile",
  25618. "profileEnd",
  25619. "profiles",
  25620. "projectionMatrix",
  25621. "promise",
  25622. "prompt",
  25623. "properties",
  25624. "propertyIsEnumerable",
  25625. "propertyName",
  25626. "protocol",
  25627. "protocolLong",
  25628. "prototype",
  25629. "provider",
  25630. "pseudoClass",
  25631. "pseudoElement",
  25632. "pt",
  25633. "publicId",
  25634. "publicKey",
  25635. "published",
  25636. "pulse",
  25637. "push",
  25638. "pushManager",
  25639. "pushNotification",
  25640. "pushState",
  25641. "put",
  25642. "putImageData",
  25643. "px",
  25644. "quadraticCurveTo",
  25645. "qualifier",
  25646. "quaternion",
  25647. "query",
  25648. "queryCommandEnabled",
  25649. "queryCommandIndeterm",
  25650. "queryCommandState",
  25651. "queryCommandSupported",
  25652. "queryCommandText",
  25653. "queryCommandValue",
  25654. "querySelector",
  25655. "querySelectorAll",
  25656. "queueMicrotask",
  25657. "quote",
  25658. "quotes",
  25659. "r",
  25660. "r1",
  25661. "r2",
  25662. "race",
  25663. "rad",
  25664. "radiogroup",
  25665. "radiusX",
  25666. "radiusY",
  25667. "random",
  25668. "range",
  25669. "rangeCount",
  25670. "rangeMax",
  25671. "rangeMin",
  25672. "rangeOffset",
  25673. "rangeOverflow",
  25674. "rangeParent",
  25675. "rangeUnderflow",
  25676. "rate",
  25677. "ratio",
  25678. "raw",
  25679. "rawId",
  25680. "read",
  25681. "readAsArrayBuffer",
  25682. "readAsBinaryString",
  25683. "readAsBlob",
  25684. "readAsDataURL",
  25685. "readAsText",
  25686. "readBuffer",
  25687. "readEntries",
  25688. "readOnly",
  25689. "readPixels",
  25690. "readReportRequested",
  25691. "readText",
  25692. "readValue",
  25693. "readable",
  25694. "ready",
  25695. "readyState",
  25696. "reason",
  25697. "reboot",
  25698. "receivedAlert",
  25699. "receiver",
  25700. "receivers",
  25701. "recipient",
  25702. "reconnect",
  25703. "recordNumber",
  25704. "recordsAvailable",
  25705. "recordset",
  25706. "rect",
  25707. "red",
  25708. "redEyeReduction",
  25709. "redirect",
  25710. "redirectCount",
  25711. "redirectEnd",
  25712. "redirectStart",
  25713. "redirected",
  25714. "reduce",
  25715. "reduceRight",
  25716. "reduction",
  25717. "refDistance",
  25718. "refX",
  25719. "refY",
  25720. "referenceNode",
  25721. "referenceSpace",
  25722. "referrer",
  25723. "referrerPolicy",
  25724. "refresh",
  25725. "region",
  25726. "regionAnchorX",
  25727. "regionAnchorY",
  25728. "regionId",
  25729. "regions",
  25730. "register",
  25731. "registerContentHandler",
  25732. "registerElement",
  25733. "registerProperty",
  25734. "registerProtocolHandler",
  25735. "reject",
  25736. "rel",
  25737. "relList",
  25738. "relatedAddress",
  25739. "relatedNode",
  25740. "relatedPort",
  25741. "relatedTarget",
  25742. "release",
  25743. "releaseCapture",
  25744. "releaseEvents",
  25745. "releaseInterface",
  25746. "releaseLock",
  25747. "releasePointerCapture",
  25748. "releaseShaderCompiler",
  25749. "reliable",
  25750. "reliableWrite",
  25751. "reload",
  25752. "rem",
  25753. "remainingSpace",
  25754. "remote",
  25755. "remoteDescription",
  25756. "remove",
  25757. "removeAllRanges",
  25758. "removeAttribute",
  25759. "removeAttributeNS",
  25760. "removeAttributeNode",
  25761. "removeBehavior",
  25762. "removeChild",
  25763. "removeCue",
  25764. "removeEventListener",
  25765. "removeFilter",
  25766. "removeImport",
  25767. "removeItem",
  25768. "removeListener",
  25769. "removeNamedItem",
  25770. "removeNamedItemNS",
  25771. "removeNode",
  25772. "removeParameter",
  25773. "removeProperty",
  25774. "removeRange",
  25775. "removeRegion",
  25776. "removeRule",
  25777. "removeSiteSpecificTrackingException",
  25778. "removeSourceBuffer",
  25779. "removeStream",
  25780. "removeTrack",
  25781. "removeVariable",
  25782. "removeWakeLockListener",
  25783. "removeWebWideTrackingException",
  25784. "removed",
  25785. "removedNodes",
  25786. "renderHeight",
  25787. "renderState",
  25788. "renderTime",
  25789. "renderWidth",
  25790. "renderbufferStorage",
  25791. "renderbufferStorageMultisample",
  25792. "renderedBuffer",
  25793. "renderingMode",
  25794. "renotify",
  25795. "repeat",
  25796. "replace",
  25797. "replaceAdjacentText",
  25798. "replaceAll",
  25799. "replaceChild",
  25800. "replaceChildren",
  25801. "replaceData",
  25802. "replaceId",
  25803. "replaceItem",
  25804. "replaceNode",
  25805. "replaceState",
  25806. "replaceSync",
  25807. "replaceTrack",
  25808. "replaceWholeText",
  25809. "replaceWith",
  25810. "reportValidity",
  25811. "request",
  25812. "requestAnimationFrame",
  25813. "requestAutocomplete",
  25814. "requestData",
  25815. "requestDevice",
  25816. "requestFrame",
  25817. "requestFullscreen",
  25818. "requestHitTestSource",
  25819. "requestHitTestSourceForTransientInput",
  25820. "requestId",
  25821. "requestIdleCallback",
  25822. "requestMIDIAccess",
  25823. "requestMediaKeySystemAccess",
  25824. "requestPermission",
  25825. "requestPictureInPicture",
  25826. "requestPointerLock",
  25827. "requestPresent",
  25828. "requestReferenceSpace",
  25829. "requestSession",
  25830. "requestStart",
  25831. "requestStorageAccess",
  25832. "requestSubmit",
  25833. "requestVideoFrameCallback",
  25834. "requestingWindow",
  25835. "requireInteraction",
  25836. "required",
  25837. "requiredExtensions",
  25838. "requiredFeatures",
  25839. "reset",
  25840. "resetPose",
  25841. "resetTransform",
  25842. "resize",
  25843. "resizeBy",
  25844. "resizeTo",
  25845. "resolve",
  25846. "response",
  25847. "responseBody",
  25848. "responseEnd",
  25849. "responseReady",
  25850. "responseStart",
  25851. "responseText",
  25852. "responseType",
  25853. "responseURL",
  25854. "responseXML",
  25855. "restartIce",
  25856. "restore",
  25857. "result",
  25858. "resultIndex",
  25859. "resultType",
  25860. "results",
  25861. "resume",
  25862. "resumeProfilers",
  25863. "resumeTransformFeedback",
  25864. "retry",
  25865. "returnValue",
  25866. "rev",
  25867. "reverse",
  25868. "reversed",
  25869. "revocable",
  25870. "revokeObjectURL",
  25871. "rgbColor",
  25872. "right",
  25873. "rightContext",
  25874. "rightDegrees",
  25875. "rightMargin",
  25876. "rightProjectionMatrix",
  25877. "rightViewMatrix",
  25878. "role",
  25879. "rolloffFactor",
  25880. "root",
  25881. "rootBounds",
  25882. "rootElement",
  25883. "rootMargin",
  25884. "rotate",
  25885. "rotateAxisAngle",
  25886. "rotateAxisAngleSelf",
  25887. "rotateFromVector",
  25888. "rotateFromVectorSelf",
  25889. "rotateSelf",
  25890. "rotation",
  25891. "rotationAngle",
  25892. "rotationRate",
  25893. "round",
  25894. "row-gap",
  25895. "rowGap",
  25896. "rowIndex",
  25897. "rowSpan",
  25898. "rows",
  25899. "rtcpTransport",
  25900. "rtt",
  25901. "ruby-align",
  25902. "ruby-position",
  25903. "rubyAlign",
  25904. "rubyOverhang",
  25905. "rubyPosition",
  25906. "rules",
  25907. "runtime",
  25908. "runtimeStyle",
  25909. "rx",
  25910. "ry",
  25911. "s",
  25912. "safari",
  25913. "sample",
  25914. "sampleCoverage",
  25915. "sampleRate",
  25916. "samplerParameterf",
  25917. "samplerParameteri",
  25918. "sandbox",
  25919. "save",
  25920. "saveData",
  25921. "scale",
  25922. "scale3d",
  25923. "scale3dSelf",
  25924. "scaleNonUniform",
  25925. "scaleNonUniformSelf",
  25926. "scaleSelf",
  25927. "scheme",
  25928. "scissor",
  25929. "scope",
  25930. "scopeName",
  25931. "scoped",
  25932. "screen",
  25933. "screenBrightness",
  25934. "screenEnabled",
  25935. "screenLeft",
  25936. "screenPixelToMillimeterX",
  25937. "screenPixelToMillimeterY",
  25938. "screenTop",
  25939. "screenX",
  25940. "screenY",
  25941. "scriptURL",
  25942. "scripts",
  25943. "scroll",
  25944. "scroll-behavior",
  25945. "scroll-margin",
  25946. "scroll-margin-block",
  25947. "scroll-margin-block-end",
  25948. "scroll-margin-block-start",
  25949. "scroll-margin-bottom",
  25950. "scroll-margin-inline",
  25951. "scroll-margin-inline-end",
  25952. "scroll-margin-inline-start",
  25953. "scroll-margin-left",
  25954. "scroll-margin-right",
  25955. "scroll-margin-top",
  25956. "scroll-padding",
  25957. "scroll-padding-block",
  25958. "scroll-padding-block-end",
  25959. "scroll-padding-block-start",
  25960. "scroll-padding-bottom",
  25961. "scroll-padding-inline",
  25962. "scroll-padding-inline-end",
  25963. "scroll-padding-inline-start",
  25964. "scroll-padding-left",
  25965. "scroll-padding-right",
  25966. "scroll-padding-top",
  25967. "scroll-snap-align",
  25968. "scroll-snap-type",
  25969. "scrollAmount",
  25970. "scrollBehavior",
  25971. "scrollBy",
  25972. "scrollByLines",
  25973. "scrollByPages",
  25974. "scrollDelay",
  25975. "scrollHeight",
  25976. "scrollIntoView",
  25977. "scrollIntoViewIfNeeded",
  25978. "scrollLeft",
  25979. "scrollLeftMax",
  25980. "scrollMargin",
  25981. "scrollMarginBlock",
  25982. "scrollMarginBlockEnd",
  25983. "scrollMarginBlockStart",
  25984. "scrollMarginBottom",
  25985. "scrollMarginInline",
  25986. "scrollMarginInlineEnd",
  25987. "scrollMarginInlineStart",
  25988. "scrollMarginLeft",
  25989. "scrollMarginRight",
  25990. "scrollMarginTop",
  25991. "scrollMaxX",
  25992. "scrollMaxY",
  25993. "scrollPadding",
  25994. "scrollPaddingBlock",
  25995. "scrollPaddingBlockEnd",
  25996. "scrollPaddingBlockStart",
  25997. "scrollPaddingBottom",
  25998. "scrollPaddingInline",
  25999. "scrollPaddingInlineEnd",
  26000. "scrollPaddingInlineStart",
  26001. "scrollPaddingLeft",
  26002. "scrollPaddingRight",
  26003. "scrollPaddingTop",
  26004. "scrollRestoration",
  26005. "scrollSnapAlign",
  26006. "scrollSnapType",
  26007. "scrollTo",
  26008. "scrollTop",
  26009. "scrollTopMax",
  26010. "scrollWidth",
  26011. "scrollX",
  26012. "scrollY",
  26013. "scrollbar-color",
  26014. "scrollbar-width",
  26015. "scrollbar3dLightColor",
  26016. "scrollbarArrowColor",
  26017. "scrollbarBaseColor",
  26018. "scrollbarColor",
  26019. "scrollbarDarkShadowColor",
  26020. "scrollbarFaceColor",
  26021. "scrollbarHighlightColor",
  26022. "scrollbarShadowColor",
  26023. "scrollbarTrackColor",
  26024. "scrollbarWidth",
  26025. "scrollbars",
  26026. "scrolling",
  26027. "scrollingElement",
  26028. "sctp",
  26029. "sctpCauseCode",
  26030. "sdp",
  26031. "sdpLineNumber",
  26032. "sdpMLineIndex",
  26033. "sdpMid",
  26034. "seal",
  26035. "search",
  26036. "searchBox",
  26037. "searchBoxJavaBridge_",
  26038. "searchParams",
  26039. "sectionRowIndex",
  26040. "secureConnectionStart",
  26041. "security",
  26042. "seed",
  26043. "seekToNextFrame",
  26044. "seekable",
  26045. "seeking",
  26046. "select",
  26047. "selectAllChildren",
  26048. "selectAlternateInterface",
  26049. "selectConfiguration",
  26050. "selectNode",
  26051. "selectNodeContents",
  26052. "selectNodes",
  26053. "selectSingleNode",
  26054. "selectSubString",
  26055. "selected",
  26056. "selectedIndex",
  26057. "selectedOptions",
  26058. "selectedStyleSheetSet",
  26059. "selectedStylesheetSet",
  26060. "selection",
  26061. "selectionDirection",
  26062. "selectionEnd",
  26063. "selectionStart",
  26064. "selector",
  26065. "selectorText",
  26066. "self",
  26067. "send",
  26068. "sendAsBinary",
  26069. "sendBeacon",
  26070. "sender",
  26071. "sentAlert",
  26072. "sentTimestamp",
  26073. "separator",
  26074. "serialNumber",
  26075. "serializeToString",
  26076. "serverTiming",
  26077. "service",
  26078. "serviceWorker",
  26079. "session",
  26080. "sessionId",
  26081. "sessionStorage",
  26082. "set",
  26083. "setActionHandler",
  26084. "setActive",
  26085. "setAlpha",
  26086. "setAppBadge",
  26087. "setAttribute",
  26088. "setAttributeNS",
  26089. "setAttributeNode",
  26090. "setAttributeNodeNS",
  26091. "setBaseAndExtent",
  26092. "setBigInt64",
  26093. "setBigUint64",
  26094. "setBingCurrentSearchDefault",
  26095. "setCapture",
  26096. "setCodecPreferences",
  26097. "setColor",
  26098. "setCompositeOperation",
  26099. "setConfiguration",
  26100. "setCurrentTime",
  26101. "setCustomValidity",
  26102. "setData",
  26103. "setDate",
  26104. "setDragImage",
  26105. "setEnd",
  26106. "setEndAfter",
  26107. "setEndBefore",
  26108. "setEndPoint",
  26109. "setFillColor",
  26110. "setFilterRes",
  26111. "setFloat32",
  26112. "setFloat64",
  26113. "setFloatValue",
  26114. "setFormValue",
  26115. "setFullYear",
  26116. "setHeaderValue",
  26117. "setHours",
  26118. "setIdentityProvider",
  26119. "setImmediate",
  26120. "setInt16",
  26121. "setInt32",
  26122. "setInt8",
  26123. "setInterval",
  26124. "setItem",
  26125. "setKeyframes",
  26126. "setLineCap",
  26127. "setLineDash",
  26128. "setLineJoin",
  26129. "setLineWidth",
  26130. "setLiveSeekableRange",
  26131. "setLocalDescription",
  26132. "setMatrix",
  26133. "setMatrixValue",
  26134. "setMediaKeys",
  26135. "setMilliseconds",
  26136. "setMinutes",
  26137. "setMiterLimit",
  26138. "setMonth",
  26139. "setNamedItem",
  26140. "setNamedItemNS",
  26141. "setNonUserCodeExceptions",
  26142. "setOrientToAngle",
  26143. "setOrientToAuto",
  26144. "setOrientation",
  26145. "setOverrideHistoryNavigationMode",
  26146. "setPaint",
  26147. "setParameter",
  26148. "setParameters",
  26149. "setPeriodicWave",
  26150. "setPointerCapture",
  26151. "setPosition",
  26152. "setPositionState",
  26153. "setPreference",
  26154. "setProperty",
  26155. "setPrototypeOf",
  26156. "setRGBColor",
  26157. "setRGBColorICCColor",
  26158. "setRadius",
  26159. "setRangeText",
  26160. "setRemoteDescription",
  26161. "setRequestHeader",
  26162. "setResizable",
  26163. "setResourceTimingBufferSize",
  26164. "setRotate",
  26165. "setScale",
  26166. "setSeconds",
  26167. "setSelectionRange",
  26168. "setServerCertificate",
  26169. "setShadow",
  26170. "setSinkId",
  26171. "setSkewX",
  26172. "setSkewY",
  26173. "setStart",
  26174. "setStartAfter",
  26175. "setStartBefore",
  26176. "setStdDeviation",
  26177. "setStreams",
  26178. "setStringValue",
  26179. "setStrokeColor",
  26180. "setSuggestResult",
  26181. "setTargetAtTime",
  26182. "setTargetValueAtTime",
  26183. "setTime",
  26184. "setTimeout",
  26185. "setTransform",
  26186. "setTranslate",
  26187. "setUTCDate",
  26188. "setUTCFullYear",
  26189. "setUTCHours",
  26190. "setUTCMilliseconds",
  26191. "setUTCMinutes",
  26192. "setUTCMonth",
  26193. "setUTCSeconds",
  26194. "setUint16",
  26195. "setUint32",
  26196. "setUint8",
  26197. "setUri",
  26198. "setValidity",
  26199. "setValueAtTime",
  26200. "setValueCurveAtTime",
  26201. "setVariable",
  26202. "setVelocity",
  26203. "setVersion",
  26204. "setYear",
  26205. "settingName",
  26206. "settingValue",
  26207. "sex",
  26208. "shaderSource",
  26209. "shadowBlur",
  26210. "shadowColor",
  26211. "shadowOffsetX",
  26212. "shadowOffsetY",
  26213. "shadowRoot",
  26214. "shape",
  26215. "shape-image-threshold",
  26216. "shape-margin",
  26217. "shape-outside",
  26218. "shape-rendering",
  26219. "shapeImageThreshold",
  26220. "shapeMargin",
  26221. "shapeOutside",
  26222. "shapeRendering",
  26223. "sheet",
  26224. "shift",
  26225. "shiftKey",
  26226. "shiftLeft",
  26227. "shippingAddress",
  26228. "shippingOption",
  26229. "shippingType",
  26230. "show",
  26231. "showHelp",
  26232. "showModal",
  26233. "showModalDialog",
  26234. "showModelessDialog",
  26235. "showNotification",
  26236. "sidebar",
  26237. "sign",
  26238. "signal",
  26239. "signalingState",
  26240. "signature",
  26241. "silent",
  26242. "sin",
  26243. "singleNodeValue",
  26244. "sinh",
  26245. "sinkId",
  26246. "sittingToStandingTransform",
  26247. "size",
  26248. "sizeToContent",
  26249. "sizeX",
  26250. "sizeZ",
  26251. "sizes",
  26252. "skewX",
  26253. "skewXSelf",
  26254. "skewY",
  26255. "skewYSelf",
  26256. "slice",
  26257. "slope",
  26258. "slot",
  26259. "small",
  26260. "smil",
  26261. "smooth",
  26262. "smoothingTimeConstant",
  26263. "snapToLines",
  26264. "snapshotItem",
  26265. "snapshotLength",
  26266. "some",
  26267. "sort",
  26268. "sortingCode",
  26269. "source",
  26270. "sourceBuffer",
  26271. "sourceBuffers",
  26272. "sourceCapabilities",
  26273. "sourceFile",
  26274. "sourceIndex",
  26275. "sources",
  26276. "spacing",
  26277. "span",
  26278. "speak",
  26279. "speakAs",
  26280. "speaking",
  26281. "species",
  26282. "specified",
  26283. "specularConstant",
  26284. "specularExponent",
  26285. "speechSynthesis",
  26286. "speed",
  26287. "speedOfSound",
  26288. "spellcheck",
  26289. "splice",
  26290. "split",
  26291. "splitText",
  26292. "spreadMethod",
  26293. "sqrt",
  26294. "src",
  26295. "srcElement",
  26296. "srcFilter",
  26297. "srcObject",
  26298. "srcUrn",
  26299. "srcdoc",
  26300. "srclang",
  26301. "srcset",
  26302. "stack",
  26303. "stackTraceLimit",
  26304. "stacktrace",
  26305. "stageParameters",
  26306. "standalone",
  26307. "standby",
  26308. "start",
  26309. "startContainer",
  26310. "startIce",
  26311. "startMessages",
  26312. "startNotifications",
  26313. "startOffset",
  26314. "startProfiling",
  26315. "startRendering",
  26316. "startShark",
  26317. "startTime",
  26318. "startsWith",
  26319. "state",
  26320. "status",
  26321. "statusCode",
  26322. "statusMessage",
  26323. "statusText",
  26324. "statusbar",
  26325. "stdDeviationX",
  26326. "stdDeviationY",
  26327. "stencilFunc",
  26328. "stencilFuncSeparate",
  26329. "stencilMask",
  26330. "stencilMaskSeparate",
  26331. "stencilOp",
  26332. "stencilOpSeparate",
  26333. "step",
  26334. "stepDown",
  26335. "stepMismatch",
  26336. "stepUp",
  26337. "sticky",
  26338. "stitchTiles",
  26339. "stop",
  26340. "stop-color",
  26341. "stop-opacity",
  26342. "stopColor",
  26343. "stopImmediatePropagation",
  26344. "stopNotifications",
  26345. "stopOpacity",
  26346. "stopProfiling",
  26347. "stopPropagation",
  26348. "stopShark",
  26349. "stopped",
  26350. "storage",
  26351. "storageArea",
  26352. "storageName",
  26353. "storageStatus",
  26354. "store",
  26355. "storeSiteSpecificTrackingException",
  26356. "storeWebWideTrackingException",
  26357. "stpVersion",
  26358. "stream",
  26359. "streams",
  26360. "stretch",
  26361. "strike",
  26362. "string",
  26363. "stringValue",
  26364. "stringify",
  26365. "stroke",
  26366. "stroke-dasharray",
  26367. "stroke-dashoffset",
  26368. "stroke-linecap",
  26369. "stroke-linejoin",
  26370. "stroke-miterlimit",
  26371. "stroke-opacity",
  26372. "stroke-width",
  26373. "strokeDasharray",
  26374. "strokeDashoffset",
  26375. "strokeLinecap",
  26376. "strokeLinejoin",
  26377. "strokeMiterlimit",
  26378. "strokeOpacity",
  26379. "strokeRect",
  26380. "strokeStyle",
  26381. "strokeText",
  26382. "strokeWidth",
  26383. "style",
  26384. "styleFloat",
  26385. "styleMap",
  26386. "styleMedia",
  26387. "styleSheet",
  26388. "styleSheetSets",
  26389. "styleSheets",
  26390. "sub",
  26391. "subarray",
  26392. "subject",
  26393. "submit",
  26394. "submitFrame",
  26395. "submitter",
  26396. "subscribe",
  26397. "substr",
  26398. "substring",
  26399. "substringData",
  26400. "subtle",
  26401. "subtree",
  26402. "suffix",
  26403. "suffixes",
  26404. "summary",
  26405. "sup",
  26406. "supported",
  26407. "supportedContentEncodings",
  26408. "supportedEntryTypes",
  26409. "supports",
  26410. "supportsSession",
  26411. "surfaceScale",
  26412. "surroundContents",
  26413. "suspend",
  26414. "suspendRedraw",
  26415. "swapCache",
  26416. "swapNode",
  26417. "sweepFlag",
  26418. "symbols",
  26419. "sync",
  26420. "sysexEnabled",
  26421. "system",
  26422. "systemCode",
  26423. "systemId",
  26424. "systemLanguage",
  26425. "systemXDPI",
  26426. "systemYDPI",
  26427. "tBodies",
  26428. "tFoot",
  26429. "tHead",
  26430. "tabIndex",
  26431. "table",
  26432. "table-layout",
  26433. "tableLayout",
  26434. "tableValues",
  26435. "tag",
  26436. "tagName",
  26437. "tagUrn",
  26438. "tags",
  26439. "taintEnabled",
  26440. "takePhoto",
  26441. "takeRecords",
  26442. "tan",
  26443. "tangentialPressure",
  26444. "tanh",
  26445. "target",
  26446. "targetElement",
  26447. "targetRayMode",
  26448. "targetRaySpace",
  26449. "targetTouches",
  26450. "targetX",
  26451. "targetY",
  26452. "tcpType",
  26453. "tee",
  26454. "tel",
  26455. "terminate",
  26456. "test",
  26457. "texImage2D",
  26458. "texImage3D",
  26459. "texParameterf",
  26460. "texParameteri",
  26461. "texStorage2D",
  26462. "texStorage3D",
  26463. "texSubImage2D",
  26464. "texSubImage3D",
  26465. "text",
  26466. "text-align",
  26467. "text-align-last",
  26468. "text-anchor",
  26469. "text-combine-upright",
  26470. "text-decoration",
  26471. "text-decoration-color",
  26472. "text-decoration-line",
  26473. "text-decoration-skip-ink",
  26474. "text-decoration-style",
  26475. "text-decoration-thickness",
  26476. "text-emphasis",
  26477. "text-emphasis-color",
  26478. "text-emphasis-position",
  26479. "text-emphasis-style",
  26480. "text-indent",
  26481. "text-justify",
  26482. "text-orientation",
  26483. "text-overflow",
  26484. "text-rendering",
  26485. "text-shadow",
  26486. "text-transform",
  26487. "text-underline-offset",
  26488. "text-underline-position",
  26489. "textAlign",
  26490. "textAlignLast",
  26491. "textAnchor",
  26492. "textAutospace",
  26493. "textBaseline",
  26494. "textCombineUpright",
  26495. "textContent",
  26496. "textDecoration",
  26497. "textDecorationBlink",
  26498. "textDecorationColor",
  26499. "textDecorationLine",
  26500. "textDecorationLineThrough",
  26501. "textDecorationNone",
  26502. "textDecorationOverline",
  26503. "textDecorationSkipInk",
  26504. "textDecorationStyle",
  26505. "textDecorationThickness",
  26506. "textDecorationUnderline",
  26507. "textEmphasis",
  26508. "textEmphasisColor",
  26509. "textEmphasisPosition",
  26510. "textEmphasisStyle",
  26511. "textIndent",
  26512. "textJustify",
  26513. "textJustifyTrim",
  26514. "textKashida",
  26515. "textKashidaSpace",
  26516. "textLength",
  26517. "textOrientation",
  26518. "textOverflow",
  26519. "textRendering",
  26520. "textShadow",
  26521. "textTracks",
  26522. "textTransform",
  26523. "textUnderlineOffset",
  26524. "textUnderlinePosition",
  26525. "then",
  26526. "threadId",
  26527. "threshold",
  26528. "thresholds",
  26529. "tiltX",
  26530. "tiltY",
  26531. "time",
  26532. "timeEnd",
  26533. "timeLog",
  26534. "timeOrigin",
  26535. "timeRemaining",
  26536. "timeStamp",
  26537. "timecode",
  26538. "timeline",
  26539. "timelineTime",
  26540. "timeout",
  26541. "timestamp",
  26542. "timestampOffset",
  26543. "timing",
  26544. "title",
  26545. "to",
  26546. "toArray",
  26547. "toBlob",
  26548. "toDataURL",
  26549. "toDateString",
  26550. "toElement",
  26551. "toExponential",
  26552. "toFixed",
  26553. "toFloat32Array",
  26554. "toFloat64Array",
  26555. "toGMTString",
  26556. "toISOString",
  26557. "toJSON",
  26558. "toLocaleDateString",
  26559. "toLocaleFormat",
  26560. "toLocaleLowerCase",
  26561. "toLocaleString",
  26562. "toLocaleTimeString",
  26563. "toLocaleUpperCase",
  26564. "toLowerCase",
  26565. "toMatrix",
  26566. "toMethod",
  26567. "toPrecision",
  26568. "toPrimitive",
  26569. "toSdp",
  26570. "toSource",
  26571. "toStaticHTML",
  26572. "toString",
  26573. "toStringTag",
  26574. "toSum",
  26575. "toTimeString",
  26576. "toUTCString",
  26577. "toUpperCase",
  26578. "toggle",
  26579. "toggleAttribute",
  26580. "toggleLongPressEnabled",
  26581. "tone",
  26582. "toneBuffer",
  26583. "tooLong",
  26584. "tooShort",
  26585. "toolbar",
  26586. "top",
  26587. "topMargin",
  26588. "total",
  26589. "totalFrameDelay",
  26590. "totalVideoFrames",
  26591. "touch-action",
  26592. "touchAction",
  26593. "touched",
  26594. "touches",
  26595. "trace",
  26596. "track",
  26597. "trackVisibility",
  26598. "transaction",
  26599. "transactions",
  26600. "transceiver",
  26601. "transferControlToOffscreen",
  26602. "transferFromImageBitmap",
  26603. "transferImageBitmap",
  26604. "transferIn",
  26605. "transferOut",
  26606. "transferSize",
  26607. "transferToImageBitmap",
  26608. "transform",
  26609. "transform-box",
  26610. "transform-origin",
  26611. "transform-style",
  26612. "transformBox",
  26613. "transformFeedbackVaryings",
  26614. "transformOrigin",
  26615. "transformPoint",
  26616. "transformString",
  26617. "transformStyle",
  26618. "transformToDocument",
  26619. "transformToFragment",
  26620. "transition",
  26621. "transition-delay",
  26622. "transition-duration",
  26623. "transition-property",
  26624. "transition-timing-function",
  26625. "transitionDelay",
  26626. "transitionDuration",
  26627. "transitionProperty",
  26628. "transitionTimingFunction",
  26629. "translate",
  26630. "translateSelf",
  26631. "translationX",
  26632. "translationY",
  26633. "transport",
  26634. "trim",
  26635. "trimEnd",
  26636. "trimLeft",
  26637. "trimRight",
  26638. "trimStart",
  26639. "trueSpeed",
  26640. "trunc",
  26641. "truncate",
  26642. "trustedTypes",
  26643. "turn",
  26644. "twist",
  26645. "type",
  26646. "typeDetail",
  26647. "typeMismatch",
  26648. "typeMustMatch",
  26649. "types",
  26650. "u2f",
  26651. "ubound",
  26652. "uint16",
  26653. "uint32",
  26654. "uint8",
  26655. "uint8Clamped",
  26656. "undefined",
  26657. "unescape",
  26658. "uneval",
  26659. "unicode",
  26660. "unicode-bidi",
  26661. "unicodeBidi",
  26662. "unicodeRange",
  26663. "uniform1f",
  26664. "uniform1fv",
  26665. "uniform1i",
  26666. "uniform1iv",
  26667. "uniform1ui",
  26668. "uniform1uiv",
  26669. "uniform2f",
  26670. "uniform2fv",
  26671. "uniform2i",
  26672. "uniform2iv",
  26673. "uniform2ui",
  26674. "uniform2uiv",
  26675. "uniform3f",
  26676. "uniform3fv",
  26677. "uniform3i",
  26678. "uniform3iv",
  26679. "uniform3ui",
  26680. "uniform3uiv",
  26681. "uniform4f",
  26682. "uniform4fv",
  26683. "uniform4i",
  26684. "uniform4iv",
  26685. "uniform4ui",
  26686. "uniform4uiv",
  26687. "uniformBlockBinding",
  26688. "uniformMatrix2fv",
  26689. "uniformMatrix2x3fv",
  26690. "uniformMatrix2x4fv",
  26691. "uniformMatrix3fv",
  26692. "uniformMatrix3x2fv",
  26693. "uniformMatrix3x4fv",
  26694. "uniformMatrix4fv",
  26695. "uniformMatrix4x2fv",
  26696. "uniformMatrix4x3fv",
  26697. "unique",
  26698. "uniqueID",
  26699. "uniqueNumber",
  26700. "unit",
  26701. "unitType",
  26702. "units",
  26703. "unloadEventEnd",
  26704. "unloadEventStart",
  26705. "unlock",
  26706. "unmount",
  26707. "unobserve",
  26708. "unpause",
  26709. "unpauseAnimations",
  26710. "unreadCount",
  26711. "unregister",
  26712. "unregisterContentHandler",
  26713. "unregisterProtocolHandler",
  26714. "unscopables",
  26715. "unselectable",
  26716. "unshift",
  26717. "unsubscribe",
  26718. "unsuspendRedraw",
  26719. "unsuspendRedrawAll",
  26720. "unwatch",
  26721. "unwrapKey",
  26722. "upDegrees",
  26723. "upX",
  26724. "upY",
  26725. "upZ",
  26726. "update",
  26727. "updateCommands",
  26728. "updateIce",
  26729. "updateInterval",
  26730. "updatePlaybackRate",
  26731. "updateRenderState",
  26732. "updateSettings",
  26733. "updateTiming",
  26734. "updateViaCache",
  26735. "updateWith",
  26736. "updated",
  26737. "updating",
  26738. "upgrade",
  26739. "upload",
  26740. "uploadTotal",
  26741. "uploaded",
  26742. "upper",
  26743. "upperBound",
  26744. "upperOpen",
  26745. "uri",
  26746. "url",
  26747. "urn",
  26748. "urns",
  26749. "usages",
  26750. "usb",
  26751. "usbVersionMajor",
  26752. "usbVersionMinor",
  26753. "usbVersionSubminor",
  26754. "useCurrentView",
  26755. "useMap",
  26756. "useProgram",
  26757. "usedSpace",
  26758. "user-select",
  26759. "userActivation",
  26760. "userAgent",
  26761. "userAgentData",
  26762. "userChoice",
  26763. "userHandle",
  26764. "userHint",
  26765. "userLanguage",
  26766. "userSelect",
  26767. "userVisibleOnly",
  26768. "username",
  26769. "usernameFragment",
  26770. "utterance",
  26771. "uuid",
  26772. "v8BreakIterator",
  26773. "vAlign",
  26774. "vLink",
  26775. "valid",
  26776. "validate",
  26777. "validateProgram",
  26778. "validationMessage",
  26779. "validity",
  26780. "value",
  26781. "valueAsDate",
  26782. "valueAsNumber",
  26783. "valueAsString",
  26784. "valueInSpecifiedUnits",
  26785. "valueMissing",
  26786. "valueOf",
  26787. "valueText",
  26788. "valueType",
  26789. "values",
  26790. "variable",
  26791. "variant",
  26792. "variationSettings",
  26793. "vector-effect",
  26794. "vectorEffect",
  26795. "velocityAngular",
  26796. "velocityExpansion",
  26797. "velocityX",
  26798. "velocityY",
  26799. "vendor",
  26800. "vendorId",
  26801. "vendorSub",
  26802. "verify",
  26803. "version",
  26804. "vertexAttrib1f",
  26805. "vertexAttrib1fv",
  26806. "vertexAttrib2f",
  26807. "vertexAttrib2fv",
  26808. "vertexAttrib3f",
  26809. "vertexAttrib3fv",
  26810. "vertexAttrib4f",
  26811. "vertexAttrib4fv",
  26812. "vertexAttribDivisor",
  26813. "vertexAttribDivisorANGLE",
  26814. "vertexAttribI4i",
  26815. "vertexAttribI4iv",
  26816. "vertexAttribI4ui",
  26817. "vertexAttribI4uiv",
  26818. "vertexAttribIPointer",
  26819. "vertexAttribPointer",
  26820. "vertical",
  26821. "vertical-align",
  26822. "verticalAlign",
  26823. "verticalOverflow",
  26824. "vh",
  26825. "vibrate",
  26826. "vibrationActuator",
  26827. "videoBitsPerSecond",
  26828. "videoHeight",
  26829. "videoTracks",
  26830. "videoWidth",
  26831. "view",
  26832. "viewBox",
  26833. "viewBoxString",
  26834. "viewTarget",
  26835. "viewTargetString",
  26836. "viewport",
  26837. "viewportAnchorX",
  26838. "viewportAnchorY",
  26839. "viewportElement",
  26840. "views",
  26841. "violatedDirective",
  26842. "visibility",
  26843. "visibilityState",
  26844. "visible",
  26845. "visualViewport",
  26846. "vlinkColor",
  26847. "vmax",
  26848. "vmin",
  26849. "voice",
  26850. "voiceURI",
  26851. "volume",
  26852. "vrml",
  26853. "vspace",
  26854. "vw",
  26855. "w",
  26856. "wait",
  26857. "waitSync",
  26858. "waiting",
  26859. "wake",
  26860. "wakeLock",
  26861. "wand",
  26862. "warn",
  26863. "wasClean",
  26864. "wasDiscarded",
  26865. "watch",
  26866. "watchAvailability",
  26867. "watchPosition",
  26868. "webdriver",
  26869. "webkitAddKey",
  26870. "webkitAlignContent",
  26871. "webkitAlignItems",
  26872. "webkitAlignSelf",
  26873. "webkitAnimation",
  26874. "webkitAnimationDelay",
  26875. "webkitAnimationDirection",
  26876. "webkitAnimationDuration",
  26877. "webkitAnimationFillMode",
  26878. "webkitAnimationIterationCount",
  26879. "webkitAnimationName",
  26880. "webkitAnimationPlayState",
  26881. "webkitAnimationTimingFunction",
  26882. "webkitAppearance",
  26883. "webkitAudioContext",
  26884. "webkitAudioDecodedByteCount",
  26885. "webkitAudioPannerNode",
  26886. "webkitBackfaceVisibility",
  26887. "webkitBackground",
  26888. "webkitBackgroundAttachment",
  26889. "webkitBackgroundClip",
  26890. "webkitBackgroundColor",
  26891. "webkitBackgroundImage",
  26892. "webkitBackgroundOrigin",
  26893. "webkitBackgroundPosition",
  26894. "webkitBackgroundPositionX",
  26895. "webkitBackgroundPositionY",
  26896. "webkitBackgroundRepeat",
  26897. "webkitBackgroundSize",
  26898. "webkitBackingStorePixelRatio",
  26899. "webkitBorderBottomLeftRadius",
  26900. "webkitBorderBottomRightRadius",
  26901. "webkitBorderImage",
  26902. "webkitBorderImageOutset",
  26903. "webkitBorderImageRepeat",
  26904. "webkitBorderImageSlice",
  26905. "webkitBorderImageSource",
  26906. "webkitBorderImageWidth",
  26907. "webkitBorderRadius",
  26908. "webkitBorderTopLeftRadius",
  26909. "webkitBorderTopRightRadius",
  26910. "webkitBoxAlign",
  26911. "webkitBoxDirection",
  26912. "webkitBoxFlex",
  26913. "webkitBoxOrdinalGroup",
  26914. "webkitBoxOrient",
  26915. "webkitBoxPack",
  26916. "webkitBoxShadow",
  26917. "webkitBoxSizing",
  26918. "webkitCancelAnimationFrame",
  26919. "webkitCancelFullScreen",
  26920. "webkitCancelKeyRequest",
  26921. "webkitCancelRequestAnimationFrame",
  26922. "webkitClearResourceTimings",
  26923. "webkitClosedCaptionsVisible",
  26924. "webkitConvertPointFromNodeToPage",
  26925. "webkitConvertPointFromPageToNode",
  26926. "webkitCreateShadowRoot",
  26927. "webkitCurrentFullScreenElement",
  26928. "webkitCurrentPlaybackTargetIsWireless",
  26929. "webkitDecodedFrameCount",
  26930. "webkitDirectionInvertedFromDevice",
  26931. "webkitDisplayingFullscreen",
  26932. "webkitDroppedFrameCount",
  26933. "webkitEnterFullScreen",
  26934. "webkitEnterFullscreen",
  26935. "webkitEntries",
  26936. "webkitExitFullScreen",
  26937. "webkitExitFullscreen",
  26938. "webkitExitPointerLock",
  26939. "webkitFilter",
  26940. "webkitFlex",
  26941. "webkitFlexBasis",
  26942. "webkitFlexDirection",
  26943. "webkitFlexFlow",
  26944. "webkitFlexGrow",
  26945. "webkitFlexShrink",
  26946. "webkitFlexWrap",
  26947. "webkitFullScreenKeyboardInputAllowed",
  26948. "webkitFullscreenElement",
  26949. "webkitFullscreenEnabled",
  26950. "webkitGenerateKeyRequest",
  26951. "webkitGetAsEntry",
  26952. "webkitGetDatabaseNames",
  26953. "webkitGetEntries",
  26954. "webkitGetEntriesByName",
  26955. "webkitGetEntriesByType",
  26956. "webkitGetFlowByName",
  26957. "webkitGetGamepads",
  26958. "webkitGetImageDataHD",
  26959. "webkitGetNamedFlows",
  26960. "webkitGetRegionFlowRanges",
  26961. "webkitGetUserMedia",
  26962. "webkitHasClosedCaptions",
  26963. "webkitHidden",
  26964. "webkitIDBCursor",
  26965. "webkitIDBDatabase",
  26966. "webkitIDBDatabaseError",
  26967. "webkitIDBDatabaseException",
  26968. "webkitIDBFactory",
  26969. "webkitIDBIndex",
  26970. "webkitIDBKeyRange",
  26971. "webkitIDBObjectStore",
  26972. "webkitIDBRequest",
  26973. "webkitIDBTransaction",
  26974. "webkitImageSmoothingEnabled",
  26975. "webkitIndexedDB",
  26976. "webkitInitMessageEvent",
  26977. "webkitIsFullScreen",
  26978. "webkitJustifyContent",
  26979. "webkitKeys",
  26980. "webkitLineClamp",
  26981. "webkitLineDashOffset",
  26982. "webkitLockOrientation",
  26983. "webkitMask",
  26984. "webkitMaskClip",
  26985. "webkitMaskComposite",
  26986. "webkitMaskImage",
  26987. "webkitMaskOrigin",
  26988. "webkitMaskPosition",
  26989. "webkitMaskPositionX",
  26990. "webkitMaskPositionY",
  26991. "webkitMaskRepeat",
  26992. "webkitMaskSize",
  26993. "webkitMatchesSelector",
  26994. "webkitMediaStream",
  26995. "webkitNotifications",
  26996. "webkitOfflineAudioContext",
  26997. "webkitOrder",
  26998. "webkitOrientation",
  26999. "webkitPeerConnection00",
  27000. "webkitPersistentStorage",
  27001. "webkitPerspective",
  27002. "webkitPerspectiveOrigin",
  27003. "webkitPointerLockElement",
  27004. "webkitPostMessage",
  27005. "webkitPreservesPitch",
  27006. "webkitPutImageDataHD",
  27007. "webkitRTCPeerConnection",
  27008. "webkitRegionOverset",
  27009. "webkitRelativePath",
  27010. "webkitRequestAnimationFrame",
  27011. "webkitRequestFileSystem",
  27012. "webkitRequestFullScreen",
  27013. "webkitRequestFullscreen",
  27014. "webkitRequestPointerLock",
  27015. "webkitResolveLocalFileSystemURL",
  27016. "webkitSetMediaKeys",
  27017. "webkitSetResourceTimingBufferSize",
  27018. "webkitShadowRoot",
  27019. "webkitShowPlaybackTargetPicker",
  27020. "webkitSlice",
  27021. "webkitSpeechGrammar",
  27022. "webkitSpeechGrammarList",
  27023. "webkitSpeechRecognition",
  27024. "webkitSpeechRecognitionError",
  27025. "webkitSpeechRecognitionEvent",
  27026. "webkitStorageInfo",
  27027. "webkitSupportsFullscreen",
  27028. "webkitTemporaryStorage",
  27029. "webkitTextFillColor",
  27030. "webkitTextSizeAdjust",
  27031. "webkitTextStroke",
  27032. "webkitTextStrokeColor",
  27033. "webkitTextStrokeWidth",
  27034. "webkitTransform",
  27035. "webkitTransformOrigin",
  27036. "webkitTransformStyle",
  27037. "webkitTransition",
  27038. "webkitTransitionDelay",
  27039. "webkitTransitionDuration",
  27040. "webkitTransitionProperty",
  27041. "webkitTransitionTimingFunction",
  27042. "webkitURL",
  27043. "webkitUnlockOrientation",
  27044. "webkitUserSelect",
  27045. "webkitVideoDecodedByteCount",
  27046. "webkitVisibilityState",
  27047. "webkitWirelessVideoPlaybackDisabled",
  27048. "webkitdirectory",
  27049. "webkitdropzone",
  27050. "webstore",
  27051. "weight",
  27052. "whatToShow",
  27053. "wheelDelta",
  27054. "wheelDeltaX",
  27055. "wheelDeltaY",
  27056. "whenDefined",
  27057. "which",
  27058. "white-space",
  27059. "whiteSpace",
  27060. "wholeText",
  27061. "widows",
  27062. "width",
  27063. "will-change",
  27064. "willChange",
  27065. "willValidate",
  27066. "window",
  27067. "withCredentials",
  27068. "word-break",
  27069. "word-spacing",
  27070. "word-wrap",
  27071. "wordBreak",
  27072. "wordSpacing",
  27073. "wordWrap",
  27074. "workerStart",
  27075. "wow64",
  27076. "wrap",
  27077. "wrapKey",
  27078. "writable",
  27079. "writableAuxiliaries",
  27080. "write",
  27081. "writeText",
  27082. "writeValue",
  27083. "writeWithoutResponse",
  27084. "writeln",
  27085. "writing-mode",
  27086. "writingMode",
  27087. "x",
  27088. "x1",
  27089. "x2",
  27090. "xChannelSelector",
  27091. "xmlEncoding",
  27092. "xmlStandalone",
  27093. "xmlVersion",
  27094. "xmlbase",
  27095. "xmllang",
  27096. "xmlspace",
  27097. "xor",
  27098. "xr",
  27099. "y",
  27100. "y1",
  27101. "y2",
  27102. "yChannelSelector",
  27103. "yandex",
  27104. "z",
  27105. "z-index",
  27106. "zIndex",
  27107. "zoom",
  27108. "zoomAndPan",
  27109. "zoomRectScreen",
  27110. ];
  27111. /***********************************************************************
  27112. A JavaScript tokenizer / parser / beautifier / compressor.
  27113. https://github.com/mishoo/UglifyJS2
  27114. -------------------------------- (C) ---------------------------------
  27115. Author: Mihai Bazon
  27116. <mihai.bazon@gmail.com>
  27117. http://mihai.bazon.net/blog
  27118. Distributed under the BSD license:
  27119. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  27120. Redistribution and use in source and binary forms, with or without
  27121. modification, are permitted provided that the following conditions
  27122. are met:
  27123. * Redistributions of source code must retain the above
  27124. copyright notice, this list of conditions and the following
  27125. disclaimer.
  27126. * Redistributions in binary form must reproduce the above
  27127. copyright notice, this list of conditions and the following
  27128. disclaimer in the documentation and/or other materials
  27129. provided with the distribution.
  27130. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  27131. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27132. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  27133. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  27134. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  27135. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27136. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27137. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27138. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  27139. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27140. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27141. SUCH DAMAGE.
  27142. ***********************************************************************/
  27143. function find_builtins(reserved) {
  27144. domprops.forEach(add);
  27145. // Compatibility fix for some standard defined globals not defined on every js environment
  27146. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  27147. var objects = {};
  27148. var global_ref = typeof global === "object" ? global : self;
  27149. new_globals.forEach(function (new_global) {
  27150. objects[new_global] = global_ref[new_global] || function() {};
  27151. });
  27152. [
  27153. "null",
  27154. "true",
  27155. "false",
  27156. "NaN",
  27157. "Infinity",
  27158. "-Infinity",
  27159. "undefined",
  27160. ].forEach(add);
  27161. [ Object, Array, Function, Number,
  27162. String, Boolean, Error, Math,
  27163. Date, RegExp, objects.Symbol, ArrayBuffer,
  27164. DataView, decodeURI, decodeURIComponent,
  27165. encodeURI, encodeURIComponent, eval, EvalError,
  27166. Float32Array, Float64Array, Int8Array, Int16Array,
  27167. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  27168. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  27169. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  27170. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  27171. objects.WeakMap, objects.WeakSet
  27172. ].forEach(function(ctor) {
  27173. Object.getOwnPropertyNames(ctor).map(add);
  27174. if (ctor.prototype) {
  27175. Object.getOwnPropertyNames(ctor.prototype).map(add);
  27176. }
  27177. });
  27178. function add(name) {
  27179. reserved.add(name);
  27180. }
  27181. }
  27182. function reserve_quoted_keys(ast, reserved) {
  27183. function add(name) {
  27184. push_uniq(reserved, name);
  27185. }
  27186. ast.walk(new TreeWalker(function(node) {
  27187. if (node instanceof AST_ObjectKeyVal && node.quote) {
  27188. add(node.key);
  27189. } else if (node instanceof AST_ObjectProperty && node.quote) {
  27190. add(node.key.name);
  27191. } else if (node instanceof AST_Sub) {
  27192. addStrings(node.property, add);
  27193. }
  27194. }));
  27195. }
  27196. function addStrings(node, add) {
  27197. node.walk(new TreeWalker(function(node) {
  27198. if (node instanceof AST_Sequence) {
  27199. addStrings(node.tail_node(), add);
  27200. } else if (node instanceof AST_String) {
  27201. add(node.value);
  27202. } else if (node instanceof AST_Conditional) {
  27203. addStrings(node.consequent, add);
  27204. addStrings(node.alternative, add);
  27205. }
  27206. return true;
  27207. }));
  27208. }
  27209. function mangle_private_properties(ast, options) {
  27210. var cprivate = -1;
  27211. var private_cache = new Map();
  27212. var nth_identifier = options.nth_identifier || base54;
  27213. ast = ast.transform(new TreeTransformer(function(node) {
  27214. if (
  27215. node instanceof AST_ClassPrivateProperty
  27216. || node instanceof AST_PrivateMethod
  27217. || node instanceof AST_PrivateGetter
  27218. || node instanceof AST_PrivateSetter
  27219. ) {
  27220. node.key.name = mangle_private(node.key.name);
  27221. } else if (node instanceof AST_DotHash) {
  27222. node.property = mangle_private(node.property);
  27223. }
  27224. }));
  27225. return ast;
  27226. function mangle_private(name) {
  27227. let mangled = private_cache.get(name);
  27228. if (!mangled) {
  27229. mangled = nth_identifier.get(++cprivate);
  27230. private_cache.set(name, mangled);
  27231. }
  27232. return mangled;
  27233. }
  27234. }
  27235. function mangle_properties(ast, options) {
  27236. options = defaults(options, {
  27237. builtins: false,
  27238. cache: null,
  27239. debug: false,
  27240. keep_quoted: false,
  27241. nth_identifier: base54,
  27242. only_cache: false,
  27243. regex: null,
  27244. reserved: null,
  27245. undeclared: false,
  27246. }, true);
  27247. var nth_identifier = options.nth_identifier;
  27248. var reserved_option = options.reserved;
  27249. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  27250. var reserved = new Set(reserved_option);
  27251. if (!options.builtins) find_builtins(reserved);
  27252. var cname = -1;
  27253. var cache;
  27254. if (options.cache) {
  27255. cache = options.cache.props;
  27256. } else {
  27257. cache = new Map();
  27258. }
  27259. var regex = options.regex && new RegExp(options.regex);
  27260. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  27261. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  27262. // the same as passing an empty string.
  27263. var debug = options.debug !== false;
  27264. var debug_name_suffix;
  27265. if (debug) {
  27266. debug_name_suffix = (options.debug === true ? "" : options.debug);
  27267. }
  27268. var names_to_mangle = new Set();
  27269. var unmangleable = new Set();
  27270. // Track each already-mangled name to prevent nth_identifier from generating
  27271. // the same name.
  27272. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  27273. var keep_quoted = !!options.keep_quoted;
  27274. // step 1: find candidates to mangle
  27275. ast.walk(new TreeWalker(function(node) {
  27276. if (
  27277. node instanceof AST_ClassPrivateProperty
  27278. || node instanceof AST_PrivateMethod
  27279. || node instanceof AST_PrivateGetter
  27280. || node instanceof AST_PrivateSetter
  27281. || node instanceof AST_DotHash
  27282. ) ; else if (node instanceof AST_ObjectKeyVal) {
  27283. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  27284. add(node.key);
  27285. }
  27286. } else if (node instanceof AST_ObjectProperty) {
  27287. // setter or getter, since KeyVal is handled above
  27288. if (!keep_quoted || !node.quote) {
  27289. add(node.key.name);
  27290. }
  27291. } else if (node instanceof AST_Dot) {
  27292. var declared = !!options.undeclared;
  27293. if (!declared) {
  27294. var root = node;
  27295. while (root.expression) {
  27296. root = root.expression;
  27297. }
  27298. declared = !(root.thedef && root.thedef.undeclared);
  27299. }
  27300. if (declared &&
  27301. (!keep_quoted || !node.quote)) {
  27302. add(node.property);
  27303. }
  27304. } else if (node instanceof AST_Sub) {
  27305. if (!keep_quoted) {
  27306. addStrings(node.property, add);
  27307. }
  27308. } else if (node instanceof AST_Call
  27309. && node.expression.print_to_string() == "Object.defineProperty") {
  27310. addStrings(node.args[1], add);
  27311. } else if (node instanceof AST_Binary && node.operator === "in") {
  27312. addStrings(node.left, add);
  27313. }
  27314. }));
  27315. // step 2: transform the tree, renaming properties
  27316. return ast.transform(new TreeTransformer(function(node) {
  27317. if (
  27318. node instanceof AST_ClassPrivateProperty
  27319. || node instanceof AST_PrivateMethod
  27320. || node instanceof AST_PrivateGetter
  27321. || node instanceof AST_PrivateSetter
  27322. || node instanceof AST_DotHash
  27323. ) ; else if (node instanceof AST_ObjectKeyVal) {
  27324. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  27325. node.key = mangle(node.key);
  27326. }
  27327. } else if (node instanceof AST_ObjectProperty) {
  27328. // setter, getter, method or class field
  27329. if (!keep_quoted || !node.quote) {
  27330. node.key.name = mangle(node.key.name);
  27331. }
  27332. } else if (node instanceof AST_Dot) {
  27333. if (!keep_quoted || !node.quote) {
  27334. node.property = mangle(node.property);
  27335. }
  27336. } else if (!keep_quoted && node instanceof AST_Sub) {
  27337. node.property = mangleStrings(node.property);
  27338. } else if (node instanceof AST_Call
  27339. && node.expression.print_to_string() == "Object.defineProperty") {
  27340. node.args[1] = mangleStrings(node.args[1]);
  27341. } else if (node instanceof AST_Binary && node.operator === "in") {
  27342. node.left = mangleStrings(node.left);
  27343. }
  27344. }));
  27345. // only function declarations after this line
  27346. function can_mangle(name) {
  27347. if (unmangleable.has(name)) return false;
  27348. if (reserved.has(name)) return false;
  27349. if (options.only_cache) {
  27350. return cache.has(name);
  27351. }
  27352. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  27353. return true;
  27354. }
  27355. function should_mangle(name) {
  27356. if (regex && !regex.test(name)) return false;
  27357. if (reserved.has(name)) return false;
  27358. return cache.has(name)
  27359. || names_to_mangle.has(name);
  27360. }
  27361. function add(name) {
  27362. if (can_mangle(name))
  27363. names_to_mangle.add(name);
  27364. if (!should_mangle(name)) {
  27365. unmangleable.add(name);
  27366. }
  27367. }
  27368. function mangle(name) {
  27369. if (!should_mangle(name)) {
  27370. return name;
  27371. }
  27372. var mangled = cache.get(name);
  27373. if (!mangled) {
  27374. if (debug) {
  27375. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  27376. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  27377. if (can_mangle(debug_mangled)) {
  27378. mangled = debug_mangled;
  27379. }
  27380. }
  27381. // either debug mode is off, or it is on and we could not use the mangled name
  27382. if (!mangled) {
  27383. do {
  27384. mangled = nth_identifier.get(++cname);
  27385. } while (!can_mangle(mangled));
  27386. }
  27387. cache.set(name, mangled);
  27388. }
  27389. return mangled;
  27390. }
  27391. function mangleStrings(node) {
  27392. return node.transform(new TreeTransformer(function(node) {
  27393. if (node instanceof AST_Sequence) {
  27394. var last = node.expressions.length - 1;
  27395. node.expressions[last] = mangleStrings(node.expressions[last]);
  27396. } else if (node instanceof AST_String) {
  27397. node.value = mangle(node.value);
  27398. } else if (node instanceof AST_Conditional) {
  27399. node.consequent = mangleStrings(node.consequent);
  27400. node.alternative = mangleStrings(node.alternative);
  27401. }
  27402. return node;
  27403. }));
  27404. }
  27405. }
  27406. var to_ascii = typeof atob == "undefined" ? function(b64) {
  27407. return Buffer.from(b64, "base64").toString();
  27408. } : atob;
  27409. var to_base64 = typeof btoa == "undefined" ? function(str) {
  27410. return Buffer.from(str).toString("base64");
  27411. } : btoa;
  27412. function read_source_map(code) {
  27413. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  27414. if (!match) {
  27415. console.warn("inline source map not found");
  27416. return null;
  27417. }
  27418. return to_ascii(match[2]);
  27419. }
  27420. function set_shorthand(name, options, keys) {
  27421. if (options[name]) {
  27422. keys.forEach(function(key) {
  27423. if (options[key]) {
  27424. if (typeof options[key] != "object") options[key] = {};
  27425. if (!(name in options[key])) options[key][name] = options[name];
  27426. }
  27427. });
  27428. }
  27429. }
  27430. function init_cache(cache) {
  27431. if (!cache) return;
  27432. if (!("props" in cache)) {
  27433. cache.props = new Map();
  27434. } else if (!(cache.props instanceof Map)) {
  27435. cache.props = map_from_object(cache.props);
  27436. }
  27437. }
  27438. function cache_to_json(cache) {
  27439. return {
  27440. props: map_to_object(cache.props)
  27441. };
  27442. }
  27443. function log_input(files, options, fs, debug_folder) {
  27444. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  27445. return;
  27446. }
  27447. try {
  27448. fs.mkdirSync(debug_folder);
  27449. } catch (e) {
  27450. if (e.code !== "EEXIST") throw e;
  27451. }
  27452. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  27453. options = options || {};
  27454. const options_str = JSON.stringify(options, (_key, thing) => {
  27455. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  27456. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  27457. return thing;
  27458. }, 4);
  27459. const files_str = (file) => {
  27460. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  27461. return JSON.stringify(file, null, 2);
  27462. } else if (typeof file === "object") {
  27463. return Object.keys(file)
  27464. .map((key) => key + ": " + files_str(file[key]))
  27465. .join("\n\n");
  27466. } else if (typeof file === "string") {
  27467. return "```\n" + file + "\n```";
  27468. } else {
  27469. return file; // What do?
  27470. }
  27471. };
  27472. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  27473. }
  27474. async function minify(files, options, _fs_module) {
  27475. if (
  27476. _fs_module
  27477. && typeof process === "object"
  27478. && process.env
  27479. && typeof process.env.TERSER_DEBUG_DIR === "string"
  27480. ) {
  27481. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  27482. }
  27483. options = defaults(options, {
  27484. compress: {},
  27485. ecma: undefined,
  27486. enclose: false,
  27487. ie8: false,
  27488. keep_classnames: undefined,
  27489. keep_fnames: false,
  27490. mangle: {},
  27491. module: false,
  27492. nameCache: null,
  27493. output: null,
  27494. format: null,
  27495. parse: {},
  27496. rename: undefined,
  27497. safari10: false,
  27498. sourceMap: false,
  27499. spidermonkey: false,
  27500. timings: false,
  27501. toplevel: false,
  27502. warnings: false,
  27503. wrap: false,
  27504. }, true);
  27505. var timings = options.timings && {
  27506. start: Date.now()
  27507. };
  27508. if (options.keep_classnames === undefined) {
  27509. options.keep_classnames = options.keep_fnames;
  27510. }
  27511. if (options.rename === undefined) {
  27512. options.rename = options.compress && options.mangle;
  27513. }
  27514. if (options.output && options.format) {
  27515. throw new Error("Please only specify either output or format option, preferrably format.");
  27516. }
  27517. options.format = options.format || options.output || {};
  27518. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  27519. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  27520. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  27521. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  27522. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  27523. set_shorthand("safari10", options, [ "mangle", "format" ]);
  27524. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  27525. set_shorthand("warnings", options, [ "compress" ]); // legacy
  27526. var quoted_props;
  27527. if (options.mangle) {
  27528. options.mangle = defaults(options.mangle, {
  27529. cache: options.nameCache && (options.nameCache.vars || {}),
  27530. eval: false,
  27531. ie8: false,
  27532. keep_classnames: false,
  27533. keep_fnames: false,
  27534. module: false,
  27535. nth_identifier: base54,
  27536. properties: false,
  27537. reserved: [],
  27538. safari10: false,
  27539. toplevel: false,
  27540. }, true);
  27541. if (options.mangle.properties) {
  27542. if (typeof options.mangle.properties != "object") {
  27543. options.mangle.properties = {};
  27544. }
  27545. if (options.mangle.properties.keep_quoted) {
  27546. quoted_props = options.mangle.properties.reserved;
  27547. if (!Array.isArray(quoted_props)) quoted_props = [];
  27548. options.mangle.properties.reserved = quoted_props;
  27549. }
  27550. if (options.nameCache && !("cache" in options.mangle.properties)) {
  27551. options.mangle.properties.cache = options.nameCache.props || {};
  27552. }
  27553. }
  27554. init_cache(options.mangle.cache);
  27555. init_cache(options.mangle.properties.cache);
  27556. }
  27557. if (options.sourceMap) {
  27558. options.sourceMap = defaults(options.sourceMap, {
  27559. asObject: false,
  27560. content: null,
  27561. filename: null,
  27562. includeSources: false,
  27563. root: null,
  27564. url: null,
  27565. }, true);
  27566. }
  27567. // -- Parse phase --
  27568. if (timings) timings.parse = Date.now();
  27569. var toplevel;
  27570. if (files instanceof AST_Toplevel) {
  27571. toplevel = files;
  27572. } else {
  27573. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  27574. files = [ files ];
  27575. }
  27576. options.parse = options.parse || {};
  27577. options.parse.toplevel = null;
  27578. if (options.parse.spidermonkey) {
  27579. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  27580. if (!toplevel) return files[name];
  27581. toplevel.body = toplevel.body.concat(files[name].body);
  27582. return toplevel;
  27583. }, null));
  27584. } else {
  27585. delete options.parse.spidermonkey;
  27586. for (var name in files) if (HOP(files, name)) {
  27587. options.parse.filename = name;
  27588. options.parse.toplevel = parse(files[name], options.parse);
  27589. if (options.sourceMap && options.sourceMap.content == "inline") {
  27590. if (Object.keys(files).length > 1)
  27591. throw new Error("inline source map only works with singular input");
  27592. options.sourceMap.content = read_source_map(files[name]);
  27593. }
  27594. }
  27595. }
  27596. toplevel = options.parse.toplevel;
  27597. }
  27598. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  27599. reserve_quoted_keys(toplevel, quoted_props);
  27600. }
  27601. if (options.wrap) {
  27602. toplevel = toplevel.wrap_commonjs(options.wrap);
  27603. }
  27604. if (options.enclose) {
  27605. toplevel = toplevel.wrap_enclose(options.enclose);
  27606. }
  27607. if (timings) timings.rename = Date.now();
  27608. // -- Compress phase --
  27609. if (timings) timings.compress = Date.now();
  27610. if (options.compress) {
  27611. toplevel = new Compressor(options.compress, {
  27612. mangle_options: options.mangle
  27613. }).compress(toplevel);
  27614. }
  27615. // -- Mangle phase --
  27616. if (timings) timings.scope = Date.now();
  27617. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  27618. if (timings) timings.mangle = Date.now();
  27619. if (options.mangle) {
  27620. toplevel.compute_char_frequency(options.mangle);
  27621. toplevel.mangle_names(options.mangle);
  27622. toplevel = mangle_private_properties(toplevel, options.mangle);
  27623. }
  27624. if (timings) timings.properties = Date.now();
  27625. if (options.mangle && options.mangle.properties) {
  27626. toplevel = mangle_properties(toplevel, options.mangle.properties);
  27627. }
  27628. // Format phase
  27629. if (timings) timings.format = Date.now();
  27630. var result = {};
  27631. if (options.format.ast) {
  27632. result.ast = toplevel;
  27633. }
  27634. if (options.format.spidermonkey) {
  27635. result.ast = toplevel.to_mozilla_ast();
  27636. }
  27637. if (!HOP(options.format, "code") || options.format.code) {
  27638. if (!options.format.ast) {
  27639. // Destroy stuff to save RAM. (unless the deprecated `ast` option is on)
  27640. options.format._destroy_ast = true;
  27641. walk(toplevel, node => {
  27642. if (node instanceof AST_Scope) {
  27643. node.variables = undefined;
  27644. node.enclosed = undefined;
  27645. node.parent_scope = undefined;
  27646. }
  27647. if (node.block_scope) {
  27648. node.block_scope.variables = undefined;
  27649. node.block_scope.enclosed = undefined;
  27650. node.parent_scope = undefined;
  27651. }
  27652. });
  27653. }
  27654. if (options.sourceMap) {
  27655. if (options.sourceMap.includeSources && files instanceof AST_Toplevel) {
  27656. throw new Error("original source content unavailable");
  27657. }
  27658. options.format.source_map = await SourceMap({
  27659. file: options.sourceMap.filename,
  27660. orig: options.sourceMap.content,
  27661. root: options.sourceMap.root,
  27662. files: options.sourceMap.includeSources ? files : null,
  27663. });
  27664. }
  27665. delete options.format.ast;
  27666. delete options.format.code;
  27667. delete options.format.spidermonkey;
  27668. var stream = OutputStream(options.format);
  27669. toplevel.print(stream);
  27670. result.code = stream.get();
  27671. if (options.sourceMap) {
  27672. Object.defineProperty(result, "map", {
  27673. configurable: true,
  27674. enumerable: true,
  27675. get() {
  27676. const map = options.format.source_map.getEncoded();
  27677. return (result.map = options.sourceMap.asObject ? map : JSON.stringify(map));
  27678. },
  27679. set(value) {
  27680. Object.defineProperty(result, "map", {
  27681. value,
  27682. writable: true,
  27683. });
  27684. }
  27685. });
  27686. result.decoded_map = options.format.source_map.getDecoded();
  27687. if (options.sourceMap.url == "inline") {
  27688. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  27689. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  27690. } else if (options.sourceMap.url) {
  27691. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  27692. }
  27693. }
  27694. }
  27695. if (options.nameCache && options.mangle) {
  27696. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  27697. if (options.mangle.properties && options.mangle.properties.cache) {
  27698. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  27699. }
  27700. }
  27701. if (options.format && options.format.source_map) {
  27702. options.format.source_map.destroy();
  27703. }
  27704. if (timings) {
  27705. timings.end = Date.now();
  27706. result.timings = {
  27707. parse: 1e-3 * (timings.rename - timings.parse),
  27708. rename: 1e-3 * (timings.compress - timings.rename),
  27709. compress: 1e-3 * (timings.scope - timings.compress),
  27710. scope: 1e-3 * (timings.mangle - timings.scope),
  27711. mangle: 1e-3 * (timings.properties - timings.mangle),
  27712. properties: 1e-3 * (timings.format - timings.properties),
  27713. format: 1e-3 * (timings.end - timings.format),
  27714. total: 1e-3 * (timings.end - timings.start)
  27715. };
  27716. }
  27717. return result;
  27718. }
  27719. async function run_cli({ program, packageJson, fs, path }) {
  27720. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  27721. var files = {};
  27722. var options = {
  27723. compress: false,
  27724. mangle: false
  27725. };
  27726. const default_options = await _default_options();
  27727. program.version(packageJson.name + " " + packageJson.version);
  27728. program.parseArgv = program.parse;
  27729. program.parse = undefined;
  27730. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  27731. else if (process.argv.includes("options")) program.helpInformation = function() {
  27732. var text = [];
  27733. for (var option in default_options) {
  27734. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  27735. text.push(format_object(default_options[option]));
  27736. text.push("");
  27737. }
  27738. return text.join("\n");
  27739. };
  27740. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  27741. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  27742. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  27743. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  27744. program.option("-f, --format [options]", "Format options.", parse_js());
  27745. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  27746. program.option("-o, --output <file>", "Output file (default STDOUT).");
  27747. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  27748. program.option("--config-file <file>", "Read minify() options from JSON file.");
  27749. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  27750. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  27751. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  27752. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  27753. program.option("--keep-classnames", "Do not mangle/drop class names.");
  27754. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  27755. program.option("--module", "Input is an ES6 module");
  27756. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  27757. program.option("--rename", "Force symbol expansion.");
  27758. program.option("--no-rename", "Disable symbol expansion.");
  27759. program.option("--safari10", "Support non-standard Safari 10.");
  27760. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  27761. program.option("--timings", "Display operations run time on STDERR.");
  27762. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  27763. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  27764. program.arguments("[files...]").parseArgv(process.argv);
  27765. if (program.configFile) {
  27766. options = JSON.parse(read_file(program.configFile));
  27767. }
  27768. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  27769. fatal("ERROR: cannot write source map to STDOUT");
  27770. }
  27771. [
  27772. "compress",
  27773. "enclose",
  27774. "ie8",
  27775. "mangle",
  27776. "module",
  27777. "safari10",
  27778. "sourceMap",
  27779. "toplevel",
  27780. "wrap"
  27781. ].forEach(function(name) {
  27782. if (name in program) {
  27783. options[name] = program[name];
  27784. }
  27785. });
  27786. if ("ecma" in program) {
  27787. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  27788. const ecma = program.ecma | 0;
  27789. if (ecma > 5 && ecma < 2015)
  27790. options.ecma = ecma + 2009;
  27791. else
  27792. options.ecma = ecma;
  27793. }
  27794. if (program.format || program.beautify) {
  27795. const chosenOption = program.format || program.beautify;
  27796. options.format = typeof chosenOption === "object" ? chosenOption : {};
  27797. }
  27798. if (program.comments) {
  27799. if (typeof options.format != "object") options.format = {};
  27800. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  27801. }
  27802. if (program.define) {
  27803. if (typeof options.compress != "object") options.compress = {};
  27804. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  27805. for (var expr in program.define) {
  27806. options.compress.global_defs[expr] = program.define[expr];
  27807. }
  27808. }
  27809. if (program.keepClassnames) {
  27810. options.keep_classnames = true;
  27811. }
  27812. if (program.keepFnames) {
  27813. options.keep_fnames = true;
  27814. }
  27815. if (program.mangleProps) {
  27816. if (program.mangleProps.domprops) {
  27817. delete program.mangleProps.domprops;
  27818. } else {
  27819. if (typeof program.mangleProps != "object") program.mangleProps = {};
  27820. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  27821. }
  27822. if (typeof options.mangle != "object") options.mangle = {};
  27823. options.mangle.properties = program.mangleProps;
  27824. }
  27825. if (program.nameCache) {
  27826. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  27827. }
  27828. if (program.output == "ast") {
  27829. options.format = {
  27830. ast: true,
  27831. code: false
  27832. };
  27833. }
  27834. if (program.parse) {
  27835. if (!program.parse.acorn && !program.parse.spidermonkey) {
  27836. options.parse = program.parse;
  27837. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  27838. fatal("ERROR: inline source map only works with built-in parser");
  27839. }
  27840. }
  27841. if (~program.rawArgs.indexOf("--rename")) {
  27842. options.rename = true;
  27843. } else if (!program.rename) {
  27844. options.rename = false;
  27845. }
  27846. let convert_path = name => name;
  27847. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  27848. convert_path = function() {
  27849. var base = program.sourceMap.base;
  27850. delete options.sourceMap.base;
  27851. return function(name) {
  27852. return path.relative(base, name);
  27853. };
  27854. }();
  27855. }
  27856. let filesList;
  27857. if (options.files && options.files.length) {
  27858. filesList = options.files;
  27859. delete options.files;
  27860. } else if (program.args.length) {
  27861. filesList = program.args;
  27862. }
  27863. if (filesList) {
  27864. simple_glob(filesList).forEach(function(name) {
  27865. files[convert_path(name)] = read_file(name);
  27866. });
  27867. } else {
  27868. await new Promise((resolve) => {
  27869. var chunks = [];
  27870. process.stdin.setEncoding("utf8");
  27871. process.stdin.on("data", function(chunk) {
  27872. chunks.push(chunk);
  27873. }).on("end", function() {
  27874. files = [ chunks.join("") ];
  27875. resolve();
  27876. });
  27877. process.stdin.resume();
  27878. });
  27879. }
  27880. await run_cli();
  27881. function convert_ast(fn) {
  27882. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  27883. }
  27884. async function run_cli() {
  27885. var content = program.sourceMap && program.sourceMap.content;
  27886. if (content && content !== "inline") {
  27887. options.sourceMap.content = read_file(content, content);
  27888. }
  27889. if (program.timings) options.timings = true;
  27890. try {
  27891. if (program.parse) {
  27892. if (program.parse.acorn) {
  27893. files = convert_ast(function(toplevel, name) {
  27894. return require("acorn").parse(files[name], {
  27895. ecmaVersion: 2018,
  27896. locations: true,
  27897. program: toplevel,
  27898. sourceFile: name,
  27899. sourceType: options.module || program.parse.module ? "module" : "script"
  27900. });
  27901. });
  27902. } else if (program.parse.spidermonkey) {
  27903. files = convert_ast(function(toplevel, name) {
  27904. var obj = JSON.parse(files[name]);
  27905. if (!toplevel) return obj;
  27906. toplevel.body = toplevel.body.concat(obj.body);
  27907. return toplevel;
  27908. });
  27909. }
  27910. }
  27911. } catch (ex) {
  27912. fatal(ex);
  27913. }
  27914. let result;
  27915. try {
  27916. result = await minify(files, options, fs);
  27917. } catch (ex) {
  27918. if (ex.name == "SyntaxError") {
  27919. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  27920. var col = ex.col;
  27921. var lines = files[ex.filename].split(/\r?\n/);
  27922. var line = lines[ex.line - 1];
  27923. if (!line && !col) {
  27924. line = lines[ex.line - 2];
  27925. col = line.length;
  27926. }
  27927. if (line) {
  27928. var limit = 70;
  27929. if (col > limit) {
  27930. line = line.slice(col - limit);
  27931. col = limit;
  27932. }
  27933. print_error(line.slice(0, 80));
  27934. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  27935. }
  27936. }
  27937. if (ex.defs) {
  27938. print_error("Supported options:");
  27939. print_error(format_object(ex.defs));
  27940. }
  27941. fatal(ex);
  27942. return;
  27943. }
  27944. if (program.output == "ast") {
  27945. if (!options.compress && !options.mangle) {
  27946. result.ast.figure_out_scope({});
  27947. }
  27948. console.log(JSON.stringify(result.ast, function(key, value) {
  27949. if (value) switch (key) {
  27950. case "thedef":
  27951. return symdef(value);
  27952. case "enclosed":
  27953. return value.length ? value.map(symdef) : undefined;
  27954. case "variables":
  27955. case "globals":
  27956. return value.size ? collect_from_map(value, symdef) : undefined;
  27957. }
  27958. if (skip_keys.has(key)) return;
  27959. if (value instanceof AST_Token) return;
  27960. if (value instanceof Map) return;
  27961. if (value instanceof AST_Node) {
  27962. var result = {
  27963. _class: "AST_" + value.TYPE
  27964. };
  27965. if (value.block_scope) {
  27966. result.variables = value.block_scope.variables;
  27967. result.enclosed = value.block_scope.enclosed;
  27968. }
  27969. value.CTOR.PROPS.forEach(function(prop) {
  27970. if (prop !== "block_scope") {
  27971. result[prop] = value[prop];
  27972. }
  27973. });
  27974. return result;
  27975. }
  27976. return value;
  27977. }, 2));
  27978. } else if (program.output == "spidermonkey") {
  27979. try {
  27980. const minified = await minify(
  27981. result.code,
  27982. {
  27983. compress: false,
  27984. mangle: false,
  27985. format: {
  27986. ast: true,
  27987. code: false
  27988. }
  27989. },
  27990. fs
  27991. );
  27992. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  27993. } catch (ex) {
  27994. fatal(ex);
  27995. return;
  27996. }
  27997. } else if (program.output) {
  27998. fs.writeFileSync(program.output, result.code);
  27999. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  28000. fs.writeFileSync(program.output + ".map", result.map);
  28001. }
  28002. } else {
  28003. console.log(result.code);
  28004. }
  28005. if (program.nameCache) {
  28006. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  28007. }
  28008. if (result.timings) for (var phase in result.timings) {
  28009. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  28010. }
  28011. }
  28012. function fatal(message) {
  28013. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  28014. print_error(message);
  28015. process.exit(1);
  28016. }
  28017. // A file glob function that only supports "*" and "?" wildcards in the basename.
  28018. // Example: "foo/bar/*baz??.*.js"
  28019. // Argument `glob` may be a string or an array of strings.
  28020. // Returns an array of strings. Garbage in, garbage out.
  28021. function simple_glob(glob) {
  28022. if (Array.isArray(glob)) {
  28023. return [].concat.apply([], glob.map(simple_glob));
  28024. }
  28025. if (glob && glob.match(/[*?]/)) {
  28026. var dir = path.dirname(glob);
  28027. try {
  28028. var entries = fs.readdirSync(dir);
  28029. } catch (ex) {}
  28030. if (entries) {
  28031. var pattern = "^" + path.basename(glob)
  28032. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  28033. .replace(/\*/g, "[^/\\\\]*")
  28034. .replace(/\?/g, "[^/\\\\]") + "$";
  28035. var mod = process.platform === "win32" ? "i" : "";
  28036. var rx = new RegExp(pattern, mod);
  28037. var results = entries.filter(function(name) {
  28038. return rx.test(name);
  28039. }).map(function(name) {
  28040. return path.join(dir, name);
  28041. });
  28042. if (results.length) return results;
  28043. }
  28044. }
  28045. return [ glob ];
  28046. }
  28047. function read_file(path, default_value) {
  28048. try {
  28049. return fs.readFileSync(path, "utf8");
  28050. } catch (ex) {
  28051. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  28052. fatal(ex);
  28053. }
  28054. }
  28055. function parse_js(flag) {
  28056. return function(value, options) {
  28057. options = options || {};
  28058. try {
  28059. walk(parse(value, { expression: true }), node => {
  28060. if (node instanceof AST_Assign) {
  28061. var name = node.left.print_to_string();
  28062. var value = node.right;
  28063. if (flag) {
  28064. options[name] = value;
  28065. } else if (value instanceof AST_Array) {
  28066. options[name] = value.elements.map(to_string);
  28067. } else if (value instanceof AST_RegExp) {
  28068. value = value.value;
  28069. options[name] = new RegExp(value.source, value.flags);
  28070. } else {
  28071. options[name] = to_string(value);
  28072. }
  28073. return true;
  28074. }
  28075. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  28076. var name = node.print_to_string();
  28077. options[name] = true;
  28078. return true;
  28079. }
  28080. if (!(node instanceof AST_Sequence)) throw node;
  28081. function to_string(value) {
  28082. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  28083. quote_keys: true
  28084. });
  28085. }
  28086. });
  28087. } catch(ex) {
  28088. if (flag) {
  28089. fatal("Error parsing arguments for '" + flag + "': " + value);
  28090. } else {
  28091. options[value] = null;
  28092. }
  28093. }
  28094. return options;
  28095. };
  28096. }
  28097. function symdef(def) {
  28098. var ret = (1e6 + def.id) + " " + def.name;
  28099. if (def.mangled_name) ret += " " + def.mangled_name;
  28100. return ret;
  28101. }
  28102. function collect_from_map(map, callback) {
  28103. var result = [];
  28104. map.forEach(function (def) {
  28105. result.push(callback(def));
  28106. });
  28107. return result;
  28108. }
  28109. function format_object(obj) {
  28110. var lines = [];
  28111. var padding = "";
  28112. Object.keys(obj).map(function(name) {
  28113. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  28114. return [ name, JSON.stringify(obj[name]) ];
  28115. }).forEach(function(tokens) {
  28116. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  28117. });
  28118. return lines.join("\n");
  28119. }
  28120. function print_error(msg) {
  28121. process.stderr.write(msg);
  28122. process.stderr.write("\n");
  28123. }
  28124. function describe_ast() {
  28125. var out = OutputStream({ beautify: true });
  28126. function doitem(ctor) {
  28127. out.print("AST_" + ctor.TYPE);
  28128. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  28129. if (props.length > 0) {
  28130. out.space();
  28131. out.with_parens(function() {
  28132. props.forEach(function(prop, i) {
  28133. if (i) out.space();
  28134. out.print(prop);
  28135. });
  28136. });
  28137. }
  28138. if (ctor.documentation) {
  28139. out.space();
  28140. out.print_string(ctor.documentation);
  28141. }
  28142. if (ctor.SUBCLASSES.length > 0) {
  28143. out.space();
  28144. out.with_block(function() {
  28145. ctor.SUBCLASSES.forEach(function(ctor) {
  28146. out.indent();
  28147. doitem(ctor);
  28148. out.newline();
  28149. });
  28150. });
  28151. }
  28152. }
  28153. doitem(AST_Node);
  28154. return out + "\n";
  28155. }
  28156. }
  28157. async function _default_options() {
  28158. const defs = {};
  28159. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  28160. const options = infer_options({
  28161. [component]: {0: 0}
  28162. });
  28163. if (options) defs[component] = options;
  28164. });
  28165. return defs;
  28166. }
  28167. async function infer_options(options) {
  28168. try {
  28169. await minify("", options);
  28170. } catch (error) {
  28171. return error.defs;
  28172. }
  28173. }
  28174. exports._default_options = _default_options;
  28175. exports._run_cli = run_cli;
  28176. exports.minify = minify;
  28177. })));