bundle.min.js 836 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('source-map')) :
  3. typeof define === 'function' && define.amd ? define(['exports', 'source-map'], factory) :
  4. (global = global || self, factory(global.Terser = {}, global.sourceMap));
  5. }(this, (function (exports, MOZ_SourceMap) { 'use strict';
  6. MOZ_SourceMap = MOZ_SourceMap && Object.prototype.hasOwnProperty.call(MOZ_SourceMap, 'default') ? MOZ_SourceMap['default'] : MOZ_SourceMap;
  7. /***********************************************************************
  8. A JavaScript tokenizer / parser / beautifier / compressor.
  9. https://github.com/mishoo/UglifyJS2
  10. -------------------------------- (C) ---------------------------------
  11. Author: Mihai Bazon
  12. <mihai.bazon@gmail.com>
  13. http://mihai.bazon.net/blog
  14. Distributed under the BSD license:
  15. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16. Redistribution and use in source and binary forms, with or without
  17. modification, are permitted provided that the following conditions
  18. are met:
  19. * Redistributions of source code must retain the above
  20. copyright notice, this list of conditions and the following
  21. disclaimer.
  22. * Redistributions in binary form must reproduce the above
  23. copyright notice, this list of conditions and the following
  24. disclaimer in the documentation and/or other materials
  25. provided with the distribution.
  26. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  27. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  30. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  31. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  32. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  33. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  34. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  35. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  36. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  37. SUCH DAMAGE.
  38. ***********************************************************************/
  39. function characters(str) {
  40. return str.split("");
  41. }
  42. function member(name, array) {
  43. return array.includes(name);
  44. }
  45. class DefaultsError extends Error {
  46. constructor(msg, defs) {
  47. super();
  48. this.name = "DefaultsError";
  49. this.message = msg;
  50. this.defs = defs;
  51. }
  52. }
  53. function defaults(args, defs, croak) {
  54. if (args === true) {
  55. args = {};
  56. }
  57. if (args != null && typeof args === "object") {
  58. args = Object.assign({}, args);
  59. }
  60. const ret = args || {};
  61. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  62. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  63. }
  64. for (const i in defs) if (HOP(defs, i)) {
  65. if (!args || !HOP(args, i)) {
  66. ret[i] = defs[i];
  67. } else if (i === "ecma") {
  68. let ecma = args[i] | 0;
  69. if (ecma > 5 && ecma < 2015) ecma += 2009;
  70. ret[i] = ecma;
  71. } else {
  72. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  73. }
  74. }
  75. return ret;
  76. }
  77. function noop() {}
  78. function return_false() { return false; }
  79. function return_true() { return true; }
  80. function return_this() { return this; }
  81. function return_null() { return null; }
  82. var MAP = (function() {
  83. function MAP(a, f, backwards) {
  84. var ret = [], top = [], i;
  85. function doit() {
  86. var val = f(a[i], i);
  87. var is_last = val instanceof Last;
  88. if (is_last) val = val.v;
  89. if (val instanceof AtTop) {
  90. val = val.v;
  91. if (val instanceof Splice) {
  92. top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
  93. } else {
  94. top.push(val);
  95. }
  96. } else if (val !== skip) {
  97. if (val instanceof Splice) {
  98. ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
  99. } else {
  100. ret.push(val);
  101. }
  102. }
  103. return is_last;
  104. }
  105. if (Array.isArray(a)) {
  106. if (backwards) {
  107. for (i = a.length; --i >= 0;) if (doit()) break;
  108. ret.reverse();
  109. top.reverse();
  110. } else {
  111. for (i = 0; i < a.length; ++i) if (doit()) break;
  112. }
  113. } else {
  114. for (i in a) if (HOP(a, i)) if (doit()) break;
  115. }
  116. return top.concat(ret);
  117. }
  118. MAP.at_top = function(val) { return new AtTop(val); };
  119. MAP.splice = function(val) { return new Splice(val); };
  120. MAP.last = function(val) { return new Last(val); };
  121. var skip = MAP.skip = {};
  122. function AtTop(val) { this.v = val; }
  123. function Splice(val) { this.v = val; }
  124. function Last(val) { this.v = val; }
  125. return MAP;
  126. })();
  127. function make_node(ctor, orig, props) {
  128. if (!props) props = {};
  129. if (orig) {
  130. if (!props.start) props.start = orig.start;
  131. if (!props.end) props.end = orig.end;
  132. }
  133. return new ctor(props);
  134. }
  135. function push_uniq(array, el) {
  136. if (!array.includes(el))
  137. array.push(el);
  138. }
  139. function string_template(text, props) {
  140. return text.replace(/{(.+?)}/g, function(str, p) {
  141. return props && props[p];
  142. });
  143. }
  144. function remove(array, el) {
  145. for (var i = array.length; --i >= 0;) {
  146. if (array[i] === el) array.splice(i, 1);
  147. }
  148. }
  149. function mergeSort(array, cmp) {
  150. if (array.length < 2) return array.slice();
  151. function merge(a, b) {
  152. var r = [], ai = 0, bi = 0, i = 0;
  153. while (ai < a.length && bi < b.length) {
  154. cmp(a[ai], b[bi]) <= 0
  155. ? r[i++] = a[ai++]
  156. : r[i++] = b[bi++];
  157. }
  158. if (ai < a.length) r.push.apply(r, a.slice(ai));
  159. if (bi < b.length) r.push.apply(r, b.slice(bi));
  160. return r;
  161. }
  162. function _ms(a) {
  163. if (a.length <= 1)
  164. return a;
  165. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  166. left = _ms(left);
  167. right = _ms(right);
  168. return merge(left, right);
  169. }
  170. return _ms(array);
  171. }
  172. function makePredicate(words) {
  173. if (!Array.isArray(words)) words = words.split(" ");
  174. return new Set(words);
  175. }
  176. function map_add(map, key, value) {
  177. if (map.has(key)) {
  178. map.get(key).push(value);
  179. } else {
  180. map.set(key, [ value ]);
  181. }
  182. }
  183. function map_from_object(obj) {
  184. var map = new Map();
  185. for (var key in obj) {
  186. if (HOP(obj, key) && key.charAt(0) === "$") {
  187. map.set(key.substr(1), obj[key]);
  188. }
  189. }
  190. return map;
  191. }
  192. function map_to_object(map) {
  193. var obj = Object.create(null);
  194. map.forEach(function (value, key) {
  195. obj["$" + key] = value;
  196. });
  197. return obj;
  198. }
  199. function HOP(obj, prop) {
  200. return Object.prototype.hasOwnProperty.call(obj, prop);
  201. }
  202. function keep_name(keep_setting, name) {
  203. return keep_setting === true
  204. || (keep_setting instanceof RegExp && keep_setting.test(name));
  205. }
  206. var lineTerminatorEscape = {
  207. "\n": "n",
  208. "\r": "r",
  209. "\u2028": "u2028",
  210. "\u2029": "u2029",
  211. };
  212. function regexp_source_fix(source) {
  213. // V8 does not escape line terminators in regexp patterns in node 12
  214. return source.replace(/[\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. const all_flags = "gimuy";
  222. function sort_regexp_flags(flags) {
  223. const existing_flags = new Set(flags.split(""));
  224. let out = "";
  225. for (const flag of all_flags) {
  226. if (existing_flags.has(flag)) {
  227. out += flag;
  228. existing_flags.delete(flag);
  229. }
  230. }
  231. if (existing_flags.size) {
  232. // Flags Terser doesn't know about
  233. existing_flags.forEach(flag => { out += flag; });
  234. }
  235. return out;
  236. }
  237. function has_annotation(node, annotation) {
  238. return node._annotations & annotation;
  239. }
  240. function set_annotation(node, annotation) {
  241. node._annotations |= annotation;
  242. }
  243. /***********************************************************************
  244. A JavaScript tokenizer / parser / beautifier / compressor.
  245. https://github.com/mishoo/UglifyJS2
  246. -------------------------------- (C) ---------------------------------
  247. Author: Mihai Bazon
  248. <mihai.bazon@gmail.com>
  249. http://mihai.bazon.net/blog
  250. Distributed under the BSD license:
  251. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  252. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  253. Redistribution and use in source and binary forms, with or without
  254. modification, are permitted provided that the following conditions
  255. are met:
  256. * Redistributions of source code must retain the above
  257. copyright notice, this list of conditions and the following
  258. disclaimer.
  259. * Redistributions in binary form must reproduce the above
  260. copyright notice, this list of conditions and the following
  261. disclaimer in the documentation and/or other materials
  262. provided with the distribution.
  263. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  264. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  265. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  266. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  267. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  268. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  269. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  270. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  271. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  272. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  273. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  274. SUCH DAMAGE.
  275. ***********************************************************************/
  276. 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";
  277. var KEYWORDS_ATOM = "false null true";
  278. var RESERVED_WORDS = "enum implements import interface package private protected public static super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  279. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  280. KEYWORDS = makePredicate(KEYWORDS);
  281. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  282. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  283. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  284. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  285. var RE_NUM_LITERAL = /[0-9a-f]/i;
  286. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  287. var RE_OCT_NUMBER = /^0[0-7]+$/;
  288. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  289. var RE_BIN_NUMBER = /^0b[01]+$/i;
  290. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  291. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  292. var OPERATORS = makePredicate([
  293. "in",
  294. "instanceof",
  295. "typeof",
  296. "new",
  297. "void",
  298. "delete",
  299. "++",
  300. "--",
  301. "+",
  302. "-",
  303. "!",
  304. "~",
  305. "&",
  306. "|",
  307. "^",
  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. 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"));
  342. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  343. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  344. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  345. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  346. /* -----[ Tokenizer ]----- */
  347. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  348. var UNICODE = {
  349. 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]/,
  350. 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])+/,
  351. };
  352. function get_full_char(str, pos) {
  353. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  354. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  355. return str.charAt(pos) + str.charAt(pos + 1);
  356. }
  357. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  358. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  359. return str.charAt(pos - 1) + str.charAt(pos);
  360. }
  361. }
  362. return str.charAt(pos);
  363. }
  364. function get_full_char_code(str, pos) {
  365. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  366. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  367. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  368. }
  369. return str.charCodeAt(pos);
  370. }
  371. function get_full_char_length(str) {
  372. var surrogates = 0;
  373. for (var i = 0; i < str.length; i++) {
  374. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  375. surrogates++;
  376. i++;
  377. }
  378. }
  379. return str.length - surrogates;
  380. }
  381. function from_char_code(code) {
  382. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  383. if (code > 0xFFFF) {
  384. code -= 0x10000;
  385. return (String.fromCharCode((code >> 10) + 0xD800) +
  386. String.fromCharCode((code % 0x400) + 0xDC00));
  387. }
  388. return String.fromCharCode(code);
  389. }
  390. function is_surrogate_pair_head(code) {
  391. return code >= 0xd800 && code <= 0xdbff;
  392. }
  393. function is_surrogate_pair_tail(code) {
  394. return code >= 0xdc00 && code <= 0xdfff;
  395. }
  396. function is_digit(code) {
  397. return code >= 48 && code <= 57;
  398. }
  399. function is_identifier_start(ch) {
  400. return UNICODE.ID_Start.test(ch);
  401. }
  402. function is_identifier_char(ch) {
  403. return UNICODE.ID_Continue.test(ch);
  404. }
  405. function is_basic_identifier_string(str) {
  406. return /^[a-z_$][a-z0-9_$]*$/i.test(str);
  407. }
  408. function is_identifier_string(str, allow_surrogates) {
  409. if (/^[a-z_$][a-z0-9_$]*$/i.test(str)) {
  410. return true;
  411. }
  412. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  413. return false;
  414. }
  415. var match = UNICODE.ID_Start.exec(str);
  416. if (!match || match.index !== 0) {
  417. return false;
  418. }
  419. str = str.slice(match[0].length);
  420. if (!str) {
  421. return true;
  422. }
  423. match = UNICODE.ID_Continue.exec(str);
  424. return !!match && match[0].length === str.length;
  425. }
  426. function parse_js_number(num, allow_e = true) {
  427. if (!allow_e && num.includes("e")) {
  428. return NaN;
  429. }
  430. if (RE_HEX_NUMBER.test(num)) {
  431. return parseInt(num.substr(2), 16);
  432. } else if (RE_OCT_NUMBER.test(num)) {
  433. return parseInt(num.substr(1), 8);
  434. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  435. return parseInt(num.substr(2), 8);
  436. } else if (RE_BIN_NUMBER.test(num)) {
  437. return parseInt(num.substr(2), 2);
  438. } else if (RE_DEC_NUMBER.test(num)) {
  439. return parseFloat(num);
  440. } else {
  441. var val = parseFloat(num);
  442. if (val == num) return val;
  443. }
  444. }
  445. class JS_Parse_Error extends Error {
  446. constructor(message, filename, line, col, pos) {
  447. super();
  448. this.name = "SyntaxError";
  449. this.message = message;
  450. this.filename = filename;
  451. this.line = line;
  452. this.col = col;
  453. this.pos = pos;
  454. }
  455. }
  456. function js_error(message, filename, line, col, pos) {
  457. throw new JS_Parse_Error(message, filename, line, col, pos);
  458. }
  459. function is_token(token, type, val) {
  460. return token.type == type && (val == null || token.value == val);
  461. }
  462. var EX_EOF = {};
  463. function tokenizer($TEXT, filename, html5_comments, shebang) {
  464. var S = {
  465. text : $TEXT,
  466. filename : filename,
  467. pos : 0,
  468. tokpos : 0,
  469. line : 1,
  470. tokline : 0,
  471. col : 0,
  472. tokcol : 0,
  473. newline_before : false,
  474. regex_allowed : false,
  475. brace_counter : 0,
  476. template_braces : [],
  477. comments_before : [],
  478. directives : {},
  479. directive_stack : []
  480. };
  481. function peek() { return get_full_char(S.text, S.pos); }
  482. // Used because parsing ?. involves a lookahead for a digit
  483. function is_option_chain_op() {
  484. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  485. if (!must_be_dot) return false;
  486. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  487. return cannot_be_digit < 48 || cannot_be_digit > 57;
  488. }
  489. function next(signal_eof, in_string) {
  490. var ch = get_full_char(S.text, S.pos++);
  491. if (signal_eof && !ch)
  492. throw EX_EOF;
  493. if (NEWLINE_CHARS.has(ch)) {
  494. S.newline_before = S.newline_before || !in_string;
  495. ++S.line;
  496. S.col = 0;
  497. if (ch == "\r" && peek() == "\n") {
  498. // treat a \r\n sequence as a single \n
  499. ++S.pos;
  500. ch = "\n";
  501. }
  502. } else {
  503. if (ch.length > 1) {
  504. ++S.pos;
  505. ++S.col;
  506. }
  507. ++S.col;
  508. }
  509. return ch;
  510. }
  511. function forward(i) {
  512. while (i--) next();
  513. }
  514. function looking_at(str) {
  515. return S.text.substr(S.pos, str.length) == str;
  516. }
  517. function find_eol() {
  518. var text = S.text;
  519. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  520. var ch = text[i];
  521. if (NEWLINE_CHARS.has(ch))
  522. return i;
  523. }
  524. return -1;
  525. }
  526. function find(what, signal_eof) {
  527. var pos = S.text.indexOf(what, S.pos);
  528. if (signal_eof && pos == -1) throw EX_EOF;
  529. return pos;
  530. }
  531. function start_token() {
  532. S.tokline = S.line;
  533. S.tokcol = S.col;
  534. S.tokpos = S.pos;
  535. }
  536. var prev_was_dot = false;
  537. var previous_token = null;
  538. function token(type, value, is_comment) {
  539. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  540. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  541. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  542. (type == "arrow");
  543. if (type == "punc" && (value == "." || value == "?.")) {
  544. prev_was_dot = true;
  545. } else if (!is_comment) {
  546. prev_was_dot = false;
  547. }
  548. var ret = {
  549. type : type,
  550. value : value,
  551. line : S.tokline,
  552. col : S.tokcol,
  553. pos : S.tokpos,
  554. endline : S.line,
  555. endcol : S.col,
  556. endpos : S.pos,
  557. nlb : S.newline_before,
  558. file : filename
  559. };
  560. if (/^(?:num|string|regexp)$/i.test(type)) {
  561. ret.raw = $TEXT.substring(ret.pos, ret.endpos);
  562. }
  563. if (!is_comment) {
  564. ret.comments_before = S.comments_before;
  565. ret.comments_after = S.comments_before = [];
  566. }
  567. S.newline_before = false;
  568. ret = new AST_Token(ret);
  569. if (!is_comment) previous_token = ret;
  570. return ret;
  571. }
  572. function skip_whitespace() {
  573. while (WHITESPACE_CHARS.has(peek()))
  574. next();
  575. }
  576. function read_while(pred) {
  577. var ret = "", ch, i = 0;
  578. while ((ch = peek()) && pred(ch, i++))
  579. ret += next();
  580. return ret;
  581. }
  582. function parse_error(err) {
  583. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  584. }
  585. function read_num(prefix) {
  586. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  587. var num = read_while(function(ch, i) {
  588. if (is_big_int) return false;
  589. var code = ch.charCodeAt(0);
  590. switch (code) {
  591. case 95: // _
  592. return (numeric_separator = true);
  593. case 98: case 66: // bB
  594. return (has_x = true); // Can occur in hex sequence, don't return false yet
  595. case 111: case 79: // oO
  596. case 120: case 88: // xX
  597. return has_x ? false : (has_x = true);
  598. case 101: case 69: // eE
  599. return has_x ? true : has_e ? false : (has_e = after_e = true);
  600. case 45: // -
  601. return after_e || (i == 0 && !prefix);
  602. case 43: // +
  603. return after_e;
  604. case (after_e = false, 46): // .
  605. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  606. }
  607. if (ch === "n") {
  608. is_big_int = true;
  609. return true;
  610. }
  611. return RE_NUM_LITERAL.test(ch);
  612. });
  613. if (prefix) num = prefix + num;
  614. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  615. parse_error("Legacy octal literals are not allowed in strict mode");
  616. }
  617. if (numeric_separator) {
  618. if (num.endsWith("_")) {
  619. parse_error("Numeric separators are not allowed at the end of numeric literals");
  620. } else if (num.includes("__")) {
  621. parse_error("Only one underscore is allowed as numeric separator");
  622. }
  623. num = num.replace(/_/g, "");
  624. }
  625. if (num.endsWith("n")) {
  626. const without_n = num.slice(0, -1);
  627. const allow_e = RE_HEX_NUMBER.test(without_n);
  628. const valid = parse_js_number(without_n, allow_e);
  629. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  630. return token("big_int", without_n);
  631. parse_error("Invalid or unexpected token");
  632. }
  633. var valid = parse_js_number(num);
  634. if (!isNaN(valid)) {
  635. return token("num", valid);
  636. } else {
  637. parse_error("Invalid syntax: " + num);
  638. }
  639. }
  640. function is_octal(ch) {
  641. return ch >= "0" && ch <= "7";
  642. }
  643. function read_escaped_char(in_string, strict_hex, template_string) {
  644. var ch = next(true, in_string);
  645. switch (ch.charCodeAt(0)) {
  646. case 110 : return "\n";
  647. case 114 : return "\r";
  648. case 116 : return "\t";
  649. case 98 : return "\b";
  650. case 118 : return "\u000b"; // \v
  651. case 102 : return "\f";
  652. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  653. case 117 : // \u
  654. if (peek() == "{") {
  655. next(true);
  656. if (peek() === "}")
  657. parse_error("Expecting hex-character between {}");
  658. while (peek() == "0") next(true); // No significance
  659. var result, length = find("}", true) - S.pos;
  660. // Avoid 32 bit integer overflow (1 << 32 === 1)
  661. // We know first character isn't 0 and thus out of range anyway
  662. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  663. parse_error("Unicode reference out of bounds");
  664. }
  665. next(true);
  666. return from_char_code(result);
  667. }
  668. return String.fromCharCode(hex_bytes(4, strict_hex));
  669. case 10 : return ""; // newline
  670. case 13 : // \r
  671. if (peek() == "\n") { // DOS newline
  672. next(true, in_string);
  673. return "";
  674. }
  675. }
  676. if (is_octal(ch)) {
  677. if (template_string && strict_hex) {
  678. const represents_null_character = ch === "0" && !is_octal(peek());
  679. if (!represents_null_character) {
  680. parse_error("Octal escape sequences are not allowed in template strings");
  681. }
  682. }
  683. return read_octal_escape_sequence(ch, strict_hex);
  684. }
  685. return ch;
  686. }
  687. function read_octal_escape_sequence(ch, strict_octal) {
  688. // Read
  689. var p = peek();
  690. if (p >= "0" && p <= "7") {
  691. ch += next(true);
  692. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  693. ch += next(true);
  694. }
  695. // Parse
  696. if (ch === "0") return "\0";
  697. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  698. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  699. return String.fromCharCode(parseInt(ch, 8));
  700. }
  701. function hex_bytes(n, strict_hex) {
  702. var num = 0;
  703. for (; n > 0; --n) {
  704. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  705. return parseInt(num, 16) || "";
  706. }
  707. var digit = next(true);
  708. if (isNaN(parseInt(digit, 16)))
  709. parse_error("Invalid hex-character pattern in string");
  710. num += digit;
  711. }
  712. return parseInt(num, 16);
  713. }
  714. var read_string = with_eof_error("Unterminated string constant", function() {
  715. var quote = next(), ret = "";
  716. for (;;) {
  717. var ch = next(true, true);
  718. if (ch == "\\") ch = read_escaped_char(true, true);
  719. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  720. else if (ch == quote) break;
  721. ret += ch;
  722. }
  723. var tok = token("string", ret);
  724. tok.quote = quote;
  725. return tok;
  726. });
  727. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  728. if (begin) {
  729. S.template_braces.push(S.brace_counter);
  730. }
  731. var content = "", raw = "", ch, tok;
  732. next(true, true);
  733. while ((ch = next(true, true)) != "`") {
  734. if (ch == "\r") {
  735. if (peek() == "\n") ++S.pos;
  736. ch = "\n";
  737. } else if (ch == "$" && peek() == "{") {
  738. next(true, true);
  739. S.brace_counter++;
  740. tok = token(begin ? "template_head" : "template_substitution", content);
  741. tok.raw = raw;
  742. return tok;
  743. }
  744. raw += ch;
  745. if (ch == "\\") {
  746. var tmp = S.pos;
  747. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  748. ch = read_escaped_char(true, !prev_is_tag, true);
  749. raw += S.text.substr(tmp, S.pos - tmp);
  750. }
  751. content += ch;
  752. }
  753. S.template_braces.pop();
  754. tok = token(begin ? "template_head" : "template_substitution", content);
  755. tok.raw = raw;
  756. tok.end = true;
  757. return tok;
  758. });
  759. function skip_line_comment(type) {
  760. var regex_allowed = S.regex_allowed;
  761. var i = find_eol(), ret;
  762. if (i == -1) {
  763. ret = S.text.substr(S.pos);
  764. S.pos = S.text.length;
  765. } else {
  766. ret = S.text.substring(S.pos, i);
  767. S.pos = i;
  768. }
  769. S.col = S.tokcol + (S.pos - S.tokpos);
  770. S.comments_before.push(token(type, ret, true));
  771. S.regex_allowed = regex_allowed;
  772. return next_token;
  773. }
  774. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  775. var regex_allowed = S.regex_allowed;
  776. var i = find("*/", true);
  777. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  778. // update stream position
  779. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  780. S.comments_before.push(token("comment2", text, true));
  781. S.newline_before = S.newline_before || text.includes("\n");
  782. S.regex_allowed = regex_allowed;
  783. return next_token;
  784. });
  785. var read_name = with_eof_error("Unterminated identifier name", function() {
  786. var name, ch, escaped = false;
  787. var read_escaped_identifier_char = function() {
  788. escaped = true;
  789. next();
  790. if (peek() !== "u") {
  791. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  792. }
  793. return read_escaped_char(false, true);
  794. };
  795. // Read first character (ID_Start)
  796. if ((name = peek()) === "\\") {
  797. name = read_escaped_identifier_char();
  798. if (!is_identifier_start(name)) {
  799. parse_error("First identifier char is an invalid identifier char");
  800. }
  801. } else if (is_identifier_start(name)) {
  802. next();
  803. } else {
  804. return "";
  805. }
  806. // Read ID_Continue
  807. while ((ch = peek()) != null) {
  808. if ((ch = peek()) === "\\") {
  809. ch = read_escaped_identifier_char();
  810. if (!is_identifier_char(ch)) {
  811. parse_error("Invalid escaped identifier char");
  812. }
  813. } else {
  814. if (!is_identifier_char(ch)) {
  815. break;
  816. }
  817. next();
  818. }
  819. name += ch;
  820. }
  821. if (RESERVED_WORDS.has(name) && escaped) {
  822. parse_error("Escaped characters are not allowed in keywords");
  823. }
  824. return name;
  825. });
  826. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  827. var prev_backslash = false, ch, in_class = false;
  828. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  829. parse_error("Unexpected line terminator");
  830. } else if (prev_backslash) {
  831. source += "\\" + ch;
  832. prev_backslash = false;
  833. } else if (ch == "[") {
  834. in_class = true;
  835. source += ch;
  836. } else if (ch == "]" && in_class) {
  837. in_class = false;
  838. source += ch;
  839. } else if (ch == "/" && !in_class) {
  840. break;
  841. } else if (ch == "\\") {
  842. prev_backslash = true;
  843. } else {
  844. source += ch;
  845. }
  846. const flags = read_name();
  847. return token("regexp", { source, flags });
  848. });
  849. function read_operator(prefix) {
  850. function grow(op) {
  851. if (!peek()) return op;
  852. var bigger = op + peek();
  853. if (OPERATORS.has(bigger)) {
  854. next();
  855. return grow(bigger);
  856. } else {
  857. return op;
  858. }
  859. }
  860. return token("operator", grow(prefix || next()));
  861. }
  862. function handle_slash() {
  863. next();
  864. switch (peek()) {
  865. case "/":
  866. next();
  867. return skip_line_comment("comment1");
  868. case "*":
  869. next();
  870. return skip_multiline_comment();
  871. }
  872. return S.regex_allowed ? read_regexp("") : read_operator("/");
  873. }
  874. function handle_eq_sign() {
  875. next();
  876. if (peek() === ">") {
  877. next();
  878. return token("arrow", "=>");
  879. } else {
  880. return read_operator("=");
  881. }
  882. }
  883. function handle_dot() {
  884. next();
  885. if (is_digit(peek().charCodeAt(0))) {
  886. return read_num(".");
  887. }
  888. if (peek() === ".") {
  889. next(); // Consume second dot
  890. next(); // Consume third dot
  891. return token("expand", "...");
  892. }
  893. return token("punc", ".");
  894. }
  895. function read_word() {
  896. var word = read_name();
  897. if (prev_was_dot) return token("name", word);
  898. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  899. : !KEYWORDS.has(word) ? token("name", word)
  900. : OPERATORS.has(word) ? token("operator", word)
  901. : token("keyword", word);
  902. }
  903. function with_eof_error(eof_error, cont) {
  904. return function(x) {
  905. try {
  906. return cont(x);
  907. } catch(ex) {
  908. if (ex === EX_EOF) parse_error(eof_error);
  909. else throw ex;
  910. }
  911. };
  912. }
  913. function next_token(force_regexp) {
  914. if (force_regexp != null)
  915. return read_regexp(force_regexp);
  916. if (shebang && S.pos == 0 && looking_at("#!")) {
  917. start_token();
  918. forward(2);
  919. skip_line_comment("comment5");
  920. }
  921. for (;;) {
  922. skip_whitespace();
  923. start_token();
  924. if (html5_comments) {
  925. if (looking_at("<!--")) {
  926. forward(4);
  927. skip_line_comment("comment3");
  928. continue;
  929. }
  930. if (looking_at("-->") && S.newline_before) {
  931. forward(3);
  932. skip_line_comment("comment4");
  933. continue;
  934. }
  935. }
  936. var ch = peek();
  937. if (!ch) return token("eof");
  938. var code = ch.charCodeAt(0);
  939. switch (code) {
  940. case 34: case 39: return read_string();
  941. case 46: return handle_dot();
  942. case 47: {
  943. var tok = handle_slash();
  944. if (tok === next_token) continue;
  945. return tok;
  946. }
  947. case 61: return handle_eq_sign();
  948. case 63: {
  949. if (!is_option_chain_op()) break; // Handled below
  950. next(); // ?
  951. next(); // .
  952. return token("punc", "?.");
  953. }
  954. case 96: return read_template_characters(true);
  955. case 123:
  956. S.brace_counter++;
  957. break;
  958. case 125:
  959. S.brace_counter--;
  960. if (S.template_braces.length > 0
  961. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  962. return read_template_characters(false);
  963. break;
  964. }
  965. if (is_digit(code)) return read_num();
  966. if (PUNC_CHARS.has(ch)) return token("punc", next());
  967. if (OPERATOR_CHARS.has(ch)) return read_operator();
  968. if (code == 92 || is_identifier_start(ch)) return read_word();
  969. break;
  970. }
  971. parse_error("Unexpected character '" + ch + "'");
  972. }
  973. next_token.next = next;
  974. next_token.peek = peek;
  975. next_token.context = function(nc) {
  976. if (nc) S = nc;
  977. return S;
  978. };
  979. next_token.add_directive = function(directive) {
  980. S.directive_stack[S.directive_stack.length - 1].push(directive);
  981. if (S.directives[directive] === undefined) {
  982. S.directives[directive] = 1;
  983. } else {
  984. S.directives[directive]++;
  985. }
  986. };
  987. next_token.push_directives_stack = function() {
  988. S.directive_stack.push([]);
  989. };
  990. next_token.pop_directives_stack = function() {
  991. var directives = S.directive_stack[S.directive_stack.length - 1];
  992. for (var i = 0; i < directives.length; i++) {
  993. S.directives[directives[i]]--;
  994. }
  995. S.directive_stack.pop();
  996. };
  997. next_token.has_directive = function(directive) {
  998. return S.directives[directive] > 0;
  999. };
  1000. return next_token;
  1001. }
  1002. /* -----[ Parser (constants) ]----- */
  1003. var UNARY_PREFIX = makePredicate([
  1004. "typeof",
  1005. "void",
  1006. "delete",
  1007. "--",
  1008. "++",
  1009. "!",
  1010. "~",
  1011. "-",
  1012. "+"
  1013. ]);
  1014. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  1015. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  1016. var PRECEDENCE = (function(a, ret) {
  1017. for (var i = 0; i < a.length; ++i) {
  1018. var b = a[i];
  1019. for (var j = 0; j < b.length; ++j) {
  1020. ret[b[j]] = i + 1;
  1021. }
  1022. }
  1023. return ret;
  1024. })(
  1025. [
  1026. ["||"],
  1027. ["??"],
  1028. ["&&"],
  1029. ["|"],
  1030. ["^"],
  1031. ["&"],
  1032. ["==", "===", "!=", "!=="],
  1033. ["<", ">", "<=", ">=", "in", "instanceof"],
  1034. [">>", "<<", ">>>"],
  1035. ["+", "-"],
  1036. ["*", "/", "%"],
  1037. ["**"]
  1038. ],
  1039. {}
  1040. );
  1041. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name" ]);
  1042. /* -----[ Parser ]----- */
  1043. function parse($TEXT, options) {
  1044. // maps start tokens to count of comments found outside of their parens
  1045. // Example: /* I count */ ( /* I don't */ foo() )
  1046. // Useful because comments_before property of call with parens outside
  1047. // contains both comments inside and outside these parens. Used to find the
  1048. // right #__PURE__ comments for an expression
  1049. const outer_comments_before_counts = new Map();
  1050. options = defaults(options, {
  1051. bare_returns : false,
  1052. ecma : null, // Legacy
  1053. expression : false,
  1054. filename : null,
  1055. html5_comments : true,
  1056. module : false,
  1057. shebang : true,
  1058. strict : false,
  1059. toplevel : null,
  1060. }, true);
  1061. var S = {
  1062. input : (typeof $TEXT == "string"
  1063. ? tokenizer($TEXT, options.filename,
  1064. options.html5_comments, options.shebang)
  1065. : $TEXT),
  1066. token : null,
  1067. prev : null,
  1068. peeked : null,
  1069. in_function : 0,
  1070. in_async : -1,
  1071. in_generator : -1,
  1072. in_directives : true,
  1073. in_loop : 0,
  1074. labels : []
  1075. };
  1076. S.token = next();
  1077. function is(type, value) {
  1078. return is_token(S.token, type, value);
  1079. }
  1080. function peek() { return S.peeked || (S.peeked = S.input()); }
  1081. function next() {
  1082. S.prev = S.token;
  1083. if (!S.peeked) peek();
  1084. S.token = S.peeked;
  1085. S.peeked = null;
  1086. S.in_directives = S.in_directives && (
  1087. S.token.type == "string" || is("punc", ";")
  1088. );
  1089. return S.token;
  1090. }
  1091. function prev() {
  1092. return S.prev;
  1093. }
  1094. function croak(msg, line, col, pos) {
  1095. var ctx = S.input.context();
  1096. js_error(msg,
  1097. ctx.filename,
  1098. line != null ? line : ctx.tokline,
  1099. col != null ? col : ctx.tokcol,
  1100. pos != null ? pos : ctx.tokpos);
  1101. }
  1102. function token_error(token, msg) {
  1103. croak(msg, token.line, token.col);
  1104. }
  1105. function unexpected(token) {
  1106. if (token == null)
  1107. token = S.token;
  1108. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  1109. }
  1110. function expect_token(type, val) {
  1111. if (is(type, val)) {
  1112. return next();
  1113. }
  1114. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  1115. }
  1116. function expect(punc) { return expect_token("punc", punc); }
  1117. function has_newline_before(token) {
  1118. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  1119. }
  1120. function can_insert_semicolon() {
  1121. return !options.strict
  1122. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  1123. }
  1124. function is_in_generator() {
  1125. return S.in_generator === S.in_function;
  1126. }
  1127. function is_in_async() {
  1128. return S.in_async === S.in_function;
  1129. }
  1130. function semicolon(optional) {
  1131. if (is("punc", ";")) next();
  1132. else if (!optional && !can_insert_semicolon()) unexpected();
  1133. }
  1134. function parenthesised() {
  1135. expect("(");
  1136. var exp = expression(true);
  1137. expect(")");
  1138. return exp;
  1139. }
  1140. function embed_tokens(parser) {
  1141. return function _embed_tokens_wrapper(...args) {
  1142. const start = S.token;
  1143. const expr = parser(...args);
  1144. expr.start = start;
  1145. expr.end = prev();
  1146. return expr;
  1147. };
  1148. }
  1149. function handle_regexp() {
  1150. if (is("operator", "/") || is("operator", "/=")) {
  1151. S.peeked = null;
  1152. S.token = S.input(S.token.value.substr(1)); // force regexp
  1153. }
  1154. }
  1155. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  1156. handle_regexp();
  1157. switch (S.token.type) {
  1158. case "string":
  1159. if (S.in_directives) {
  1160. var token = peek();
  1161. if (!S.token.raw.includes("\\")
  1162. && (is_token(token, "punc", ";")
  1163. || is_token(token, "punc", "}")
  1164. || has_newline_before(token)
  1165. || is_token(token, "eof"))) {
  1166. S.input.add_directive(S.token.value);
  1167. } else {
  1168. S.in_directives = false;
  1169. }
  1170. }
  1171. var dir = S.in_directives, stat = simple_statement();
  1172. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  1173. case "template_head":
  1174. case "num":
  1175. case "big_int":
  1176. case "regexp":
  1177. case "operator":
  1178. case "atom":
  1179. return simple_statement();
  1180. case "name":
  1181. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  1182. next();
  1183. next();
  1184. if (is_for_body) {
  1185. croak("functions are not allowed as the body of a loop");
  1186. }
  1187. return function_(AST_Defun, false, true, is_export_default);
  1188. }
  1189. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  1190. next();
  1191. var node = import_();
  1192. semicolon();
  1193. return node;
  1194. }
  1195. return is_token(peek(), "punc", ":")
  1196. ? labeled_statement()
  1197. : simple_statement();
  1198. case "punc":
  1199. switch (S.token.value) {
  1200. case "{":
  1201. return new AST_BlockStatement({
  1202. start : S.token,
  1203. body : block_(),
  1204. end : prev()
  1205. });
  1206. case "[":
  1207. case "(":
  1208. return simple_statement();
  1209. case ";":
  1210. S.in_directives = false;
  1211. next();
  1212. return new AST_EmptyStatement();
  1213. default:
  1214. unexpected();
  1215. }
  1216. case "keyword":
  1217. switch (S.token.value) {
  1218. case "break":
  1219. next();
  1220. return break_cont(AST_Break);
  1221. case "continue":
  1222. next();
  1223. return break_cont(AST_Continue);
  1224. case "debugger":
  1225. next();
  1226. semicolon();
  1227. return new AST_Debugger();
  1228. case "do":
  1229. next();
  1230. var body = in_loop(statement);
  1231. expect_token("keyword", "while");
  1232. var condition = parenthesised();
  1233. semicolon(true);
  1234. return new AST_Do({
  1235. body : body,
  1236. condition : condition
  1237. });
  1238. case "while":
  1239. next();
  1240. return new AST_While({
  1241. condition : parenthesised(),
  1242. body : in_loop(function() { return statement(false, true); })
  1243. });
  1244. case "for":
  1245. next();
  1246. return for_();
  1247. case "class":
  1248. next();
  1249. if (is_for_body) {
  1250. croak("classes are not allowed as the body of a loop");
  1251. }
  1252. if (is_if_body) {
  1253. croak("classes are not allowed as the body of an if");
  1254. }
  1255. return class_(AST_DefClass);
  1256. case "function":
  1257. next();
  1258. if (is_for_body) {
  1259. croak("functions are not allowed as the body of a loop");
  1260. }
  1261. return function_(AST_Defun, false, false, is_export_default);
  1262. case "if":
  1263. next();
  1264. return if_();
  1265. case "return":
  1266. if (S.in_function == 0 && !options.bare_returns)
  1267. croak("'return' outside of function");
  1268. next();
  1269. var value = null;
  1270. if (is("punc", ";")) {
  1271. next();
  1272. } else if (!can_insert_semicolon()) {
  1273. value = expression(true);
  1274. semicolon();
  1275. }
  1276. return new AST_Return({
  1277. value: value
  1278. });
  1279. case "switch":
  1280. next();
  1281. return new AST_Switch({
  1282. expression : parenthesised(),
  1283. body : in_loop(switch_body_)
  1284. });
  1285. case "throw":
  1286. next();
  1287. if (has_newline_before(S.token))
  1288. croak("Illegal newline after 'throw'");
  1289. var value = expression(true);
  1290. semicolon();
  1291. return new AST_Throw({
  1292. value: value
  1293. });
  1294. case "try":
  1295. next();
  1296. return try_();
  1297. case "var":
  1298. next();
  1299. var node = var_();
  1300. semicolon();
  1301. return node;
  1302. case "let":
  1303. next();
  1304. var node = let_();
  1305. semicolon();
  1306. return node;
  1307. case "const":
  1308. next();
  1309. var node = const_();
  1310. semicolon();
  1311. return node;
  1312. case "with":
  1313. if (S.input.has_directive("use strict")) {
  1314. croak("Strict mode may not include a with statement");
  1315. }
  1316. next();
  1317. return new AST_With({
  1318. expression : parenthesised(),
  1319. body : statement()
  1320. });
  1321. case "export":
  1322. if (!is_token(peek(), "punc", "(")) {
  1323. next();
  1324. var node = export_();
  1325. if (is("punc", ";")) semicolon();
  1326. return node;
  1327. }
  1328. }
  1329. }
  1330. unexpected();
  1331. });
  1332. function labeled_statement() {
  1333. var label = as_symbol(AST_Label);
  1334. if (label.name === "await" && is_in_async()) {
  1335. token_error(S.prev, "await cannot be used as label inside async function");
  1336. }
  1337. if (S.labels.some((l) => l.name === label.name)) {
  1338. // ECMA-262, 12.12: An ECMAScript program is considered
  1339. // syntactically incorrect if it contains a
  1340. // LabelledStatement that is enclosed by a
  1341. // LabelledStatement with the same Identifier as label.
  1342. croak("Label " + label.name + " defined twice");
  1343. }
  1344. expect(":");
  1345. S.labels.push(label);
  1346. var stat = statement();
  1347. S.labels.pop();
  1348. if (!(stat instanceof AST_IterationStatement)) {
  1349. // check for `continue` that refers to this label.
  1350. // those should be reported as syntax errors.
  1351. // https://github.com/mishoo/UglifyJS2/issues/287
  1352. label.references.forEach(function(ref) {
  1353. if (ref instanceof AST_Continue) {
  1354. ref = ref.label.start;
  1355. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  1356. ref.line, ref.col, ref.pos);
  1357. }
  1358. });
  1359. }
  1360. return new AST_LabeledStatement({ body: stat, label: label });
  1361. }
  1362. function simple_statement(tmp) {
  1363. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  1364. }
  1365. function break_cont(type) {
  1366. var label = null, ldef;
  1367. if (!can_insert_semicolon()) {
  1368. label = as_symbol(AST_LabelRef, true);
  1369. }
  1370. if (label != null) {
  1371. ldef = S.labels.find((l) => l.name === label.name);
  1372. if (!ldef)
  1373. croak("Undefined label " + label.name);
  1374. label.thedef = ldef;
  1375. } else if (S.in_loop == 0)
  1376. croak(type.TYPE + " not inside a loop or switch");
  1377. semicolon();
  1378. var stat = new type({ label: label });
  1379. if (ldef) ldef.references.push(stat);
  1380. return stat;
  1381. }
  1382. function for_() {
  1383. var for_await_error = "`for await` invalid in this context";
  1384. var await_tok = S.token;
  1385. if (await_tok.type == "name" && await_tok.value == "await") {
  1386. if (!is_in_async()) {
  1387. token_error(await_tok, for_await_error);
  1388. }
  1389. next();
  1390. } else {
  1391. await_tok = false;
  1392. }
  1393. expect("(");
  1394. var init = null;
  1395. if (!is("punc", ";")) {
  1396. init =
  1397. is("keyword", "var") ? (next(), var_(true)) :
  1398. is("keyword", "let") ? (next(), let_(true)) :
  1399. is("keyword", "const") ? (next(), const_(true)) :
  1400. expression(true, true);
  1401. var is_in = is("operator", "in");
  1402. var is_of = is("name", "of");
  1403. if (await_tok && !is_of) {
  1404. token_error(await_tok, for_await_error);
  1405. }
  1406. if (is_in || is_of) {
  1407. if (init instanceof AST_Definitions) {
  1408. if (init.definitions.length > 1)
  1409. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  1410. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  1411. token_error(init.start, "Invalid left-hand side in for..in loop");
  1412. }
  1413. next();
  1414. if (is_in) {
  1415. return for_in(init);
  1416. } else {
  1417. return for_of(init, !!await_tok);
  1418. }
  1419. }
  1420. } else if (await_tok) {
  1421. token_error(await_tok, for_await_error);
  1422. }
  1423. return regular_for(init);
  1424. }
  1425. function regular_for(init) {
  1426. expect(";");
  1427. var test = is("punc", ";") ? null : expression(true);
  1428. expect(";");
  1429. var step = is("punc", ")") ? null : expression(true);
  1430. expect(")");
  1431. return new AST_For({
  1432. init : init,
  1433. condition : test,
  1434. step : step,
  1435. body : in_loop(function() { return statement(false, true); })
  1436. });
  1437. }
  1438. function for_of(init, is_await) {
  1439. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  1440. var obj = expression(true);
  1441. expect(")");
  1442. return new AST_ForOf({
  1443. await : is_await,
  1444. init : init,
  1445. name : lhs,
  1446. object : obj,
  1447. body : in_loop(function() { return statement(false, true); })
  1448. });
  1449. }
  1450. function for_in(init) {
  1451. var obj = expression(true);
  1452. expect(")");
  1453. return new AST_ForIn({
  1454. init : init,
  1455. object : obj,
  1456. body : in_loop(function() { return statement(false, true); })
  1457. });
  1458. }
  1459. var arrow_function = function(start, argnames, is_async) {
  1460. if (has_newline_before(S.token)) {
  1461. croak("Unexpected newline before arrow (=>)");
  1462. }
  1463. expect_token("arrow", "=>");
  1464. var body = _function_body(is("punc", "{"), false, is_async);
  1465. var end =
  1466. body instanceof Array && body.length ? body[body.length - 1].end :
  1467. body instanceof Array ? start :
  1468. body.end;
  1469. return new AST_Arrow({
  1470. start : start,
  1471. end : end,
  1472. async : is_async,
  1473. argnames : argnames,
  1474. body : body
  1475. });
  1476. };
  1477. var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
  1478. var in_statement = ctor === AST_Defun;
  1479. var is_generator = is("operator", "*");
  1480. if (is_generator) {
  1481. next();
  1482. }
  1483. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  1484. if (in_statement && !name) {
  1485. if (is_export_default) {
  1486. ctor = AST_Function;
  1487. } else {
  1488. unexpected();
  1489. }
  1490. }
  1491. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  1492. unexpected(prev());
  1493. var args = [];
  1494. var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
  1495. return new ctor({
  1496. start : args.start,
  1497. end : body.end,
  1498. is_generator: is_generator,
  1499. async : is_async,
  1500. name : name,
  1501. argnames: args,
  1502. body : body
  1503. });
  1504. };
  1505. function track_used_binding_identifiers(is_parameter, strict) {
  1506. var parameters = new Set();
  1507. var duplicate = false;
  1508. var default_assignment = false;
  1509. var spread = false;
  1510. var strict_mode = !!strict;
  1511. var tracker = {
  1512. add_parameter: function(token) {
  1513. if (parameters.has(token.value)) {
  1514. if (duplicate === false) {
  1515. duplicate = token;
  1516. }
  1517. tracker.check_strict();
  1518. } else {
  1519. parameters.add(token.value);
  1520. if (is_parameter) {
  1521. switch (token.value) {
  1522. case "arguments":
  1523. case "eval":
  1524. case "yield":
  1525. if (strict_mode) {
  1526. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1527. }
  1528. break;
  1529. default:
  1530. if (RESERVED_WORDS.has(token.value)) {
  1531. unexpected();
  1532. }
  1533. }
  1534. }
  1535. }
  1536. },
  1537. mark_default_assignment: function(token) {
  1538. if (default_assignment === false) {
  1539. default_assignment = token;
  1540. }
  1541. },
  1542. mark_spread: function(token) {
  1543. if (spread === false) {
  1544. spread = token;
  1545. }
  1546. },
  1547. mark_strict_mode: function() {
  1548. strict_mode = true;
  1549. },
  1550. is_strict: function() {
  1551. return default_assignment !== false || spread !== false || strict_mode;
  1552. },
  1553. check_strict: function() {
  1554. if (tracker.is_strict() && duplicate !== false) {
  1555. token_error(duplicate, "Parameter " + duplicate.value + " was used already");
  1556. }
  1557. }
  1558. };
  1559. return tracker;
  1560. }
  1561. function parameters(params) {
  1562. var used_parameters = track_used_binding_identifiers(true, S.input.has_directive("use strict"));
  1563. expect("(");
  1564. while (!is("punc", ")")) {
  1565. var param = parameter(used_parameters);
  1566. params.push(param);
  1567. if (!is("punc", ")")) {
  1568. expect(",");
  1569. }
  1570. if (param instanceof AST_Expansion) {
  1571. break;
  1572. }
  1573. }
  1574. next();
  1575. }
  1576. function parameter(used_parameters, symbol_type) {
  1577. var param;
  1578. var expand = false;
  1579. if (used_parameters === undefined) {
  1580. used_parameters = track_used_binding_identifiers(true, S.input.has_directive("use strict"));
  1581. }
  1582. if (is("expand", "...")) {
  1583. expand = S.token;
  1584. used_parameters.mark_spread(S.token);
  1585. next();
  1586. }
  1587. param = binding_element(used_parameters, symbol_type);
  1588. if (is("operator", "=") && expand === false) {
  1589. used_parameters.mark_default_assignment(S.token);
  1590. next();
  1591. param = new AST_DefaultAssign({
  1592. start: param.start,
  1593. left: param,
  1594. operator: "=",
  1595. right: expression(false),
  1596. end: S.token
  1597. });
  1598. }
  1599. if (expand !== false) {
  1600. if (!is("punc", ")")) {
  1601. unexpected();
  1602. }
  1603. param = new AST_Expansion({
  1604. start: expand,
  1605. expression: param,
  1606. end: expand
  1607. });
  1608. }
  1609. used_parameters.check_strict();
  1610. return param;
  1611. }
  1612. function binding_element(used_parameters, symbol_type) {
  1613. var elements = [];
  1614. var first = true;
  1615. var is_expand = false;
  1616. var expand_token;
  1617. var first_token = S.token;
  1618. if (used_parameters === undefined) {
  1619. used_parameters = track_used_binding_identifiers(false, S.input.has_directive("use strict"));
  1620. }
  1621. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1622. if (is("punc", "[")) {
  1623. next();
  1624. while (!is("punc", "]")) {
  1625. if (first) {
  1626. first = false;
  1627. } else {
  1628. expect(",");
  1629. }
  1630. if (is("expand", "...")) {
  1631. is_expand = true;
  1632. expand_token = S.token;
  1633. used_parameters.mark_spread(S.token);
  1634. next();
  1635. }
  1636. if (is("punc")) {
  1637. switch (S.token.value) {
  1638. case ",":
  1639. elements.push(new AST_Hole({
  1640. start: S.token,
  1641. end: S.token
  1642. }));
  1643. continue;
  1644. case "]": // Trailing comma after last element
  1645. break;
  1646. case "[":
  1647. case "{":
  1648. elements.push(binding_element(used_parameters, symbol_type));
  1649. break;
  1650. default:
  1651. unexpected();
  1652. }
  1653. } else if (is("name")) {
  1654. used_parameters.add_parameter(S.token);
  1655. elements.push(as_symbol(symbol_type));
  1656. } else {
  1657. croak("Invalid function parameter");
  1658. }
  1659. if (is("operator", "=") && is_expand === false) {
  1660. used_parameters.mark_default_assignment(S.token);
  1661. next();
  1662. elements[elements.length - 1] = new AST_DefaultAssign({
  1663. start: elements[elements.length - 1].start,
  1664. left: elements[elements.length - 1],
  1665. operator: "=",
  1666. right: expression(false),
  1667. end: S.token
  1668. });
  1669. }
  1670. if (is_expand) {
  1671. if (!is("punc", "]")) {
  1672. croak("Rest element must be last element");
  1673. }
  1674. elements[elements.length - 1] = new AST_Expansion({
  1675. start: expand_token,
  1676. expression: elements[elements.length - 1],
  1677. end: expand_token
  1678. });
  1679. }
  1680. }
  1681. expect("]");
  1682. used_parameters.check_strict();
  1683. return new AST_Destructuring({
  1684. start: first_token,
  1685. names: elements,
  1686. is_array: true,
  1687. end: prev()
  1688. });
  1689. } else if (is("punc", "{")) {
  1690. next();
  1691. while (!is("punc", "}")) {
  1692. if (first) {
  1693. first = false;
  1694. } else {
  1695. expect(",");
  1696. }
  1697. if (is("expand", "...")) {
  1698. is_expand = true;
  1699. expand_token = S.token;
  1700. used_parameters.mark_spread(S.token);
  1701. next();
  1702. }
  1703. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1704. used_parameters.add_parameter(S.token);
  1705. var start = prev();
  1706. var value = as_symbol(symbol_type);
  1707. if (is_expand) {
  1708. elements.push(new AST_Expansion({
  1709. start: expand_token,
  1710. expression: value,
  1711. end: value.end,
  1712. }));
  1713. } else {
  1714. elements.push(new AST_ObjectKeyVal({
  1715. start: start,
  1716. key: value.name,
  1717. value: value,
  1718. end: value.end,
  1719. }));
  1720. }
  1721. } else if (is("punc", "}")) {
  1722. continue; // Allow trailing hole
  1723. } else {
  1724. var property_token = S.token;
  1725. var property = as_property_name();
  1726. if (property === null) {
  1727. unexpected(prev());
  1728. } else if (prev().type === "name" && !is("punc", ":")) {
  1729. elements.push(new AST_ObjectKeyVal({
  1730. start: prev(),
  1731. key: property,
  1732. value: new symbol_type({
  1733. start: prev(),
  1734. name: property,
  1735. end: prev()
  1736. }),
  1737. end: prev()
  1738. }));
  1739. } else {
  1740. expect(":");
  1741. elements.push(new AST_ObjectKeyVal({
  1742. start: property_token,
  1743. quote: property_token.quote,
  1744. key: property,
  1745. value: binding_element(used_parameters, symbol_type),
  1746. end: prev()
  1747. }));
  1748. }
  1749. }
  1750. if (is_expand) {
  1751. if (!is("punc", "}")) {
  1752. croak("Rest element must be last element");
  1753. }
  1754. } else if (is("operator", "=")) {
  1755. used_parameters.mark_default_assignment(S.token);
  1756. next();
  1757. elements[elements.length - 1].value = new AST_DefaultAssign({
  1758. start: elements[elements.length - 1].value.start,
  1759. left: elements[elements.length - 1].value,
  1760. operator: "=",
  1761. right: expression(false),
  1762. end: S.token
  1763. });
  1764. }
  1765. }
  1766. expect("}");
  1767. used_parameters.check_strict();
  1768. return new AST_Destructuring({
  1769. start: first_token,
  1770. names: elements,
  1771. is_array: false,
  1772. end: prev()
  1773. });
  1774. } else if (is("name")) {
  1775. used_parameters.add_parameter(S.token);
  1776. return as_symbol(symbol_type);
  1777. } else {
  1778. croak("Invalid function parameter");
  1779. }
  1780. }
  1781. function params_or_seq_(allow_arrows, maybe_sequence) {
  1782. var spread_token;
  1783. var invalid_sequence;
  1784. var trailing_comma;
  1785. var a = [];
  1786. expect("(");
  1787. while (!is("punc", ")")) {
  1788. if (spread_token) unexpected(spread_token);
  1789. if (is("expand", "...")) {
  1790. spread_token = S.token;
  1791. if (maybe_sequence) invalid_sequence = S.token;
  1792. next();
  1793. a.push(new AST_Expansion({
  1794. start: prev(),
  1795. expression: expression(),
  1796. end: S.token,
  1797. }));
  1798. } else {
  1799. a.push(expression());
  1800. }
  1801. if (!is("punc", ")")) {
  1802. expect(",");
  1803. if (is("punc", ")")) {
  1804. trailing_comma = prev();
  1805. if (maybe_sequence) invalid_sequence = trailing_comma;
  1806. }
  1807. }
  1808. }
  1809. expect(")");
  1810. if (allow_arrows && is("arrow", "=>")) {
  1811. if (spread_token && trailing_comma) unexpected(trailing_comma);
  1812. } else if (invalid_sequence) {
  1813. unexpected(invalid_sequence);
  1814. }
  1815. return a;
  1816. }
  1817. function _function_body(block, generator, is_async, name, args) {
  1818. var loop = S.in_loop;
  1819. var labels = S.labels;
  1820. var current_generator = S.in_generator;
  1821. var current_async = S.in_async;
  1822. ++S.in_function;
  1823. if (generator)
  1824. S.in_generator = S.in_function;
  1825. if (is_async)
  1826. S.in_async = S.in_function;
  1827. if (args) parameters(args);
  1828. if (block)
  1829. S.in_directives = true;
  1830. S.in_loop = 0;
  1831. S.labels = [];
  1832. if (block) {
  1833. S.input.push_directives_stack();
  1834. var a = block_();
  1835. if (name) _verify_symbol(name);
  1836. if (args) args.forEach(_verify_symbol);
  1837. S.input.pop_directives_stack();
  1838. } else {
  1839. var a = [new AST_Return({
  1840. start: S.token,
  1841. value: expression(false),
  1842. end: S.token
  1843. })];
  1844. }
  1845. --S.in_function;
  1846. S.in_loop = loop;
  1847. S.labels = labels;
  1848. S.in_generator = current_generator;
  1849. S.in_async = current_async;
  1850. return a;
  1851. }
  1852. function _await_expression() {
  1853. // Previous token must be "await" and not be interpreted as an identifier
  1854. if (!is_in_async()) {
  1855. croak("Unexpected await expression outside async function",
  1856. S.prev.line, S.prev.col, S.prev.pos);
  1857. }
  1858. // the await expression is parsed as a unary expression in Babel
  1859. return new AST_Await({
  1860. start: prev(),
  1861. end: S.token,
  1862. expression : maybe_unary(true),
  1863. });
  1864. }
  1865. function _yield_expression() {
  1866. // Previous token must be keyword yield and not be interpret as an identifier
  1867. if (!is_in_generator()) {
  1868. croak("Unexpected yield expression outside generator function",
  1869. S.prev.line, S.prev.col, S.prev.pos);
  1870. }
  1871. var start = S.token;
  1872. var star = false;
  1873. var has_expression = true;
  1874. // Attempt to get expression or star (and then the mandatory expression)
  1875. // behind yield on the same line.
  1876. //
  1877. // If nothing follows on the same line of the yieldExpression,
  1878. // it should default to the value `undefined` for yield to return.
  1879. // In that case, the `undefined` stored as `null` in ast.
  1880. //
  1881. // Note 1: It isn't allowed for yield* to close without an expression
  1882. // Note 2: If there is a nlb between yield and star, it is interpret as
  1883. // yield <explicit undefined> <inserted automatic semicolon> *
  1884. if (can_insert_semicolon() ||
  1885. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  1886. has_expression = false;
  1887. } else if (is("operator", "*")) {
  1888. star = true;
  1889. next();
  1890. }
  1891. return new AST_Yield({
  1892. start : start,
  1893. is_star : star,
  1894. expression : has_expression ? expression() : null,
  1895. end : prev()
  1896. });
  1897. }
  1898. function if_() {
  1899. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  1900. if (is("keyword", "else")) {
  1901. next();
  1902. belse = statement(false, false, true);
  1903. }
  1904. return new AST_If({
  1905. condition : cond,
  1906. body : body,
  1907. alternative : belse
  1908. });
  1909. }
  1910. function block_() {
  1911. expect("{");
  1912. var a = [];
  1913. while (!is("punc", "}")) {
  1914. if (is("eof")) unexpected();
  1915. a.push(statement());
  1916. }
  1917. next();
  1918. return a;
  1919. }
  1920. function switch_body_() {
  1921. expect("{");
  1922. var a = [], cur = null, branch = null, tmp;
  1923. while (!is("punc", "}")) {
  1924. if (is("eof")) unexpected();
  1925. if (is("keyword", "case")) {
  1926. if (branch) branch.end = prev();
  1927. cur = [];
  1928. branch = new AST_Case({
  1929. start : (tmp = S.token, next(), tmp),
  1930. expression : expression(true),
  1931. body : cur
  1932. });
  1933. a.push(branch);
  1934. expect(":");
  1935. } else if (is("keyword", "default")) {
  1936. if (branch) branch.end = prev();
  1937. cur = [];
  1938. branch = new AST_Default({
  1939. start : (tmp = S.token, next(), expect(":"), tmp),
  1940. body : cur
  1941. });
  1942. a.push(branch);
  1943. } else {
  1944. if (!cur) unexpected();
  1945. cur.push(statement());
  1946. }
  1947. }
  1948. if (branch) branch.end = prev();
  1949. next();
  1950. return a;
  1951. }
  1952. function try_() {
  1953. var body = block_(), bcatch = null, bfinally = null;
  1954. if (is("keyword", "catch")) {
  1955. var start = S.token;
  1956. next();
  1957. if (is("punc", "{")) {
  1958. var name = null;
  1959. } else {
  1960. expect("(");
  1961. var name = parameter(undefined, AST_SymbolCatch);
  1962. expect(")");
  1963. }
  1964. bcatch = new AST_Catch({
  1965. start : start,
  1966. argname : name,
  1967. body : block_(),
  1968. end : prev()
  1969. });
  1970. }
  1971. if (is("keyword", "finally")) {
  1972. var start = S.token;
  1973. next();
  1974. bfinally = new AST_Finally({
  1975. start : start,
  1976. body : block_(),
  1977. end : prev()
  1978. });
  1979. }
  1980. if (!bcatch && !bfinally)
  1981. croak("Missing catch/finally blocks");
  1982. return new AST_Try({
  1983. body : body,
  1984. bcatch : bcatch,
  1985. bfinally : bfinally
  1986. });
  1987. }
  1988. function vardefs(no_in, kind) {
  1989. var a = [];
  1990. var def;
  1991. for (;;) {
  1992. var sym_type =
  1993. kind === "var" ? AST_SymbolVar :
  1994. kind === "const" ? AST_SymbolConst :
  1995. kind === "let" ? AST_SymbolLet : null;
  1996. if (is("punc", "{") || is("punc", "[")) {
  1997. def = new AST_VarDef({
  1998. start: S.token,
  1999. name: binding_element(undefined ,sym_type),
  2000. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  2001. end: prev()
  2002. });
  2003. } else {
  2004. def = new AST_VarDef({
  2005. start : S.token,
  2006. name : as_symbol(sym_type),
  2007. value : is("operator", "=")
  2008. ? (next(), expression(false, no_in))
  2009. : !no_in && kind === "const"
  2010. ? croak("Missing initializer in const declaration") : null,
  2011. end : prev()
  2012. });
  2013. if (def.name.name == "import") croak("Unexpected token: import");
  2014. }
  2015. a.push(def);
  2016. if (!is("punc", ","))
  2017. break;
  2018. next();
  2019. }
  2020. return a;
  2021. }
  2022. var var_ = function(no_in) {
  2023. return new AST_Var({
  2024. start : prev(),
  2025. definitions : vardefs(no_in, "var"),
  2026. end : prev()
  2027. });
  2028. };
  2029. var let_ = function(no_in) {
  2030. return new AST_Let({
  2031. start : prev(),
  2032. definitions : vardefs(no_in, "let"),
  2033. end : prev()
  2034. });
  2035. };
  2036. var const_ = function(no_in) {
  2037. return new AST_Const({
  2038. start : prev(),
  2039. definitions : vardefs(no_in, "const"),
  2040. end : prev()
  2041. });
  2042. };
  2043. var new_ = function(allow_calls) {
  2044. var start = S.token;
  2045. expect_token("operator", "new");
  2046. if (is("punc", ".")) {
  2047. next();
  2048. expect_token("name", "target");
  2049. return subscripts(new AST_NewTarget({
  2050. start : start,
  2051. end : prev()
  2052. }), allow_calls);
  2053. }
  2054. var newexp = expr_atom(false), args;
  2055. if (is("punc", "(")) {
  2056. next();
  2057. args = expr_list(")", true);
  2058. } else {
  2059. args = [];
  2060. }
  2061. var call = new AST_New({
  2062. start : start,
  2063. expression : newexp,
  2064. args : args,
  2065. end : prev()
  2066. });
  2067. annotate(call);
  2068. return subscripts(call, allow_calls);
  2069. };
  2070. function as_atom_node() {
  2071. var tok = S.token, ret;
  2072. switch (tok.type) {
  2073. case "name":
  2074. ret = _make_symbol(AST_SymbolRef);
  2075. break;
  2076. case "num":
  2077. ret = new AST_Number({ start: tok, end: tok, value: tok.value });
  2078. break;
  2079. case "big_int":
  2080. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  2081. break;
  2082. case "string":
  2083. ret = new AST_String({
  2084. start : tok,
  2085. end : tok,
  2086. value : tok.value,
  2087. quote : tok.quote
  2088. });
  2089. break;
  2090. case "regexp":
  2091. ret = new AST_RegExp({ start: tok, end: tok, value: tok.value });
  2092. break;
  2093. case "atom":
  2094. switch (tok.value) {
  2095. case "false":
  2096. ret = new AST_False({ start: tok, end: tok });
  2097. break;
  2098. case "true":
  2099. ret = new AST_True({ start: tok, end: tok });
  2100. break;
  2101. case "null":
  2102. ret = new AST_Null({ start: tok, end: tok });
  2103. break;
  2104. }
  2105. break;
  2106. }
  2107. next();
  2108. return ret;
  2109. }
  2110. function to_fun_args(ex, default_seen_above) {
  2111. var insert_default = function(ex, default_value) {
  2112. if (default_value) {
  2113. return new AST_DefaultAssign({
  2114. start: ex.start,
  2115. left: ex,
  2116. operator: "=",
  2117. right: default_value,
  2118. end: default_value.end
  2119. });
  2120. }
  2121. return ex;
  2122. };
  2123. if (ex instanceof AST_Object) {
  2124. return insert_default(new AST_Destructuring({
  2125. start: ex.start,
  2126. end: ex.end,
  2127. is_array: false,
  2128. names: ex.properties.map(prop => to_fun_args(prop))
  2129. }), default_seen_above);
  2130. } else if (ex instanceof AST_ObjectKeyVal) {
  2131. ex.value = to_fun_args(ex.value);
  2132. return insert_default(ex, default_seen_above);
  2133. } else if (ex instanceof AST_Hole) {
  2134. return ex;
  2135. } else if (ex instanceof AST_Destructuring) {
  2136. ex.names = ex.names.map(name => to_fun_args(name));
  2137. return insert_default(ex, default_seen_above);
  2138. } else if (ex instanceof AST_SymbolRef) {
  2139. return insert_default(new AST_SymbolFunarg({
  2140. name: ex.name,
  2141. start: ex.start,
  2142. end: ex.end
  2143. }), default_seen_above);
  2144. } else if (ex instanceof AST_Expansion) {
  2145. ex.expression = to_fun_args(ex.expression);
  2146. return insert_default(ex, default_seen_above);
  2147. } else if (ex instanceof AST_Array) {
  2148. return insert_default(new AST_Destructuring({
  2149. start: ex.start,
  2150. end: ex.end,
  2151. is_array: true,
  2152. names: ex.elements.map(elm => to_fun_args(elm))
  2153. }), default_seen_above);
  2154. } else if (ex instanceof AST_Assign) {
  2155. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2156. } else if (ex instanceof AST_DefaultAssign) {
  2157. ex.left = to_fun_args(ex.left);
  2158. return ex;
  2159. } else {
  2160. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2161. }
  2162. }
  2163. var expr_atom = function(allow_calls, allow_arrows) {
  2164. if (is("operator", "new")) {
  2165. return new_(allow_calls);
  2166. }
  2167. if (is("operator", "import")) {
  2168. return import_meta();
  2169. }
  2170. var start = S.token;
  2171. var peeked;
  2172. var async = is("name", "async")
  2173. && (peeked = peek()).value != "["
  2174. && peeked.type != "arrow"
  2175. && as_atom_node();
  2176. if (is("punc")) {
  2177. switch (S.token.value) {
  2178. case "(":
  2179. if (async && !allow_calls) break;
  2180. var exprs = params_or_seq_(allow_arrows, !async);
  2181. if (allow_arrows && is("arrow", "=>")) {
  2182. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2183. }
  2184. var ex = async ? new AST_Call({
  2185. expression: async,
  2186. args: exprs
  2187. }) : exprs.length == 1 ? exprs[0] : new AST_Sequence({
  2188. expressions: exprs
  2189. });
  2190. if (ex.start) {
  2191. const outer_comments_before = start.comments_before.length;
  2192. outer_comments_before_counts.set(start, outer_comments_before);
  2193. ex.start.comments_before.unshift(...start.comments_before);
  2194. start.comments_before = ex.start.comments_before;
  2195. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2196. var comment = start.comments_before[0];
  2197. if (!comment.nlb) {
  2198. comment.nlb = start.nlb;
  2199. start.nlb = false;
  2200. }
  2201. }
  2202. start.comments_after = ex.start.comments_after;
  2203. }
  2204. ex.start = start;
  2205. var end = prev();
  2206. if (ex.end) {
  2207. end.comments_before = ex.end.comments_before;
  2208. ex.end.comments_after.push(...end.comments_after);
  2209. end.comments_after = ex.end.comments_after;
  2210. }
  2211. ex.end = end;
  2212. if (ex instanceof AST_Call) annotate(ex);
  2213. return subscripts(ex, allow_calls);
  2214. case "[":
  2215. return subscripts(array_(), allow_calls);
  2216. case "{":
  2217. return subscripts(object_or_destructuring_(), allow_calls);
  2218. }
  2219. if (!async) unexpected();
  2220. }
  2221. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2222. var param = new AST_SymbolFunarg({
  2223. name: S.token.value,
  2224. start: start,
  2225. end: start,
  2226. });
  2227. next();
  2228. return arrow_function(start, [param], !!async);
  2229. }
  2230. if (is("keyword", "function")) {
  2231. next();
  2232. var func = function_(AST_Function, false, !!async);
  2233. func.start = start;
  2234. func.end = prev();
  2235. return subscripts(func, allow_calls);
  2236. }
  2237. if (async) return subscripts(async, allow_calls);
  2238. if (is("keyword", "class")) {
  2239. next();
  2240. var cls = class_(AST_ClassExpression);
  2241. cls.start = start;
  2242. cls.end = prev();
  2243. return subscripts(cls, allow_calls);
  2244. }
  2245. if (is("template_head")) {
  2246. return subscripts(template_string(), allow_calls);
  2247. }
  2248. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2249. return subscripts(as_atom_node(), allow_calls);
  2250. }
  2251. unexpected();
  2252. };
  2253. function template_string() {
  2254. var segments = [], start = S.token;
  2255. segments.push(new AST_TemplateSegment({
  2256. start: S.token,
  2257. raw: S.token.raw,
  2258. value: S.token.value,
  2259. end: S.token
  2260. }));
  2261. while (!S.token.end) {
  2262. next();
  2263. handle_regexp();
  2264. segments.push(expression(true));
  2265. if (!is_token("template_substitution")) {
  2266. unexpected();
  2267. }
  2268. segments.push(new AST_TemplateSegment({
  2269. start: S.token,
  2270. raw: S.token.raw,
  2271. value: S.token.value,
  2272. end: S.token
  2273. }));
  2274. }
  2275. next();
  2276. return new AST_TemplateString({
  2277. start: start,
  2278. segments: segments,
  2279. end: S.token
  2280. });
  2281. }
  2282. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2283. var first = true, a = [];
  2284. while (!is("punc", closing)) {
  2285. if (first) first = false; else expect(",");
  2286. if (allow_trailing_comma && is("punc", closing)) break;
  2287. if (is("punc", ",") && allow_empty) {
  2288. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2289. } else if (is("expand", "...")) {
  2290. next();
  2291. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2292. } else {
  2293. a.push(expression(false));
  2294. }
  2295. }
  2296. next();
  2297. return a;
  2298. }
  2299. var array_ = embed_tokens(function() {
  2300. expect("[");
  2301. return new AST_Array({
  2302. elements: expr_list("]", !options.strict, true)
  2303. });
  2304. });
  2305. var create_accessor = embed_tokens((is_generator, is_async) => {
  2306. return function_(AST_Accessor, is_generator, is_async);
  2307. });
  2308. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2309. var start = S.token, first = true, a = [];
  2310. expect("{");
  2311. while (!is("punc", "}")) {
  2312. if (first) first = false; else expect(",");
  2313. if (!options.strict && is("punc", "}"))
  2314. // allow trailing comma
  2315. break;
  2316. start = S.token;
  2317. if (start.type == "expand") {
  2318. next();
  2319. a.push(new AST_Expansion({
  2320. start: start,
  2321. expression: expression(false),
  2322. end: prev(),
  2323. }));
  2324. continue;
  2325. }
  2326. var name = as_property_name();
  2327. var value;
  2328. // Check property and fetch value
  2329. if (!is("punc", ":")) {
  2330. var concise = concise_method_or_getset(name, start);
  2331. if (concise) {
  2332. a.push(concise);
  2333. continue;
  2334. }
  2335. value = new AST_SymbolRef({
  2336. start: prev(),
  2337. name: name,
  2338. end: prev()
  2339. });
  2340. } else if (name === null) {
  2341. unexpected(prev());
  2342. } else {
  2343. next(); // `:` - see first condition
  2344. value = expression(false);
  2345. }
  2346. // Check for default value and alter value accordingly if necessary
  2347. if (is("operator", "=")) {
  2348. next();
  2349. value = new AST_Assign({
  2350. start: start,
  2351. left: value,
  2352. operator: "=",
  2353. right: expression(false),
  2354. end: prev()
  2355. });
  2356. }
  2357. // Create property
  2358. a.push(new AST_ObjectKeyVal({
  2359. start: start,
  2360. quote: start.quote,
  2361. key: name instanceof AST_Node ? name : "" + name,
  2362. value: value,
  2363. end: prev()
  2364. }));
  2365. }
  2366. next();
  2367. return new AST_Object({ properties: a });
  2368. });
  2369. function class_(KindOfClass) {
  2370. var start, method, class_name, extends_, a = [];
  2371. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2372. S.input.add_directive("use strict");
  2373. if (S.token.type == "name" && S.token.value != "extends") {
  2374. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2375. }
  2376. if (KindOfClass === AST_DefClass && !class_name) {
  2377. unexpected();
  2378. }
  2379. if (S.token.value == "extends") {
  2380. next();
  2381. extends_ = expression(true);
  2382. }
  2383. expect("{");
  2384. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2385. while (!is("punc", "}")) {
  2386. start = S.token;
  2387. method = concise_method_or_getset(as_property_name(), start, true);
  2388. if (!method) { unexpected(); }
  2389. a.push(method);
  2390. while (is("punc", ";")) { next(); }
  2391. }
  2392. S.input.pop_directives_stack();
  2393. next();
  2394. return new KindOfClass({
  2395. start: start,
  2396. name: class_name,
  2397. extends: extends_,
  2398. properties: a,
  2399. end: prev(),
  2400. });
  2401. }
  2402. function concise_method_or_getset(name, start, is_class) {
  2403. var get_method_name_ast = function(name, start) {
  2404. if (typeof name === "string" || typeof name === "number") {
  2405. return new AST_SymbolMethod({
  2406. start,
  2407. name: "" + name,
  2408. end: prev()
  2409. });
  2410. } else if (name === null) {
  2411. unexpected();
  2412. }
  2413. return name;
  2414. };
  2415. const get_class_property_key_ast = (name) => {
  2416. if (typeof name === "string" || typeof name === "number") {
  2417. return new AST_SymbolClassProperty({
  2418. start: property_token,
  2419. end: property_token,
  2420. name: "" + name
  2421. });
  2422. } else if (name === null) {
  2423. unexpected();
  2424. }
  2425. return name;
  2426. };
  2427. var is_async = false;
  2428. var is_static = false;
  2429. var is_generator = false;
  2430. var property_token = start;
  2431. if (is_class && name === "static" && !is("punc", "(")) {
  2432. is_static = true;
  2433. property_token = S.token;
  2434. name = as_property_name();
  2435. }
  2436. if (name === "async" && !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("operator", "=")) {
  2437. is_async = true;
  2438. property_token = S.token;
  2439. name = as_property_name();
  2440. }
  2441. if (name === null) {
  2442. is_generator = true;
  2443. property_token = S.token;
  2444. name = as_property_name();
  2445. if (name === null) {
  2446. unexpected();
  2447. }
  2448. }
  2449. if (is("punc", "(")) {
  2450. name = get_method_name_ast(name, start);
  2451. var node = new AST_ConciseMethod({
  2452. start : start,
  2453. static : is_static,
  2454. is_generator: is_generator,
  2455. async : is_async,
  2456. key : name,
  2457. quote : name instanceof AST_SymbolMethod ?
  2458. property_token.quote : undefined,
  2459. value : create_accessor(is_generator, is_async),
  2460. end : prev()
  2461. });
  2462. return node;
  2463. }
  2464. const setter_token = S.token;
  2465. if (name == "get") {
  2466. if (!is("punc") || is("punc", "[")) {
  2467. name = get_method_name_ast(as_property_name(), start);
  2468. return new AST_ObjectGetter({
  2469. start : start,
  2470. static: is_static,
  2471. key : name,
  2472. quote : name instanceof AST_SymbolMethod ?
  2473. setter_token.quote : undefined,
  2474. value : create_accessor(),
  2475. end : prev()
  2476. });
  2477. }
  2478. } else if (name == "set") {
  2479. if (!is("punc") || is("punc", "[")) {
  2480. name = get_method_name_ast(as_property_name(), start);
  2481. return new AST_ObjectSetter({
  2482. start : start,
  2483. static: is_static,
  2484. key : name,
  2485. quote : name instanceof AST_SymbolMethod ?
  2486. setter_token.quote : undefined,
  2487. value : create_accessor(),
  2488. end : prev()
  2489. });
  2490. }
  2491. }
  2492. if (is_class) {
  2493. const key = get_class_property_key_ast(name);
  2494. const quote = key instanceof AST_SymbolClassProperty
  2495. ? property_token.quote
  2496. : undefined;
  2497. if (is("operator", "=")) {
  2498. next();
  2499. return new AST_ClassProperty({
  2500. start,
  2501. static: is_static,
  2502. quote,
  2503. key,
  2504. value: expression(false),
  2505. end: prev()
  2506. });
  2507. } else if (is("name") || is("punc", ";") || is("punc", "}")) {
  2508. return new AST_ClassProperty({
  2509. start,
  2510. static: is_static,
  2511. quote,
  2512. key,
  2513. end: prev()
  2514. });
  2515. }
  2516. }
  2517. }
  2518. function import_() {
  2519. var start = prev();
  2520. var imported_name;
  2521. var imported_names;
  2522. if (is("name")) {
  2523. imported_name = as_symbol(AST_SymbolImport);
  2524. }
  2525. if (is("punc", ",")) {
  2526. next();
  2527. }
  2528. imported_names = map_names(true);
  2529. if (imported_names || imported_name) {
  2530. expect_token("name", "from");
  2531. }
  2532. var mod_str = S.token;
  2533. if (mod_str.type !== "string") {
  2534. unexpected();
  2535. }
  2536. next();
  2537. return new AST_Import({
  2538. start: start,
  2539. imported_name: imported_name,
  2540. imported_names: imported_names,
  2541. module_name: new AST_String({
  2542. start: mod_str,
  2543. value: mod_str.value,
  2544. quote: mod_str.quote,
  2545. end: mod_str,
  2546. }),
  2547. end: S.token,
  2548. });
  2549. }
  2550. function import_meta() {
  2551. var start = S.token;
  2552. expect_token("operator", "import");
  2553. expect_token("punc", ".");
  2554. expect_token("name", "meta");
  2555. return subscripts(new AST_ImportMeta({
  2556. start: start,
  2557. end: prev()
  2558. }), false);
  2559. }
  2560. function map_name(is_import) {
  2561. function make_symbol(type) {
  2562. return new type({
  2563. name: as_property_name(),
  2564. start: prev(),
  2565. end: prev()
  2566. });
  2567. }
  2568. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2569. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2570. var start = S.token;
  2571. var foreign_name;
  2572. var name;
  2573. if (is_import) {
  2574. foreign_name = make_symbol(foreign_type);
  2575. } else {
  2576. name = make_symbol(type);
  2577. }
  2578. if (is("name", "as")) {
  2579. next(); // The "as" word
  2580. if (is_import) {
  2581. name = make_symbol(type);
  2582. } else {
  2583. foreign_name = make_symbol(foreign_type);
  2584. }
  2585. } else if (is_import) {
  2586. name = new type(foreign_name);
  2587. } else {
  2588. foreign_name = new foreign_type(name);
  2589. }
  2590. return new AST_NameMapping({
  2591. start: start,
  2592. foreign_name: foreign_name,
  2593. name: name,
  2594. end: prev(),
  2595. });
  2596. }
  2597. function map_nameAsterisk(is_import, name) {
  2598. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2599. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2600. var start = S.token;
  2601. var foreign_name;
  2602. var end = prev();
  2603. name = name || new type({
  2604. name: "*",
  2605. start: start,
  2606. end: end,
  2607. });
  2608. foreign_name = new foreign_type({
  2609. name: "*",
  2610. start: start,
  2611. end: end,
  2612. });
  2613. return new AST_NameMapping({
  2614. start: start,
  2615. foreign_name: foreign_name,
  2616. name: name,
  2617. end: end,
  2618. });
  2619. }
  2620. function map_names(is_import) {
  2621. var names;
  2622. if (is("punc", "{")) {
  2623. next();
  2624. names = [];
  2625. while (!is("punc", "}")) {
  2626. names.push(map_name(is_import));
  2627. if (is("punc", ",")) {
  2628. next();
  2629. }
  2630. }
  2631. next();
  2632. } else if (is("operator", "*")) {
  2633. var name;
  2634. next();
  2635. if (is_import && is("name", "as")) {
  2636. next(); // The "as" word
  2637. name = as_symbol(is_import ? AST_SymbolImport : AST_SymbolExportForeign);
  2638. }
  2639. names = [map_nameAsterisk(is_import, name)];
  2640. }
  2641. return names;
  2642. }
  2643. function export_() {
  2644. var start = S.token;
  2645. var is_default;
  2646. var exported_names;
  2647. if (is("keyword", "default")) {
  2648. is_default = true;
  2649. next();
  2650. } else if (exported_names = map_names(false)) {
  2651. if (is("name", "from")) {
  2652. next();
  2653. var mod_str = S.token;
  2654. if (mod_str.type !== "string") {
  2655. unexpected();
  2656. }
  2657. next();
  2658. return new AST_Export({
  2659. start: start,
  2660. is_default: is_default,
  2661. exported_names: exported_names,
  2662. module_name: new AST_String({
  2663. start: mod_str,
  2664. value: mod_str.value,
  2665. quote: mod_str.quote,
  2666. end: mod_str,
  2667. }),
  2668. end: prev(),
  2669. });
  2670. } else {
  2671. return new AST_Export({
  2672. start: start,
  2673. is_default: is_default,
  2674. exported_names: exported_names,
  2675. end: prev(),
  2676. });
  2677. }
  2678. }
  2679. var node;
  2680. var exported_value;
  2681. var exported_definition;
  2682. if (is("punc", "{")
  2683. || is_default
  2684. && (is("keyword", "class") || is("keyword", "function"))
  2685. && is_token(peek(), "punc")) {
  2686. exported_value = expression(false);
  2687. semicolon();
  2688. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2689. unexpected(node.start);
  2690. } else if (node instanceof AST_Definitions || node instanceof AST_Lambda || node instanceof AST_DefClass) {
  2691. exported_definition = node;
  2692. } else if (node instanceof AST_SimpleStatement) {
  2693. exported_value = node.body;
  2694. } else {
  2695. unexpected(node.start);
  2696. }
  2697. return new AST_Export({
  2698. start: start,
  2699. is_default: is_default,
  2700. exported_value: exported_value,
  2701. exported_definition: exported_definition,
  2702. end: prev(),
  2703. });
  2704. }
  2705. function as_property_name() {
  2706. var tmp = S.token;
  2707. switch (tmp.type) {
  2708. case "punc":
  2709. if (tmp.value === "[") {
  2710. next();
  2711. var ex = expression(false);
  2712. expect("]");
  2713. return ex;
  2714. } else unexpected(tmp);
  2715. case "operator":
  2716. if (tmp.value === "*") {
  2717. next();
  2718. return null;
  2719. }
  2720. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2721. unexpected(tmp);
  2722. }
  2723. /* falls through */
  2724. case "name":
  2725. case "string":
  2726. case "num":
  2727. case "big_int":
  2728. case "keyword":
  2729. case "atom":
  2730. next();
  2731. return tmp.value;
  2732. default:
  2733. unexpected(tmp);
  2734. }
  2735. }
  2736. function as_name() {
  2737. var tmp = S.token;
  2738. if (tmp.type != "name") unexpected();
  2739. next();
  2740. return tmp.value;
  2741. }
  2742. function _make_symbol(type) {
  2743. var name = S.token.value;
  2744. return new (name == "this" ? AST_This :
  2745. name == "super" ? AST_Super :
  2746. type)({
  2747. name : String(name),
  2748. start : S.token,
  2749. end : S.token
  2750. });
  2751. }
  2752. function _verify_symbol(sym) {
  2753. var name = sym.name;
  2754. if (is_in_generator() && name == "yield") {
  2755. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2756. }
  2757. if (S.input.has_directive("use strict")) {
  2758. if (name == "yield") {
  2759. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2760. }
  2761. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2762. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2763. }
  2764. }
  2765. }
  2766. function as_symbol(type, noerror) {
  2767. if (!is("name")) {
  2768. if (!noerror) croak("Name expected");
  2769. return null;
  2770. }
  2771. var sym = _make_symbol(type);
  2772. _verify_symbol(sym);
  2773. next();
  2774. return sym;
  2775. }
  2776. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2777. function annotate(node) {
  2778. var start = node.start;
  2779. var comments = start.comments_before;
  2780. const comments_outside_parens = outer_comments_before_counts.get(start);
  2781. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2782. while (--i >= 0) {
  2783. var comment = comments[i];
  2784. if (/[@#]__/.test(comment.value)) {
  2785. if (/[@#]__PURE__/.test(comment.value)) {
  2786. set_annotation(node, _PURE);
  2787. break;
  2788. }
  2789. if (/[@#]__INLINE__/.test(comment.value)) {
  2790. set_annotation(node, _INLINE);
  2791. break;
  2792. }
  2793. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2794. set_annotation(node, _NOINLINE);
  2795. break;
  2796. }
  2797. }
  2798. }
  2799. }
  2800. var subscripts = function(expr, allow_calls, is_chain) {
  2801. var start = expr.start;
  2802. if (is("punc", ".")) {
  2803. next();
  2804. return subscripts(new AST_Dot({
  2805. start : start,
  2806. expression : expr,
  2807. optional : false,
  2808. property : as_name(),
  2809. end : prev()
  2810. }), allow_calls, is_chain);
  2811. }
  2812. if (is("punc", "[")) {
  2813. next();
  2814. var prop = expression(true);
  2815. expect("]");
  2816. return subscripts(new AST_Sub({
  2817. start : start,
  2818. expression : expr,
  2819. optional : false,
  2820. property : prop,
  2821. end : prev()
  2822. }), allow_calls, is_chain);
  2823. }
  2824. if (allow_calls && is("punc", "(")) {
  2825. next();
  2826. var call = new AST_Call({
  2827. start : start,
  2828. expression : expr,
  2829. optional : false,
  2830. args : call_args(),
  2831. end : prev()
  2832. });
  2833. annotate(call);
  2834. return subscripts(call, true, is_chain);
  2835. }
  2836. if (is("punc", "?.")) {
  2837. next();
  2838. let chain_contents;
  2839. if (allow_calls && is("punc", "(")) {
  2840. next();
  2841. const call = new AST_Call({
  2842. start,
  2843. optional: true,
  2844. expression: expr,
  2845. args: call_args(),
  2846. end: prev()
  2847. });
  2848. annotate(call);
  2849. chain_contents = subscripts(call, true, true);
  2850. } else if (is("name")) {
  2851. chain_contents = subscripts(new AST_Dot({
  2852. start,
  2853. expression: expr,
  2854. optional: true,
  2855. property: as_name(),
  2856. end: prev()
  2857. }), allow_calls, true);
  2858. } else if (is("punc", "[")) {
  2859. next();
  2860. const property = expression(true);
  2861. expect("]");
  2862. chain_contents = subscripts(new AST_Sub({
  2863. start,
  2864. expression: expr,
  2865. optional: true,
  2866. property,
  2867. end: prev()
  2868. }), allow_calls, true);
  2869. }
  2870. if (!chain_contents) unexpected();
  2871. if (chain_contents instanceof AST_Chain) return chain_contents;
  2872. return new AST_Chain({
  2873. start,
  2874. expression: chain_contents,
  2875. end: prev()
  2876. });
  2877. }
  2878. if (is("template_head")) {
  2879. if (is_chain) {
  2880. // a?.b`c` is a syntax error
  2881. unexpected();
  2882. }
  2883. return subscripts(new AST_PrefixedTemplateString({
  2884. start: start,
  2885. prefix: expr,
  2886. template_string: template_string(),
  2887. end: prev()
  2888. }), allow_calls);
  2889. }
  2890. return expr;
  2891. };
  2892. function call_args() {
  2893. var args = [];
  2894. while (!is("punc", ")")) {
  2895. if (is("expand", "...")) {
  2896. next();
  2897. args.push(new AST_Expansion({
  2898. start: prev(),
  2899. expression: expression(false),
  2900. end: prev()
  2901. }));
  2902. } else {
  2903. args.push(expression(false));
  2904. }
  2905. if (!is("punc", ")")) {
  2906. expect(",");
  2907. }
  2908. }
  2909. next();
  2910. return args;
  2911. }
  2912. var maybe_unary = function(allow_calls, allow_arrows) {
  2913. var start = S.token;
  2914. if (start.type == "name" && start.value == "await") {
  2915. if (is_in_async()) {
  2916. next();
  2917. return _await_expression();
  2918. } else if (S.input.has_directive("use strict")) {
  2919. token_error(S.token, "Unexpected await identifier inside strict mode");
  2920. }
  2921. }
  2922. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  2923. next();
  2924. handle_regexp();
  2925. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  2926. ex.start = start;
  2927. ex.end = prev();
  2928. return ex;
  2929. }
  2930. var val = expr_atom(allow_calls, allow_arrows);
  2931. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  2932. if (val instanceof AST_Arrow) unexpected();
  2933. val = make_unary(AST_UnaryPostfix, S.token, val);
  2934. val.start = start;
  2935. val.end = S.token;
  2936. next();
  2937. }
  2938. return val;
  2939. };
  2940. function make_unary(ctor, token, expr) {
  2941. var op = token.value;
  2942. switch (op) {
  2943. case "++":
  2944. case "--":
  2945. if (!is_assignable(expr))
  2946. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  2947. break;
  2948. case "delete":
  2949. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  2950. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  2951. break;
  2952. }
  2953. return new ctor({ operator: op, expression: expr });
  2954. }
  2955. var expr_op = function(left, min_prec, no_in) {
  2956. var op = is("operator") ? S.token.value : null;
  2957. if (op == "in" && no_in) op = null;
  2958. if (op == "**" && left instanceof AST_UnaryPrefix
  2959. /* unary token in front not allowed - parenthesis required */
  2960. && !is_token(left.start, "punc", "(")
  2961. && left.operator !== "--" && left.operator !== "++")
  2962. unexpected(left.start);
  2963. var prec = op != null ? PRECEDENCE[op] : null;
  2964. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  2965. next();
  2966. var right = expr_op(maybe_unary(true), prec, no_in);
  2967. return expr_op(new AST_Binary({
  2968. start : left.start,
  2969. left : left,
  2970. operator : op,
  2971. right : right,
  2972. end : right.end
  2973. }), min_prec, no_in);
  2974. }
  2975. return left;
  2976. };
  2977. function expr_ops(no_in) {
  2978. return expr_op(maybe_unary(true, true), 0, no_in);
  2979. }
  2980. var maybe_conditional = function(no_in) {
  2981. var start = S.token;
  2982. var expr = expr_ops(no_in);
  2983. if (is("operator", "?")) {
  2984. next();
  2985. var yes = expression(false);
  2986. expect(":");
  2987. return new AST_Conditional({
  2988. start : start,
  2989. condition : expr,
  2990. consequent : yes,
  2991. alternative : expression(false, no_in),
  2992. end : prev()
  2993. });
  2994. }
  2995. return expr;
  2996. };
  2997. function is_assignable(expr) {
  2998. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  2999. }
  3000. function to_destructuring(node) {
  3001. if (node instanceof AST_Object) {
  3002. node = new AST_Destructuring({
  3003. start: node.start,
  3004. names: node.properties.map(to_destructuring),
  3005. is_array: false,
  3006. end: node.end
  3007. });
  3008. } else if (node instanceof AST_Array) {
  3009. var names = [];
  3010. for (var i = 0; i < node.elements.length; i++) {
  3011. // Only allow expansion as last element
  3012. if (node.elements[i] instanceof AST_Expansion) {
  3013. if (i + 1 !== node.elements.length) {
  3014. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3015. }
  3016. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3017. }
  3018. names.push(to_destructuring(node.elements[i]));
  3019. }
  3020. node = new AST_Destructuring({
  3021. start: node.start,
  3022. names: names,
  3023. is_array: true,
  3024. end: node.end
  3025. });
  3026. } else if (node instanceof AST_ObjectProperty) {
  3027. node.value = to_destructuring(node.value);
  3028. } else if (node instanceof AST_Assign) {
  3029. node = new AST_DefaultAssign({
  3030. start: node.start,
  3031. left: node.left,
  3032. operator: "=",
  3033. right: node.right,
  3034. end: node.end
  3035. });
  3036. }
  3037. return node;
  3038. }
  3039. // In ES6, AssignmentExpression can also be an ArrowFunction
  3040. var maybe_assign = function(no_in) {
  3041. handle_regexp();
  3042. var start = S.token;
  3043. if (start.type == "name" && start.value == "yield") {
  3044. if (is_in_generator()) {
  3045. next();
  3046. return _yield_expression();
  3047. } else if (S.input.has_directive("use strict")) {
  3048. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3049. }
  3050. }
  3051. var left = maybe_conditional(no_in);
  3052. var val = S.token.value;
  3053. if (is("operator") && ASSIGNMENT.has(val)) {
  3054. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3055. next();
  3056. return new AST_Assign({
  3057. start : start,
  3058. left : left,
  3059. operator : val,
  3060. right : maybe_assign(no_in),
  3061. end : prev()
  3062. });
  3063. }
  3064. croak("Invalid assignment");
  3065. }
  3066. return left;
  3067. };
  3068. var expression = function(commas, no_in) {
  3069. var start = S.token;
  3070. var exprs = [];
  3071. while (true) {
  3072. exprs.push(maybe_assign(no_in));
  3073. if (!commas || !is("punc", ",")) break;
  3074. next();
  3075. commas = true;
  3076. }
  3077. return exprs.length == 1 ? exprs[0] : new AST_Sequence({
  3078. start : start,
  3079. expressions : exprs,
  3080. end : peek()
  3081. });
  3082. };
  3083. function in_loop(cont) {
  3084. ++S.in_loop;
  3085. var ret = cont();
  3086. --S.in_loop;
  3087. return ret;
  3088. }
  3089. if (options.expression) {
  3090. return expression(true);
  3091. }
  3092. return (function parse_toplevel() {
  3093. var start = S.token;
  3094. var body = [];
  3095. S.input.push_directives_stack();
  3096. if (options.module) S.input.add_directive("use strict");
  3097. while (!is("eof")) {
  3098. body.push(statement());
  3099. }
  3100. S.input.pop_directives_stack();
  3101. var end = prev();
  3102. var toplevel = options.toplevel;
  3103. if (toplevel) {
  3104. toplevel.body = toplevel.body.concat(body);
  3105. toplevel.end = end;
  3106. } else {
  3107. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3108. }
  3109. return toplevel;
  3110. })();
  3111. }
  3112. /***********************************************************************
  3113. A JavaScript tokenizer / parser / beautifier / compressor.
  3114. https://github.com/mishoo/UglifyJS2
  3115. -------------------------------- (C) ---------------------------------
  3116. Author: Mihai Bazon
  3117. <mihai.bazon@gmail.com>
  3118. http://mihai.bazon.net/blog
  3119. Distributed under the BSD license:
  3120. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3121. Redistribution and use in source and binary forms, with or without
  3122. modification, are permitted provided that the following conditions
  3123. are met:
  3124. * Redistributions of source code must retain the above
  3125. copyright notice, this list of conditions and the following
  3126. disclaimer.
  3127. * Redistributions in binary form must reproduce the above
  3128. copyright notice, this list of conditions and the following
  3129. disclaimer in the documentation and/or other materials
  3130. provided with the distribution.
  3131. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3132. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3133. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3134. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3135. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3136. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3137. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3138. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3139. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3140. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3141. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3142. SUCH DAMAGE.
  3143. ***********************************************************************/
  3144. function DEFNODE(type, props, methods, base = AST_Node) {
  3145. if (!props) props = [];
  3146. else props = props.split(/\s+/);
  3147. var self_props = props;
  3148. if (base && base.PROPS)
  3149. props = props.concat(base.PROPS);
  3150. var code = "return function AST_" + type + "(props){ if (props) { ";
  3151. for (var i = props.length; --i >= 0;) {
  3152. code += "this." + props[i] + " = props." + props[i] + ";";
  3153. }
  3154. const proto = base && Object.create(base.prototype);
  3155. if (proto && proto.initialize || (methods && methods.initialize))
  3156. code += "this.initialize();";
  3157. code += "}";
  3158. code += "this.flags = 0;";
  3159. code += "}";
  3160. var ctor = new Function(code)();
  3161. if (proto) {
  3162. ctor.prototype = proto;
  3163. ctor.BASE = base;
  3164. }
  3165. if (base) base.SUBCLASSES.push(ctor);
  3166. ctor.prototype.CTOR = ctor;
  3167. ctor.prototype.constructor = ctor;
  3168. ctor.PROPS = props || null;
  3169. ctor.SELF_PROPS = self_props;
  3170. ctor.SUBCLASSES = [];
  3171. if (type) {
  3172. ctor.prototype.TYPE = ctor.TYPE = type;
  3173. }
  3174. if (methods) for (i in methods) if (HOP(methods, i)) {
  3175. if (i[0] === "$") {
  3176. ctor[i.substr(1)] = methods[i];
  3177. } else {
  3178. ctor.prototype[i] = methods[i];
  3179. }
  3180. }
  3181. ctor.DEFMETHOD = function(name, method) {
  3182. this.prototype[name] = method;
  3183. };
  3184. return ctor;
  3185. }
  3186. var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before comments_after file raw quote end", {
  3187. }, null);
  3188. var AST_Node = DEFNODE("Node", "start end", {
  3189. _clone: function(deep) {
  3190. if (deep) {
  3191. var self = this.clone();
  3192. return self.transform(new TreeTransformer(function(node) {
  3193. if (node !== self) {
  3194. return node.clone(true);
  3195. }
  3196. }));
  3197. }
  3198. return new this.CTOR(this);
  3199. },
  3200. clone: function(deep) {
  3201. return this._clone(deep);
  3202. },
  3203. $documentation: "Base class of all AST nodes",
  3204. $propdoc: {
  3205. start: "[AST_Token] The first token of this node",
  3206. end: "[AST_Token] The last token of this node"
  3207. },
  3208. _walk: function(visitor) {
  3209. return visitor._visit(this);
  3210. },
  3211. walk: function(visitor) {
  3212. return this._walk(visitor); // not sure the indirection will be any help
  3213. },
  3214. _children_backwards: () => {}
  3215. }, null);
  3216. /* -----[ statements ]----- */
  3217. var AST_Statement = DEFNODE("Statement", null, {
  3218. $documentation: "Base class of all statements",
  3219. });
  3220. var AST_Debugger = DEFNODE("Debugger", null, {
  3221. $documentation: "Represents a debugger statement",
  3222. }, AST_Statement);
  3223. var AST_Directive = DEFNODE("Directive", "value quote", {
  3224. $documentation: "Represents a directive, like \"use strict\";",
  3225. $propdoc: {
  3226. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3227. quote: "[string] the original quote character"
  3228. },
  3229. }, AST_Statement);
  3230. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
  3231. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3232. $propdoc: {
  3233. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3234. },
  3235. _walk: function(visitor) {
  3236. return visitor._visit(this, function() {
  3237. this.body._walk(visitor);
  3238. });
  3239. },
  3240. _children_backwards(push) {
  3241. push(this.body);
  3242. }
  3243. }, AST_Statement);
  3244. function walk_body(node, visitor) {
  3245. const body = node.body;
  3246. for (var i = 0, len = body.length; i < len; i++) {
  3247. body[i]._walk(visitor);
  3248. }
  3249. }
  3250. function clone_block_scope(deep) {
  3251. var clone = this._clone(deep);
  3252. if (this.block_scope) {
  3253. // TODO this is sometimes undefined during compression.
  3254. // But it should always have a value!
  3255. clone.block_scope = this.block_scope.clone();
  3256. }
  3257. return clone;
  3258. }
  3259. var AST_Block = DEFNODE("Block", "body block_scope", {
  3260. $documentation: "A body of statements (usually braced)",
  3261. $propdoc: {
  3262. body: "[AST_Statement*] an array of statements",
  3263. block_scope: "[AST_Scope] the block scope"
  3264. },
  3265. _walk: function(visitor) {
  3266. return visitor._visit(this, function() {
  3267. walk_body(this, visitor);
  3268. });
  3269. },
  3270. _children_backwards(push) {
  3271. let i = this.body.length;
  3272. while (i--) push(this.body[i]);
  3273. },
  3274. clone: clone_block_scope
  3275. }, AST_Statement);
  3276. var AST_BlockStatement = DEFNODE("BlockStatement", null, {
  3277. $documentation: "A block statement",
  3278. }, AST_Block);
  3279. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, {
  3280. $documentation: "The empty statement (empty block or simply a semicolon)"
  3281. }, AST_Statement);
  3282. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", {
  3283. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3284. $propdoc: {
  3285. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3286. }
  3287. }, AST_Statement);
  3288. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
  3289. $documentation: "Statement with a label",
  3290. $propdoc: {
  3291. label: "[AST_Label] a label definition"
  3292. },
  3293. _walk: function(visitor) {
  3294. return visitor._visit(this, function() {
  3295. this.label._walk(visitor);
  3296. this.body._walk(visitor);
  3297. });
  3298. },
  3299. _children_backwards(push) {
  3300. push(this.body);
  3301. push(this.label);
  3302. },
  3303. clone: function(deep) {
  3304. var node = this._clone(deep);
  3305. if (deep) {
  3306. var label = node.label;
  3307. var def = this.label;
  3308. node.walk(new TreeWalker(function(node) {
  3309. if (node instanceof AST_LoopControl
  3310. && node.label && node.label.thedef === def) {
  3311. node.label.thedef = label;
  3312. label.references.push(node);
  3313. }
  3314. }));
  3315. }
  3316. return node;
  3317. }
  3318. }, AST_StatementWithBody);
  3319. var AST_IterationStatement = DEFNODE("IterationStatement", "block_scope", {
  3320. $documentation: "Internal class. All loops inherit from it.",
  3321. $propdoc: {
  3322. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3323. },
  3324. clone: clone_block_scope
  3325. }, AST_StatementWithBody);
  3326. var AST_DWLoop = DEFNODE("DWLoop", "condition", {
  3327. $documentation: "Base class for do/while statements",
  3328. $propdoc: {
  3329. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3330. }
  3331. }, AST_IterationStatement);
  3332. var AST_Do = DEFNODE("Do", null, {
  3333. $documentation: "A `do` statement",
  3334. _walk: function(visitor) {
  3335. return visitor._visit(this, function() {
  3336. this.body._walk(visitor);
  3337. this.condition._walk(visitor);
  3338. });
  3339. },
  3340. _children_backwards(push) {
  3341. push(this.condition);
  3342. push(this.body);
  3343. }
  3344. }, AST_DWLoop);
  3345. var AST_While = DEFNODE("While", null, {
  3346. $documentation: "A `while` statement",
  3347. _walk: function(visitor) {
  3348. return visitor._visit(this, function() {
  3349. this.condition._walk(visitor);
  3350. this.body._walk(visitor);
  3351. });
  3352. },
  3353. _children_backwards(push) {
  3354. push(this.body);
  3355. push(this.condition);
  3356. },
  3357. }, AST_DWLoop);
  3358. var AST_For = DEFNODE("For", "init condition step", {
  3359. $documentation: "A `for` statement",
  3360. $propdoc: {
  3361. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3362. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3363. step: "[AST_Node?] the `for` update clause, or null if empty"
  3364. },
  3365. _walk: function(visitor) {
  3366. return visitor._visit(this, function() {
  3367. if (this.init) this.init._walk(visitor);
  3368. if (this.condition) this.condition._walk(visitor);
  3369. if (this.step) this.step._walk(visitor);
  3370. this.body._walk(visitor);
  3371. });
  3372. },
  3373. _children_backwards(push) {
  3374. push(this.body);
  3375. if (this.step) push(this.step);
  3376. if (this.condition) push(this.condition);
  3377. if (this.init) push(this.init);
  3378. },
  3379. }, AST_IterationStatement);
  3380. var AST_ForIn = DEFNODE("ForIn", "init object", {
  3381. $documentation: "A `for ... in` statement",
  3382. $propdoc: {
  3383. init: "[AST_Node] the `for/in` initialization code",
  3384. object: "[AST_Node] the object that we're looping through"
  3385. },
  3386. _walk: function(visitor) {
  3387. return visitor._visit(this, function() {
  3388. this.init._walk(visitor);
  3389. this.object._walk(visitor);
  3390. this.body._walk(visitor);
  3391. });
  3392. },
  3393. _children_backwards(push) {
  3394. push(this.body);
  3395. if (this.object) push(this.object);
  3396. if (this.init) push(this.init);
  3397. },
  3398. }, AST_IterationStatement);
  3399. var AST_ForOf = DEFNODE("ForOf", "await", {
  3400. $documentation: "A `for ... of` statement",
  3401. }, AST_ForIn);
  3402. var AST_With = DEFNODE("With", "expression", {
  3403. $documentation: "A `with` statement",
  3404. $propdoc: {
  3405. expression: "[AST_Node] the `with` expression"
  3406. },
  3407. _walk: function(visitor) {
  3408. return visitor._visit(this, function() {
  3409. this.expression._walk(visitor);
  3410. this.body._walk(visitor);
  3411. });
  3412. },
  3413. _children_backwards(push) {
  3414. push(this.body);
  3415. push(this.expression);
  3416. },
  3417. }, AST_StatementWithBody);
  3418. /* -----[ scope and functions ]----- */
  3419. var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", {
  3420. $documentation: "Base class for all statements introducing a lexical scope",
  3421. $propdoc: {
  3422. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3423. functions: "[Map/S] like `variables`, but only lists function declarations",
  3424. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3425. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3426. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3427. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3428. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3429. },
  3430. get_defun_scope: function() {
  3431. var self = this;
  3432. while (self.is_block_scope()) {
  3433. self = self.parent_scope;
  3434. }
  3435. return self;
  3436. },
  3437. clone: function(deep, toplevel) {
  3438. var node = this._clone(deep);
  3439. if (deep && this.variables && toplevel && !this._block_scope) {
  3440. node.figure_out_scope({}, {
  3441. toplevel: toplevel,
  3442. parent_scope: this.parent_scope
  3443. });
  3444. } else {
  3445. if (this.variables) node.variables = new Map(this.variables);
  3446. if (this.functions) node.functions = new Map(this.functions);
  3447. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3448. if (this._block_scope) node._block_scope = this._block_scope;
  3449. }
  3450. return node;
  3451. },
  3452. pinned: function() {
  3453. return this.uses_eval || this.uses_with;
  3454. }
  3455. }, AST_Block);
  3456. var AST_Toplevel = DEFNODE("Toplevel", "globals", {
  3457. $documentation: "The toplevel scope",
  3458. $propdoc: {
  3459. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3460. },
  3461. wrap_commonjs: function(name) {
  3462. var body = this.body;
  3463. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3464. wrapped_tl = parse(wrapped_tl);
  3465. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3466. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3467. return MAP.splice(body);
  3468. }
  3469. }));
  3470. return wrapped_tl;
  3471. },
  3472. wrap_enclose: function(args_values) {
  3473. if (typeof args_values != "string") args_values = "";
  3474. var index = args_values.indexOf(":");
  3475. if (index < 0) index = args_values.length;
  3476. var body = this.body;
  3477. return parse([
  3478. "(function(",
  3479. args_values.slice(0, index),
  3480. '){"$ORIG"})(',
  3481. args_values.slice(index + 1),
  3482. ")"
  3483. ].join("")).transform(new TreeTransformer(function(node) {
  3484. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3485. return MAP.splice(body);
  3486. }
  3487. }));
  3488. }
  3489. }, AST_Scope);
  3490. var AST_Expansion = DEFNODE("Expansion", "expression", {
  3491. $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",
  3492. $propdoc: {
  3493. expression: "[AST_Node] the thing to be expanded"
  3494. },
  3495. _walk: function(visitor) {
  3496. return visitor._visit(this, function() {
  3497. this.expression.walk(visitor);
  3498. });
  3499. },
  3500. _children_backwards(push) {
  3501. push(this.expression);
  3502. },
  3503. });
  3504. var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments is_generator async", {
  3505. $documentation: "Base class for functions",
  3506. $propdoc: {
  3507. name: "[AST_SymbolDeclaration?] the name of this function",
  3508. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3509. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3510. is_generator: "[boolean] is this a generator method",
  3511. async: "[boolean] is this method async",
  3512. },
  3513. args_as_names: function () {
  3514. var out = [];
  3515. for (var i = 0; i < this.argnames.length; i++) {
  3516. if (this.argnames[i] instanceof AST_Destructuring) {
  3517. out.push(...this.argnames[i].all_symbols());
  3518. } else {
  3519. out.push(this.argnames[i]);
  3520. }
  3521. }
  3522. return out;
  3523. },
  3524. _walk: function(visitor) {
  3525. return visitor._visit(this, function() {
  3526. if (this.name) this.name._walk(visitor);
  3527. var argnames = this.argnames;
  3528. for (var i = 0, len = argnames.length; i < len; i++) {
  3529. argnames[i]._walk(visitor);
  3530. }
  3531. walk_body(this, visitor);
  3532. });
  3533. },
  3534. _children_backwards(push) {
  3535. let i = this.body.length;
  3536. while (i--) push(this.body[i]);
  3537. i = this.argnames.length;
  3538. while (i--) push(this.argnames[i]);
  3539. if (this.name) push(this.name);
  3540. },
  3541. }, AST_Scope);
  3542. var AST_Accessor = DEFNODE("Accessor", null, {
  3543. $documentation: "A setter/getter function. The `name` property is always null."
  3544. }, AST_Lambda);
  3545. var AST_Function = DEFNODE("Function", null, {
  3546. $documentation: "A function expression"
  3547. }, AST_Lambda);
  3548. var AST_Arrow = DEFNODE("Arrow", null, {
  3549. $documentation: "An ES6 Arrow function ((a) => b)"
  3550. }, AST_Lambda);
  3551. var AST_Defun = DEFNODE("Defun", null, {
  3552. $documentation: "A function definition"
  3553. }, AST_Lambda);
  3554. /* -----[ DESTRUCTURING ]----- */
  3555. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", {
  3556. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  3557. $propdoc: {
  3558. "names": "[AST_Node*] Array of properties or elements",
  3559. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  3560. },
  3561. _walk: function(visitor) {
  3562. return visitor._visit(this, function() {
  3563. this.names.forEach(function(name) {
  3564. name._walk(visitor);
  3565. });
  3566. });
  3567. },
  3568. _children_backwards(push) {
  3569. let i = this.names.length;
  3570. while (i--) push(this.names[i]);
  3571. },
  3572. all_symbols: function() {
  3573. var out = [];
  3574. this.walk(new TreeWalker(function (node) {
  3575. if (node instanceof AST_Symbol) {
  3576. out.push(node);
  3577. }
  3578. }));
  3579. return out;
  3580. }
  3581. });
  3582. var AST_PrefixedTemplateString = DEFNODE("PrefixedTemplateString", "template_string prefix", {
  3583. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  3584. $propdoc: {
  3585. template_string: "[AST_TemplateString] The template string",
  3586. prefix: "[AST_Node] The prefix, which will get called."
  3587. },
  3588. _walk: function(visitor) {
  3589. return visitor._visit(this, function () {
  3590. this.prefix._walk(visitor);
  3591. this.template_string._walk(visitor);
  3592. });
  3593. },
  3594. _children_backwards(push) {
  3595. push(this.template_string);
  3596. push(this.prefix);
  3597. },
  3598. });
  3599. var AST_TemplateString = DEFNODE("TemplateString", "segments", {
  3600. $documentation: "A template string literal",
  3601. $propdoc: {
  3602. 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."
  3603. },
  3604. _walk: function(visitor) {
  3605. return visitor._visit(this, function() {
  3606. this.segments.forEach(function(seg) {
  3607. seg._walk(visitor);
  3608. });
  3609. });
  3610. },
  3611. _children_backwards(push) {
  3612. let i = this.segments.length;
  3613. while (i--) push(this.segments[i]);
  3614. }
  3615. });
  3616. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", {
  3617. $documentation: "A segment of a template string literal",
  3618. $propdoc: {
  3619. value: "Content of the segment",
  3620. raw: "Raw content of the segment"
  3621. }
  3622. });
  3623. /* -----[ JUMPS ]----- */
  3624. var AST_Jump = DEFNODE("Jump", null, {
  3625. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  3626. }, AST_Statement);
  3627. var AST_Exit = DEFNODE("Exit", "value", {
  3628. $documentation: "Base class for “exits” (`return` and `throw`)",
  3629. $propdoc: {
  3630. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  3631. },
  3632. _walk: function(visitor) {
  3633. return visitor._visit(this, this.value && function() {
  3634. this.value._walk(visitor);
  3635. });
  3636. },
  3637. _children_backwards(push) {
  3638. if (this.value) push(this.value);
  3639. },
  3640. }, AST_Jump);
  3641. var AST_Return = DEFNODE("Return", null, {
  3642. $documentation: "A `return` statement"
  3643. }, AST_Exit);
  3644. var AST_Throw = DEFNODE("Throw", null, {
  3645. $documentation: "A `throw` statement"
  3646. }, AST_Exit);
  3647. var AST_LoopControl = DEFNODE("LoopControl", "label", {
  3648. $documentation: "Base class for loop control statements (`break` and `continue`)",
  3649. $propdoc: {
  3650. label: "[AST_LabelRef?] the label, or null if none",
  3651. },
  3652. _walk: function(visitor) {
  3653. return visitor._visit(this, this.label && function() {
  3654. this.label._walk(visitor);
  3655. });
  3656. },
  3657. _children_backwards(push) {
  3658. if (this.label) push(this.label);
  3659. },
  3660. }, AST_Jump);
  3661. var AST_Break = DEFNODE("Break", null, {
  3662. $documentation: "A `break` statement"
  3663. }, AST_LoopControl);
  3664. var AST_Continue = DEFNODE("Continue", null, {
  3665. $documentation: "A `continue` statement"
  3666. }, AST_LoopControl);
  3667. var AST_Await = DEFNODE("Await", "expression", {
  3668. $documentation: "An `await` statement",
  3669. $propdoc: {
  3670. expression: "[AST_Node] the mandatory expression being awaited",
  3671. },
  3672. _walk: function(visitor) {
  3673. return visitor._visit(this, function() {
  3674. this.expression._walk(visitor);
  3675. });
  3676. },
  3677. _children_backwards(push) {
  3678. push(this.expression);
  3679. },
  3680. });
  3681. var AST_Yield = DEFNODE("Yield", "expression is_star", {
  3682. $documentation: "A `yield` statement",
  3683. $propdoc: {
  3684. 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",
  3685. is_star: "[Boolean] Whether this is a yield or yield* statement"
  3686. },
  3687. _walk: function(visitor) {
  3688. return visitor._visit(this, this.expression && function() {
  3689. this.expression._walk(visitor);
  3690. });
  3691. },
  3692. _children_backwards(push) {
  3693. if (this.expression) push(this.expression);
  3694. }
  3695. });
  3696. /* -----[ IF ]----- */
  3697. var AST_If = DEFNODE("If", "condition alternative", {
  3698. $documentation: "A `if` statement",
  3699. $propdoc: {
  3700. condition: "[AST_Node] the `if` condition",
  3701. alternative: "[AST_Statement?] the `else` part, or null if not present"
  3702. },
  3703. _walk: function(visitor) {
  3704. return visitor._visit(this, function() {
  3705. this.condition._walk(visitor);
  3706. this.body._walk(visitor);
  3707. if (this.alternative) this.alternative._walk(visitor);
  3708. });
  3709. },
  3710. _children_backwards(push) {
  3711. if (this.alternative) {
  3712. push(this.alternative);
  3713. }
  3714. push(this.body);
  3715. push(this.condition);
  3716. }
  3717. }, AST_StatementWithBody);
  3718. /* -----[ SWITCH ]----- */
  3719. var AST_Switch = DEFNODE("Switch", "expression", {
  3720. $documentation: "A `switch` statement",
  3721. $propdoc: {
  3722. expression: "[AST_Node] the `switch` “discriminant”"
  3723. },
  3724. _walk: function(visitor) {
  3725. return visitor._visit(this, function() {
  3726. this.expression._walk(visitor);
  3727. walk_body(this, visitor);
  3728. });
  3729. },
  3730. _children_backwards(push) {
  3731. let i = this.body.length;
  3732. while (i--) push(this.body[i]);
  3733. push(this.expression);
  3734. }
  3735. }, AST_Block);
  3736. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
  3737. $documentation: "Base class for `switch` branches",
  3738. }, AST_Block);
  3739. var AST_Default = DEFNODE("Default", null, {
  3740. $documentation: "A `default` switch branch",
  3741. }, AST_SwitchBranch);
  3742. var AST_Case = DEFNODE("Case", "expression", {
  3743. $documentation: "A `case` switch branch",
  3744. $propdoc: {
  3745. expression: "[AST_Node] the `case` expression"
  3746. },
  3747. _walk: function(visitor) {
  3748. return visitor._visit(this, function() {
  3749. this.expression._walk(visitor);
  3750. walk_body(this, visitor);
  3751. });
  3752. },
  3753. _children_backwards(push) {
  3754. let i = this.body.length;
  3755. while (i--) push(this.body[i]);
  3756. push(this.expression);
  3757. },
  3758. }, AST_SwitchBranch);
  3759. /* -----[ EXCEPTIONS ]----- */
  3760. var AST_Try = DEFNODE("Try", "bcatch bfinally", {
  3761. $documentation: "A `try` statement",
  3762. $propdoc: {
  3763. bcatch: "[AST_Catch?] the catch block, or null if not present",
  3764. bfinally: "[AST_Finally?] the finally block, or null if not present"
  3765. },
  3766. _walk: function(visitor) {
  3767. return visitor._visit(this, function() {
  3768. walk_body(this, visitor);
  3769. if (this.bcatch) this.bcatch._walk(visitor);
  3770. if (this.bfinally) this.bfinally._walk(visitor);
  3771. });
  3772. },
  3773. _children_backwards(push) {
  3774. if (this.bfinally) push(this.bfinally);
  3775. if (this.bcatch) push(this.bcatch);
  3776. let i = this.body.length;
  3777. while (i--) push(this.body[i]);
  3778. },
  3779. }, AST_Block);
  3780. var AST_Catch = DEFNODE("Catch", "argname", {
  3781. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  3782. $propdoc: {
  3783. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  3784. },
  3785. _walk: function(visitor) {
  3786. return visitor._visit(this, function() {
  3787. if (this.argname) this.argname._walk(visitor);
  3788. walk_body(this, visitor);
  3789. });
  3790. },
  3791. _children_backwards(push) {
  3792. let i = this.body.length;
  3793. while (i--) push(this.body[i]);
  3794. if (this.argname) push(this.argname);
  3795. },
  3796. }, AST_Block);
  3797. var AST_Finally = DEFNODE("Finally", null, {
  3798. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  3799. }, AST_Block);
  3800. /* -----[ VAR/CONST ]----- */
  3801. var AST_Definitions = DEFNODE("Definitions", "definitions", {
  3802. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  3803. $propdoc: {
  3804. definitions: "[AST_VarDef*] array of variable definitions"
  3805. },
  3806. _walk: function(visitor) {
  3807. return visitor._visit(this, function() {
  3808. var definitions = this.definitions;
  3809. for (var i = 0, len = definitions.length; i < len; i++) {
  3810. definitions[i]._walk(visitor);
  3811. }
  3812. });
  3813. },
  3814. _children_backwards(push) {
  3815. let i = this.definitions.length;
  3816. while (i--) push(this.definitions[i]);
  3817. },
  3818. }, AST_Statement);
  3819. var AST_Var = DEFNODE("Var", null, {
  3820. $documentation: "A `var` statement"
  3821. }, AST_Definitions);
  3822. var AST_Let = DEFNODE("Let", null, {
  3823. $documentation: "A `let` statement"
  3824. }, AST_Definitions);
  3825. var AST_Const = DEFNODE("Const", null, {
  3826. $documentation: "A `const` statement"
  3827. }, AST_Definitions);
  3828. var AST_VarDef = DEFNODE("VarDef", "name value", {
  3829. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  3830. $propdoc: {
  3831. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  3832. value: "[AST_Node?] initializer, or null of there's no initializer"
  3833. },
  3834. _walk: function(visitor) {
  3835. return visitor._visit(this, function() {
  3836. this.name._walk(visitor);
  3837. if (this.value) this.value._walk(visitor);
  3838. });
  3839. },
  3840. _children_backwards(push) {
  3841. if (this.value) push(this.value);
  3842. push(this.name);
  3843. },
  3844. });
  3845. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", {
  3846. $documentation: "The part of the export/import statement that declare names from a module.",
  3847. $propdoc: {
  3848. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  3849. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  3850. },
  3851. _walk: function (visitor) {
  3852. return visitor._visit(this, function() {
  3853. this.foreign_name._walk(visitor);
  3854. this.name._walk(visitor);
  3855. });
  3856. },
  3857. _children_backwards(push) {
  3858. push(this.name);
  3859. push(this.foreign_name);
  3860. },
  3861. });
  3862. var AST_Import = DEFNODE("Import", "imported_name imported_names module_name", {
  3863. $documentation: "An `import` statement",
  3864. $propdoc: {
  3865. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  3866. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  3867. module_name: "[AST_String] String literal describing where this module came from",
  3868. },
  3869. _walk: function(visitor) {
  3870. return visitor._visit(this, function() {
  3871. if (this.imported_name) {
  3872. this.imported_name._walk(visitor);
  3873. }
  3874. if (this.imported_names) {
  3875. this.imported_names.forEach(function(name_import) {
  3876. name_import._walk(visitor);
  3877. });
  3878. }
  3879. this.module_name._walk(visitor);
  3880. });
  3881. },
  3882. _children_backwards(push) {
  3883. push(this.module_name);
  3884. if (this.imported_names) {
  3885. let i = this.imported_names.length;
  3886. while (i--) push(this.imported_names[i]);
  3887. }
  3888. if (this.imported_name) push(this.imported_name);
  3889. },
  3890. });
  3891. var AST_ImportMeta = DEFNODE("ImportMeta", null, {
  3892. $documentation: "A reference to import.meta",
  3893. });
  3894. var AST_Export = DEFNODE("Export", "exported_definition exported_value is_default exported_names module_name", {
  3895. $documentation: "An `export` statement",
  3896. $propdoc: {
  3897. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  3898. exported_value: "[AST_Node?] An exported value",
  3899. exported_names: "[AST_NameMapping*?] List of exported names",
  3900. module_name: "[AST_String?] Name of the file to load exports from",
  3901. is_default: "[Boolean] Whether this is the default exported value of this module"
  3902. },
  3903. _walk: function (visitor) {
  3904. return visitor._visit(this, function () {
  3905. if (this.exported_definition) {
  3906. this.exported_definition._walk(visitor);
  3907. }
  3908. if (this.exported_value) {
  3909. this.exported_value._walk(visitor);
  3910. }
  3911. if (this.exported_names) {
  3912. this.exported_names.forEach(function(name_export) {
  3913. name_export._walk(visitor);
  3914. });
  3915. }
  3916. if (this.module_name) {
  3917. this.module_name._walk(visitor);
  3918. }
  3919. });
  3920. },
  3921. _children_backwards(push) {
  3922. if (this.module_name) push(this.module_name);
  3923. if (this.exported_names) {
  3924. let i = this.exported_names.length;
  3925. while (i--) push(this.exported_names[i]);
  3926. }
  3927. if (this.exported_value) push(this.exported_value);
  3928. if (this.exported_definition) push(this.exported_definition);
  3929. }
  3930. }, AST_Statement);
  3931. /* -----[ OTHER ]----- */
  3932. var AST_Call = DEFNODE("Call", "expression args optional _annotations", {
  3933. $documentation: "A function call expression",
  3934. $propdoc: {
  3935. expression: "[AST_Node] expression to invoke as function",
  3936. args: "[AST_Node*] array of arguments",
  3937. optional: "[boolean] whether this is an optional call (IE ?.() )",
  3938. _annotations: "[number] bitfield containing information about the call"
  3939. },
  3940. initialize() {
  3941. if (this._annotations == null) this._annotations = 0;
  3942. },
  3943. _walk(visitor) {
  3944. return visitor._visit(this, function() {
  3945. var args = this.args;
  3946. for (var i = 0, len = args.length; i < len; i++) {
  3947. args[i]._walk(visitor);
  3948. }
  3949. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  3950. });
  3951. },
  3952. _children_backwards(push) {
  3953. let i = this.args.length;
  3954. while (i--) push(this.args[i]);
  3955. push(this.expression);
  3956. },
  3957. });
  3958. var AST_New = DEFNODE("New", null, {
  3959. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  3960. }, AST_Call);
  3961. var AST_Sequence = DEFNODE("Sequence", "expressions", {
  3962. $documentation: "A sequence expression (comma-separated expressions)",
  3963. $propdoc: {
  3964. expressions: "[AST_Node*] array of expressions (at least two)"
  3965. },
  3966. _walk: function(visitor) {
  3967. return visitor._visit(this, function() {
  3968. this.expressions.forEach(function(node) {
  3969. node._walk(visitor);
  3970. });
  3971. });
  3972. },
  3973. _children_backwards(push) {
  3974. let i = this.expressions.length;
  3975. while (i--) push(this.expressions[i]);
  3976. },
  3977. });
  3978. var AST_PropAccess = DEFNODE("PropAccess", "expression property optional", {
  3979. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  3980. $propdoc: {
  3981. expression: "[AST_Node] the “container” expression",
  3982. property: "[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
  3983. optional: "[boolean] whether this is an optional property access (IE ?.)"
  3984. }
  3985. });
  3986. var AST_Dot = DEFNODE("Dot", "quote", {
  3987. $documentation: "A dotted property access expression",
  3988. $propdoc: {
  3989. quote: "[string] the original quote character when transformed from AST_Sub",
  3990. },
  3991. _walk: function(visitor) {
  3992. return visitor._visit(this, function() {
  3993. this.expression._walk(visitor);
  3994. });
  3995. },
  3996. _children_backwards(push) {
  3997. push(this.expression);
  3998. },
  3999. }, AST_PropAccess);
  4000. var AST_Sub = DEFNODE("Sub", null, {
  4001. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4002. _walk: function(visitor) {
  4003. return visitor._visit(this, function() {
  4004. this.expression._walk(visitor);
  4005. this.property._walk(visitor);
  4006. });
  4007. },
  4008. _children_backwards(push) {
  4009. push(this.property);
  4010. push(this.expression);
  4011. },
  4012. }, AST_PropAccess);
  4013. var AST_Chain = DEFNODE("Chain", "expression", {
  4014. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4015. $propdoc: {
  4016. expression: "[AST_Call|AST_Dot|AST_Sub] chain element."
  4017. },
  4018. _walk: function (visitor) {
  4019. return visitor._visit(this, function() {
  4020. this.expression._walk(visitor);
  4021. });
  4022. },
  4023. _children_backwards(push) {
  4024. push(this.expression);
  4025. },
  4026. });
  4027. var AST_Unary = DEFNODE("Unary", "operator expression", {
  4028. $documentation: "Base class for unary expressions",
  4029. $propdoc: {
  4030. operator: "[string] the operator",
  4031. expression: "[AST_Node] expression that this unary operator applies to"
  4032. },
  4033. _walk: function(visitor) {
  4034. return visitor._visit(this, function() {
  4035. this.expression._walk(visitor);
  4036. });
  4037. },
  4038. _children_backwards(push) {
  4039. push(this.expression);
  4040. },
  4041. });
  4042. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, {
  4043. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4044. }, AST_Unary);
  4045. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, {
  4046. $documentation: "Unary postfix expression, i.e. `i++`"
  4047. }, AST_Unary);
  4048. var AST_Binary = DEFNODE("Binary", "operator left right", {
  4049. $documentation: "Binary expression, i.e. `a + b`",
  4050. $propdoc: {
  4051. left: "[AST_Node] left-hand side expression",
  4052. operator: "[string] the operator",
  4053. right: "[AST_Node] right-hand side expression"
  4054. },
  4055. _walk: function(visitor) {
  4056. return visitor._visit(this, function() {
  4057. this.left._walk(visitor);
  4058. this.right._walk(visitor);
  4059. });
  4060. },
  4061. _children_backwards(push) {
  4062. push(this.right);
  4063. push(this.left);
  4064. },
  4065. });
  4066. var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative", {
  4067. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  4068. $propdoc: {
  4069. condition: "[AST_Node]",
  4070. consequent: "[AST_Node]",
  4071. alternative: "[AST_Node]"
  4072. },
  4073. _walk: function(visitor) {
  4074. return visitor._visit(this, function() {
  4075. this.condition._walk(visitor);
  4076. this.consequent._walk(visitor);
  4077. this.alternative._walk(visitor);
  4078. });
  4079. },
  4080. _children_backwards(push) {
  4081. push(this.alternative);
  4082. push(this.consequent);
  4083. push(this.condition);
  4084. },
  4085. });
  4086. var AST_Assign = DEFNODE("Assign", null, {
  4087. $documentation: "An assignment expression — `a = b + 5`",
  4088. }, AST_Binary);
  4089. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, {
  4090. $documentation: "A default assignment expression like in `(a = 3) => a`"
  4091. }, AST_Binary);
  4092. /* -----[ LITERALS ]----- */
  4093. var AST_Array = DEFNODE("Array", "elements", {
  4094. $documentation: "An array literal",
  4095. $propdoc: {
  4096. elements: "[AST_Node*] array of elements"
  4097. },
  4098. _walk: function(visitor) {
  4099. return visitor._visit(this, function() {
  4100. var elements = this.elements;
  4101. for (var i = 0, len = elements.length; i < len; i++) {
  4102. elements[i]._walk(visitor);
  4103. }
  4104. });
  4105. },
  4106. _children_backwards(push) {
  4107. let i = this.elements.length;
  4108. while (i--) push(this.elements[i]);
  4109. },
  4110. });
  4111. var AST_Object = DEFNODE("Object", "properties", {
  4112. $documentation: "An object literal",
  4113. $propdoc: {
  4114. properties: "[AST_ObjectProperty*] array of properties"
  4115. },
  4116. _walk: function(visitor) {
  4117. return visitor._visit(this, function() {
  4118. var properties = this.properties;
  4119. for (var i = 0, len = properties.length; i < len; i++) {
  4120. properties[i]._walk(visitor);
  4121. }
  4122. });
  4123. },
  4124. _children_backwards(push) {
  4125. let i = this.properties.length;
  4126. while (i--) push(this.properties[i]);
  4127. },
  4128. });
  4129. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
  4130. $documentation: "Base class for literal object properties",
  4131. $propdoc: {
  4132. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  4133. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  4134. },
  4135. _walk: function(visitor) {
  4136. return visitor._visit(this, function() {
  4137. if (this.key instanceof AST_Node)
  4138. this.key._walk(visitor);
  4139. this.value._walk(visitor);
  4140. });
  4141. },
  4142. _children_backwards(push) {
  4143. push(this.value);
  4144. if (this.key instanceof AST_Node) push(this.key);
  4145. }
  4146. });
  4147. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
  4148. $documentation: "A key: value object property",
  4149. $propdoc: {
  4150. quote: "[string] the original quote character"
  4151. },
  4152. computed_key() {
  4153. return this.key instanceof AST_Node;
  4154. }
  4155. }, AST_ObjectProperty);
  4156. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", {
  4157. $propdoc: {
  4158. quote: "[string|undefined] the original quote character, if any",
  4159. static: "[boolean] whether this is a static setter (classes only)"
  4160. },
  4161. $documentation: "An object setter property",
  4162. computed_key() {
  4163. return !(this.key instanceof AST_SymbolMethod);
  4164. }
  4165. }, AST_ObjectProperty);
  4166. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", {
  4167. $propdoc: {
  4168. quote: "[string|undefined] the original quote character, if any",
  4169. static: "[boolean] whether this is a static getter (classes only)"
  4170. },
  4171. $documentation: "An object getter property",
  4172. computed_key() {
  4173. return !(this.key instanceof AST_SymbolMethod);
  4174. }
  4175. }, AST_ObjectProperty);
  4176. var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator async", {
  4177. $propdoc: {
  4178. quote: "[string|undefined] the original quote character, if any",
  4179. static: "[boolean] is this method static (classes only)",
  4180. is_generator: "[boolean] is this a generator method",
  4181. async: "[boolean] is this method async",
  4182. },
  4183. $documentation: "An ES6 concise method inside an object or class",
  4184. computed_key() {
  4185. return !(this.key instanceof AST_SymbolMethod);
  4186. }
  4187. }, AST_ObjectProperty);
  4188. var AST_Class = DEFNODE("Class", "name extends properties", {
  4189. $propdoc: {
  4190. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  4191. extends: "[AST_Node]? optional parent class",
  4192. properties: "[AST_ObjectProperty*] array of properties"
  4193. },
  4194. $documentation: "An ES6 class",
  4195. _walk: function(visitor) {
  4196. return visitor._visit(this, function() {
  4197. if (this.name) {
  4198. this.name._walk(visitor);
  4199. }
  4200. if (this.extends) {
  4201. this.extends._walk(visitor);
  4202. }
  4203. this.properties.forEach((prop) => prop._walk(visitor));
  4204. });
  4205. },
  4206. _children_backwards(push) {
  4207. let i = this.properties.length;
  4208. while (i--) push(this.properties[i]);
  4209. if (this.extends) push(this.extends);
  4210. if (this.name) push(this.name);
  4211. },
  4212. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  4213. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", {
  4214. $documentation: "A class property",
  4215. $propdoc: {
  4216. static: "[boolean] whether this is a static key",
  4217. quote: "[string] which quote is being used"
  4218. },
  4219. _walk: function(visitor) {
  4220. return visitor._visit(this, function() {
  4221. if (this.key instanceof AST_Node)
  4222. this.key._walk(visitor);
  4223. if (this.value instanceof AST_Node)
  4224. this.value._walk(visitor);
  4225. });
  4226. },
  4227. _children_backwards(push) {
  4228. if (this.value instanceof AST_Node) push(this.value);
  4229. if (this.key instanceof AST_Node) push(this.key);
  4230. },
  4231. computed_key() {
  4232. return !(this.key instanceof AST_SymbolClassProperty);
  4233. }
  4234. }, AST_ObjectProperty);
  4235. var AST_DefClass = DEFNODE("DefClass", null, {
  4236. $documentation: "A class definition",
  4237. }, AST_Class);
  4238. var AST_ClassExpression = DEFNODE("ClassExpression", null, {
  4239. $documentation: "A class expression."
  4240. }, AST_Class);
  4241. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
  4242. $propdoc: {
  4243. name: "[string] name of this symbol",
  4244. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  4245. thedef: "[SymbolDef/S] the definition of this symbol"
  4246. },
  4247. $documentation: "Base class for all symbols"
  4248. });
  4249. var AST_NewTarget = DEFNODE("NewTarget", null, {
  4250. $documentation: "A reference to new.target"
  4251. });
  4252. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
  4253. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  4254. }, AST_Symbol);
  4255. var AST_SymbolVar = DEFNODE("SymbolVar", null, {
  4256. $documentation: "Symbol defining a variable",
  4257. }, AST_SymbolDeclaration);
  4258. var AST_SymbolBlockDeclaration = DEFNODE("SymbolBlockDeclaration", null, {
  4259. $documentation: "Base class for block-scoped declaration symbols"
  4260. }, AST_SymbolDeclaration);
  4261. var AST_SymbolConst = DEFNODE("SymbolConst", null, {
  4262. $documentation: "A constant declaration"
  4263. }, AST_SymbolBlockDeclaration);
  4264. var AST_SymbolLet = DEFNODE("SymbolLet", null, {
  4265. $documentation: "A block-scoped `let` declaration"
  4266. }, AST_SymbolBlockDeclaration);
  4267. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
  4268. $documentation: "Symbol naming a function argument",
  4269. }, AST_SymbolVar);
  4270. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, {
  4271. $documentation: "Symbol defining a function",
  4272. }, AST_SymbolDeclaration);
  4273. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, {
  4274. $documentation: "Symbol in an object defining a method",
  4275. }, AST_Symbol);
  4276. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, {
  4277. $documentation: "Symbol for a class property",
  4278. }, AST_Symbol);
  4279. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, {
  4280. $documentation: "Symbol naming a function expression",
  4281. }, AST_SymbolDeclaration);
  4282. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, {
  4283. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  4284. }, AST_SymbolBlockDeclaration);
  4285. var AST_SymbolClass = DEFNODE("SymbolClass", null, {
  4286. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  4287. }, AST_SymbolDeclaration);
  4288. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, {
  4289. $documentation: "Symbol naming the exception in catch",
  4290. }, AST_SymbolBlockDeclaration);
  4291. var AST_SymbolImport = DEFNODE("SymbolImport", null, {
  4292. $documentation: "Symbol referring to an imported name",
  4293. }, AST_SymbolBlockDeclaration);
  4294. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, {
  4295. $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",
  4296. }, AST_Symbol);
  4297. var AST_Label = DEFNODE("Label", "references", {
  4298. $documentation: "Symbol naming a label (declaration)",
  4299. $propdoc: {
  4300. references: "[AST_LoopControl*] a list of nodes referring to this label"
  4301. },
  4302. initialize: function() {
  4303. this.references = [];
  4304. this.thedef = this;
  4305. }
  4306. }, AST_Symbol);
  4307. var AST_SymbolRef = DEFNODE("SymbolRef", null, {
  4308. $documentation: "Reference to some symbol (not definition/declaration)",
  4309. }, AST_Symbol);
  4310. var AST_SymbolExport = DEFNODE("SymbolExport", null, {
  4311. $documentation: "Symbol referring to a name to export",
  4312. }, AST_SymbolRef);
  4313. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, {
  4314. $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",
  4315. }, AST_Symbol);
  4316. var AST_LabelRef = DEFNODE("LabelRef", null, {
  4317. $documentation: "Reference to a label symbol",
  4318. }, AST_Symbol);
  4319. var AST_This = DEFNODE("This", null, {
  4320. $documentation: "The `this` symbol",
  4321. }, AST_Symbol);
  4322. var AST_Super = DEFNODE("Super", null, {
  4323. $documentation: "The `super` symbol",
  4324. }, AST_This);
  4325. var AST_Constant = DEFNODE("Constant", null, {
  4326. $documentation: "Base class for all constants",
  4327. getValue: function() {
  4328. return this.value;
  4329. }
  4330. });
  4331. var AST_String = DEFNODE("String", "value quote", {
  4332. $documentation: "A string literal",
  4333. $propdoc: {
  4334. value: "[string] the contents of this string",
  4335. quote: "[string] the original quote character"
  4336. }
  4337. }, AST_Constant);
  4338. var AST_Number = DEFNODE("Number", "value literal", {
  4339. $documentation: "A number literal",
  4340. $propdoc: {
  4341. value: "[number] the numeric value",
  4342. literal: "[string] numeric value as string (optional)"
  4343. }
  4344. }, AST_Constant);
  4345. var AST_BigInt = DEFNODE("BigInt", "value", {
  4346. $documentation: "A big int literal",
  4347. $propdoc: {
  4348. value: "[string] big int value"
  4349. }
  4350. }, AST_Constant);
  4351. var AST_RegExp = DEFNODE("RegExp", "value", {
  4352. $documentation: "A regexp literal",
  4353. $propdoc: {
  4354. value: "[RegExp] the actual regexp",
  4355. }
  4356. }, AST_Constant);
  4357. var AST_Atom = DEFNODE("Atom", null, {
  4358. $documentation: "Base class for atoms",
  4359. }, AST_Constant);
  4360. var AST_Null = DEFNODE("Null", null, {
  4361. $documentation: "The `null` atom",
  4362. value: null
  4363. }, AST_Atom);
  4364. var AST_NaN = DEFNODE("NaN", null, {
  4365. $documentation: "The impossible value",
  4366. value: 0/0
  4367. }, AST_Atom);
  4368. var AST_Undefined = DEFNODE("Undefined", null, {
  4369. $documentation: "The `undefined` value",
  4370. value: (function() {}())
  4371. }, AST_Atom);
  4372. var AST_Hole = DEFNODE("Hole", null, {
  4373. $documentation: "A hole in an array",
  4374. value: (function() {}())
  4375. }, AST_Atom);
  4376. var AST_Infinity = DEFNODE("Infinity", null, {
  4377. $documentation: "The `Infinity` value",
  4378. value: 1/0
  4379. }, AST_Atom);
  4380. var AST_Boolean = DEFNODE("Boolean", null, {
  4381. $documentation: "Base class for booleans",
  4382. }, AST_Atom);
  4383. var AST_False = DEFNODE("False", null, {
  4384. $documentation: "The `false` atom",
  4385. value: false
  4386. }, AST_Boolean);
  4387. var AST_True = DEFNODE("True", null, {
  4388. $documentation: "The `true` atom",
  4389. value: true
  4390. }, AST_Boolean);
  4391. /* -----[ Walk function ]---- */
  4392. /**
  4393. * Walk nodes in depth-first search fashion.
  4394. * Callback can return `walk_abort` symbol to stop iteration.
  4395. * It can also return `true` to stop iteration just for child nodes.
  4396. * Iteration can be stopped and continued by passing the `to_visit` argument,
  4397. * which is given to the callback in the second argument.
  4398. **/
  4399. function walk(node, cb, to_visit = [node]) {
  4400. const push = to_visit.push.bind(to_visit);
  4401. while (to_visit.length) {
  4402. const node = to_visit.pop();
  4403. const ret = cb(node, to_visit);
  4404. if (ret) {
  4405. if (ret === walk_abort) return true;
  4406. continue;
  4407. }
  4408. node._children_backwards(push);
  4409. }
  4410. return false;
  4411. }
  4412. function walk_parent(node, cb, initial_stack) {
  4413. const to_visit = [node];
  4414. const push = to_visit.push.bind(to_visit);
  4415. const stack = initial_stack ? initial_stack.slice() : [];
  4416. const parent_pop_indices = [];
  4417. let current;
  4418. const info = {
  4419. parent: (n = 0) => {
  4420. if (n === -1) {
  4421. return current;
  4422. }
  4423. // [ p1 p0 ] [ 1 0 ]
  4424. if (initial_stack && n >= stack.length) {
  4425. n -= stack.length;
  4426. return initial_stack[
  4427. initial_stack.length - (n + 1)
  4428. ];
  4429. }
  4430. return stack[stack.length - (1 + n)];
  4431. },
  4432. };
  4433. while (to_visit.length) {
  4434. current = to_visit.pop();
  4435. while (
  4436. parent_pop_indices.length &&
  4437. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  4438. ) {
  4439. stack.pop();
  4440. parent_pop_indices.pop();
  4441. }
  4442. const ret = cb(current, info);
  4443. if (ret) {
  4444. if (ret === walk_abort) return true;
  4445. continue;
  4446. }
  4447. const visit_length = to_visit.length;
  4448. current._children_backwards(push);
  4449. // Push only if we're going to traverse the children
  4450. if (to_visit.length > visit_length) {
  4451. stack.push(current);
  4452. parent_pop_indices.push(visit_length - 1);
  4453. }
  4454. }
  4455. return false;
  4456. }
  4457. const walk_abort = Symbol("abort walk");
  4458. /* -----[ TreeWalker ]----- */
  4459. class TreeWalker {
  4460. constructor(callback) {
  4461. this.visit = callback;
  4462. this.stack = [];
  4463. this.directives = Object.create(null);
  4464. }
  4465. _visit(node, descend) {
  4466. this.push(node);
  4467. var ret = this.visit(node, descend ? function() {
  4468. descend.call(node);
  4469. } : noop);
  4470. if (!ret && descend) {
  4471. descend.call(node);
  4472. }
  4473. this.pop();
  4474. return ret;
  4475. }
  4476. parent(n) {
  4477. return this.stack[this.stack.length - 2 - (n || 0)];
  4478. }
  4479. push(node) {
  4480. if (node instanceof AST_Lambda) {
  4481. this.directives = Object.create(this.directives);
  4482. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  4483. this.directives[node.value] = node;
  4484. } else if (node instanceof AST_Class) {
  4485. this.directives = Object.create(this.directives);
  4486. if (!this.directives["use strict"]) {
  4487. this.directives["use strict"] = node;
  4488. }
  4489. }
  4490. this.stack.push(node);
  4491. }
  4492. pop() {
  4493. var node = this.stack.pop();
  4494. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  4495. this.directives = Object.getPrototypeOf(this.directives);
  4496. }
  4497. }
  4498. self() {
  4499. return this.stack[this.stack.length - 1];
  4500. }
  4501. find_parent(type) {
  4502. var stack = this.stack;
  4503. for (var i = stack.length; --i >= 0;) {
  4504. var x = stack[i];
  4505. if (x instanceof type) return x;
  4506. }
  4507. }
  4508. has_directive(type) {
  4509. var dir = this.directives[type];
  4510. if (dir) return dir;
  4511. var node = this.stack[this.stack.length - 1];
  4512. if (node instanceof AST_Scope && node.body) {
  4513. for (var i = 0; i < node.body.length; ++i) {
  4514. var st = node.body[i];
  4515. if (!(st instanceof AST_Directive)) break;
  4516. if (st.value == type) return st;
  4517. }
  4518. }
  4519. }
  4520. loopcontrol_target(node) {
  4521. var stack = this.stack;
  4522. if (node.label) for (var i = stack.length; --i >= 0;) {
  4523. var x = stack[i];
  4524. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  4525. return x.body;
  4526. } else for (var i = stack.length; --i >= 0;) {
  4527. var x = stack[i];
  4528. if (x instanceof AST_IterationStatement
  4529. || node instanceof AST_Break && x instanceof AST_Switch)
  4530. return x;
  4531. }
  4532. }
  4533. }
  4534. // Tree transformer helpers.
  4535. class TreeTransformer extends TreeWalker {
  4536. constructor(before, after) {
  4537. super();
  4538. this.before = before;
  4539. this.after = after;
  4540. }
  4541. }
  4542. const _PURE = 0b00000001;
  4543. const _INLINE = 0b00000010;
  4544. const _NOINLINE = 0b00000100;
  4545. var ast = /*#__PURE__*/Object.freeze({
  4546. __proto__: null,
  4547. AST_Accessor: AST_Accessor,
  4548. AST_Array: AST_Array,
  4549. AST_Arrow: AST_Arrow,
  4550. AST_Assign: AST_Assign,
  4551. AST_Atom: AST_Atom,
  4552. AST_Await: AST_Await,
  4553. AST_BigInt: AST_BigInt,
  4554. AST_Binary: AST_Binary,
  4555. AST_Block: AST_Block,
  4556. AST_BlockStatement: AST_BlockStatement,
  4557. AST_Boolean: AST_Boolean,
  4558. AST_Break: AST_Break,
  4559. AST_Call: AST_Call,
  4560. AST_Case: AST_Case,
  4561. AST_Catch: AST_Catch,
  4562. AST_Chain: AST_Chain,
  4563. AST_Class: AST_Class,
  4564. AST_ClassExpression: AST_ClassExpression,
  4565. AST_ClassProperty: AST_ClassProperty,
  4566. AST_ConciseMethod: AST_ConciseMethod,
  4567. AST_Conditional: AST_Conditional,
  4568. AST_Const: AST_Const,
  4569. AST_Constant: AST_Constant,
  4570. AST_Continue: AST_Continue,
  4571. AST_Debugger: AST_Debugger,
  4572. AST_Default: AST_Default,
  4573. AST_DefaultAssign: AST_DefaultAssign,
  4574. AST_DefClass: AST_DefClass,
  4575. AST_Definitions: AST_Definitions,
  4576. AST_Defun: AST_Defun,
  4577. AST_Destructuring: AST_Destructuring,
  4578. AST_Directive: AST_Directive,
  4579. AST_Do: AST_Do,
  4580. AST_Dot: AST_Dot,
  4581. AST_DWLoop: AST_DWLoop,
  4582. AST_EmptyStatement: AST_EmptyStatement,
  4583. AST_Exit: AST_Exit,
  4584. AST_Expansion: AST_Expansion,
  4585. AST_Export: AST_Export,
  4586. AST_False: AST_False,
  4587. AST_Finally: AST_Finally,
  4588. AST_For: AST_For,
  4589. AST_ForIn: AST_ForIn,
  4590. AST_ForOf: AST_ForOf,
  4591. AST_Function: AST_Function,
  4592. AST_Hole: AST_Hole,
  4593. AST_If: AST_If,
  4594. AST_Import: AST_Import,
  4595. AST_ImportMeta: AST_ImportMeta,
  4596. AST_Infinity: AST_Infinity,
  4597. AST_IterationStatement: AST_IterationStatement,
  4598. AST_Jump: AST_Jump,
  4599. AST_Label: AST_Label,
  4600. AST_LabeledStatement: AST_LabeledStatement,
  4601. AST_LabelRef: AST_LabelRef,
  4602. AST_Lambda: AST_Lambda,
  4603. AST_Let: AST_Let,
  4604. AST_LoopControl: AST_LoopControl,
  4605. AST_NameMapping: AST_NameMapping,
  4606. AST_NaN: AST_NaN,
  4607. AST_New: AST_New,
  4608. AST_NewTarget: AST_NewTarget,
  4609. AST_Node: AST_Node,
  4610. AST_Null: AST_Null,
  4611. AST_Number: AST_Number,
  4612. AST_Object: AST_Object,
  4613. AST_ObjectGetter: AST_ObjectGetter,
  4614. AST_ObjectKeyVal: AST_ObjectKeyVal,
  4615. AST_ObjectProperty: AST_ObjectProperty,
  4616. AST_ObjectSetter: AST_ObjectSetter,
  4617. AST_PrefixedTemplateString: AST_PrefixedTemplateString,
  4618. AST_PropAccess: AST_PropAccess,
  4619. AST_RegExp: AST_RegExp,
  4620. AST_Return: AST_Return,
  4621. AST_Scope: AST_Scope,
  4622. AST_Sequence: AST_Sequence,
  4623. AST_SimpleStatement: AST_SimpleStatement,
  4624. AST_Statement: AST_Statement,
  4625. AST_StatementWithBody: AST_StatementWithBody,
  4626. AST_String: AST_String,
  4627. AST_Sub: AST_Sub,
  4628. AST_Super: AST_Super,
  4629. AST_Switch: AST_Switch,
  4630. AST_SwitchBranch: AST_SwitchBranch,
  4631. AST_Symbol: AST_Symbol,
  4632. AST_SymbolBlockDeclaration: AST_SymbolBlockDeclaration,
  4633. AST_SymbolCatch: AST_SymbolCatch,
  4634. AST_SymbolClass: AST_SymbolClass,
  4635. AST_SymbolClassProperty: AST_SymbolClassProperty,
  4636. AST_SymbolConst: AST_SymbolConst,
  4637. AST_SymbolDeclaration: AST_SymbolDeclaration,
  4638. AST_SymbolDefClass: AST_SymbolDefClass,
  4639. AST_SymbolDefun: AST_SymbolDefun,
  4640. AST_SymbolExport: AST_SymbolExport,
  4641. AST_SymbolExportForeign: AST_SymbolExportForeign,
  4642. AST_SymbolFunarg: AST_SymbolFunarg,
  4643. AST_SymbolImport: AST_SymbolImport,
  4644. AST_SymbolImportForeign: AST_SymbolImportForeign,
  4645. AST_SymbolLambda: AST_SymbolLambda,
  4646. AST_SymbolLet: AST_SymbolLet,
  4647. AST_SymbolMethod: AST_SymbolMethod,
  4648. AST_SymbolRef: AST_SymbolRef,
  4649. AST_SymbolVar: AST_SymbolVar,
  4650. AST_TemplateSegment: AST_TemplateSegment,
  4651. AST_TemplateString: AST_TemplateString,
  4652. AST_This: AST_This,
  4653. AST_Throw: AST_Throw,
  4654. AST_Token: AST_Token,
  4655. AST_Toplevel: AST_Toplevel,
  4656. AST_True: AST_True,
  4657. AST_Try: AST_Try,
  4658. AST_Unary: AST_Unary,
  4659. AST_UnaryPostfix: AST_UnaryPostfix,
  4660. AST_UnaryPrefix: AST_UnaryPrefix,
  4661. AST_Undefined: AST_Undefined,
  4662. AST_Var: AST_Var,
  4663. AST_VarDef: AST_VarDef,
  4664. AST_While: AST_While,
  4665. AST_With: AST_With,
  4666. AST_Yield: AST_Yield,
  4667. TreeTransformer: TreeTransformer,
  4668. TreeWalker: TreeWalker,
  4669. walk: walk,
  4670. walk_abort: walk_abort,
  4671. walk_body: walk_body,
  4672. walk_parent: walk_parent,
  4673. _INLINE: _INLINE,
  4674. _NOINLINE: _NOINLINE,
  4675. _PURE: _PURE
  4676. });
  4677. /***********************************************************************
  4678. A JavaScript tokenizer / parser / beautifier / compressor.
  4679. https://github.com/mishoo/UglifyJS2
  4680. -------------------------------- (C) ---------------------------------
  4681. Author: Mihai Bazon
  4682. <mihai.bazon@gmail.com>
  4683. http://mihai.bazon.net/blog
  4684. Distributed under the BSD license:
  4685. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  4686. Redistribution and use in source and binary forms, with or without
  4687. modification, are permitted provided that the following conditions
  4688. are met:
  4689. * Redistributions of source code must retain the above
  4690. copyright notice, this list of conditions and the following
  4691. disclaimer.
  4692. * Redistributions in binary form must reproduce the above
  4693. copyright notice, this list of conditions and the following
  4694. disclaimer in the documentation and/or other materials
  4695. provided with the distribution.
  4696. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  4697. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4698. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  4699. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  4700. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  4701. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  4702. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  4703. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  4704. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  4705. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  4706. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4707. SUCH DAMAGE.
  4708. ***********************************************************************/
  4709. function def_transform(node, descend) {
  4710. node.DEFMETHOD("transform", function(tw, in_list) {
  4711. let transformed = undefined;
  4712. tw.push(this);
  4713. if (tw.before) transformed = tw.before(this, descend, in_list);
  4714. if (transformed === undefined) {
  4715. transformed = this;
  4716. descend(transformed, tw);
  4717. if (tw.after) {
  4718. const after_ret = tw.after(transformed, in_list);
  4719. if (after_ret !== undefined) transformed = after_ret;
  4720. }
  4721. }
  4722. tw.pop();
  4723. return transformed;
  4724. });
  4725. }
  4726. function do_list(list, tw) {
  4727. return MAP(list, function(node) {
  4728. return node.transform(tw, true);
  4729. });
  4730. }
  4731. def_transform(AST_Node, noop);
  4732. def_transform(AST_LabeledStatement, function(self, tw) {
  4733. self.label = self.label.transform(tw);
  4734. self.body = self.body.transform(tw);
  4735. });
  4736. def_transform(AST_SimpleStatement, function(self, tw) {
  4737. self.body = self.body.transform(tw);
  4738. });
  4739. def_transform(AST_Block, function(self, tw) {
  4740. self.body = do_list(self.body, tw);
  4741. });
  4742. def_transform(AST_Do, function(self, tw) {
  4743. self.body = self.body.transform(tw);
  4744. self.condition = self.condition.transform(tw);
  4745. });
  4746. def_transform(AST_While, function(self, tw) {
  4747. self.condition = self.condition.transform(tw);
  4748. self.body = self.body.transform(tw);
  4749. });
  4750. def_transform(AST_For, function(self, tw) {
  4751. if (self.init) self.init = self.init.transform(tw);
  4752. if (self.condition) self.condition = self.condition.transform(tw);
  4753. if (self.step) self.step = self.step.transform(tw);
  4754. self.body = self.body.transform(tw);
  4755. });
  4756. def_transform(AST_ForIn, function(self, tw) {
  4757. self.init = self.init.transform(tw);
  4758. self.object = self.object.transform(tw);
  4759. self.body = self.body.transform(tw);
  4760. });
  4761. def_transform(AST_With, function(self, tw) {
  4762. self.expression = self.expression.transform(tw);
  4763. self.body = self.body.transform(tw);
  4764. });
  4765. def_transform(AST_Exit, function(self, tw) {
  4766. if (self.value) self.value = self.value.transform(tw);
  4767. });
  4768. def_transform(AST_LoopControl, function(self, tw) {
  4769. if (self.label) self.label = self.label.transform(tw);
  4770. });
  4771. def_transform(AST_If, function(self, tw) {
  4772. self.condition = self.condition.transform(tw);
  4773. self.body = self.body.transform(tw);
  4774. if (self.alternative) self.alternative = self.alternative.transform(tw);
  4775. });
  4776. def_transform(AST_Switch, function(self, tw) {
  4777. self.expression = self.expression.transform(tw);
  4778. self.body = do_list(self.body, tw);
  4779. });
  4780. def_transform(AST_Case, function(self, tw) {
  4781. self.expression = self.expression.transform(tw);
  4782. self.body = do_list(self.body, tw);
  4783. });
  4784. def_transform(AST_Try, function(self, tw) {
  4785. self.body = do_list(self.body, tw);
  4786. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  4787. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  4788. });
  4789. def_transform(AST_Catch, function(self, tw) {
  4790. if (self.argname) self.argname = self.argname.transform(tw);
  4791. self.body = do_list(self.body, tw);
  4792. });
  4793. def_transform(AST_Definitions, function(self, tw) {
  4794. self.definitions = do_list(self.definitions, tw);
  4795. });
  4796. def_transform(AST_VarDef, function(self, tw) {
  4797. self.name = self.name.transform(tw);
  4798. if (self.value) self.value = self.value.transform(tw);
  4799. });
  4800. def_transform(AST_Destructuring, function(self, tw) {
  4801. self.names = do_list(self.names, tw);
  4802. });
  4803. def_transform(AST_Lambda, function(self, tw) {
  4804. if (self.name) self.name = self.name.transform(tw);
  4805. self.argnames = do_list(self.argnames, tw);
  4806. if (self.body instanceof AST_Node) {
  4807. self.body = self.body.transform(tw);
  4808. } else {
  4809. self.body = do_list(self.body, tw);
  4810. }
  4811. });
  4812. def_transform(AST_Call, function(self, tw) {
  4813. self.expression = self.expression.transform(tw);
  4814. self.args = do_list(self.args, tw);
  4815. });
  4816. def_transform(AST_Sequence, function(self, tw) {
  4817. const result = do_list(self.expressions, tw);
  4818. self.expressions = result.length
  4819. ? result
  4820. : [new AST_Number({ value: 0 })];
  4821. });
  4822. def_transform(AST_Dot, function(self, tw) {
  4823. self.expression = self.expression.transform(tw);
  4824. });
  4825. def_transform(AST_Sub, function(self, tw) {
  4826. self.expression = self.expression.transform(tw);
  4827. self.property = self.property.transform(tw);
  4828. });
  4829. def_transform(AST_Chain, function(self, tw) {
  4830. self.expression = self.expression.transform(tw);
  4831. });
  4832. def_transform(AST_Yield, function(self, tw) {
  4833. if (self.expression) self.expression = self.expression.transform(tw);
  4834. });
  4835. def_transform(AST_Await, function(self, tw) {
  4836. self.expression = self.expression.transform(tw);
  4837. });
  4838. def_transform(AST_Unary, function(self, tw) {
  4839. self.expression = self.expression.transform(tw);
  4840. });
  4841. def_transform(AST_Binary, function(self, tw) {
  4842. self.left = self.left.transform(tw);
  4843. self.right = self.right.transform(tw);
  4844. });
  4845. def_transform(AST_Conditional, function(self, tw) {
  4846. self.condition = self.condition.transform(tw);
  4847. self.consequent = self.consequent.transform(tw);
  4848. self.alternative = self.alternative.transform(tw);
  4849. });
  4850. def_transform(AST_Array, function(self, tw) {
  4851. self.elements = do_list(self.elements, tw);
  4852. });
  4853. def_transform(AST_Object, function(self, tw) {
  4854. self.properties = do_list(self.properties, tw);
  4855. });
  4856. def_transform(AST_ObjectProperty, function(self, tw) {
  4857. if (self.key instanceof AST_Node) {
  4858. self.key = self.key.transform(tw);
  4859. }
  4860. if (self.value) self.value = self.value.transform(tw);
  4861. });
  4862. def_transform(AST_Class, function(self, tw) {
  4863. if (self.name) self.name = self.name.transform(tw);
  4864. if (self.extends) self.extends = self.extends.transform(tw);
  4865. self.properties = do_list(self.properties, tw);
  4866. });
  4867. def_transform(AST_Expansion, function(self, tw) {
  4868. self.expression = self.expression.transform(tw);
  4869. });
  4870. def_transform(AST_NameMapping, function(self, tw) {
  4871. self.foreign_name = self.foreign_name.transform(tw);
  4872. self.name = self.name.transform(tw);
  4873. });
  4874. def_transform(AST_Import, function(self, tw) {
  4875. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  4876. if (self.imported_names) do_list(self.imported_names, tw);
  4877. self.module_name = self.module_name.transform(tw);
  4878. });
  4879. def_transform(AST_Export, function(self, tw) {
  4880. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  4881. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  4882. if (self.exported_names) do_list(self.exported_names, tw);
  4883. if (self.module_name) self.module_name = self.module_name.transform(tw);
  4884. });
  4885. def_transform(AST_TemplateString, function(self, tw) {
  4886. self.segments = do_list(self.segments, tw);
  4887. });
  4888. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  4889. self.prefix = self.prefix.transform(tw);
  4890. self.template_string = self.template_string.transform(tw);
  4891. });
  4892. /***********************************************************************
  4893. A JavaScript tokenizer / parser / beautifier / compressor.
  4894. https://github.com/mishoo/UglifyJS2
  4895. -------------------------------- (C) ---------------------------------
  4896. Author: Mihai Bazon
  4897. <mihai.bazon@gmail.com>
  4898. http://mihai.bazon.net/blog
  4899. Distributed under the BSD license:
  4900. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  4901. Redistribution and use in source and binary forms, with or without
  4902. modification, are permitted provided that the following conditions
  4903. are met:
  4904. * Redistributions of source code must retain the above
  4905. copyright notice, this list of conditions and the following
  4906. disclaimer.
  4907. * Redistributions in binary form must reproduce the above
  4908. copyright notice, this list of conditions and the following
  4909. disclaimer in the documentation and/or other materials
  4910. provided with the distribution.
  4911. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  4912. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4913. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  4914. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  4915. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  4916. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  4917. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  4918. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  4919. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  4920. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  4921. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4922. SUCH DAMAGE.
  4923. ***********************************************************************/
  4924. (function() {
  4925. var normalize_directives = function(body) {
  4926. var in_directive = true;
  4927. for (var i = 0; i < body.length; i++) {
  4928. if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  4929. body[i] = new AST_Directive({
  4930. start: body[i].start,
  4931. end: body[i].end,
  4932. value: body[i].body.value
  4933. });
  4934. } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
  4935. in_directive = false;
  4936. }
  4937. }
  4938. return body;
  4939. };
  4940. var MOZ_TO_ME = {
  4941. Program: function(M) {
  4942. return new AST_Toplevel({
  4943. start: my_start_token(M),
  4944. end: my_end_token(M),
  4945. body: normalize_directives(M.body.map(from_moz))
  4946. });
  4947. },
  4948. ArrayPattern: function(M) {
  4949. return new AST_Destructuring({
  4950. start: my_start_token(M),
  4951. end: my_end_token(M),
  4952. names: M.elements.map(function(elm) {
  4953. if (elm === null) {
  4954. return new AST_Hole();
  4955. }
  4956. return from_moz(elm);
  4957. }),
  4958. is_array: true
  4959. });
  4960. },
  4961. ObjectPattern: function(M) {
  4962. return new AST_Destructuring({
  4963. start: my_start_token(M),
  4964. end: my_end_token(M),
  4965. names: M.properties.map(from_moz),
  4966. is_array: false
  4967. });
  4968. },
  4969. AssignmentPattern: function(M) {
  4970. return new AST_DefaultAssign({
  4971. start: my_start_token(M),
  4972. end: my_end_token(M),
  4973. left: from_moz(M.left),
  4974. operator: "=",
  4975. right: from_moz(M.right)
  4976. });
  4977. },
  4978. SpreadElement: function(M) {
  4979. return new AST_Expansion({
  4980. start: my_start_token(M),
  4981. end: my_end_token(M),
  4982. expression: from_moz(M.argument)
  4983. });
  4984. },
  4985. RestElement: function(M) {
  4986. return new AST_Expansion({
  4987. start: my_start_token(M),
  4988. end: my_end_token(M),
  4989. expression: from_moz(M.argument)
  4990. });
  4991. },
  4992. TemplateElement: function(M) {
  4993. return new AST_TemplateSegment({
  4994. start: my_start_token(M),
  4995. end: my_end_token(M),
  4996. value: M.value.cooked,
  4997. raw: M.value.raw
  4998. });
  4999. },
  5000. TemplateLiteral: function(M) {
  5001. var segments = [];
  5002. for (var i = 0; i < M.quasis.length; i++) {
  5003. segments.push(from_moz(M.quasis[i]));
  5004. if (M.expressions[i]) {
  5005. segments.push(from_moz(M.expressions[i]));
  5006. }
  5007. }
  5008. return new AST_TemplateString({
  5009. start: my_start_token(M),
  5010. end: my_end_token(M),
  5011. segments: segments
  5012. });
  5013. },
  5014. TaggedTemplateExpression: function(M) {
  5015. return new AST_PrefixedTemplateString({
  5016. start: my_start_token(M),
  5017. end: my_end_token(M),
  5018. template_string: from_moz(M.quasi),
  5019. prefix: from_moz(M.tag)
  5020. });
  5021. },
  5022. FunctionDeclaration: function(M) {
  5023. return new AST_Defun({
  5024. start: my_start_token(M),
  5025. end: my_end_token(M),
  5026. name: from_moz(M.id),
  5027. argnames: M.params.map(from_moz),
  5028. is_generator: M.generator,
  5029. async: M.async,
  5030. body: normalize_directives(from_moz(M.body).body)
  5031. });
  5032. },
  5033. FunctionExpression: function(M) {
  5034. return new AST_Function({
  5035. start: my_start_token(M),
  5036. end: my_end_token(M),
  5037. name: from_moz(M.id),
  5038. argnames: M.params.map(from_moz),
  5039. is_generator: M.generator,
  5040. async: M.async,
  5041. body: normalize_directives(from_moz(M.body).body)
  5042. });
  5043. },
  5044. ArrowFunctionExpression: function(M) {
  5045. const body = M.body.type === "BlockStatement"
  5046. ? from_moz(M.body).body
  5047. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  5048. return new AST_Arrow({
  5049. start: my_start_token(M),
  5050. end: my_end_token(M),
  5051. argnames: M.params.map(from_moz),
  5052. body,
  5053. async: M.async,
  5054. });
  5055. },
  5056. ExpressionStatement: function(M) {
  5057. return new AST_SimpleStatement({
  5058. start: my_start_token(M),
  5059. end: my_end_token(M),
  5060. body: from_moz(M.expression)
  5061. });
  5062. },
  5063. TryStatement: function(M) {
  5064. var handlers = M.handlers || [M.handler];
  5065. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  5066. throw new Error("Multiple catch clauses are not supported.");
  5067. }
  5068. return new AST_Try({
  5069. start : my_start_token(M),
  5070. end : my_end_token(M),
  5071. body : from_moz(M.block).body,
  5072. bcatch : from_moz(handlers[0]),
  5073. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  5074. });
  5075. },
  5076. Property: function(M) {
  5077. var key = M.key;
  5078. var args = {
  5079. start : my_start_token(key || M.value),
  5080. end : my_end_token(M.value),
  5081. key : key.type == "Identifier" ? key.name : key.value,
  5082. value : from_moz(M.value)
  5083. };
  5084. if (M.computed) {
  5085. args.key = from_moz(M.key);
  5086. }
  5087. if (M.method) {
  5088. args.is_generator = M.value.generator;
  5089. args.async = M.value.async;
  5090. if (!M.computed) {
  5091. args.key = new AST_SymbolMethod({ name: args.key });
  5092. } else {
  5093. args.key = from_moz(M.key);
  5094. }
  5095. return new AST_ConciseMethod(args);
  5096. }
  5097. if (M.kind == "init") {
  5098. if (key.type != "Identifier" && key.type != "Literal") {
  5099. args.key = from_moz(key);
  5100. }
  5101. return new AST_ObjectKeyVal(args);
  5102. }
  5103. if (typeof args.key === "string" || typeof args.key === "number") {
  5104. args.key = new AST_SymbolMethod({
  5105. name: args.key
  5106. });
  5107. }
  5108. args.value = new AST_Accessor(args.value);
  5109. if (M.kind == "get") return new AST_ObjectGetter(args);
  5110. if (M.kind == "set") return new AST_ObjectSetter(args);
  5111. if (M.kind == "method") {
  5112. args.async = M.value.async;
  5113. args.is_generator = M.value.generator;
  5114. args.quote = M.computed ? "\"" : null;
  5115. return new AST_ConciseMethod(args);
  5116. }
  5117. },
  5118. MethodDefinition: function(M) {
  5119. var args = {
  5120. start : my_start_token(M),
  5121. end : my_end_token(M),
  5122. key : M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value }),
  5123. value : from_moz(M.value),
  5124. static : M.static,
  5125. };
  5126. if (M.kind == "get") {
  5127. return new AST_ObjectGetter(args);
  5128. }
  5129. if (M.kind == "set") {
  5130. return new AST_ObjectSetter(args);
  5131. }
  5132. args.is_generator = M.value.generator;
  5133. args.async = M.value.async;
  5134. return new AST_ConciseMethod(args);
  5135. },
  5136. FieldDefinition: function(M) {
  5137. let key;
  5138. if (M.computed) {
  5139. key = from_moz(M.key);
  5140. } else {
  5141. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  5142. key = from_moz(M.key);
  5143. }
  5144. return new AST_ClassProperty({
  5145. start : my_start_token(M),
  5146. end : my_end_token(M),
  5147. key,
  5148. value : from_moz(M.value),
  5149. static : M.static,
  5150. });
  5151. },
  5152. ArrayExpression: function(M) {
  5153. return new AST_Array({
  5154. start : my_start_token(M),
  5155. end : my_end_token(M),
  5156. elements : M.elements.map(function(elem) {
  5157. return elem === null ? new AST_Hole() : from_moz(elem);
  5158. })
  5159. });
  5160. },
  5161. ObjectExpression: function(M) {
  5162. return new AST_Object({
  5163. start : my_start_token(M),
  5164. end : my_end_token(M),
  5165. properties : M.properties.map(function(prop) {
  5166. if (prop.type === "SpreadElement") {
  5167. return from_moz(prop);
  5168. }
  5169. prop.type = "Property";
  5170. return from_moz(prop);
  5171. })
  5172. });
  5173. },
  5174. SequenceExpression: function(M) {
  5175. return new AST_Sequence({
  5176. start : my_start_token(M),
  5177. end : my_end_token(M),
  5178. expressions: M.expressions.map(from_moz)
  5179. });
  5180. },
  5181. MemberExpression: function(M) {
  5182. return new (M.computed ? AST_Sub : AST_Dot)({
  5183. start : my_start_token(M),
  5184. end : my_end_token(M),
  5185. property : M.computed ? from_moz(M.property) : M.property.name,
  5186. expression : from_moz(M.object),
  5187. optional : M.optional || false
  5188. });
  5189. },
  5190. ChainExpression: function(M) {
  5191. return new AST_Chain({
  5192. start : my_start_token(M),
  5193. end : my_end_token(M),
  5194. expression : from_moz(M.expression)
  5195. });
  5196. },
  5197. SwitchCase: function(M) {
  5198. return new (M.test ? AST_Case : AST_Default)({
  5199. start : my_start_token(M),
  5200. end : my_end_token(M),
  5201. expression : from_moz(M.test),
  5202. body : M.consequent.map(from_moz)
  5203. });
  5204. },
  5205. VariableDeclaration: function(M) {
  5206. return new (M.kind === "const" ? AST_Const :
  5207. M.kind === "let" ? AST_Let : AST_Var)({
  5208. start : my_start_token(M),
  5209. end : my_end_token(M),
  5210. definitions : M.declarations.map(from_moz)
  5211. });
  5212. },
  5213. ImportDeclaration: function(M) {
  5214. var imported_name = null;
  5215. var imported_names = null;
  5216. M.specifiers.forEach(function (specifier) {
  5217. if (specifier.type === "ImportSpecifier") {
  5218. if (!imported_names) { imported_names = []; }
  5219. imported_names.push(new AST_NameMapping({
  5220. start: my_start_token(specifier),
  5221. end: my_end_token(specifier),
  5222. foreign_name: from_moz(specifier.imported),
  5223. name: from_moz(specifier.local)
  5224. }));
  5225. } else if (specifier.type === "ImportDefaultSpecifier") {
  5226. imported_name = from_moz(specifier.local);
  5227. } else if (specifier.type === "ImportNamespaceSpecifier") {
  5228. if (!imported_names) { imported_names = []; }
  5229. imported_names.push(new AST_NameMapping({
  5230. start: my_start_token(specifier),
  5231. end: my_end_token(specifier),
  5232. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  5233. name: from_moz(specifier.local)
  5234. }));
  5235. }
  5236. });
  5237. return new AST_Import({
  5238. start : my_start_token(M),
  5239. end : my_end_token(M),
  5240. imported_name: imported_name,
  5241. imported_names : imported_names,
  5242. module_name : from_moz(M.source)
  5243. });
  5244. },
  5245. ExportAllDeclaration: function(M) {
  5246. return new AST_Export({
  5247. start: my_start_token(M),
  5248. end: my_end_token(M),
  5249. exported_names: [
  5250. new AST_NameMapping({
  5251. name: new AST_SymbolExportForeign({ name: "*" }),
  5252. foreign_name: new AST_SymbolExportForeign({ name: "*" })
  5253. })
  5254. ],
  5255. module_name: from_moz(M.source)
  5256. });
  5257. },
  5258. ExportNamedDeclaration: function(M) {
  5259. return new AST_Export({
  5260. start: my_start_token(M),
  5261. end: my_end_token(M),
  5262. exported_definition: from_moz(M.declaration),
  5263. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(function (specifier) {
  5264. return new AST_NameMapping({
  5265. foreign_name: from_moz(specifier.exported),
  5266. name: from_moz(specifier.local)
  5267. });
  5268. }) : null,
  5269. module_name: from_moz(M.source)
  5270. });
  5271. },
  5272. ExportDefaultDeclaration: function(M) {
  5273. return new AST_Export({
  5274. start: my_start_token(M),
  5275. end: my_end_token(M),
  5276. exported_value: from_moz(M.declaration),
  5277. is_default: true
  5278. });
  5279. },
  5280. Literal: function(M) {
  5281. var val = M.value, args = {
  5282. start : my_start_token(M),
  5283. end : my_end_token(M)
  5284. };
  5285. var rx = M.regex;
  5286. if (rx && rx.pattern) {
  5287. // RegExpLiteral as per ESTree AST spec
  5288. args.value = {
  5289. source: rx.pattern,
  5290. flags: rx.flags
  5291. };
  5292. return new AST_RegExp(args);
  5293. } else if (rx) {
  5294. // support legacy RegExp
  5295. const rx_source = M.raw || val;
  5296. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  5297. if (!match) throw new Error("Invalid regex source " + rx_source);
  5298. const [_, source, flags] = match;
  5299. args.value = { source, flags };
  5300. return new AST_RegExp(args);
  5301. }
  5302. if (val === null) return new AST_Null(args);
  5303. switch (typeof val) {
  5304. case "string":
  5305. args.value = val;
  5306. return new AST_String(args);
  5307. case "number":
  5308. args.value = val;
  5309. return new AST_Number(args);
  5310. case "boolean":
  5311. return new (val ? AST_True : AST_False)(args);
  5312. }
  5313. },
  5314. MetaProperty: function(M) {
  5315. if (M.meta.name === "new" && M.property.name === "target") {
  5316. return new AST_NewTarget({
  5317. start: my_start_token(M),
  5318. end: my_end_token(M)
  5319. });
  5320. } else if (M.meta.name === "import" && M.property.name === "meta") {
  5321. return new AST_ImportMeta({
  5322. start: my_start_token(M),
  5323. end: my_end_token(M)
  5324. });
  5325. }
  5326. },
  5327. Identifier: function(M) {
  5328. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  5329. return new ( p.type == "LabeledStatement" ? AST_Label
  5330. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  5331. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  5332. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  5333. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  5334. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  5335. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  5336. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  5337. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  5338. : p.type == "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  5339. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  5340. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  5341. : p.type == "CatchClause" ? AST_SymbolCatch
  5342. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  5343. : AST_SymbolRef)({
  5344. start : my_start_token(M),
  5345. end : my_end_token(M),
  5346. name : M.name
  5347. });
  5348. },
  5349. BigIntLiteral(M) {
  5350. return new AST_BigInt({
  5351. start : my_start_token(M),
  5352. end : my_end_token(M),
  5353. value : M.value
  5354. });
  5355. }
  5356. };
  5357. MOZ_TO_ME.UpdateExpression =
  5358. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  5359. var prefix = "prefix" in M ? M.prefix
  5360. : M.type == "UnaryExpression" ? true : false;
  5361. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  5362. start : my_start_token(M),
  5363. end : my_end_token(M),
  5364. operator : M.operator,
  5365. expression : from_moz(M.argument)
  5366. });
  5367. };
  5368. MOZ_TO_ME.ClassDeclaration =
  5369. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  5370. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  5371. start : my_start_token(M),
  5372. end : my_end_token(M),
  5373. name : from_moz(M.id),
  5374. extends : from_moz(M.superClass),
  5375. properties: M.body.body.map(from_moz)
  5376. });
  5377. };
  5378. map("EmptyStatement", AST_EmptyStatement);
  5379. map("BlockStatement", AST_BlockStatement, "body@body");
  5380. map("IfStatement", AST_If, "test>condition, consequent>body, alternate>alternative");
  5381. map("LabeledStatement", AST_LabeledStatement, "label>label, body>body");
  5382. map("BreakStatement", AST_Break, "label>label");
  5383. map("ContinueStatement", AST_Continue, "label>label");
  5384. map("WithStatement", AST_With, "object>expression, body>body");
  5385. map("SwitchStatement", AST_Switch, "discriminant>expression, cases@body");
  5386. map("ReturnStatement", AST_Return, "argument>value");
  5387. map("ThrowStatement", AST_Throw, "argument>value");
  5388. map("WhileStatement", AST_While, "test>condition, body>body");
  5389. map("DoWhileStatement", AST_Do, "test>condition, body>body");
  5390. map("ForStatement", AST_For, "init>init, test>condition, update>step, body>body");
  5391. map("ForInStatement", AST_ForIn, "left>init, right>object, body>body");
  5392. map("ForOfStatement", AST_ForOf, "left>init, right>object, body>body, await=await");
  5393. map("AwaitExpression", AST_Await, "argument>expression");
  5394. map("YieldExpression", AST_Yield, "argument>expression, delegate=is_star");
  5395. map("DebuggerStatement", AST_Debugger);
  5396. map("VariableDeclarator", AST_VarDef, "id>name, init>value");
  5397. map("CatchClause", AST_Catch, "param>argname, body%body");
  5398. map("ThisExpression", AST_This);
  5399. map("Super", AST_Super);
  5400. map("BinaryExpression", AST_Binary, "operator=operator, left>left, right>right");
  5401. map("LogicalExpression", AST_Binary, "operator=operator, left>left, right>right");
  5402. map("AssignmentExpression", AST_Assign, "operator=operator, left>left, right>right");
  5403. map("ConditionalExpression", AST_Conditional, "test>condition, consequent>consequent, alternate>alternative");
  5404. map("NewExpression", AST_New, "callee>expression, arguments@args");
  5405. map("CallExpression", AST_Call, "callee>expression, optional=optional, arguments@args");
  5406. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  5407. return to_moz_scope("Program", M);
  5408. });
  5409. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  5410. return {
  5411. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  5412. argument: to_moz(M.expression)
  5413. };
  5414. });
  5415. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  5416. return {
  5417. type: "TaggedTemplateExpression",
  5418. tag: to_moz(M.prefix),
  5419. quasi: to_moz(M.template_string)
  5420. };
  5421. });
  5422. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  5423. var quasis = [];
  5424. var expressions = [];
  5425. for (var i = 0; i < M.segments.length; i++) {
  5426. if (i % 2 !== 0) {
  5427. expressions.push(to_moz(M.segments[i]));
  5428. } else {
  5429. quasis.push({
  5430. type: "TemplateElement",
  5431. value: {
  5432. raw: M.segments[i].raw,
  5433. cooked: M.segments[i].value
  5434. },
  5435. tail: i === M.segments.length - 1
  5436. });
  5437. }
  5438. }
  5439. return {
  5440. type: "TemplateLiteral",
  5441. quasis: quasis,
  5442. expressions: expressions
  5443. };
  5444. });
  5445. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  5446. return {
  5447. type: "FunctionDeclaration",
  5448. id: to_moz(M.name),
  5449. params: M.argnames.map(to_moz),
  5450. generator: M.is_generator,
  5451. async: M.async,
  5452. body: to_moz_scope("BlockStatement", M)
  5453. };
  5454. });
  5455. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  5456. var is_generator = parent.is_generator !== undefined ?
  5457. parent.is_generator : M.is_generator;
  5458. return {
  5459. type: "FunctionExpression",
  5460. id: to_moz(M.name),
  5461. params: M.argnames.map(to_moz),
  5462. generator: is_generator,
  5463. async: M.async,
  5464. body: to_moz_scope("BlockStatement", M)
  5465. };
  5466. });
  5467. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  5468. var body = {
  5469. type: "BlockStatement",
  5470. body: M.body.map(to_moz)
  5471. };
  5472. return {
  5473. type: "ArrowFunctionExpression",
  5474. params: M.argnames.map(to_moz),
  5475. async: M.async,
  5476. body: body
  5477. };
  5478. });
  5479. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  5480. if (M.is_array) {
  5481. return {
  5482. type: "ArrayPattern",
  5483. elements: M.names.map(to_moz)
  5484. };
  5485. }
  5486. return {
  5487. type: "ObjectPattern",
  5488. properties: M.names.map(to_moz)
  5489. };
  5490. });
  5491. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  5492. return {
  5493. type: "ExpressionStatement",
  5494. expression: {
  5495. type: "Literal",
  5496. value: M.value,
  5497. raw: M.print_to_string()
  5498. },
  5499. directive: M.value
  5500. };
  5501. });
  5502. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  5503. return {
  5504. type: "ExpressionStatement",
  5505. expression: to_moz(M.body)
  5506. };
  5507. });
  5508. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  5509. return {
  5510. type: "SwitchCase",
  5511. test: to_moz(M.expression),
  5512. consequent: M.body.map(to_moz)
  5513. };
  5514. });
  5515. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  5516. return {
  5517. type: "TryStatement",
  5518. block: to_moz_block(M),
  5519. handler: to_moz(M.bcatch),
  5520. guardedHandlers: [],
  5521. finalizer: to_moz(M.bfinally)
  5522. };
  5523. });
  5524. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  5525. return {
  5526. type: "CatchClause",
  5527. param: to_moz(M.argname),
  5528. guard: null,
  5529. body: to_moz_block(M)
  5530. };
  5531. });
  5532. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  5533. return {
  5534. type: "VariableDeclaration",
  5535. kind:
  5536. M instanceof AST_Const ? "const" :
  5537. M instanceof AST_Let ? "let" : "var",
  5538. declarations: M.definitions.map(to_moz)
  5539. };
  5540. });
  5541. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  5542. if (M.exported_names) {
  5543. if (M.exported_names[0].name.name === "*") {
  5544. return {
  5545. type: "ExportAllDeclaration",
  5546. source: to_moz(M.module_name)
  5547. };
  5548. }
  5549. return {
  5550. type: "ExportNamedDeclaration",
  5551. specifiers: M.exported_names.map(function (name_mapping) {
  5552. return {
  5553. type: "ExportSpecifier",
  5554. exported: to_moz(name_mapping.foreign_name),
  5555. local: to_moz(name_mapping.name)
  5556. };
  5557. }),
  5558. declaration: to_moz(M.exported_definition),
  5559. source: to_moz(M.module_name)
  5560. };
  5561. }
  5562. return {
  5563. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  5564. declaration: to_moz(M.exported_value || M.exported_definition)
  5565. };
  5566. });
  5567. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  5568. var specifiers = [];
  5569. if (M.imported_name) {
  5570. specifiers.push({
  5571. type: "ImportDefaultSpecifier",
  5572. local: to_moz(M.imported_name)
  5573. });
  5574. }
  5575. if (M.imported_names && M.imported_names[0].foreign_name.name === "*") {
  5576. specifiers.push({
  5577. type: "ImportNamespaceSpecifier",
  5578. local: to_moz(M.imported_names[0].name)
  5579. });
  5580. } else if (M.imported_names) {
  5581. M.imported_names.forEach(function(name_mapping) {
  5582. specifiers.push({
  5583. type: "ImportSpecifier",
  5584. local: to_moz(name_mapping.name),
  5585. imported: to_moz(name_mapping.foreign_name)
  5586. });
  5587. });
  5588. }
  5589. return {
  5590. type: "ImportDeclaration",
  5591. specifiers: specifiers,
  5592. source: to_moz(M.module_name)
  5593. };
  5594. });
  5595. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  5596. return {
  5597. type: "MetaProperty",
  5598. meta: {
  5599. type: "Identifier",
  5600. name: "import"
  5601. },
  5602. property: {
  5603. type: "Identifier",
  5604. name: "meta"
  5605. }
  5606. };
  5607. });
  5608. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  5609. return {
  5610. type: "SequenceExpression",
  5611. expressions: M.expressions.map(to_moz)
  5612. };
  5613. });
  5614. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  5615. var isComputed = M instanceof AST_Sub;
  5616. return {
  5617. type: "MemberExpression",
  5618. object: to_moz(M.expression),
  5619. computed: isComputed,
  5620. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  5621. optional: M.optional
  5622. };
  5623. });
  5624. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  5625. return {
  5626. type: "ChainExpression",
  5627. expression: to_moz(M.expression)
  5628. };
  5629. });
  5630. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  5631. return {
  5632. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  5633. operator: M.operator,
  5634. prefix: M instanceof AST_UnaryPrefix,
  5635. argument: to_moz(M.expression)
  5636. };
  5637. });
  5638. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  5639. if (M.operator == "=" && to_moz_in_destructuring()) {
  5640. return {
  5641. type: "AssignmentPattern",
  5642. left: to_moz(M.left),
  5643. right: to_moz(M.right)
  5644. };
  5645. }
  5646. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  5647. ? "LogicalExpression"
  5648. : "BinaryExpression";
  5649. return {
  5650. type,
  5651. left: to_moz(M.left),
  5652. operator: M.operator,
  5653. right: to_moz(M.right)
  5654. };
  5655. });
  5656. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  5657. return {
  5658. type: "ArrayExpression",
  5659. elements: M.elements.map(to_moz)
  5660. };
  5661. });
  5662. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  5663. return {
  5664. type: "ObjectExpression",
  5665. properties: M.properties.map(to_moz)
  5666. };
  5667. });
  5668. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  5669. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  5670. type: "Identifier",
  5671. value: M.key
  5672. };
  5673. if (typeof M.key === "number") {
  5674. key = {
  5675. type: "Literal",
  5676. value: Number(M.key)
  5677. };
  5678. }
  5679. if (typeof M.key === "string") {
  5680. key = {
  5681. type: "Identifier",
  5682. name: M.key
  5683. };
  5684. }
  5685. var kind;
  5686. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  5687. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  5688. if (M instanceof AST_ObjectKeyVal) {
  5689. kind = "init";
  5690. computed = !string_or_num;
  5691. } else
  5692. if (M instanceof AST_ObjectGetter) {
  5693. kind = "get";
  5694. } else
  5695. if (M instanceof AST_ObjectSetter) {
  5696. kind = "set";
  5697. }
  5698. if (M instanceof AST_ClassProperty) {
  5699. return {
  5700. type: "FieldDefinition",
  5701. computed,
  5702. key,
  5703. value: to_moz(M.value),
  5704. static: M.static
  5705. };
  5706. }
  5707. if (parent instanceof AST_Class) {
  5708. return {
  5709. type: "MethodDefinition",
  5710. computed: computed,
  5711. kind: kind,
  5712. static: M.static,
  5713. key: to_moz(M.key),
  5714. value: to_moz(M.value)
  5715. };
  5716. }
  5717. return {
  5718. type: "Property",
  5719. computed: computed,
  5720. kind: kind,
  5721. key: key,
  5722. value: to_moz(M.value)
  5723. };
  5724. });
  5725. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  5726. if (parent instanceof AST_Object) {
  5727. return {
  5728. type: "Property",
  5729. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  5730. kind: "init",
  5731. method: true,
  5732. shorthand: false,
  5733. key: to_moz(M.key),
  5734. value: to_moz(M.value)
  5735. };
  5736. }
  5737. return {
  5738. type: "MethodDefinition",
  5739. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  5740. kind: M.key === "constructor" ? "constructor" : "method",
  5741. static: M.static,
  5742. key: to_moz(M.key),
  5743. value: to_moz(M.value)
  5744. };
  5745. });
  5746. def_to_moz(AST_Class, function To_Moz_Class(M) {
  5747. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  5748. return {
  5749. type: type,
  5750. superClass: to_moz(M.extends),
  5751. id: M.name ? to_moz(M.name) : null,
  5752. body: {
  5753. type: "ClassBody",
  5754. body: M.properties.map(to_moz)
  5755. }
  5756. };
  5757. });
  5758. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  5759. return {
  5760. type: "MetaProperty",
  5761. meta: {
  5762. type: "Identifier",
  5763. name: "new"
  5764. },
  5765. property: {
  5766. type: "Identifier",
  5767. name: "target"
  5768. }
  5769. };
  5770. });
  5771. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  5772. if (M instanceof AST_SymbolMethod && parent.quote) {
  5773. return {
  5774. type: "Literal",
  5775. value: M.name
  5776. };
  5777. }
  5778. var def = M.definition();
  5779. return {
  5780. type: "Identifier",
  5781. name: def ? def.mangled_name || def.name : M.name
  5782. };
  5783. });
  5784. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  5785. const pattern = M.value.source;
  5786. const flags = M.value.flags;
  5787. return {
  5788. type: "Literal",
  5789. value: null,
  5790. raw: M.print_to_string(),
  5791. regex: { pattern, flags }
  5792. };
  5793. });
  5794. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  5795. var value = M.value;
  5796. if (typeof value === "number" && (value < 0 || (value === 0 && 1 / value < 0))) {
  5797. return {
  5798. type: "UnaryExpression",
  5799. operator: "-",
  5800. prefix: true,
  5801. argument: {
  5802. type: "Literal",
  5803. value: -value,
  5804. raw: M.start.raw
  5805. }
  5806. };
  5807. }
  5808. return {
  5809. type: "Literal",
  5810. value: value,
  5811. raw: M.start.raw
  5812. };
  5813. });
  5814. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  5815. return {
  5816. type: "Identifier",
  5817. name: String(M.value)
  5818. };
  5819. });
  5820. def_to_moz(AST_BigInt, M => ({
  5821. type: "BigIntLiteral",
  5822. value: M.value
  5823. }));
  5824. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  5825. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  5826. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  5827. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  5828. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  5829. /* -----[ tools ]----- */
  5830. function raw_token(moznode) {
  5831. if (moznode.type == "Literal") {
  5832. return moznode.raw != null ? moznode.raw : moznode.value + "";
  5833. }
  5834. }
  5835. function my_start_token(moznode) {
  5836. var loc = moznode.loc, start = loc && loc.start;
  5837. var range = moznode.range;
  5838. return new AST_Token({
  5839. file : loc && loc.source,
  5840. line : start && start.line,
  5841. col : start && start.column,
  5842. pos : range ? range[0] : moznode.start,
  5843. endline : start && start.line,
  5844. endcol : start && start.column,
  5845. endpos : range ? range[0] : moznode.start,
  5846. raw : raw_token(moznode),
  5847. });
  5848. }
  5849. function my_end_token(moznode) {
  5850. var loc = moznode.loc, end = loc && loc.end;
  5851. var range = moznode.range;
  5852. return new AST_Token({
  5853. file : loc && loc.source,
  5854. line : end && end.line,
  5855. col : end && end.column,
  5856. pos : range ? range[1] : moznode.end,
  5857. endline : end && end.line,
  5858. endcol : end && end.column,
  5859. endpos : range ? range[1] : moznode.end,
  5860. raw : raw_token(moznode),
  5861. });
  5862. }
  5863. function map(moztype, mytype, propmap) {
  5864. var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
  5865. moz_to_me += "return new U2." + mytype.name + "({\n" +
  5866. "start: my_start_token(M),\n" +
  5867. "end: my_end_token(M)";
  5868. var me_to_moz = "function To_Moz_" + moztype + "(M){\n";
  5869. me_to_moz += "return {\n" +
  5870. "type: " + JSON.stringify(moztype);
  5871. if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
  5872. var m = /([a-z0-9$_]+)([=@>%])([a-z0-9$_]+)/i.exec(prop);
  5873. if (!m) throw new Error("Can't understand property map: " + prop);
  5874. var moz = m[1], how = m[2], my = m[3];
  5875. moz_to_me += ",\n" + my + ": ";
  5876. me_to_moz += ",\n" + moz + ": ";
  5877. switch (how) {
  5878. case "@":
  5879. moz_to_me += "M." + moz + ".map(from_moz)";
  5880. me_to_moz += "M." + my + ".map(to_moz)";
  5881. break;
  5882. case ">":
  5883. moz_to_me += "from_moz(M." + moz + ")";
  5884. me_to_moz += "to_moz(M." + my + ")";
  5885. break;
  5886. case "=":
  5887. moz_to_me += "M." + moz;
  5888. me_to_moz += "M." + my;
  5889. break;
  5890. case "%":
  5891. moz_to_me += "from_moz(M." + moz + ").body";
  5892. me_to_moz += "to_moz_block(M)";
  5893. break;
  5894. default:
  5895. throw new Error("Can't understand operator in propmap: " + prop);
  5896. }
  5897. });
  5898. moz_to_me += "\n})\n}";
  5899. me_to_moz += "\n}\n}";
  5900. moz_to_me = new Function("U2", "my_start_token", "my_end_token", "from_moz", "return(" + moz_to_me + ")")(
  5901. ast, my_start_token, my_end_token, from_moz
  5902. );
  5903. me_to_moz = new Function("to_moz", "to_moz_block", "to_moz_scope", "return(" + me_to_moz + ")")(
  5904. to_moz, to_moz_block, to_moz_scope
  5905. );
  5906. MOZ_TO_ME[moztype] = moz_to_me;
  5907. def_to_moz(mytype, me_to_moz);
  5908. }
  5909. var FROM_MOZ_STACK = null;
  5910. function from_moz(node) {
  5911. FROM_MOZ_STACK.push(node);
  5912. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  5913. FROM_MOZ_STACK.pop();
  5914. return ret;
  5915. }
  5916. AST_Node.from_mozilla_ast = function(node) {
  5917. var save_stack = FROM_MOZ_STACK;
  5918. FROM_MOZ_STACK = [];
  5919. var ast = from_moz(node);
  5920. FROM_MOZ_STACK = save_stack;
  5921. return ast;
  5922. };
  5923. function set_moz_loc(mynode, moznode) {
  5924. var start = mynode.start;
  5925. var end = mynode.end;
  5926. if (!(start && end)) {
  5927. return moznode;
  5928. }
  5929. if (start.pos != null && end.endpos != null) {
  5930. moznode.range = [start.pos, end.endpos];
  5931. }
  5932. if (start.line) {
  5933. moznode.loc = {
  5934. start: {line: start.line, column: start.col},
  5935. end: end.endline ? {line: end.endline, column: end.endcol} : null
  5936. };
  5937. if (start.file) {
  5938. moznode.loc.source = start.file;
  5939. }
  5940. }
  5941. return moznode;
  5942. }
  5943. function def_to_moz(mytype, handler) {
  5944. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  5945. return set_moz_loc(this, handler(this, parent));
  5946. });
  5947. }
  5948. var TO_MOZ_STACK = null;
  5949. function to_moz(node) {
  5950. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  5951. TO_MOZ_STACK.push(node);
  5952. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  5953. TO_MOZ_STACK.pop();
  5954. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  5955. return ast;
  5956. }
  5957. function to_moz_in_destructuring() {
  5958. var i = TO_MOZ_STACK.length;
  5959. while (i--) {
  5960. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  5961. return true;
  5962. }
  5963. }
  5964. return false;
  5965. }
  5966. function to_moz_block(node) {
  5967. return {
  5968. type: "BlockStatement",
  5969. body: node.body.map(to_moz)
  5970. };
  5971. }
  5972. function to_moz_scope(type, node) {
  5973. var body = node.body.map(to_moz);
  5974. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  5975. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  5976. }
  5977. return {
  5978. type: type,
  5979. body: body
  5980. };
  5981. }
  5982. })();
  5983. // return true if the node at the top of the stack (that means the
  5984. // innermost node in the current output) is lexically the first in
  5985. // a statement.
  5986. function first_in_statement(stack) {
  5987. let node = stack.parent(-1);
  5988. for (let i = 0, p; p = stack.parent(i); i++) {
  5989. if (p instanceof AST_Statement && p.body === node)
  5990. return true;
  5991. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  5992. (p.TYPE === "Call" && p.expression === node) ||
  5993. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  5994. (p instanceof AST_Dot && p.expression === node) ||
  5995. (p instanceof AST_Sub && p.expression === node) ||
  5996. (p instanceof AST_Conditional && p.condition === node) ||
  5997. (p instanceof AST_Binary && p.left === node) ||
  5998. (p instanceof AST_UnaryPostfix && p.expression === node)
  5999. ) {
  6000. node = p;
  6001. } else {
  6002. return false;
  6003. }
  6004. }
  6005. }
  6006. // Returns whether the leftmost item in the expression is an object
  6007. function left_is_object(node) {
  6008. if (node instanceof AST_Object) return true;
  6009. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  6010. if (node.TYPE === "Call") return left_is_object(node.expression);
  6011. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  6012. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  6013. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  6014. if (node instanceof AST_Binary) return left_is_object(node.left);
  6015. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  6016. return false;
  6017. }
  6018. /***********************************************************************
  6019. A JavaScript tokenizer / parser / beautifier / compressor.
  6020. https://github.com/mishoo/UglifyJS2
  6021. -------------------------------- (C) ---------------------------------
  6022. Author: Mihai Bazon
  6023. <mihai.bazon@gmail.com>
  6024. http://mihai.bazon.net/blog
  6025. Distributed under the BSD license:
  6026. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6027. Redistribution and use in source and binary forms, with or without
  6028. modification, are permitted provided that the following conditions
  6029. are met:
  6030. * Redistributions of source code must retain the above
  6031. copyright notice, this list of conditions and the following
  6032. disclaimer.
  6033. * Redistributions in binary form must reproduce the above
  6034. copyright notice, this list of conditions and the following
  6035. disclaimer in the documentation and/or other materials
  6036. provided with the distribution.
  6037. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6038. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6039. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6040. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6041. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6042. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6043. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6044. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6045. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6046. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6047. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6048. SUCH DAMAGE.
  6049. ***********************************************************************/
  6050. const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
  6051. const CODE_LINE_BREAK = 10;
  6052. const CODE_SPACE = 32;
  6053. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/g;
  6054. function is_some_comments(comment) {
  6055. // multiline comment
  6056. return (
  6057. (comment.type === "comment2" || comment.type === "comment1")
  6058. && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
  6059. );
  6060. }
  6061. function OutputStream(options) {
  6062. var readonly = !options;
  6063. options = defaults(options, {
  6064. ascii_only : false,
  6065. beautify : false,
  6066. braces : false,
  6067. comments : "some",
  6068. ecma : 5,
  6069. ie8 : false,
  6070. indent_level : 4,
  6071. indent_start : 0,
  6072. inline_script : true,
  6073. keep_numbers : false,
  6074. keep_quoted_props : false,
  6075. max_line_len : false,
  6076. preamble : null,
  6077. preserve_annotations : false,
  6078. quote_keys : false,
  6079. quote_style : 0,
  6080. safari10 : false,
  6081. semicolons : true,
  6082. shebang : true,
  6083. shorthand : undefined,
  6084. source_map : null,
  6085. webkit : false,
  6086. width : 80,
  6087. wrap_iife : false,
  6088. wrap_func_args : true,
  6089. }, true);
  6090. if (options.shorthand === undefined)
  6091. options.shorthand = options.ecma > 5;
  6092. // Convert comment option to RegExp if neccessary and set up comments filter
  6093. var comment_filter = return_false; // Default case, throw all comments away
  6094. if (options.comments) {
  6095. let comments = options.comments;
  6096. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  6097. var regex_pos = options.comments.lastIndexOf("/");
  6098. comments = new RegExp(
  6099. options.comments.substr(1, regex_pos - 1),
  6100. options.comments.substr(regex_pos + 1)
  6101. );
  6102. }
  6103. if (comments instanceof RegExp) {
  6104. comment_filter = function(comment) {
  6105. return comment.type != "comment5" && comments.test(comment.value);
  6106. };
  6107. } else if (typeof comments === "function") {
  6108. comment_filter = function(comment) {
  6109. return comment.type != "comment5" && comments(this, comment);
  6110. };
  6111. } else if (comments === "some") {
  6112. comment_filter = is_some_comments;
  6113. } else { // NOTE includes "all" option
  6114. comment_filter = return_true;
  6115. }
  6116. }
  6117. var indentation = 0;
  6118. var current_col = 0;
  6119. var current_line = 1;
  6120. var current_pos = 0;
  6121. var OUTPUT = "";
  6122. let printed_comments = new Set();
  6123. var to_utf8 = options.ascii_only ? function(str, identifier) {
  6124. if (options.ecma >= 2015) {
  6125. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  6126. var code = get_full_char_code(ch, 0).toString(16);
  6127. return "\\u{" + code + "}";
  6128. });
  6129. }
  6130. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  6131. var code = ch.charCodeAt(0).toString(16);
  6132. if (code.length <= 2 && !identifier) {
  6133. while (code.length < 2) code = "0" + code;
  6134. return "\\x" + code;
  6135. } else {
  6136. while (code.length < 4) code = "0" + code;
  6137. return "\\u" + code;
  6138. }
  6139. });
  6140. } : function(str) {
  6141. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  6142. if (lone) {
  6143. return "\\u" + lone.charCodeAt(0).toString(16);
  6144. }
  6145. return match;
  6146. });
  6147. };
  6148. function make_string(str, quote) {
  6149. var dq = 0, sq = 0;
  6150. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  6151. function(s, i) {
  6152. switch (s) {
  6153. case '"': ++dq; return '"';
  6154. case "'": ++sq; return "'";
  6155. case "\\": return "\\\\";
  6156. case "\n": return "\\n";
  6157. case "\r": return "\\r";
  6158. case "\t": return "\\t";
  6159. case "\b": return "\\b";
  6160. case "\f": return "\\f";
  6161. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  6162. case "\u2028": return "\\u2028";
  6163. case "\u2029": return "\\u2029";
  6164. case "\ufeff": return "\\ufeff";
  6165. case "\0":
  6166. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  6167. }
  6168. return s;
  6169. });
  6170. function quote_single() {
  6171. return "'" + str.replace(/\x27/g, "\\'") + "'";
  6172. }
  6173. function quote_double() {
  6174. return '"' + str.replace(/\x22/g, '\\"') + '"';
  6175. }
  6176. function quote_template() {
  6177. return "`" + str.replace(/`/g, "\\`") + "`";
  6178. }
  6179. str = to_utf8(str);
  6180. if (quote === "`") return quote_template();
  6181. switch (options.quote_style) {
  6182. case 1:
  6183. return quote_single();
  6184. case 2:
  6185. return quote_double();
  6186. case 3:
  6187. return quote == "'" ? quote_single() : quote_double();
  6188. default:
  6189. return dq > sq ? quote_single() : quote_double();
  6190. }
  6191. }
  6192. function encode_string(str, quote) {
  6193. var ret = make_string(str, quote);
  6194. if (options.inline_script) {
  6195. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  6196. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  6197. ret = ret.replace(/--\x3e/g, "--\\x3e");
  6198. }
  6199. return ret;
  6200. }
  6201. function make_name(name) {
  6202. name = name.toString();
  6203. name = to_utf8(name, true);
  6204. return name;
  6205. }
  6206. function make_indent(back) {
  6207. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  6208. }
  6209. /* -----[ beautification/minification ]----- */
  6210. var has_parens = false;
  6211. var might_need_space = false;
  6212. var might_need_semicolon = false;
  6213. var might_add_newline = 0;
  6214. var need_newline_indented = false;
  6215. var need_space = false;
  6216. var newline_insert = -1;
  6217. var last = "";
  6218. var mapping_token, mapping_name, mappings = options.source_map && [];
  6219. var do_add_mapping = mappings ? function() {
  6220. mappings.forEach(function(mapping) {
  6221. try {
  6222. options.source_map.add(
  6223. mapping.token.file,
  6224. mapping.line, mapping.col,
  6225. mapping.token.line, mapping.token.col,
  6226. !mapping.name && mapping.token.type == "name" ? mapping.token.value : mapping.name
  6227. );
  6228. } catch(ex) {
  6229. // Ignore bad mapping
  6230. }
  6231. });
  6232. mappings = [];
  6233. } : noop;
  6234. var ensure_line_len = options.max_line_len ? function() {
  6235. if (current_col > options.max_line_len) {
  6236. if (might_add_newline) {
  6237. var left = OUTPUT.slice(0, might_add_newline);
  6238. var right = OUTPUT.slice(might_add_newline);
  6239. if (mappings) {
  6240. var delta = right.length - current_col;
  6241. mappings.forEach(function(mapping) {
  6242. mapping.line++;
  6243. mapping.col += delta;
  6244. });
  6245. }
  6246. OUTPUT = left + "\n" + right;
  6247. current_line++;
  6248. current_pos++;
  6249. current_col = right.length;
  6250. }
  6251. }
  6252. if (might_add_newline) {
  6253. might_add_newline = 0;
  6254. do_add_mapping();
  6255. }
  6256. } : noop;
  6257. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  6258. function print(str) {
  6259. str = String(str);
  6260. var ch = get_full_char(str, 0);
  6261. if (need_newline_indented && ch) {
  6262. need_newline_indented = false;
  6263. if (ch !== "\n") {
  6264. print("\n");
  6265. indent();
  6266. }
  6267. }
  6268. if (need_space && ch) {
  6269. need_space = false;
  6270. if (!/[\s;})]/.test(ch)) {
  6271. space();
  6272. }
  6273. }
  6274. newline_insert = -1;
  6275. var prev = last.charAt(last.length - 1);
  6276. if (might_need_semicolon) {
  6277. might_need_semicolon = false;
  6278. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  6279. if (options.semicolons || requireSemicolonChars.has(ch)) {
  6280. OUTPUT += ";";
  6281. current_col++;
  6282. current_pos++;
  6283. } else {
  6284. ensure_line_len();
  6285. if (current_col > 0) {
  6286. OUTPUT += "\n";
  6287. current_pos++;
  6288. current_line++;
  6289. current_col = 0;
  6290. }
  6291. if (/^\s+$/.test(str)) {
  6292. // reset the semicolon flag, since we didn't print one
  6293. // now and might still have to later
  6294. might_need_semicolon = true;
  6295. }
  6296. }
  6297. if (!options.beautify)
  6298. might_need_space = false;
  6299. }
  6300. }
  6301. if (might_need_space) {
  6302. if ((is_identifier_char(prev)
  6303. && (is_identifier_char(ch) || ch == "\\"))
  6304. || (ch == "/" && ch == prev)
  6305. || ((ch == "+" || ch == "-") && ch == last)
  6306. ) {
  6307. OUTPUT += " ";
  6308. current_col++;
  6309. current_pos++;
  6310. }
  6311. might_need_space = false;
  6312. }
  6313. if (mapping_token) {
  6314. mappings.push({
  6315. token: mapping_token,
  6316. name: mapping_name,
  6317. line: current_line,
  6318. col: current_col
  6319. });
  6320. mapping_token = false;
  6321. if (!might_add_newline) do_add_mapping();
  6322. }
  6323. OUTPUT += str;
  6324. has_parens = str[str.length - 1] == "(";
  6325. current_pos += str.length;
  6326. var a = str.split(/\r?\n/), n = a.length - 1;
  6327. current_line += n;
  6328. current_col += a[0].length;
  6329. if (n > 0) {
  6330. ensure_line_len();
  6331. current_col = a[n].length;
  6332. }
  6333. last = str;
  6334. }
  6335. var star = function() {
  6336. print("*");
  6337. };
  6338. var space = options.beautify ? function() {
  6339. print(" ");
  6340. } : function() {
  6341. might_need_space = true;
  6342. };
  6343. var indent = options.beautify ? function(half) {
  6344. if (options.beautify) {
  6345. print(make_indent(half ? 0.5 : 0));
  6346. }
  6347. } : noop;
  6348. var with_indent = options.beautify ? function(col, cont) {
  6349. if (col === true) col = next_indent();
  6350. var save_indentation = indentation;
  6351. indentation = col;
  6352. var ret = cont();
  6353. indentation = save_indentation;
  6354. return ret;
  6355. } : function(col, cont) { return cont(); };
  6356. var newline = options.beautify ? function() {
  6357. if (newline_insert < 0) return print("\n");
  6358. if (OUTPUT[newline_insert] != "\n") {
  6359. OUTPUT = OUTPUT.slice(0, newline_insert) + "\n" + OUTPUT.slice(newline_insert);
  6360. current_pos++;
  6361. current_line++;
  6362. }
  6363. newline_insert++;
  6364. } : options.max_line_len ? function() {
  6365. ensure_line_len();
  6366. might_add_newline = OUTPUT.length;
  6367. } : noop;
  6368. var semicolon = options.beautify ? function() {
  6369. print(";");
  6370. } : function() {
  6371. might_need_semicolon = true;
  6372. };
  6373. function force_semicolon() {
  6374. might_need_semicolon = false;
  6375. print(";");
  6376. }
  6377. function next_indent() {
  6378. return indentation + options.indent_level;
  6379. }
  6380. function with_block(cont) {
  6381. var ret;
  6382. print("{");
  6383. newline();
  6384. with_indent(next_indent(), function() {
  6385. ret = cont();
  6386. });
  6387. indent();
  6388. print("}");
  6389. return ret;
  6390. }
  6391. function with_parens(cont) {
  6392. print("(");
  6393. //XXX: still nice to have that for argument lists
  6394. //var ret = with_indent(current_col, cont);
  6395. var ret = cont();
  6396. print(")");
  6397. return ret;
  6398. }
  6399. function with_square(cont) {
  6400. print("[");
  6401. //var ret = with_indent(current_col, cont);
  6402. var ret = cont();
  6403. print("]");
  6404. return ret;
  6405. }
  6406. function comma() {
  6407. print(",");
  6408. space();
  6409. }
  6410. function colon() {
  6411. print(":");
  6412. space();
  6413. }
  6414. var add_mapping = mappings ? function(token, name) {
  6415. mapping_token = token;
  6416. mapping_name = name;
  6417. } : noop;
  6418. function get() {
  6419. if (might_add_newline) {
  6420. ensure_line_len();
  6421. }
  6422. return OUTPUT;
  6423. }
  6424. function has_nlb() {
  6425. let n = OUTPUT.length - 1;
  6426. while (n >= 0) {
  6427. const code = OUTPUT.charCodeAt(n);
  6428. if (code === CODE_LINE_BREAK) {
  6429. return true;
  6430. }
  6431. if (code !== CODE_SPACE) {
  6432. return false;
  6433. }
  6434. n--;
  6435. }
  6436. return true;
  6437. }
  6438. function filter_comment(comment) {
  6439. if (!options.preserve_annotations) {
  6440. comment = comment.replace(r_annotation, " ");
  6441. }
  6442. if (/^\s*$/.test(comment)) {
  6443. return "";
  6444. }
  6445. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  6446. }
  6447. function prepend_comments(node) {
  6448. var self = this;
  6449. var start = node.start;
  6450. if (!start) return;
  6451. var printed_comments = self.printed_comments;
  6452. // There cannot be a newline between return and its value.
  6453. const return_with_value = node instanceof AST_Exit && node.value;
  6454. if (
  6455. start.comments_before
  6456. && printed_comments.has(start.comments_before)
  6457. ) {
  6458. if (return_with_value) {
  6459. start.comments_before = [];
  6460. } else {
  6461. return;
  6462. }
  6463. }
  6464. var comments = start.comments_before;
  6465. if (!comments) {
  6466. comments = start.comments_before = [];
  6467. }
  6468. printed_comments.add(comments);
  6469. if (return_with_value) {
  6470. var tw = new TreeWalker(function(node) {
  6471. var parent = tw.parent();
  6472. if (parent instanceof AST_Exit
  6473. || parent instanceof AST_Binary && parent.left === node
  6474. || parent.TYPE == "Call" && parent.expression === node
  6475. || parent instanceof AST_Conditional && parent.condition === node
  6476. || parent instanceof AST_Dot && parent.expression === node
  6477. || parent instanceof AST_Sequence && parent.expressions[0] === node
  6478. || parent instanceof AST_Sub && parent.expression === node
  6479. || parent instanceof AST_UnaryPostfix) {
  6480. if (!node.start) return;
  6481. var text = node.start.comments_before;
  6482. if (text && !printed_comments.has(text)) {
  6483. printed_comments.add(text);
  6484. comments = comments.concat(text);
  6485. }
  6486. } else {
  6487. return true;
  6488. }
  6489. });
  6490. tw.push(node);
  6491. node.value.walk(tw);
  6492. }
  6493. if (current_pos == 0) {
  6494. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  6495. && !printed_comments.has(comments[0])) {
  6496. print("#!" + comments.shift().value + "\n");
  6497. indent();
  6498. }
  6499. var preamble = options.preamble;
  6500. if (preamble) {
  6501. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  6502. }
  6503. }
  6504. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  6505. if (comments.length == 0) return;
  6506. var last_nlb = has_nlb();
  6507. comments.forEach(function(c, i) {
  6508. printed_comments.add(c);
  6509. if (!last_nlb) {
  6510. if (c.nlb) {
  6511. print("\n");
  6512. indent();
  6513. last_nlb = true;
  6514. } else if (i > 0) {
  6515. space();
  6516. }
  6517. }
  6518. if (/comment[134]/.test(c.type)) {
  6519. var value = filter_comment(c.value);
  6520. if (value) {
  6521. print("//" + value + "\n");
  6522. indent();
  6523. }
  6524. last_nlb = true;
  6525. } else if (c.type == "comment2") {
  6526. var value = filter_comment(c.value);
  6527. if (value) {
  6528. print("/*" + value + "*/");
  6529. }
  6530. last_nlb = false;
  6531. }
  6532. });
  6533. if (!last_nlb) {
  6534. if (start.nlb) {
  6535. print("\n");
  6536. indent();
  6537. } else {
  6538. space();
  6539. }
  6540. }
  6541. }
  6542. function append_comments(node, tail) {
  6543. var self = this;
  6544. var token = node.end;
  6545. if (!token) return;
  6546. var printed_comments = self.printed_comments;
  6547. var comments = token[tail ? "comments_before" : "comments_after"];
  6548. if (!comments || printed_comments.has(comments)) return;
  6549. if (!(node instanceof AST_Statement || comments.every((c) =>
  6550. !/comment[134]/.test(c.type)
  6551. ))) return;
  6552. printed_comments.add(comments);
  6553. var insert = OUTPUT.length;
  6554. comments.filter(comment_filter, node).forEach(function(c, i) {
  6555. if (printed_comments.has(c)) return;
  6556. printed_comments.add(c);
  6557. need_space = false;
  6558. if (need_newline_indented) {
  6559. print("\n");
  6560. indent();
  6561. need_newline_indented = false;
  6562. } else if (c.nlb && (i > 0 || !has_nlb())) {
  6563. print("\n");
  6564. indent();
  6565. } else if (i > 0 || !tail) {
  6566. space();
  6567. }
  6568. if (/comment[134]/.test(c.type)) {
  6569. const value = filter_comment(c.value);
  6570. if (value) {
  6571. print("//" + value);
  6572. }
  6573. need_newline_indented = true;
  6574. } else if (c.type == "comment2") {
  6575. const value = filter_comment(c.value);
  6576. if (value) {
  6577. print("/*" + value + "*/");
  6578. }
  6579. need_space = true;
  6580. }
  6581. });
  6582. if (OUTPUT.length > insert) newline_insert = insert;
  6583. }
  6584. var stack = [];
  6585. return {
  6586. get : get,
  6587. toString : get,
  6588. indent : indent,
  6589. in_directive : false,
  6590. use_asm : null,
  6591. active_scope : null,
  6592. indentation : function() { return indentation; },
  6593. current_width : function() { return current_col - indentation; },
  6594. should_break : function() { return options.width && this.current_width() >= options.width; },
  6595. has_parens : function() { return has_parens; },
  6596. newline : newline,
  6597. print : print,
  6598. star : star,
  6599. space : space,
  6600. comma : comma,
  6601. colon : colon,
  6602. last : function() { return last; },
  6603. semicolon : semicolon,
  6604. force_semicolon : force_semicolon,
  6605. to_utf8 : to_utf8,
  6606. print_name : function(name) { print(make_name(name)); },
  6607. print_string : function(str, quote, escape_directive) {
  6608. var encoded = encode_string(str, quote);
  6609. if (escape_directive === true && !encoded.includes("\\")) {
  6610. // Insert semicolons to break directive prologue
  6611. if (!EXPECT_DIRECTIVE.test(OUTPUT)) {
  6612. force_semicolon();
  6613. }
  6614. force_semicolon();
  6615. }
  6616. print(encoded);
  6617. },
  6618. print_template_string_chars: function(str) {
  6619. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  6620. return print(encoded.substr(1, encoded.length - 2));
  6621. },
  6622. encode_string : encode_string,
  6623. next_indent : next_indent,
  6624. with_indent : with_indent,
  6625. with_block : with_block,
  6626. with_parens : with_parens,
  6627. with_square : with_square,
  6628. add_mapping : add_mapping,
  6629. option : function(opt) { return options[opt]; },
  6630. printed_comments: printed_comments,
  6631. prepend_comments: readonly ? noop : prepend_comments,
  6632. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  6633. line : function() { return current_line; },
  6634. col : function() { return current_col; },
  6635. pos : function() { return current_pos; },
  6636. push_node : function(node) { stack.push(node); },
  6637. pop_node : function() { return stack.pop(); },
  6638. parent : function(n) {
  6639. return stack[stack.length - 2 - (n || 0)];
  6640. }
  6641. };
  6642. }
  6643. /* -----[ code generators ]----- */
  6644. (function() {
  6645. /* -----[ utils ]----- */
  6646. function DEFPRINT(nodetype, generator) {
  6647. nodetype.DEFMETHOD("_codegen", generator);
  6648. }
  6649. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  6650. var self = this, generator = self._codegen;
  6651. if (self instanceof AST_Scope) {
  6652. output.active_scope = self;
  6653. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  6654. output.use_asm = output.active_scope;
  6655. }
  6656. function doit() {
  6657. output.prepend_comments(self);
  6658. self.add_source_map(output);
  6659. generator(self, output);
  6660. output.append_comments(self);
  6661. }
  6662. output.push_node(self);
  6663. if (force_parens || self.needs_parens(output)) {
  6664. output.with_parens(doit);
  6665. } else {
  6666. doit();
  6667. }
  6668. output.pop_node();
  6669. if (self === output.use_asm) {
  6670. output.use_asm = null;
  6671. }
  6672. });
  6673. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  6674. AST_Node.DEFMETHOD("print_to_string", function(options) {
  6675. var output = OutputStream(options);
  6676. this.print(output);
  6677. return output.get();
  6678. });
  6679. /* -----[ PARENTHESES ]----- */
  6680. function PARENS(nodetype, func) {
  6681. if (Array.isArray(nodetype)) {
  6682. nodetype.forEach(function(nodetype) {
  6683. PARENS(nodetype, func);
  6684. });
  6685. } else {
  6686. nodetype.DEFMETHOD("needs_parens", func);
  6687. }
  6688. }
  6689. PARENS(AST_Node, return_false);
  6690. // a function expression needs parens around it when it's provably
  6691. // the first token to appear in a statement.
  6692. PARENS(AST_Function, function(output) {
  6693. if (!output.has_parens() && first_in_statement(output)) {
  6694. return true;
  6695. }
  6696. if (output.option("webkit")) {
  6697. var p = output.parent();
  6698. if (p instanceof AST_PropAccess && p.expression === this) {
  6699. return true;
  6700. }
  6701. }
  6702. if (output.option("wrap_iife")) {
  6703. var p = output.parent();
  6704. if (p instanceof AST_Call && p.expression === this) {
  6705. return true;
  6706. }
  6707. }
  6708. if (output.option("wrap_func_args")) {
  6709. var p = output.parent();
  6710. if (p instanceof AST_Call && p.args.includes(this)) {
  6711. return true;
  6712. }
  6713. }
  6714. return false;
  6715. });
  6716. PARENS(AST_Arrow, function(output) {
  6717. var p = output.parent();
  6718. if (
  6719. output.option("wrap_func_args")
  6720. && p instanceof AST_Call
  6721. && p.args.includes(this)
  6722. ) {
  6723. return true;
  6724. }
  6725. return p instanceof AST_PropAccess && p.expression === this;
  6726. });
  6727. // same goes for an object literal (as in AST_Function), because
  6728. // otherwise {...} would be interpreted as a block of code.
  6729. PARENS(AST_Object, function(output) {
  6730. return !output.has_parens() && first_in_statement(output);
  6731. });
  6732. PARENS(AST_ClassExpression, first_in_statement);
  6733. PARENS(AST_Unary, function(output) {
  6734. var p = output.parent();
  6735. return p instanceof AST_PropAccess && p.expression === this
  6736. || p instanceof AST_Call && p.expression === this
  6737. || p instanceof AST_Binary
  6738. && p.operator === "**"
  6739. && this instanceof AST_UnaryPrefix
  6740. && p.left === this
  6741. && this.operator !== "++"
  6742. && this.operator !== "--";
  6743. });
  6744. PARENS(AST_Await, function(output) {
  6745. var p = output.parent();
  6746. return p instanceof AST_PropAccess && p.expression === this
  6747. || p instanceof AST_Call && p.expression === this
  6748. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  6749. });
  6750. PARENS(AST_Sequence, function(output) {
  6751. var p = output.parent();
  6752. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  6753. || p instanceof AST_Unary // !(foo, bar, baz)
  6754. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  6755. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  6756. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  6757. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  6758. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  6759. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  6760. * ==> 20 (side effect, set a := 10 and b := 20) */
  6761. || p instanceof AST_Arrow // x => (x, x)
  6762. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  6763. || p instanceof AST_Expansion // [...(a, b)]
  6764. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  6765. || p instanceof AST_Yield // yield (foo, bar)
  6766. || p instanceof AST_Export // export default (foo, bar)
  6767. ;
  6768. });
  6769. PARENS(AST_Binary, function(output) {
  6770. var p = output.parent();
  6771. // (foo && bar)()
  6772. if (p instanceof AST_Call && p.expression === this)
  6773. return true;
  6774. // typeof (foo && bar)
  6775. if (p instanceof AST_Unary)
  6776. return true;
  6777. // (foo && bar)["prop"], (foo && bar).prop
  6778. if (p instanceof AST_PropAccess && p.expression === this)
  6779. return true;
  6780. // this deals with precedence: 3 * (2 + 1)
  6781. if (p instanceof AST_Binary) {
  6782. const po = p.operator;
  6783. const so = this.operator;
  6784. if (so === "??" && (po === "||" || po === "&&")) {
  6785. return true;
  6786. }
  6787. if (po === "??" && (so === "||" || so === "&&")) {
  6788. return true;
  6789. }
  6790. const pp = PRECEDENCE[po];
  6791. const sp = PRECEDENCE[so];
  6792. if (pp > sp
  6793. || (pp == sp
  6794. && (this === p.right || po == "**"))) {
  6795. return true;
  6796. }
  6797. }
  6798. });
  6799. PARENS(AST_Yield, function(output) {
  6800. var p = output.parent();
  6801. // (yield 1) + (yield 2)
  6802. // a = yield 3
  6803. if (p instanceof AST_Binary && p.operator !== "=")
  6804. return true;
  6805. // (yield 1)()
  6806. // new (yield 1)()
  6807. if (p instanceof AST_Call && p.expression === this)
  6808. return true;
  6809. // (yield 1) ? yield 2 : yield 3
  6810. if (p instanceof AST_Conditional && p.condition === this)
  6811. return true;
  6812. // -(yield 4)
  6813. if (p instanceof AST_Unary)
  6814. return true;
  6815. // (yield x).foo
  6816. // (yield x)['foo']
  6817. if (p instanceof AST_PropAccess && p.expression === this)
  6818. return true;
  6819. });
  6820. PARENS(AST_PropAccess, function(output) {
  6821. var p = output.parent();
  6822. if (p instanceof AST_New && p.expression === this) {
  6823. // i.e. new (foo.bar().baz)
  6824. //
  6825. // if there's one call into this subtree, then we need
  6826. // parens around it too, otherwise the call will be
  6827. // interpreted as passing the arguments to the upper New
  6828. // expression.
  6829. return walk(this, node => {
  6830. if (node instanceof AST_Scope) return true;
  6831. if (node instanceof AST_Call) {
  6832. return walk_abort; // makes walk() return true.
  6833. }
  6834. });
  6835. }
  6836. });
  6837. PARENS(AST_Call, function(output) {
  6838. var p = output.parent(), p1;
  6839. if (p instanceof AST_New && p.expression === this
  6840. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  6841. return true;
  6842. // workaround for Safari bug.
  6843. // https://bugs.webkit.org/show_bug.cgi?id=123506
  6844. return this.expression instanceof AST_Function
  6845. && p instanceof AST_PropAccess
  6846. && p.expression === this
  6847. && (p1 = output.parent(1)) instanceof AST_Assign
  6848. && p1.left === p;
  6849. });
  6850. PARENS(AST_New, function(output) {
  6851. var p = output.parent();
  6852. if (this.args.length === 0
  6853. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  6854. || p instanceof AST_Call && p.expression === this)) // (new foo)(bar)
  6855. return true;
  6856. });
  6857. PARENS(AST_Number, function(output) {
  6858. var p = output.parent();
  6859. if (p instanceof AST_PropAccess && p.expression === this) {
  6860. var value = this.getValue();
  6861. if (value < 0 || /^0/.test(make_num(value))) {
  6862. return true;
  6863. }
  6864. }
  6865. });
  6866. PARENS(AST_BigInt, function(output) {
  6867. var p = output.parent();
  6868. if (p instanceof AST_PropAccess && p.expression === this) {
  6869. var value = this.getValue();
  6870. if (value.startsWith("-")) {
  6871. return true;
  6872. }
  6873. }
  6874. });
  6875. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  6876. var p = output.parent();
  6877. // !(a = false) → true
  6878. if (p instanceof AST_Unary)
  6879. return true;
  6880. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  6881. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  6882. return true;
  6883. // (a = func)() —or— new (a = Object)()
  6884. if (p instanceof AST_Call && p.expression === this)
  6885. return true;
  6886. // (a = foo) ? bar : baz
  6887. if (p instanceof AST_Conditional && p.condition === this)
  6888. return true;
  6889. // (a = foo)["prop"] —or— (a = foo).prop
  6890. if (p instanceof AST_PropAccess && p.expression === this)
  6891. return true;
  6892. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  6893. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  6894. return true;
  6895. });
  6896. /* -----[ PRINTERS ]----- */
  6897. DEFPRINT(AST_Directive, function(self, output) {
  6898. output.print_string(self.value, self.quote);
  6899. output.semicolon();
  6900. });
  6901. DEFPRINT(AST_Expansion, function (self, output) {
  6902. output.print("...");
  6903. self.expression.print(output);
  6904. });
  6905. DEFPRINT(AST_Destructuring, function (self, output) {
  6906. output.print(self.is_array ? "[" : "{");
  6907. var len = self.names.length;
  6908. self.names.forEach(function (name, i) {
  6909. if (i > 0) output.comma();
  6910. name.print(output);
  6911. // If the final element is a hole, we need to make sure it
  6912. // doesn't look like a trailing comma, by inserting an actual
  6913. // trailing comma.
  6914. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  6915. });
  6916. output.print(self.is_array ? "]" : "}");
  6917. });
  6918. DEFPRINT(AST_Debugger, function(self, output) {
  6919. output.print("debugger");
  6920. output.semicolon();
  6921. });
  6922. /* -----[ statements ]----- */
  6923. function display_body(body, is_toplevel, output, allow_directives) {
  6924. var last = body.length - 1;
  6925. output.in_directive = allow_directives;
  6926. body.forEach(function(stmt, i) {
  6927. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  6928. stmt instanceof AST_EmptyStatement ||
  6929. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  6930. )) {
  6931. output.in_directive = false;
  6932. }
  6933. if (!(stmt instanceof AST_EmptyStatement)) {
  6934. output.indent();
  6935. stmt.print(output);
  6936. if (!(i == last && is_toplevel)) {
  6937. output.newline();
  6938. if (is_toplevel) output.newline();
  6939. }
  6940. }
  6941. if (output.in_directive === true &&
  6942. stmt instanceof AST_SimpleStatement &&
  6943. stmt.body instanceof AST_String
  6944. ) {
  6945. output.in_directive = false;
  6946. }
  6947. });
  6948. output.in_directive = false;
  6949. }
  6950. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  6951. force_statement(this.body, output);
  6952. });
  6953. DEFPRINT(AST_Statement, function(self, output) {
  6954. self.body.print(output);
  6955. output.semicolon();
  6956. });
  6957. DEFPRINT(AST_Toplevel, function(self, output) {
  6958. display_body(self.body, true, output, true);
  6959. output.print("");
  6960. });
  6961. DEFPRINT(AST_LabeledStatement, function(self, output) {
  6962. self.label.print(output);
  6963. output.colon();
  6964. self.body.print(output);
  6965. });
  6966. DEFPRINT(AST_SimpleStatement, function(self, output) {
  6967. self.body.print(output);
  6968. output.semicolon();
  6969. });
  6970. function print_braced_empty(self, output) {
  6971. output.print("{");
  6972. output.with_indent(output.next_indent(), function() {
  6973. output.append_comments(self, true);
  6974. });
  6975. output.print("}");
  6976. }
  6977. function print_braced(self, output, allow_directives) {
  6978. if (self.body.length > 0) {
  6979. output.with_block(function() {
  6980. display_body(self.body, false, output, allow_directives);
  6981. });
  6982. } else print_braced_empty(self, output);
  6983. }
  6984. DEFPRINT(AST_BlockStatement, function(self, output) {
  6985. print_braced(self, output);
  6986. });
  6987. DEFPRINT(AST_EmptyStatement, function(self, output) {
  6988. output.semicolon();
  6989. });
  6990. DEFPRINT(AST_Do, function(self, output) {
  6991. output.print("do");
  6992. output.space();
  6993. make_block(self.body, output);
  6994. output.space();
  6995. output.print("while");
  6996. output.space();
  6997. output.with_parens(function() {
  6998. self.condition.print(output);
  6999. });
  7000. output.semicolon();
  7001. });
  7002. DEFPRINT(AST_While, function(self, output) {
  7003. output.print("while");
  7004. output.space();
  7005. output.with_parens(function() {
  7006. self.condition.print(output);
  7007. });
  7008. output.space();
  7009. self._do_print_body(output);
  7010. });
  7011. DEFPRINT(AST_For, function(self, output) {
  7012. output.print("for");
  7013. output.space();
  7014. output.with_parens(function() {
  7015. if (self.init) {
  7016. if (self.init instanceof AST_Definitions) {
  7017. self.init.print(output);
  7018. } else {
  7019. parenthesize_for_noin(self.init, output, true);
  7020. }
  7021. output.print(";");
  7022. output.space();
  7023. } else {
  7024. output.print(";");
  7025. }
  7026. if (self.condition) {
  7027. self.condition.print(output);
  7028. output.print(";");
  7029. output.space();
  7030. } else {
  7031. output.print(";");
  7032. }
  7033. if (self.step) {
  7034. self.step.print(output);
  7035. }
  7036. });
  7037. output.space();
  7038. self._do_print_body(output);
  7039. });
  7040. DEFPRINT(AST_ForIn, function(self, output) {
  7041. output.print("for");
  7042. if (self.await) {
  7043. output.space();
  7044. output.print("await");
  7045. }
  7046. output.space();
  7047. output.with_parens(function() {
  7048. self.init.print(output);
  7049. output.space();
  7050. output.print(self instanceof AST_ForOf ? "of" : "in");
  7051. output.space();
  7052. self.object.print(output);
  7053. });
  7054. output.space();
  7055. self._do_print_body(output);
  7056. });
  7057. DEFPRINT(AST_With, function(self, output) {
  7058. output.print("with");
  7059. output.space();
  7060. output.with_parens(function() {
  7061. self.expression.print(output);
  7062. });
  7063. output.space();
  7064. self._do_print_body(output);
  7065. });
  7066. /* -----[ functions ]----- */
  7067. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  7068. var self = this;
  7069. if (!nokeyword) {
  7070. if (self.async) {
  7071. output.print("async");
  7072. output.space();
  7073. }
  7074. output.print("function");
  7075. if (self.is_generator) {
  7076. output.star();
  7077. }
  7078. if (self.name) {
  7079. output.space();
  7080. }
  7081. }
  7082. if (self.name instanceof AST_Symbol) {
  7083. self.name.print(output);
  7084. } else if (nokeyword && self.name instanceof AST_Node) {
  7085. output.with_square(function() {
  7086. self.name.print(output); // Computed method name
  7087. });
  7088. }
  7089. output.with_parens(function() {
  7090. self.argnames.forEach(function(arg, i) {
  7091. if (i) output.comma();
  7092. arg.print(output);
  7093. });
  7094. });
  7095. output.space();
  7096. print_braced(self, output, true);
  7097. });
  7098. DEFPRINT(AST_Lambda, function(self, output) {
  7099. self._do_print(output);
  7100. });
  7101. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  7102. var tag = self.prefix;
  7103. var parenthesize_tag = tag instanceof AST_Lambda
  7104. || tag instanceof AST_Binary
  7105. || tag instanceof AST_Conditional
  7106. || tag instanceof AST_Sequence
  7107. || tag instanceof AST_Unary
  7108. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  7109. if (parenthesize_tag) output.print("(");
  7110. self.prefix.print(output);
  7111. if (parenthesize_tag) output.print(")");
  7112. self.template_string.print(output);
  7113. });
  7114. DEFPRINT(AST_TemplateString, function(self, output) {
  7115. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  7116. output.print("`");
  7117. for (var i = 0; i < self.segments.length; i++) {
  7118. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  7119. output.print("${");
  7120. self.segments[i].print(output);
  7121. output.print("}");
  7122. } else if (is_tagged) {
  7123. output.print(self.segments[i].raw);
  7124. } else {
  7125. output.print_template_string_chars(self.segments[i].value);
  7126. }
  7127. }
  7128. output.print("`");
  7129. });
  7130. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  7131. var self = this;
  7132. var parent = output.parent();
  7133. var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
  7134. parent instanceof AST_Unary ||
  7135. (parent instanceof AST_Call && self === parent.expression);
  7136. if (needs_parens) { output.print("("); }
  7137. if (self.async) {
  7138. output.print("async");
  7139. output.space();
  7140. }
  7141. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  7142. self.argnames[0].print(output);
  7143. } else {
  7144. output.with_parens(function() {
  7145. self.argnames.forEach(function(arg, i) {
  7146. if (i) output.comma();
  7147. arg.print(output);
  7148. });
  7149. });
  7150. }
  7151. output.space();
  7152. output.print("=>");
  7153. output.space();
  7154. const first_statement = self.body[0];
  7155. if (
  7156. self.body.length === 1
  7157. && first_statement instanceof AST_Return
  7158. ) {
  7159. const returned = first_statement.value;
  7160. if (!returned) {
  7161. output.print("{}");
  7162. } else if (left_is_object(returned)) {
  7163. output.print("(");
  7164. returned.print(output);
  7165. output.print(")");
  7166. } else {
  7167. returned.print(output);
  7168. }
  7169. } else {
  7170. print_braced(self, output);
  7171. }
  7172. if (needs_parens) { output.print(")"); }
  7173. });
  7174. /* -----[ exits ]----- */
  7175. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  7176. output.print(kind);
  7177. if (this.value) {
  7178. output.space();
  7179. const comments = this.value.start.comments_before;
  7180. if (comments && comments.length && !output.printed_comments.has(comments)) {
  7181. output.print("(");
  7182. this.value.print(output);
  7183. output.print(")");
  7184. } else {
  7185. this.value.print(output);
  7186. }
  7187. }
  7188. output.semicolon();
  7189. });
  7190. DEFPRINT(AST_Return, function(self, output) {
  7191. self._do_print(output, "return");
  7192. });
  7193. DEFPRINT(AST_Throw, function(self, output) {
  7194. self._do_print(output, "throw");
  7195. });
  7196. /* -----[ yield ]----- */
  7197. DEFPRINT(AST_Yield, function(self, output) {
  7198. var star = self.is_star ? "*" : "";
  7199. output.print("yield" + star);
  7200. if (self.expression) {
  7201. output.space();
  7202. self.expression.print(output);
  7203. }
  7204. });
  7205. DEFPRINT(AST_Await, function(self, output) {
  7206. output.print("await");
  7207. output.space();
  7208. var e = self.expression;
  7209. var parens = !(
  7210. e instanceof AST_Call
  7211. || e instanceof AST_SymbolRef
  7212. || e instanceof AST_PropAccess
  7213. || e instanceof AST_Unary
  7214. || e instanceof AST_Constant
  7215. || e instanceof AST_Await
  7216. || e instanceof AST_Object
  7217. );
  7218. if (parens) output.print("(");
  7219. self.expression.print(output);
  7220. if (parens) output.print(")");
  7221. });
  7222. /* -----[ loop control ]----- */
  7223. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  7224. output.print(kind);
  7225. if (this.label) {
  7226. output.space();
  7227. this.label.print(output);
  7228. }
  7229. output.semicolon();
  7230. });
  7231. DEFPRINT(AST_Break, function(self, output) {
  7232. self._do_print(output, "break");
  7233. });
  7234. DEFPRINT(AST_Continue, function(self, output) {
  7235. self._do_print(output, "continue");
  7236. });
  7237. /* -----[ if ]----- */
  7238. function make_then(self, output) {
  7239. var b = self.body;
  7240. if (output.option("braces")
  7241. || output.option("ie8") && b instanceof AST_Do)
  7242. return make_block(b, output);
  7243. // The squeezer replaces "block"-s that contain only a single
  7244. // statement with the statement itself; technically, the AST
  7245. // is correct, but this can create problems when we output an
  7246. // IF having an ELSE clause where the THEN clause ends in an
  7247. // IF *without* an ELSE block (then the outer ELSE would refer
  7248. // to the inner IF). This function checks for this case and
  7249. // adds the block braces if needed.
  7250. if (!b) return output.force_semicolon();
  7251. while (true) {
  7252. if (b instanceof AST_If) {
  7253. if (!b.alternative) {
  7254. make_block(self.body, output);
  7255. return;
  7256. }
  7257. b = b.alternative;
  7258. } else if (b instanceof AST_StatementWithBody) {
  7259. b = b.body;
  7260. } else break;
  7261. }
  7262. force_statement(self.body, output);
  7263. }
  7264. DEFPRINT(AST_If, function(self, output) {
  7265. output.print("if");
  7266. output.space();
  7267. output.with_parens(function() {
  7268. self.condition.print(output);
  7269. });
  7270. output.space();
  7271. if (self.alternative) {
  7272. make_then(self, output);
  7273. output.space();
  7274. output.print("else");
  7275. output.space();
  7276. if (self.alternative instanceof AST_If)
  7277. self.alternative.print(output);
  7278. else
  7279. force_statement(self.alternative, output);
  7280. } else {
  7281. self._do_print_body(output);
  7282. }
  7283. });
  7284. /* -----[ switch ]----- */
  7285. DEFPRINT(AST_Switch, function(self, output) {
  7286. output.print("switch");
  7287. output.space();
  7288. output.with_parens(function() {
  7289. self.expression.print(output);
  7290. });
  7291. output.space();
  7292. var last = self.body.length - 1;
  7293. if (last < 0) print_braced_empty(self, output);
  7294. else output.with_block(function() {
  7295. self.body.forEach(function(branch, i) {
  7296. output.indent(true);
  7297. branch.print(output);
  7298. if (i < last && branch.body.length > 0)
  7299. output.newline();
  7300. });
  7301. });
  7302. });
  7303. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  7304. output.newline();
  7305. this.body.forEach(function(stmt) {
  7306. output.indent();
  7307. stmt.print(output);
  7308. output.newline();
  7309. });
  7310. });
  7311. DEFPRINT(AST_Default, function(self, output) {
  7312. output.print("default:");
  7313. self._do_print_body(output);
  7314. });
  7315. DEFPRINT(AST_Case, function(self, output) {
  7316. output.print("case");
  7317. output.space();
  7318. self.expression.print(output);
  7319. output.print(":");
  7320. self._do_print_body(output);
  7321. });
  7322. /* -----[ exceptions ]----- */
  7323. DEFPRINT(AST_Try, function(self, output) {
  7324. output.print("try");
  7325. output.space();
  7326. print_braced(self, output);
  7327. if (self.bcatch) {
  7328. output.space();
  7329. self.bcatch.print(output);
  7330. }
  7331. if (self.bfinally) {
  7332. output.space();
  7333. self.bfinally.print(output);
  7334. }
  7335. });
  7336. DEFPRINT(AST_Catch, function(self, output) {
  7337. output.print("catch");
  7338. if (self.argname) {
  7339. output.space();
  7340. output.with_parens(function() {
  7341. self.argname.print(output);
  7342. });
  7343. }
  7344. output.space();
  7345. print_braced(self, output);
  7346. });
  7347. DEFPRINT(AST_Finally, function(self, output) {
  7348. output.print("finally");
  7349. output.space();
  7350. print_braced(self, output);
  7351. });
  7352. /* -----[ var/const ]----- */
  7353. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  7354. output.print(kind);
  7355. output.space();
  7356. this.definitions.forEach(function(def, i) {
  7357. if (i) output.comma();
  7358. def.print(output);
  7359. });
  7360. var p = output.parent();
  7361. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  7362. var output_semicolon = !in_for || p && p.init !== this;
  7363. if (output_semicolon)
  7364. output.semicolon();
  7365. });
  7366. DEFPRINT(AST_Let, function(self, output) {
  7367. self._do_print(output, "let");
  7368. });
  7369. DEFPRINT(AST_Var, function(self, output) {
  7370. self._do_print(output, "var");
  7371. });
  7372. DEFPRINT(AST_Const, function(self, output) {
  7373. self._do_print(output, "const");
  7374. });
  7375. DEFPRINT(AST_Import, function(self, output) {
  7376. output.print("import");
  7377. output.space();
  7378. if (self.imported_name) {
  7379. self.imported_name.print(output);
  7380. }
  7381. if (self.imported_name && self.imported_names) {
  7382. output.print(",");
  7383. output.space();
  7384. }
  7385. if (self.imported_names) {
  7386. if (self.imported_names.length === 1 && self.imported_names[0].foreign_name.name === "*") {
  7387. self.imported_names[0].print(output);
  7388. } else {
  7389. output.print("{");
  7390. self.imported_names.forEach(function (name_import, i) {
  7391. output.space();
  7392. name_import.print(output);
  7393. if (i < self.imported_names.length - 1) {
  7394. output.print(",");
  7395. }
  7396. });
  7397. output.space();
  7398. output.print("}");
  7399. }
  7400. }
  7401. if (self.imported_name || self.imported_names) {
  7402. output.space();
  7403. output.print("from");
  7404. output.space();
  7405. }
  7406. self.module_name.print(output);
  7407. output.semicolon();
  7408. });
  7409. DEFPRINT(AST_ImportMeta, function(self, output) {
  7410. output.print("import.meta");
  7411. });
  7412. DEFPRINT(AST_NameMapping, function(self, output) {
  7413. var is_import = output.parent() instanceof AST_Import;
  7414. var definition = self.name.definition();
  7415. var names_are_different =
  7416. (definition && definition.mangled_name || self.name.name) !==
  7417. self.foreign_name.name;
  7418. if (names_are_different) {
  7419. if (is_import) {
  7420. output.print(self.foreign_name.name);
  7421. } else {
  7422. self.name.print(output);
  7423. }
  7424. output.space();
  7425. output.print("as");
  7426. output.space();
  7427. if (is_import) {
  7428. self.name.print(output);
  7429. } else {
  7430. output.print(self.foreign_name.name);
  7431. }
  7432. } else {
  7433. self.name.print(output);
  7434. }
  7435. });
  7436. DEFPRINT(AST_Export, function(self, output) {
  7437. output.print("export");
  7438. output.space();
  7439. if (self.is_default) {
  7440. output.print("default");
  7441. output.space();
  7442. }
  7443. if (self.exported_names) {
  7444. if (self.exported_names.length === 1 && self.exported_names[0].name.name === "*") {
  7445. self.exported_names[0].print(output);
  7446. } else {
  7447. output.print("{");
  7448. self.exported_names.forEach(function(name_export, i) {
  7449. output.space();
  7450. name_export.print(output);
  7451. if (i < self.exported_names.length - 1) {
  7452. output.print(",");
  7453. }
  7454. });
  7455. output.space();
  7456. output.print("}");
  7457. }
  7458. } else if (self.exported_value) {
  7459. self.exported_value.print(output);
  7460. } else if (self.exported_definition) {
  7461. self.exported_definition.print(output);
  7462. if (self.exported_definition instanceof AST_Definitions) return;
  7463. }
  7464. if (self.module_name) {
  7465. output.space();
  7466. output.print("from");
  7467. output.space();
  7468. self.module_name.print(output);
  7469. }
  7470. if (self.exported_value
  7471. && !(self.exported_value instanceof AST_Defun ||
  7472. self.exported_value instanceof AST_Function ||
  7473. self.exported_value instanceof AST_Class)
  7474. || self.module_name
  7475. || self.exported_names
  7476. ) {
  7477. output.semicolon();
  7478. }
  7479. });
  7480. function parenthesize_for_noin(node, output, noin) {
  7481. var parens = false;
  7482. // need to take some precautions here:
  7483. // https://github.com/mishoo/UglifyJS2/issues/60
  7484. if (noin) {
  7485. parens = walk(node, node => {
  7486. if (node instanceof AST_Scope) return true;
  7487. if (node instanceof AST_Binary && node.operator == "in") {
  7488. return walk_abort; // makes walk() return true
  7489. }
  7490. });
  7491. }
  7492. node.print(output, parens);
  7493. }
  7494. DEFPRINT(AST_VarDef, function(self, output) {
  7495. self.name.print(output);
  7496. if (self.value) {
  7497. output.space();
  7498. output.print("=");
  7499. output.space();
  7500. var p = output.parent(1);
  7501. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  7502. parenthesize_for_noin(self.value, output, noin);
  7503. }
  7504. });
  7505. /* -----[ other expressions ]----- */
  7506. DEFPRINT(AST_Call, function(self, output) {
  7507. self.expression.print(output);
  7508. if (self instanceof AST_New && self.args.length === 0)
  7509. return;
  7510. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  7511. output.add_mapping(self.start);
  7512. }
  7513. if (self.optional) output.print("?.");
  7514. output.with_parens(function() {
  7515. self.args.forEach(function(expr, i) {
  7516. if (i) output.comma();
  7517. expr.print(output);
  7518. });
  7519. });
  7520. });
  7521. DEFPRINT(AST_New, function(self, output) {
  7522. output.print("new");
  7523. output.space();
  7524. AST_Call.prototype._codegen(self, output);
  7525. });
  7526. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  7527. this.expressions.forEach(function(node, index) {
  7528. if (index > 0) {
  7529. output.comma();
  7530. if (output.should_break()) {
  7531. output.newline();
  7532. output.indent();
  7533. }
  7534. }
  7535. node.print(output);
  7536. });
  7537. });
  7538. DEFPRINT(AST_Sequence, function(self, output) {
  7539. self._do_print(output);
  7540. // var p = output.parent();
  7541. // if (p instanceof AST_Statement) {
  7542. // output.with_indent(output.next_indent(), function(){
  7543. // self._do_print(output);
  7544. // });
  7545. // } else {
  7546. // self._do_print(output);
  7547. // }
  7548. });
  7549. DEFPRINT(AST_Dot, function(self, output) {
  7550. var expr = self.expression;
  7551. expr.print(output);
  7552. var prop = self.property;
  7553. var print_computed = RESERVED_WORDS.has(prop)
  7554. ? output.option("ie8")
  7555. : !is_identifier_string(prop, output.option("ecma") >= 2015);
  7556. if (self.optional) output.print("?.");
  7557. if (print_computed) {
  7558. output.print("[");
  7559. output.add_mapping(self.end);
  7560. output.print_string(prop);
  7561. output.print("]");
  7562. } else {
  7563. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  7564. if (!/[xa-f.)]/i.test(output.last())) {
  7565. output.print(".");
  7566. }
  7567. }
  7568. if (!self.optional) output.print(".");
  7569. // the name after dot would be mapped about here.
  7570. output.add_mapping(self.end);
  7571. output.print_name(prop);
  7572. }
  7573. });
  7574. DEFPRINT(AST_Sub, function(self, output) {
  7575. self.expression.print(output);
  7576. if (self.optional) output.print("?.");
  7577. output.print("[");
  7578. self.property.print(output);
  7579. output.print("]");
  7580. });
  7581. DEFPRINT(AST_Chain, function(self, output) {
  7582. self.expression.print(output);
  7583. });
  7584. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  7585. var op = self.operator;
  7586. output.print(op);
  7587. if (/^[a-z]/i.test(op)
  7588. || (/[+-]$/.test(op)
  7589. && self.expression instanceof AST_UnaryPrefix
  7590. && /^[+-]/.test(self.expression.operator))) {
  7591. output.space();
  7592. }
  7593. self.expression.print(output);
  7594. });
  7595. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  7596. self.expression.print(output);
  7597. output.print(self.operator);
  7598. });
  7599. DEFPRINT(AST_Binary, function(self, output) {
  7600. var op = self.operator;
  7601. self.left.print(output);
  7602. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  7603. && self.left instanceof AST_UnaryPostfix
  7604. && self.left.operator == "--") {
  7605. // space is mandatory to avoid outputting -->
  7606. output.print(" ");
  7607. } else {
  7608. // the space is optional depending on "beautify"
  7609. output.space();
  7610. }
  7611. output.print(op);
  7612. if ((op == "<" || op == "<<")
  7613. && self.right instanceof AST_UnaryPrefix
  7614. && self.right.operator == "!"
  7615. && self.right.expression instanceof AST_UnaryPrefix
  7616. && self.right.expression.operator == "--") {
  7617. // space is mandatory to avoid outputting <!--
  7618. output.print(" ");
  7619. } else {
  7620. // the space is optional depending on "beautify"
  7621. output.space();
  7622. }
  7623. self.right.print(output);
  7624. });
  7625. DEFPRINT(AST_Conditional, function(self, output) {
  7626. self.condition.print(output);
  7627. output.space();
  7628. output.print("?");
  7629. output.space();
  7630. self.consequent.print(output);
  7631. output.space();
  7632. output.colon();
  7633. self.alternative.print(output);
  7634. });
  7635. /* -----[ literals ]----- */
  7636. DEFPRINT(AST_Array, function(self, output) {
  7637. output.with_square(function() {
  7638. var a = self.elements, len = a.length;
  7639. if (len > 0) output.space();
  7640. a.forEach(function(exp, i) {
  7641. if (i) output.comma();
  7642. exp.print(output);
  7643. // If the final element is a hole, we need to make sure it
  7644. // doesn't look like a trailing comma, by inserting an actual
  7645. // trailing comma.
  7646. if (i === len - 1 && exp instanceof AST_Hole)
  7647. output.comma();
  7648. });
  7649. if (len > 0) output.space();
  7650. });
  7651. });
  7652. DEFPRINT(AST_Object, function(self, output) {
  7653. if (self.properties.length > 0) output.with_block(function() {
  7654. self.properties.forEach(function(prop, i) {
  7655. if (i) {
  7656. output.print(",");
  7657. output.newline();
  7658. }
  7659. output.indent();
  7660. prop.print(output);
  7661. });
  7662. output.newline();
  7663. });
  7664. else print_braced_empty(self, output);
  7665. });
  7666. DEFPRINT(AST_Class, function(self, output) {
  7667. output.print("class");
  7668. output.space();
  7669. if (self.name) {
  7670. self.name.print(output);
  7671. output.space();
  7672. }
  7673. if (self.extends) {
  7674. var parens = (
  7675. !(self.extends instanceof AST_SymbolRef)
  7676. && !(self.extends instanceof AST_PropAccess)
  7677. && !(self.extends instanceof AST_ClassExpression)
  7678. && !(self.extends instanceof AST_Function)
  7679. );
  7680. output.print("extends");
  7681. if (parens) {
  7682. output.print("(");
  7683. } else {
  7684. output.space();
  7685. }
  7686. self.extends.print(output);
  7687. if (parens) {
  7688. output.print(")");
  7689. } else {
  7690. output.space();
  7691. }
  7692. }
  7693. if (self.properties.length > 0) output.with_block(function() {
  7694. self.properties.forEach(function(prop, i) {
  7695. if (i) {
  7696. output.newline();
  7697. }
  7698. output.indent();
  7699. prop.print(output);
  7700. });
  7701. output.newline();
  7702. });
  7703. else output.print("{}");
  7704. });
  7705. DEFPRINT(AST_NewTarget, function(self, output) {
  7706. output.print("new.target");
  7707. });
  7708. function print_property_name(key, quote, output) {
  7709. if (output.option("quote_keys")) {
  7710. return output.print_string(key);
  7711. }
  7712. if ("" + +key == key && key >= 0) {
  7713. if (output.option("keep_numbers")) {
  7714. return output.print(key);
  7715. }
  7716. return output.print(make_num(key));
  7717. }
  7718. var print_string = RESERVED_WORDS.has(key)
  7719. ? output.option("ie8")
  7720. : (
  7721. output.option("ecma") < 2015
  7722. ? !is_basic_identifier_string(key)
  7723. : !is_identifier_string(key, true)
  7724. );
  7725. if (print_string || (quote && output.option("keep_quoted_props"))) {
  7726. return output.print_string(key, quote);
  7727. }
  7728. return output.print_name(key);
  7729. }
  7730. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  7731. function get_name(self) {
  7732. var def = self.definition();
  7733. return def ? def.mangled_name || def.name : self.name;
  7734. }
  7735. var allowShortHand = output.option("shorthand");
  7736. if (allowShortHand &&
  7737. self.value instanceof AST_Symbol &&
  7738. is_identifier_string(self.key, output.option("ecma") >= 2015) &&
  7739. get_name(self.value) === self.key &&
  7740. !RESERVED_WORDS.has(self.key)
  7741. ) {
  7742. print_property_name(self.key, self.quote, output);
  7743. } else if (allowShortHand &&
  7744. self.value instanceof AST_DefaultAssign &&
  7745. self.value.left instanceof AST_Symbol &&
  7746. is_identifier_string(self.key, output.option("ecma") >= 2015) &&
  7747. get_name(self.value.left) === self.key
  7748. ) {
  7749. print_property_name(self.key, self.quote, output);
  7750. output.space();
  7751. output.print("=");
  7752. output.space();
  7753. self.value.right.print(output);
  7754. } else {
  7755. if (!(self.key instanceof AST_Node)) {
  7756. print_property_name(self.key, self.quote, output);
  7757. } else {
  7758. output.with_square(function() {
  7759. self.key.print(output);
  7760. });
  7761. }
  7762. output.colon();
  7763. self.value.print(output);
  7764. }
  7765. });
  7766. DEFPRINT(AST_ClassProperty, (self, output) => {
  7767. if (self.static) {
  7768. output.print("static");
  7769. output.space();
  7770. }
  7771. if (self.key instanceof AST_SymbolClassProperty) {
  7772. print_property_name(self.key.name, self.quote, output);
  7773. } else {
  7774. output.print("[");
  7775. self.key.print(output);
  7776. output.print("]");
  7777. }
  7778. if (self.value) {
  7779. output.print("=");
  7780. self.value.print(output);
  7781. }
  7782. output.semicolon();
  7783. });
  7784. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, output) {
  7785. var self = this;
  7786. if (self.static) {
  7787. output.print("static");
  7788. output.space();
  7789. }
  7790. if (type) {
  7791. output.print(type);
  7792. output.space();
  7793. }
  7794. if (self.key instanceof AST_SymbolMethod) {
  7795. print_property_name(self.key.name, self.quote, output);
  7796. } else {
  7797. output.with_square(function() {
  7798. self.key.print(output);
  7799. });
  7800. }
  7801. self.value._do_print(output, true);
  7802. });
  7803. DEFPRINT(AST_ObjectSetter, function(self, output) {
  7804. self._print_getter_setter("set", output);
  7805. });
  7806. DEFPRINT(AST_ObjectGetter, function(self, output) {
  7807. self._print_getter_setter("get", output);
  7808. });
  7809. DEFPRINT(AST_ConciseMethod, function(self, output) {
  7810. var type;
  7811. if (self.is_generator && self.async) {
  7812. type = "async*";
  7813. } else if (self.is_generator) {
  7814. type = "*";
  7815. } else if (self.async) {
  7816. type = "async";
  7817. }
  7818. self._print_getter_setter(type, output);
  7819. });
  7820. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  7821. var def = this.definition();
  7822. output.print_name(def ? def.mangled_name || def.name : this.name);
  7823. });
  7824. DEFPRINT(AST_Symbol, function (self, output) {
  7825. self._do_print(output);
  7826. });
  7827. DEFPRINT(AST_Hole, noop);
  7828. DEFPRINT(AST_This, function(self, output) {
  7829. output.print("this");
  7830. });
  7831. DEFPRINT(AST_Super, function(self, output) {
  7832. output.print("super");
  7833. });
  7834. DEFPRINT(AST_Constant, function(self, output) {
  7835. output.print(self.getValue());
  7836. });
  7837. DEFPRINT(AST_String, function(self, output) {
  7838. output.print_string(self.getValue(), self.quote, output.in_directive);
  7839. });
  7840. DEFPRINT(AST_Number, function(self, output) {
  7841. if ((output.option("keep_numbers") || output.use_asm) && self.start && self.start.raw != null) {
  7842. output.print(self.start.raw);
  7843. } else {
  7844. output.print(make_num(self.getValue()));
  7845. }
  7846. });
  7847. DEFPRINT(AST_BigInt, function(self, output) {
  7848. output.print(self.getValue() + "n");
  7849. });
  7850. const r_slash_script = /(<\s*\/\s*script)/i;
  7851. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  7852. DEFPRINT(AST_RegExp, function(self, output) {
  7853. let { source, flags } = self.getValue();
  7854. source = regexp_source_fix(source);
  7855. flags = flags ? sort_regexp_flags(flags) : "";
  7856. source = source.replace(r_slash_script, slash_script_replace);
  7857. output.print(output.to_utf8(`/${source}/${flags}`));
  7858. const parent = output.parent();
  7859. if (
  7860. parent instanceof AST_Binary
  7861. && /^\w/.test(parent.operator)
  7862. && parent.left === self
  7863. ) {
  7864. output.print(" ");
  7865. }
  7866. });
  7867. function force_statement(stat, output) {
  7868. if (output.option("braces")) {
  7869. make_block(stat, output);
  7870. } else {
  7871. if (!stat || stat instanceof AST_EmptyStatement)
  7872. output.force_semicolon();
  7873. else
  7874. stat.print(output);
  7875. }
  7876. }
  7877. function best_of(a) {
  7878. var best = a[0], len = best.length;
  7879. for (var i = 1; i < a.length; ++i) {
  7880. if (a[i].length < len) {
  7881. best = a[i];
  7882. len = best.length;
  7883. }
  7884. }
  7885. return best;
  7886. }
  7887. function make_num(num) {
  7888. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  7889. var candidates = [ str ];
  7890. if (Math.floor(num) === num) {
  7891. if (num < 0) {
  7892. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  7893. } else {
  7894. candidates.push("0x" + num.toString(16).toLowerCase());
  7895. }
  7896. }
  7897. var match, len, digits;
  7898. if (match = /^\.0+/.exec(str)) {
  7899. len = match[0].length;
  7900. digits = str.slice(len);
  7901. candidates.push(digits + "e-" + (digits.length + len - 1));
  7902. } else if (match = /0+$/.exec(str)) {
  7903. len = match[0].length;
  7904. candidates.push(str.slice(0, -len) + "e" + len);
  7905. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  7906. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  7907. }
  7908. return best_of(candidates);
  7909. }
  7910. function make_block(stmt, output) {
  7911. if (!stmt || stmt instanceof AST_EmptyStatement)
  7912. output.print("{}");
  7913. else if (stmt instanceof AST_BlockStatement)
  7914. stmt.print(output);
  7915. else output.with_block(function() {
  7916. output.indent();
  7917. stmt.print(output);
  7918. output.newline();
  7919. });
  7920. }
  7921. /* -----[ source map generators ]----- */
  7922. function DEFMAP(nodetype, generator) {
  7923. nodetype.forEach(function(nodetype) {
  7924. nodetype.DEFMETHOD("add_source_map", generator);
  7925. });
  7926. }
  7927. DEFMAP([
  7928. // We could easily add info for ALL nodes, but it seems to me that
  7929. // would be quite wasteful, hence this noop in the base class.
  7930. AST_Node,
  7931. // since the label symbol will mark it
  7932. AST_LabeledStatement,
  7933. AST_Toplevel,
  7934. ], noop);
  7935. // XXX: I'm not exactly sure if we need it for all of these nodes,
  7936. // or if we should add even more.
  7937. DEFMAP([
  7938. AST_Array,
  7939. AST_BlockStatement,
  7940. AST_Catch,
  7941. AST_Class,
  7942. AST_Constant,
  7943. AST_Debugger,
  7944. AST_Definitions,
  7945. AST_Directive,
  7946. AST_Finally,
  7947. AST_Jump,
  7948. AST_Lambda,
  7949. AST_New,
  7950. AST_Object,
  7951. AST_StatementWithBody,
  7952. AST_Symbol,
  7953. AST_Switch,
  7954. AST_SwitchBranch,
  7955. AST_TemplateString,
  7956. AST_TemplateSegment,
  7957. AST_Try,
  7958. ], function(output) {
  7959. output.add_mapping(this.start);
  7960. });
  7961. DEFMAP([
  7962. AST_ObjectGetter,
  7963. AST_ObjectSetter,
  7964. ], function(output) {
  7965. output.add_mapping(this.start, this.key.name);
  7966. });
  7967. DEFMAP([ AST_ObjectProperty ], function(output) {
  7968. output.add_mapping(this.start, this.key);
  7969. });
  7970. })();
  7971. const shallow_cmp = (node1, node2) => {
  7972. return (
  7973. node1 === null && node2 === null
  7974. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  7975. );
  7976. };
  7977. const equivalent_to = (tree1, tree2) => {
  7978. if (!shallow_cmp(tree1, tree2)) return false;
  7979. const walk_1_state = [tree1];
  7980. const walk_2_state = [tree2];
  7981. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  7982. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  7983. while (walk_1_state.length && walk_2_state.length) {
  7984. const node_1 = walk_1_state.pop();
  7985. const node_2 = walk_2_state.pop();
  7986. if (!shallow_cmp(node_1, node_2)) return false;
  7987. node_1._children_backwards(walk_1_push);
  7988. node_2._children_backwards(walk_2_push);
  7989. if (walk_1_state.length !== walk_2_state.length) {
  7990. // Different number of children
  7991. return false;
  7992. }
  7993. }
  7994. return walk_1_state.length == 0 && walk_2_state.length == 0;
  7995. };
  7996. // Creates a shallow compare function
  7997. const mkshallow = (props) => {
  7998. const comparisons = Object
  7999. .keys(props)
  8000. .map(key => {
  8001. if (props[key] === "eq") {
  8002. return `this.${key} === other.${key}`;
  8003. } else if (props[key] === "exist") {
  8004. return `(this.${key} == null ? other.${key} == null : this.${key} === other.${key})`;
  8005. } else {
  8006. throw new Error(`mkshallow: Unexpected instruction: ${props[key]}`);
  8007. }
  8008. })
  8009. .join(" && ");
  8010. return new Function("other", "return " + comparisons);
  8011. };
  8012. const pass_through = () => true;
  8013. AST_Node.prototype.shallow_cmp = function () {
  8014. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  8015. };
  8016. AST_Debugger.prototype.shallow_cmp = pass_through;
  8017. AST_Directive.prototype.shallow_cmp = mkshallow({ value: "eq" });
  8018. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  8019. AST_Block.prototype.shallow_cmp = pass_through;
  8020. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  8021. AST_LabeledStatement.prototype.shallow_cmp = mkshallow({ "label.name": "eq" });
  8022. AST_Do.prototype.shallow_cmp = pass_through;
  8023. AST_While.prototype.shallow_cmp = pass_through;
  8024. AST_For.prototype.shallow_cmp = mkshallow({
  8025. init: "exist",
  8026. condition: "exist",
  8027. step: "exist"
  8028. });
  8029. AST_ForIn.prototype.shallow_cmp = pass_through;
  8030. AST_ForOf.prototype.shallow_cmp = pass_through;
  8031. AST_With.prototype.shallow_cmp = pass_through;
  8032. AST_Toplevel.prototype.shallow_cmp = pass_through;
  8033. AST_Expansion.prototype.shallow_cmp = pass_through;
  8034. AST_Lambda.prototype.shallow_cmp = mkshallow({
  8035. is_generator: "eq",
  8036. async: "eq"
  8037. });
  8038. AST_Destructuring.prototype.shallow_cmp = mkshallow({
  8039. is_array: "eq"
  8040. });
  8041. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  8042. AST_TemplateString.prototype.shallow_cmp = pass_through;
  8043. AST_TemplateSegment.prototype.shallow_cmp = mkshallow({
  8044. "value": "eq"
  8045. });
  8046. AST_Jump.prototype.shallow_cmp = pass_through;
  8047. AST_LoopControl.prototype.shallow_cmp = pass_through;
  8048. AST_Await.prototype.shallow_cmp = pass_through;
  8049. AST_Yield.prototype.shallow_cmp = mkshallow({
  8050. is_star: "eq"
  8051. });
  8052. AST_If.prototype.shallow_cmp = mkshallow({
  8053. alternative: "exist"
  8054. });
  8055. AST_Switch.prototype.shallow_cmp = pass_through;
  8056. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  8057. AST_Try.prototype.shallow_cmp = mkshallow({
  8058. bcatch: "exist",
  8059. bfinally: "exist"
  8060. });
  8061. AST_Catch.prototype.shallow_cmp = mkshallow({
  8062. argname: "exist"
  8063. });
  8064. AST_Finally.prototype.shallow_cmp = pass_through;
  8065. AST_Definitions.prototype.shallow_cmp = pass_through;
  8066. AST_VarDef.prototype.shallow_cmp = mkshallow({
  8067. value: "exist"
  8068. });
  8069. AST_NameMapping.prototype.shallow_cmp = pass_through;
  8070. AST_Import.prototype.shallow_cmp = mkshallow({
  8071. imported_name: "exist",
  8072. imported_names: "exist"
  8073. });
  8074. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  8075. AST_Export.prototype.shallow_cmp = mkshallow({
  8076. exported_definition: "exist",
  8077. exported_value: "exist",
  8078. exported_names: "exist",
  8079. module_name: "eq",
  8080. is_default: "eq",
  8081. });
  8082. AST_Call.prototype.shallow_cmp = pass_through;
  8083. AST_Sequence.prototype.shallow_cmp = pass_through;
  8084. AST_PropAccess.prototype.shallow_cmp = pass_through;
  8085. AST_Chain.prototype.shallow_cmp = pass_through;
  8086. AST_Dot.prototype.shallow_cmp = mkshallow({
  8087. property: "eq"
  8088. });
  8089. AST_Unary.prototype.shallow_cmp = mkshallow({
  8090. operator: "eq"
  8091. });
  8092. AST_Binary.prototype.shallow_cmp = mkshallow({
  8093. operator: "eq"
  8094. });
  8095. AST_Conditional.prototype.shallow_cmp = pass_through;
  8096. AST_Array.prototype.shallow_cmp = pass_through;
  8097. AST_Object.prototype.shallow_cmp = pass_through;
  8098. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  8099. AST_ObjectKeyVal.prototype.shallow_cmp = mkshallow({
  8100. key: "eq"
  8101. });
  8102. AST_ObjectSetter.prototype.shallow_cmp = mkshallow({
  8103. static: "eq"
  8104. });
  8105. AST_ObjectGetter.prototype.shallow_cmp = mkshallow({
  8106. static: "eq"
  8107. });
  8108. AST_ConciseMethod.prototype.shallow_cmp = mkshallow({
  8109. static: "eq",
  8110. is_generator: "eq",
  8111. async: "eq",
  8112. });
  8113. AST_Class.prototype.shallow_cmp = mkshallow({
  8114. name: "exist",
  8115. extends: "exist",
  8116. });
  8117. AST_ClassProperty.prototype.shallow_cmp = mkshallow({
  8118. static: "eq"
  8119. });
  8120. AST_Symbol.prototype.shallow_cmp = mkshallow({
  8121. name: "eq"
  8122. });
  8123. AST_NewTarget.prototype.shallow_cmp = pass_through;
  8124. AST_This.prototype.shallow_cmp = pass_through;
  8125. AST_Super.prototype.shallow_cmp = pass_through;
  8126. AST_String.prototype.shallow_cmp = mkshallow({
  8127. value: "eq"
  8128. });
  8129. AST_Number.prototype.shallow_cmp = mkshallow({
  8130. value: "eq"
  8131. });
  8132. AST_BigInt.prototype.shallow_cmp = mkshallow({
  8133. value: "eq"
  8134. });
  8135. AST_RegExp.prototype.shallow_cmp = function (other) {
  8136. return (
  8137. this.value.flags === other.value.flags
  8138. && this.value.source === other.value.source
  8139. );
  8140. };
  8141. AST_Atom.prototype.shallow_cmp = pass_through;
  8142. /***********************************************************************
  8143. A JavaScript tokenizer / parser / beautifier / compressor.
  8144. https://github.com/mishoo/UglifyJS2
  8145. -------------------------------- (C) ---------------------------------
  8146. Author: Mihai Bazon
  8147. <mihai.bazon@gmail.com>
  8148. http://mihai.bazon.net/blog
  8149. Distributed under the BSD license:
  8150. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8151. Redistribution and use in source and binary forms, with or without
  8152. modification, are permitted provided that the following conditions
  8153. are met:
  8154. * Redistributions of source code must retain the above
  8155. copyright notice, this list of conditions and the following
  8156. disclaimer.
  8157. * Redistributions in binary form must reproduce the above
  8158. copyright notice, this list of conditions and the following
  8159. disclaimer in the documentation and/or other materials
  8160. provided with the distribution.
  8161. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8162. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8163. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8164. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8165. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8166. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8167. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8168. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8169. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8170. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8171. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8172. SUCH DAMAGE.
  8173. ***********************************************************************/
  8174. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  8175. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  8176. let function_defs = null;
  8177. let unmangleable_names = null;
  8178. class SymbolDef {
  8179. constructor(scope, orig, init) {
  8180. this.name = orig.name;
  8181. this.orig = [ orig ];
  8182. this.init = init;
  8183. this.eliminated = 0;
  8184. this.assignments = 0;
  8185. this.scope = scope;
  8186. this.replaced = 0;
  8187. this.global = false;
  8188. this.export = 0;
  8189. this.mangled_name = null;
  8190. this.undeclared = false;
  8191. this.id = SymbolDef.next_id++;
  8192. this.chained = false;
  8193. this.direct_access = false;
  8194. this.escaped = 0;
  8195. this.recursive_refs = 0;
  8196. this.references = [];
  8197. this.should_replace = undefined;
  8198. this.single_use = false;
  8199. this.fixed = false;
  8200. Object.seal(this);
  8201. }
  8202. fixed_value() {
  8203. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  8204. return this.fixed();
  8205. }
  8206. unmangleable(options) {
  8207. if (!options) options = {};
  8208. if (
  8209. function_defs &&
  8210. function_defs.has(this.id) &&
  8211. keep_name(options.keep_fnames, this.orig[0].name)
  8212. ) return true;
  8213. return this.global && !options.toplevel
  8214. || (this.export & MASK_EXPORT_DONT_MANGLE)
  8215. || this.undeclared
  8216. || !options.eval && this.scope.pinned()
  8217. || (this.orig[0] instanceof AST_SymbolLambda
  8218. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  8219. || this.orig[0] instanceof AST_SymbolMethod
  8220. || (this.orig[0] instanceof AST_SymbolClass
  8221. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  8222. }
  8223. mangle(options) {
  8224. const cache = options.cache && options.cache.props;
  8225. if (this.global && cache && cache.has(this.name)) {
  8226. this.mangled_name = cache.get(this.name);
  8227. } else if (!this.mangled_name && !this.unmangleable(options)) {
  8228. var s = this.scope;
  8229. var sym = this.orig[0];
  8230. if (options.ie8 && sym instanceof AST_SymbolLambda)
  8231. s = s.parent_scope;
  8232. const redefinition = redefined_catch_def(this);
  8233. this.mangled_name = redefinition
  8234. ? redefinition.mangled_name || redefinition.name
  8235. : s.next_mangled(options, this);
  8236. if (this.global && cache) {
  8237. cache.set(this.name, this.mangled_name);
  8238. }
  8239. }
  8240. }
  8241. }
  8242. SymbolDef.next_id = 1;
  8243. function redefined_catch_def(def) {
  8244. if (def.orig[0] instanceof AST_SymbolCatch
  8245. && def.scope.is_block_scope()
  8246. ) {
  8247. return def.scope.get_defun_scope().variables.get(def.name);
  8248. }
  8249. }
  8250. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  8251. options = defaults(options, {
  8252. cache: null,
  8253. ie8: false,
  8254. safari10: false,
  8255. });
  8256. if (!(toplevel instanceof AST_Toplevel)) {
  8257. throw new Error("Invalid toplevel scope");
  8258. }
  8259. // pass 1: setup scope chaining and handle definitions
  8260. var scope = this.parent_scope = parent_scope;
  8261. var labels = new Map();
  8262. var defun = null;
  8263. var in_destructuring = null;
  8264. var for_scopes = [];
  8265. var tw = new TreeWalker((node, descend) => {
  8266. if (node.is_block_scope()) {
  8267. const save_scope = scope;
  8268. node.block_scope = scope = new AST_Scope(node);
  8269. scope._block_scope = true;
  8270. // AST_Try in the AST sadly *is* (not has) a body itself,
  8271. // and its catch and finally branches are children of the AST_Try itself
  8272. const parent_scope = node instanceof AST_Catch
  8273. ? save_scope.parent_scope
  8274. : save_scope;
  8275. scope.init_scope_vars(parent_scope);
  8276. scope.uses_with = save_scope.uses_with;
  8277. scope.uses_eval = save_scope.uses_eval;
  8278. if (options.safari10) {
  8279. if (node instanceof AST_For || node instanceof AST_ForIn) {
  8280. for_scopes.push(scope);
  8281. }
  8282. }
  8283. if (node instanceof AST_Switch) {
  8284. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  8285. // AST_Switch has a scope within the body, but it itself "is a block scope"
  8286. // This means the switched expression has to belong to the outer scope
  8287. // while the body inside belongs to the switch itself.
  8288. // This is pretty nasty and warrants an AST change similar to AST_Try (read above)
  8289. const the_block_scope = scope;
  8290. scope = save_scope;
  8291. node.expression.walk(tw);
  8292. scope = the_block_scope;
  8293. for (let i = 0; i < node.body.length; i++) {
  8294. node.body[i].walk(tw);
  8295. }
  8296. } else {
  8297. descend();
  8298. }
  8299. scope = save_scope;
  8300. return true;
  8301. }
  8302. if (node instanceof AST_Destructuring) {
  8303. const save_destructuring = in_destructuring;
  8304. in_destructuring = node;
  8305. descend();
  8306. in_destructuring = save_destructuring;
  8307. return true;
  8308. }
  8309. if (node instanceof AST_Scope) {
  8310. node.init_scope_vars(scope);
  8311. var save_scope = scope;
  8312. var save_defun = defun;
  8313. var save_labels = labels;
  8314. defun = scope = node;
  8315. labels = new Map();
  8316. descend();
  8317. scope = save_scope;
  8318. defun = save_defun;
  8319. labels = save_labels;
  8320. return true; // don't descend again in TreeWalker
  8321. }
  8322. if (node instanceof AST_LabeledStatement) {
  8323. var l = node.label;
  8324. if (labels.has(l.name)) {
  8325. throw new Error(string_template("Label {name} defined twice", l));
  8326. }
  8327. labels.set(l.name, l);
  8328. descend();
  8329. labels.delete(l.name);
  8330. return true; // no descend again
  8331. }
  8332. if (node instanceof AST_With) {
  8333. for (var s = scope; s; s = s.parent_scope)
  8334. s.uses_with = true;
  8335. return;
  8336. }
  8337. if (node instanceof AST_Symbol) {
  8338. node.scope = scope;
  8339. }
  8340. if (node instanceof AST_Label) {
  8341. node.thedef = node;
  8342. node.references = [];
  8343. }
  8344. if (node instanceof AST_SymbolLambda) {
  8345. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  8346. } else if (node instanceof AST_SymbolDefun) {
  8347. // Careful here, the scope where this should be defined is
  8348. // the parent scope. The reason is that we enter a new
  8349. // scope when we encounter the AST_Defun node (which is
  8350. // instanceof AST_Scope) but we get to the symbol a bit
  8351. // later.
  8352. mark_export((node.scope = defun.parent_scope.get_defun_scope()).def_function(node, defun), 1);
  8353. } else if (node instanceof AST_SymbolClass) {
  8354. mark_export(defun.def_variable(node, defun), 1);
  8355. } else if (node instanceof AST_SymbolImport) {
  8356. scope.def_variable(node);
  8357. } else if (node instanceof AST_SymbolDefClass) {
  8358. // This deals with the name of the class being available
  8359. // inside the class.
  8360. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  8361. } else if (
  8362. node instanceof AST_SymbolVar
  8363. || node instanceof AST_SymbolLet
  8364. || node instanceof AST_SymbolConst
  8365. || node instanceof AST_SymbolCatch
  8366. ) {
  8367. var def;
  8368. if (node instanceof AST_SymbolBlockDeclaration) {
  8369. def = scope.def_variable(node, null);
  8370. } else {
  8371. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  8372. }
  8373. if (!def.orig.every((sym) => {
  8374. if (sym === node) return true;
  8375. if (node instanceof AST_SymbolBlockDeclaration) {
  8376. return sym instanceof AST_SymbolLambda;
  8377. }
  8378. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  8379. })) {
  8380. js_error(
  8381. `"${node.name}" is redeclared`,
  8382. node.start.file,
  8383. node.start.line,
  8384. node.start.col,
  8385. node.start.pos
  8386. );
  8387. }
  8388. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  8389. if (defun !== scope) {
  8390. node.mark_enclosed();
  8391. var def = scope.find_variable(node);
  8392. if (node.thedef !== def) {
  8393. node.thedef = def;
  8394. node.reference();
  8395. }
  8396. }
  8397. } else if (node instanceof AST_LabelRef) {
  8398. var sym = labels.get(node.name);
  8399. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  8400. name: node.name,
  8401. line: node.start.line,
  8402. col: node.start.col
  8403. }));
  8404. node.thedef = sym;
  8405. }
  8406. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  8407. js_error(
  8408. `"${node.TYPE}" statement may only appear at the top level`,
  8409. node.start.file,
  8410. node.start.line,
  8411. node.start.col,
  8412. node.start.pos
  8413. );
  8414. }
  8415. });
  8416. this.walk(tw);
  8417. function mark_export(def, level) {
  8418. if (in_destructuring) {
  8419. var i = 0;
  8420. do {
  8421. level++;
  8422. } while (tw.parent(i++) !== in_destructuring);
  8423. }
  8424. var node = tw.parent(level);
  8425. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  8426. var exported = node.exported_definition;
  8427. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  8428. def.export = MASK_EXPORT_WANT_MANGLE;
  8429. }
  8430. }
  8431. }
  8432. // pass 2: find back references and eval
  8433. const is_toplevel = this instanceof AST_Toplevel;
  8434. if (is_toplevel) {
  8435. this.globals = new Map();
  8436. }
  8437. var tw = new TreeWalker(node => {
  8438. if (node instanceof AST_LoopControl && node.label) {
  8439. node.label.thedef.references.push(node);
  8440. return true;
  8441. }
  8442. if (node instanceof AST_SymbolRef) {
  8443. var name = node.name;
  8444. if (name == "eval" && tw.parent() instanceof AST_Call) {
  8445. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  8446. s.uses_eval = true;
  8447. }
  8448. }
  8449. var sym;
  8450. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  8451. || !(sym = node.scope.find_variable(name))) {
  8452. sym = toplevel.def_global(node);
  8453. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  8454. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  8455. sym.scope.uses_arguments = true;
  8456. }
  8457. node.thedef = sym;
  8458. node.reference();
  8459. if (node.scope.is_block_scope()
  8460. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  8461. node.scope = node.scope.get_defun_scope();
  8462. }
  8463. return true;
  8464. }
  8465. // ensure mangling works if catch reuses a scope variable
  8466. var def;
  8467. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  8468. var s = node.scope;
  8469. while (s) {
  8470. push_uniq(s.enclosed, def);
  8471. if (s === def.scope) break;
  8472. s = s.parent_scope;
  8473. }
  8474. }
  8475. });
  8476. this.walk(tw);
  8477. // pass 3: work around IE8 and Safari catch scope bugs
  8478. if (options.ie8 || options.safari10) {
  8479. walk(this, node => {
  8480. if (node instanceof AST_SymbolCatch) {
  8481. var name = node.name;
  8482. var refs = node.thedef.references;
  8483. var scope = node.scope.get_defun_scope();
  8484. var def = scope.find_variable(name)
  8485. || toplevel.globals.get(name)
  8486. || scope.def_variable(node);
  8487. refs.forEach(function(ref) {
  8488. ref.thedef = def;
  8489. ref.reference();
  8490. });
  8491. node.thedef = def;
  8492. node.reference();
  8493. return true;
  8494. }
  8495. });
  8496. }
  8497. // pass 4: add symbol definitions to loop scopes
  8498. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  8499. // https://github.com/mishoo/UglifyJS2/issues/1753
  8500. // https://bugs.webkit.org/show_bug.cgi?id=171041
  8501. if (options.safari10) {
  8502. for (const scope of for_scopes) {
  8503. scope.parent_scope.variables.forEach(function(def) {
  8504. push_uniq(scope.enclosed, def);
  8505. });
  8506. }
  8507. }
  8508. });
  8509. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  8510. var globals = this.globals, name = node.name;
  8511. if (globals.has(name)) {
  8512. return globals.get(name);
  8513. } else {
  8514. var g = new SymbolDef(this, node);
  8515. g.undeclared = true;
  8516. g.global = true;
  8517. globals.set(name, g);
  8518. return g;
  8519. }
  8520. });
  8521. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  8522. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  8523. this.functions = new Map(); // map name to AST_SymbolDefun (functions defined in this scope)
  8524. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  8525. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  8526. this.parent_scope = parent_scope; // the parent scope
  8527. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  8528. this.cname = -1; // the current index for mangling functions/variables
  8529. });
  8530. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  8531. return (
  8532. this.enclosed.find(def => def.name === name)
  8533. || this.variables.has(name)
  8534. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  8535. );
  8536. });
  8537. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  8538. return (
  8539. this.enclosed.find(def => def.name === name)
  8540. || this.variables.has(name)
  8541. );
  8542. });
  8543. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  8544. // `scope` is going to be moved into `this` right now.
  8545. // Update the required scopes' information
  8546. if (scope.parent_scope === this) return;
  8547. scope.parent_scope = this;
  8548. // TODO uses_with, uses_eval, etc
  8549. const scope_ancestry = (() => {
  8550. const ancestry = [];
  8551. let cur = this;
  8552. do {
  8553. ancestry.push(cur);
  8554. } while ((cur = cur.parent_scope));
  8555. ancestry.reverse();
  8556. return ancestry;
  8557. })();
  8558. const new_scope_enclosed_set = new Set(scope.enclosed);
  8559. const to_enclose = [];
  8560. for (const scope_topdown of scope_ancestry) {
  8561. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  8562. for (const def of scope_topdown.variables.values()) {
  8563. if (new_scope_enclosed_set.has(def)) {
  8564. push_uniq(to_enclose, def);
  8565. push_uniq(scope_topdown.enclosed, def);
  8566. }
  8567. }
  8568. }
  8569. });
  8570. function find_scopes_visible_from(scopes) {
  8571. const found_scopes = new Set();
  8572. for (const scope of new Set(scopes)) {
  8573. (function bubble_up(scope) {
  8574. if (scope == null || found_scopes.has(scope)) return;
  8575. found_scopes.add(scope);
  8576. bubble_up(scope.parent_scope);
  8577. })(scope);
  8578. }
  8579. return [...found_scopes];
  8580. }
  8581. // Creates a symbol during compression
  8582. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  8583. source,
  8584. tentative_name,
  8585. scope,
  8586. conflict_scopes = [scope],
  8587. init = null
  8588. } = {}) {
  8589. let symbol_name;
  8590. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  8591. if (tentative_name) {
  8592. // Implement hygiene (no new names are conflicting with existing names)
  8593. tentative_name =
  8594. symbol_name =
  8595. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  8596. let i = 0;
  8597. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  8598. symbol_name = tentative_name + "$" + i++;
  8599. }
  8600. }
  8601. if (!symbol_name) {
  8602. throw new Error("No symbol name could be generated in create_symbol()");
  8603. }
  8604. const symbol = make_node(SymClass, source, {
  8605. name: symbol_name,
  8606. scope
  8607. });
  8608. this.def_variable(symbol, init || null);
  8609. symbol.mark_enclosed();
  8610. return symbol;
  8611. });
  8612. AST_Node.DEFMETHOD("is_block_scope", return_false);
  8613. AST_Class.DEFMETHOD("is_block_scope", return_false);
  8614. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  8615. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  8616. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  8617. AST_Block.DEFMETHOD("is_block_scope", return_true);
  8618. AST_Scope.DEFMETHOD("is_block_scope", function () {
  8619. return this._block_scope || false;
  8620. });
  8621. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  8622. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  8623. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  8624. this.uses_arguments = false;
  8625. this.def_variable(new AST_SymbolFunarg({
  8626. name: "arguments",
  8627. start: this.start,
  8628. end: this.end
  8629. }));
  8630. });
  8631. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  8632. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  8633. this.uses_arguments = false;
  8634. });
  8635. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  8636. var def = this.definition();
  8637. var s = this.scope;
  8638. while (s) {
  8639. push_uniq(s.enclosed, def);
  8640. if (s === def.scope) break;
  8641. s = s.parent_scope;
  8642. }
  8643. });
  8644. AST_Symbol.DEFMETHOD("reference", function() {
  8645. this.definition().references.push(this);
  8646. this.mark_enclosed();
  8647. });
  8648. AST_Scope.DEFMETHOD("find_variable", function(name) {
  8649. if (name instanceof AST_Symbol) name = name.name;
  8650. return this.variables.get(name)
  8651. || (this.parent_scope && this.parent_scope.find_variable(name));
  8652. });
  8653. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  8654. var def = this.def_variable(symbol, init);
  8655. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  8656. this.functions.set(symbol.name, def);
  8657. return def;
  8658. });
  8659. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  8660. var def = this.variables.get(symbol.name);
  8661. if (def) {
  8662. def.orig.push(symbol);
  8663. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  8664. def.init = init;
  8665. }
  8666. } else {
  8667. def = new SymbolDef(this, symbol, init);
  8668. this.variables.set(symbol.name, def);
  8669. def.global = !this.parent_scope;
  8670. }
  8671. return symbol.thedef = def;
  8672. });
  8673. function next_mangled(scope, options) {
  8674. var ext = scope.enclosed;
  8675. out: while (true) {
  8676. var m = base54(++scope.cname);
  8677. if (RESERVED_WORDS.has(m)) continue; // skip over "do"
  8678. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  8679. // shadow a name reserved from mangling.
  8680. if (options.reserved.has(m)) continue;
  8681. // Functions with short names might collide with base54 output
  8682. // and therefore cause collisions when keep_fnames is true.
  8683. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  8684. // we must ensure that the mangled name does not shadow a name
  8685. // from some parent scope that is referenced in this or in
  8686. // inner scopes.
  8687. for (let i = ext.length; --i >= 0;) {
  8688. const def = ext[i];
  8689. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  8690. if (m == name) continue out;
  8691. }
  8692. return m;
  8693. }
  8694. }
  8695. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  8696. return next_mangled(this, options);
  8697. });
  8698. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  8699. let name;
  8700. const mangled_names = this.mangled_names;
  8701. do {
  8702. name = next_mangled(this, options);
  8703. } while (mangled_names.has(name));
  8704. return name;
  8705. });
  8706. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  8707. // #179, #326
  8708. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  8709. // a function expression's argument cannot shadow the function expression's name
  8710. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  8711. // the function's mangled_name is null when keep_fnames is true
  8712. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  8713. while (true) {
  8714. var name = next_mangled(this, options);
  8715. if (!tricky_name || tricky_name != name)
  8716. return name;
  8717. }
  8718. });
  8719. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  8720. var def = this.definition();
  8721. return !def || def.unmangleable(options);
  8722. });
  8723. // labels are always mangleable
  8724. AST_Label.DEFMETHOD("unmangleable", return_false);
  8725. AST_Symbol.DEFMETHOD("unreferenced", function() {
  8726. return !this.definition().references.length && !this.scope.pinned();
  8727. });
  8728. AST_Symbol.DEFMETHOD("definition", function() {
  8729. return this.thedef;
  8730. });
  8731. AST_Symbol.DEFMETHOD("global", function() {
  8732. return this.thedef.global;
  8733. });
  8734. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  8735. options = defaults(options, {
  8736. eval : false,
  8737. ie8 : false,
  8738. keep_classnames: false,
  8739. keep_fnames : false,
  8740. module : false,
  8741. reserved : [],
  8742. toplevel : false,
  8743. });
  8744. if (options.module) options.toplevel = true;
  8745. if (!Array.isArray(options.reserved)
  8746. && !(options.reserved instanceof Set)
  8747. ) {
  8748. options.reserved = [];
  8749. }
  8750. options.reserved = new Set(options.reserved);
  8751. // Never mangle arguments
  8752. options.reserved.add("arguments");
  8753. return options;
  8754. });
  8755. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  8756. options = this._default_mangler_options(options);
  8757. // We only need to mangle declaration nodes. Special logic wired
  8758. // into the code generator will display the mangled name if it's
  8759. // present (and for AST_SymbolRef-s it'll use the mangled name of
  8760. // the AST_SymbolDeclaration that it points to).
  8761. var lname = -1;
  8762. var to_mangle = [];
  8763. if (options.keep_fnames) {
  8764. function_defs = new Set();
  8765. }
  8766. const mangled_names = this.mangled_names = new Set();
  8767. if (options.cache) {
  8768. this.globals.forEach(collect);
  8769. if (options.cache.props) {
  8770. options.cache.props.forEach(function(mangled_name) {
  8771. mangled_names.add(mangled_name);
  8772. });
  8773. }
  8774. }
  8775. var tw = new TreeWalker(function(node, descend) {
  8776. if (node instanceof AST_LabeledStatement) {
  8777. // lname is incremented when we get to the AST_Label
  8778. var save_nesting = lname;
  8779. descend();
  8780. lname = save_nesting;
  8781. return true; // don't descend again in TreeWalker
  8782. }
  8783. if (node instanceof AST_Scope) {
  8784. node.variables.forEach(collect);
  8785. return;
  8786. }
  8787. if (node.is_block_scope()) {
  8788. node.block_scope.variables.forEach(collect);
  8789. return;
  8790. }
  8791. if (
  8792. function_defs
  8793. && node instanceof AST_VarDef
  8794. && node.value instanceof AST_Lambda
  8795. && !node.value.name
  8796. && keep_name(options.keep_fnames, node.name.name)
  8797. ) {
  8798. function_defs.add(node.name.definition().id);
  8799. return;
  8800. }
  8801. if (node instanceof AST_Label) {
  8802. let name;
  8803. do {
  8804. name = base54(++lname);
  8805. } while (RESERVED_WORDS.has(name));
  8806. node.mangled_name = name;
  8807. return true;
  8808. }
  8809. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  8810. to_mangle.push(node.definition());
  8811. return;
  8812. }
  8813. });
  8814. this.walk(tw);
  8815. if (options.keep_fnames || options.keep_classnames) {
  8816. unmangleable_names = new Set();
  8817. // Collect a set of short names which are unmangleable,
  8818. // for use in avoiding collisions in next_mangled.
  8819. to_mangle.forEach(def => {
  8820. if (def.name.length < 6 && def.unmangleable(options)) {
  8821. unmangleable_names.add(def.name);
  8822. }
  8823. });
  8824. }
  8825. to_mangle.forEach(def => { def.mangle(options); });
  8826. function_defs = null;
  8827. unmangleable_names = null;
  8828. function collect(symbol) {
  8829. const should_mangle = !options.reserved.has(symbol.name)
  8830. && !(symbol.export & MASK_EXPORT_DONT_MANGLE);
  8831. if (should_mangle) {
  8832. to_mangle.push(symbol);
  8833. }
  8834. }
  8835. });
  8836. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  8837. const cache = options.cache && options.cache.props;
  8838. const avoid = new Set();
  8839. options.reserved.forEach(to_avoid);
  8840. this.globals.forEach(add_def);
  8841. this.walk(new TreeWalker(function(node) {
  8842. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  8843. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  8844. }));
  8845. return avoid;
  8846. function to_avoid(name) {
  8847. avoid.add(name);
  8848. }
  8849. function add_def(def) {
  8850. var name = def.name;
  8851. if (def.global && cache && cache.has(name)) name = cache.get(name);
  8852. else if (!def.unmangleable(options)) return;
  8853. to_avoid(name);
  8854. }
  8855. });
  8856. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  8857. base54.reset();
  8858. base54.sort();
  8859. options = this._default_mangler_options(options);
  8860. var avoid = this.find_colliding_names(options);
  8861. var cname = 0;
  8862. this.globals.forEach(rename);
  8863. this.walk(new TreeWalker(function(node) {
  8864. if (node instanceof AST_Scope) node.variables.forEach(rename);
  8865. if (node instanceof AST_SymbolCatch) rename(node.definition());
  8866. }));
  8867. function next_name() {
  8868. var name;
  8869. do {
  8870. name = base54(cname++);
  8871. } while (avoid.has(name) || RESERVED_WORDS.has(name));
  8872. return name;
  8873. }
  8874. function rename(def) {
  8875. if (def.global && options.cache) return;
  8876. if (def.unmangleable(options)) return;
  8877. if (options.reserved.has(def.name)) return;
  8878. const redefinition = redefined_catch_def(def);
  8879. const name = def.name = redefinition ? redefinition.name : next_name();
  8880. def.orig.forEach(function(sym) {
  8881. sym.name = name;
  8882. });
  8883. def.references.forEach(function(sym) {
  8884. sym.name = name;
  8885. });
  8886. }
  8887. });
  8888. AST_Node.DEFMETHOD("tail_node", return_this);
  8889. AST_Sequence.DEFMETHOD("tail_node", function() {
  8890. return this.expressions[this.expressions.length - 1];
  8891. });
  8892. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  8893. options = this._default_mangler_options(options);
  8894. try {
  8895. AST_Node.prototype.print = function(stream, force_parens) {
  8896. this._print(stream, force_parens);
  8897. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  8898. base54.consider(this.name, -1);
  8899. } else if (options.properties) {
  8900. if (this instanceof AST_Dot) {
  8901. base54.consider(this.property, -1);
  8902. } else if (this instanceof AST_Sub) {
  8903. skip_string(this.property);
  8904. }
  8905. }
  8906. };
  8907. base54.consider(this.print_to_string(), 1);
  8908. } finally {
  8909. AST_Node.prototype.print = AST_Node.prototype._print;
  8910. }
  8911. base54.sort();
  8912. function skip_string(node) {
  8913. if (node instanceof AST_String) {
  8914. base54.consider(node.value, -1);
  8915. } else if (node instanceof AST_Conditional) {
  8916. skip_string(node.consequent);
  8917. skip_string(node.alternative);
  8918. } else if (node instanceof AST_Sequence) {
  8919. skip_string(node.tail_node());
  8920. }
  8921. }
  8922. });
  8923. const base54 = (() => {
  8924. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  8925. const digits = "0123456789".split("");
  8926. let chars;
  8927. let frequency;
  8928. function reset() {
  8929. frequency = new Map();
  8930. leading.forEach(function(ch) {
  8931. frequency.set(ch, 0);
  8932. });
  8933. digits.forEach(function(ch) {
  8934. frequency.set(ch, 0);
  8935. });
  8936. }
  8937. base54.consider = function(str, delta) {
  8938. for (var i = str.length; --i >= 0;) {
  8939. frequency.set(str[i], frequency.get(str[i]) + delta);
  8940. }
  8941. };
  8942. function compare(a, b) {
  8943. return frequency.get(b) - frequency.get(a);
  8944. }
  8945. base54.sort = function() {
  8946. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  8947. };
  8948. base54.reset = reset;
  8949. reset();
  8950. function base54(num) {
  8951. var ret = "", base = 54;
  8952. num++;
  8953. do {
  8954. num--;
  8955. ret += chars[num % base];
  8956. num = Math.floor(num / base);
  8957. base = 64;
  8958. } while (num > 0);
  8959. return ret;
  8960. }
  8961. return base54;
  8962. })();
  8963. let mangle_options = undefined;
  8964. AST_Node.prototype.size = function (compressor, stack) {
  8965. mangle_options = compressor && compressor.mangle_options;
  8966. let size = 0;
  8967. walk_parent(this, (node, info) => {
  8968. size += node._size(info);
  8969. }, stack || (compressor && compressor.stack));
  8970. // just to save a bit of memory
  8971. mangle_options = undefined;
  8972. return size;
  8973. };
  8974. AST_Node.prototype._size = () => 0;
  8975. AST_Debugger.prototype._size = () => 8;
  8976. AST_Directive.prototype._size = function () {
  8977. // TODO string encoding stuff
  8978. return 2 + this.value.length;
  8979. };
  8980. const list_overhead = (array) => array.length && array.length - 1;
  8981. AST_Block.prototype._size = function () {
  8982. return 2 + list_overhead(this.body);
  8983. };
  8984. AST_Toplevel.prototype._size = function() {
  8985. return list_overhead(this.body);
  8986. };
  8987. AST_EmptyStatement.prototype._size = () => 1;
  8988. AST_LabeledStatement.prototype._size = () => 2; // x:
  8989. AST_Do.prototype._size = () => 9;
  8990. AST_While.prototype._size = () => 7;
  8991. AST_For.prototype._size = () => 8;
  8992. AST_ForIn.prototype._size = () => 8;
  8993. // AST_ForOf inherits ^
  8994. AST_With.prototype._size = () => 6;
  8995. AST_Expansion.prototype._size = () => 3;
  8996. /*#__INLINE__*/
  8997. const lambda_modifiers = func =>
  8998. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  8999. AST_Accessor.prototype._size = function () {
  9000. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  9001. };
  9002. AST_Function.prototype._size = function (info) {
  9003. const first = !!first_in_statement(info);
  9004. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  9005. };
  9006. AST_Defun.prototype._size = function () {
  9007. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  9008. };
  9009. AST_Arrow.prototype._size = function () {
  9010. let args_and_arrow = 2 + list_overhead(this.argnames);
  9011. if (
  9012. !(
  9013. this.argnames.length === 1
  9014. && this.argnames[0] instanceof AST_Symbol
  9015. )
  9016. ) {
  9017. args_and_arrow += 2;
  9018. }
  9019. return lambda_modifiers(this) + args_and_arrow + (Array.isArray(this.body) ? list_overhead(this.body) : this.body._size());
  9020. };
  9021. AST_Destructuring.prototype._size = () => 2;
  9022. AST_TemplateString.prototype._size = function () {
  9023. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  9024. };
  9025. AST_TemplateSegment.prototype._size = function () {
  9026. return this.value.length;
  9027. };
  9028. AST_Return.prototype._size = function () {
  9029. return this.value ? 7 : 6;
  9030. };
  9031. AST_Throw.prototype._size = () => 6;
  9032. AST_Break.prototype._size = function () {
  9033. return this.label ? 6 : 5;
  9034. };
  9035. AST_Continue.prototype._size = function () {
  9036. return this.label ? 9 : 8;
  9037. };
  9038. AST_If.prototype._size = () => 4;
  9039. AST_Switch.prototype._size = function () {
  9040. return 8 + list_overhead(this.body);
  9041. };
  9042. AST_Case.prototype._size = function () {
  9043. return 5 + list_overhead(this.body);
  9044. };
  9045. AST_Default.prototype._size = function () {
  9046. return 8 + list_overhead(this.body);
  9047. };
  9048. AST_Try.prototype._size = function () {
  9049. return 3 + list_overhead(this.body);
  9050. };
  9051. AST_Catch.prototype._size = function () {
  9052. let size = 7 + list_overhead(this.body);
  9053. if (this.argname) {
  9054. size += 2;
  9055. }
  9056. return size;
  9057. };
  9058. AST_Finally.prototype._size = function () {
  9059. return 7 + list_overhead(this.body);
  9060. };
  9061. /*#__INLINE__*/
  9062. const def_size = (size, def) => size + list_overhead(def.definitions);
  9063. AST_Var.prototype._size = function () {
  9064. return def_size(4, this);
  9065. };
  9066. AST_Let.prototype._size = function () {
  9067. return def_size(4, this);
  9068. };
  9069. AST_Const.prototype._size = function () {
  9070. return def_size(6, this);
  9071. };
  9072. AST_VarDef.prototype._size = function () {
  9073. return this.value ? 1 : 0;
  9074. };
  9075. AST_NameMapping.prototype._size = function () {
  9076. // foreign name isn't mangled
  9077. return this.name ? 4 : 0;
  9078. };
  9079. AST_Import.prototype._size = function () {
  9080. // import
  9081. let size = 6;
  9082. if (this.imported_name) size += 1;
  9083. // from
  9084. if (this.imported_name || this.imported_names) size += 5;
  9085. // braces, and the commas
  9086. if (this.imported_names) {
  9087. size += 2 + list_overhead(this.imported_names);
  9088. }
  9089. return size;
  9090. };
  9091. AST_ImportMeta.prototype._size = () => 11;
  9092. AST_Export.prototype._size = function () {
  9093. let size = 7 + (this.is_default ? 8 : 0);
  9094. if (this.exported_value) {
  9095. size += this.exported_value._size();
  9096. }
  9097. if (this.exported_names) {
  9098. // Braces and commas
  9099. size += 2 + list_overhead(this.exported_names);
  9100. }
  9101. if (this.module_name) {
  9102. // "from "
  9103. size += 5;
  9104. }
  9105. return size;
  9106. };
  9107. AST_Call.prototype._size = function () {
  9108. if (this.optional) {
  9109. return 4 + list_overhead(this.args);
  9110. }
  9111. return 2 + list_overhead(this.args);
  9112. };
  9113. AST_New.prototype._size = function () {
  9114. return 6 + list_overhead(this.args);
  9115. };
  9116. AST_Sequence.prototype._size = function () {
  9117. return list_overhead(this.expressions);
  9118. };
  9119. AST_Dot.prototype._size = function () {
  9120. if (this.optional) {
  9121. return this.property.length + 2;
  9122. }
  9123. return this.property.length + 1;
  9124. };
  9125. AST_Sub.prototype._size = function () {
  9126. return this.optional ? 4 : 2;
  9127. };
  9128. AST_Unary.prototype._size = function () {
  9129. if (this.operator === "typeof") return 7;
  9130. if (this.operator === "void") return 5;
  9131. return this.operator.length;
  9132. };
  9133. AST_Binary.prototype._size = function (info) {
  9134. if (this.operator === "in") return 4;
  9135. let size = this.operator.length;
  9136. if (
  9137. (this.operator === "+" || this.operator === "-")
  9138. && this.right instanceof AST_Unary && this.right.operator === this.operator
  9139. ) {
  9140. // 1+ +a > needs space between the +
  9141. size += 1;
  9142. }
  9143. if (this.needs_parens(info)) {
  9144. size += 2;
  9145. }
  9146. return size;
  9147. };
  9148. AST_Conditional.prototype._size = () => 3;
  9149. AST_Array.prototype._size = function () {
  9150. return 2 + list_overhead(this.elements);
  9151. };
  9152. AST_Object.prototype._size = function (info) {
  9153. let base = 2;
  9154. if (first_in_statement(info)) {
  9155. base += 2; // parens
  9156. }
  9157. return base + list_overhead(this.properties);
  9158. };
  9159. /*#__INLINE__*/
  9160. const key_size = key =>
  9161. typeof key === "string" ? key.length : 0;
  9162. AST_ObjectKeyVal.prototype._size = function () {
  9163. return key_size(this.key) + 1;
  9164. };
  9165. /*#__INLINE__*/
  9166. const static_size = is_static => is_static ? 7 : 0;
  9167. AST_ObjectGetter.prototype._size = function () {
  9168. return 5 + static_size(this.static) + key_size(this.key);
  9169. };
  9170. AST_ObjectSetter.prototype._size = function () {
  9171. return 5 + static_size(this.static) + key_size(this.key);
  9172. };
  9173. AST_ConciseMethod.prototype._size = function () {
  9174. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  9175. };
  9176. AST_Class.prototype._size = function () {
  9177. return (
  9178. (this.name ? 8 : 7)
  9179. + (this.extends ? 8 : 0)
  9180. );
  9181. };
  9182. AST_ClassProperty.prototype._size = function () {
  9183. return (
  9184. static_size(this.static)
  9185. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  9186. + (this.value ? 1 : 0)
  9187. );
  9188. };
  9189. AST_Symbol.prototype._size = function () {
  9190. return !mangle_options || this.definition().unmangleable(mangle_options)
  9191. ? this.name.length
  9192. : 1;
  9193. };
  9194. // TODO take propmangle into account
  9195. AST_SymbolClassProperty.prototype._size = function () {
  9196. return this.name.length;
  9197. };
  9198. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  9199. const { name, thedef } = this;
  9200. if (thedef && thedef.global) return name.length;
  9201. if (name === "arguments") return 9;
  9202. return AST_Symbol.prototype._size.call(this);
  9203. };
  9204. AST_NewTarget.prototype._size = () => 10;
  9205. AST_SymbolImportForeign.prototype._size = function () {
  9206. return this.name.length;
  9207. };
  9208. AST_SymbolExportForeign.prototype._size = function () {
  9209. return this.name.length;
  9210. };
  9211. AST_This.prototype._size = () => 4;
  9212. AST_Super.prototype._size = () => 5;
  9213. AST_String.prototype._size = function () {
  9214. return this.value.length + 2;
  9215. };
  9216. AST_Number.prototype._size = function () {
  9217. const { value } = this;
  9218. if (value === 0) return 1;
  9219. if (value > 0 && Math.floor(value) === value) {
  9220. return Math.floor(Math.log10(value) + 1);
  9221. }
  9222. return value.toString().length;
  9223. };
  9224. AST_BigInt.prototype._size = function () {
  9225. return this.value.length;
  9226. };
  9227. AST_RegExp.prototype._size = function () {
  9228. return this.value.toString().length;
  9229. };
  9230. AST_Null.prototype._size = () => 4;
  9231. AST_NaN.prototype._size = () => 3;
  9232. AST_Undefined.prototype._size = () => 6; // "void 0"
  9233. AST_Hole.prototype._size = () => 0; // comma is taken into account
  9234. AST_Infinity.prototype._size = () => 8;
  9235. AST_True.prototype._size = () => 4;
  9236. AST_False.prototype._size = () => 5;
  9237. AST_Await.prototype._size = () => 6;
  9238. AST_Yield.prototype._size = () => 6;
  9239. /***********************************************************************
  9240. A JavaScript tokenizer / parser / beautifier / compressor.
  9241. https://github.com/mishoo/UglifyJS2
  9242. -------------------------------- (C) ---------------------------------
  9243. Author: Mihai Bazon
  9244. <mihai.bazon@gmail.com>
  9245. http://mihai.bazon.net/blog
  9246. Distributed under the BSD license:
  9247. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  9248. Redistribution and use in source and binary forms, with or without
  9249. modification, are permitted provided that the following conditions
  9250. are met:
  9251. * Redistributions of source code must retain the above
  9252. copyright notice, this list of conditions and the following
  9253. disclaimer.
  9254. * Redistributions in binary form must reproduce the above
  9255. copyright notice, this list of conditions and the following
  9256. disclaimer in the documentation and/or other materials
  9257. provided with the distribution.
  9258. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  9259. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9260. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9261. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  9262. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  9263. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9264. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9265. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9266. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  9267. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  9268. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9269. SUCH DAMAGE.
  9270. ***********************************************************************/
  9271. const UNUSED = 0b00000001;
  9272. const TRUTHY = 0b00000010;
  9273. const FALSY = 0b00000100;
  9274. const UNDEFINED = 0b00001000;
  9275. const INLINED = 0b00010000;
  9276. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  9277. const WRITE_ONLY= 0b00100000;
  9278. // information specific to a single compression pass
  9279. const SQUEEZED = 0b0000000100000000;
  9280. const OPTIMIZED = 0b0000001000000000;
  9281. const TOP = 0b0000010000000000;
  9282. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  9283. /*@__INLINE__*/
  9284. const has_flag = (node, flag) => node.flags & flag;
  9285. /*@__INLINE__*/
  9286. const set_flag = (node, flag) => { node.flags |= flag; };
  9287. /*@__INLINE__*/
  9288. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  9289. class Compressor extends TreeWalker {
  9290. constructor(options, { false_by_default = false, mangle_options = false }) {
  9291. super();
  9292. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  9293. this.options = defaults(options, {
  9294. arguments : false,
  9295. arrows : !false_by_default,
  9296. booleans : !false_by_default,
  9297. booleans_as_integers : false,
  9298. collapse_vars : !false_by_default,
  9299. comparisons : !false_by_default,
  9300. computed_props: !false_by_default,
  9301. conditionals : !false_by_default,
  9302. dead_code : !false_by_default,
  9303. defaults : true,
  9304. directives : !false_by_default,
  9305. drop_console : false,
  9306. drop_debugger : !false_by_default,
  9307. ecma : 5,
  9308. evaluate : !false_by_default,
  9309. expression : false,
  9310. global_defs : false,
  9311. hoist_funs : false,
  9312. hoist_props : !false_by_default,
  9313. hoist_vars : false,
  9314. ie8 : false,
  9315. if_return : !false_by_default,
  9316. inline : !false_by_default,
  9317. join_vars : !false_by_default,
  9318. keep_classnames: false,
  9319. keep_fargs : true,
  9320. keep_fnames : false,
  9321. keep_infinity : false,
  9322. loops : !false_by_default,
  9323. module : false,
  9324. negate_iife : !false_by_default,
  9325. passes : 1,
  9326. properties : !false_by_default,
  9327. pure_getters : !false_by_default && "strict",
  9328. pure_funcs : null,
  9329. reduce_funcs : null, // legacy
  9330. reduce_vars : !false_by_default,
  9331. sequences : !false_by_default,
  9332. side_effects : !false_by_default,
  9333. switches : !false_by_default,
  9334. top_retain : null,
  9335. toplevel : !!(options && options["top_retain"]),
  9336. typeofs : !false_by_default,
  9337. unsafe : false,
  9338. unsafe_arrows : false,
  9339. unsafe_comps : false,
  9340. unsafe_Function: false,
  9341. unsafe_math : false,
  9342. unsafe_symbols: false,
  9343. unsafe_methods: false,
  9344. unsafe_proto : false,
  9345. unsafe_regexp : false,
  9346. unsafe_undefined: false,
  9347. unused : !false_by_default,
  9348. warnings : false // legacy
  9349. }, true);
  9350. var global_defs = this.options["global_defs"];
  9351. if (typeof global_defs == "object") for (var key in global_defs) {
  9352. if (key[0] === "@" && HOP(global_defs, key)) {
  9353. global_defs[key.slice(1)] = parse(global_defs[key], {
  9354. expression: true
  9355. });
  9356. }
  9357. }
  9358. if (this.options["inline"] === true) this.options["inline"] = 3;
  9359. var pure_funcs = this.options["pure_funcs"];
  9360. if (typeof pure_funcs == "function") {
  9361. this.pure_funcs = pure_funcs;
  9362. } else {
  9363. this.pure_funcs = pure_funcs ? function(node) {
  9364. return !pure_funcs.includes(node.expression.print_to_string());
  9365. } : return_true;
  9366. }
  9367. var top_retain = this.options["top_retain"];
  9368. if (top_retain instanceof RegExp) {
  9369. this.top_retain = function(def) {
  9370. return top_retain.test(def.name);
  9371. };
  9372. } else if (typeof top_retain == "function") {
  9373. this.top_retain = top_retain;
  9374. } else if (top_retain) {
  9375. if (typeof top_retain == "string") {
  9376. top_retain = top_retain.split(/,/);
  9377. }
  9378. this.top_retain = function(def) {
  9379. return top_retain.includes(def.name);
  9380. };
  9381. }
  9382. if (this.options["module"]) {
  9383. this.directives["use strict"] = true;
  9384. this.options["toplevel"] = true;
  9385. }
  9386. var toplevel = this.options["toplevel"];
  9387. this.toplevel = typeof toplevel == "string" ? {
  9388. funcs: /funcs/.test(toplevel),
  9389. vars: /vars/.test(toplevel)
  9390. } : {
  9391. funcs: toplevel,
  9392. vars: toplevel
  9393. };
  9394. var sequences = this.options["sequences"];
  9395. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  9396. this.evaluated_regexps = new Map();
  9397. this._toplevel = undefined;
  9398. this.mangle_options = mangle_options;
  9399. }
  9400. option(key) {
  9401. return this.options[key];
  9402. }
  9403. exposed(def) {
  9404. if (def.export) return true;
  9405. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  9406. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  9407. return true;
  9408. return false;
  9409. }
  9410. in_boolean_context() {
  9411. if (!this.option("booleans")) return false;
  9412. var self = this.self();
  9413. for (var i = 0, p; p = this.parent(i); i++) {
  9414. if (p instanceof AST_SimpleStatement
  9415. || p instanceof AST_Conditional && p.condition === self
  9416. || p instanceof AST_DWLoop && p.condition === self
  9417. || p instanceof AST_For && p.condition === self
  9418. || p instanceof AST_If && p.condition === self
  9419. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  9420. return true;
  9421. }
  9422. if (
  9423. p instanceof AST_Binary
  9424. && (
  9425. p.operator == "&&"
  9426. || p.operator == "||"
  9427. || p.operator == "??"
  9428. )
  9429. || p instanceof AST_Conditional
  9430. || p.tail_node() === self
  9431. ) {
  9432. self = p;
  9433. } else {
  9434. return false;
  9435. }
  9436. }
  9437. }
  9438. get_toplevel() {
  9439. return this._toplevel;
  9440. }
  9441. compress(toplevel) {
  9442. toplevel = toplevel.resolve_defines(this);
  9443. this._toplevel = toplevel;
  9444. if (this.option("expression")) {
  9445. this._toplevel.process_expression(true);
  9446. }
  9447. var passes = +this.options.passes || 1;
  9448. var min_count = 1 / 0;
  9449. var stopping = false;
  9450. var mangle = { ie8: this.option("ie8") };
  9451. for (var pass = 0; pass < passes; pass++) {
  9452. this._toplevel.figure_out_scope(mangle);
  9453. if (pass === 0 && this.option("drop_console")) {
  9454. // must be run before reduce_vars and compress pass
  9455. this._toplevel = this._toplevel.drop_console();
  9456. }
  9457. if (pass > 0 || this.option("reduce_vars")) {
  9458. this._toplevel.reset_opt_flags(this);
  9459. }
  9460. this._toplevel = this._toplevel.transform(this);
  9461. if (passes > 1) {
  9462. let count = 0;
  9463. walk(this._toplevel, () => { count++; });
  9464. if (count < min_count) {
  9465. min_count = count;
  9466. stopping = false;
  9467. } else if (stopping) {
  9468. break;
  9469. } else {
  9470. stopping = true;
  9471. }
  9472. }
  9473. }
  9474. if (this.option("expression")) {
  9475. this._toplevel.process_expression(false);
  9476. }
  9477. toplevel = this._toplevel;
  9478. this._toplevel = undefined;
  9479. return toplevel;
  9480. }
  9481. before(node, descend) {
  9482. if (has_flag(node, SQUEEZED)) return node;
  9483. var was_scope = false;
  9484. if (node instanceof AST_Scope) {
  9485. node = node.hoist_properties(this);
  9486. node = node.hoist_declarations(this);
  9487. was_scope = true;
  9488. }
  9489. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  9490. // would call AST_Node.transform() if a different instance of AST_Node is
  9491. // produced after def_optimize().
  9492. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  9493. // Migrate and defer all children's AST_Node.transform() to below, which
  9494. // will now happen after this parent AST_Node has been properly substituted
  9495. // thus gives a consistent AST snapshot.
  9496. descend(node, this);
  9497. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  9498. // following replacement call would result in degraded efficiency of both
  9499. // output and performance.
  9500. descend(node, this);
  9501. var opt = node.optimize(this);
  9502. if (was_scope && opt instanceof AST_Scope) {
  9503. opt.drop_unused(this);
  9504. descend(opt, this);
  9505. }
  9506. if (opt === node) set_flag(opt, SQUEEZED);
  9507. return opt;
  9508. }
  9509. }
  9510. function def_optimize(node, optimizer) {
  9511. node.DEFMETHOD("optimize", function(compressor) {
  9512. var self = this;
  9513. if (has_flag(self, OPTIMIZED)) return self;
  9514. if (compressor.has_directive("use asm")) return self;
  9515. var opt = optimizer(self, compressor);
  9516. set_flag(opt, OPTIMIZED);
  9517. return opt;
  9518. });
  9519. }
  9520. def_optimize(AST_Node, function(self) {
  9521. return self;
  9522. });
  9523. AST_Toplevel.DEFMETHOD("drop_console", function() {
  9524. return this.transform(new TreeTransformer(function(self) {
  9525. if (self.TYPE == "Call") {
  9526. var exp = self.expression;
  9527. if (exp instanceof AST_PropAccess) {
  9528. var name = exp.expression;
  9529. while (name.expression) {
  9530. name = name.expression;
  9531. }
  9532. if (is_undeclared_ref(name) && name.name == "console") {
  9533. return make_node(AST_Undefined, self);
  9534. }
  9535. }
  9536. }
  9537. }));
  9538. });
  9539. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  9540. return equivalent_to(this, node);
  9541. });
  9542. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  9543. var self = this;
  9544. var tt = new TreeTransformer(function(node) {
  9545. if (insert && node instanceof AST_SimpleStatement) {
  9546. return make_node(AST_Return, node, {
  9547. value: node.body
  9548. });
  9549. }
  9550. if (!insert && node instanceof AST_Return) {
  9551. if (compressor) {
  9552. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  9553. return value ? make_node(AST_SimpleStatement, node, {
  9554. body: value
  9555. }) : make_node(AST_EmptyStatement, node);
  9556. }
  9557. return make_node(AST_SimpleStatement, node, {
  9558. body: node.value || make_node(AST_UnaryPrefix, node, {
  9559. operator: "void",
  9560. expression: make_node(AST_Number, node, {
  9561. value: 0
  9562. })
  9563. })
  9564. });
  9565. }
  9566. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  9567. return node;
  9568. }
  9569. if (node instanceof AST_Block) {
  9570. var index = node.body.length - 1;
  9571. if (index >= 0) {
  9572. node.body[index] = node.body[index].transform(tt);
  9573. }
  9574. } else if (node instanceof AST_If) {
  9575. node.body = node.body.transform(tt);
  9576. if (node.alternative) {
  9577. node.alternative = node.alternative.transform(tt);
  9578. }
  9579. } else if (node instanceof AST_With) {
  9580. node.body = node.body.transform(tt);
  9581. }
  9582. return node;
  9583. });
  9584. self.transform(tt);
  9585. });
  9586. function read_property(obj, key) {
  9587. key = get_value(key);
  9588. if (key instanceof AST_Node) return;
  9589. var value;
  9590. if (obj instanceof AST_Array) {
  9591. var elements = obj.elements;
  9592. if (key == "length") return make_node_from_constant(elements.length, obj);
  9593. if (typeof key == "number" && key in elements) value = elements[key];
  9594. } else if (obj instanceof AST_Object) {
  9595. key = "" + key;
  9596. var props = obj.properties;
  9597. for (var i = props.length; --i >= 0;) {
  9598. var prop = props[i];
  9599. if (!(prop instanceof AST_ObjectKeyVal)) return;
  9600. if (!value && props[i].key === key) value = props[i].value;
  9601. }
  9602. }
  9603. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  9604. }
  9605. function is_modified(compressor, tw, node, value, level, immutable) {
  9606. var parent = tw.parent(level);
  9607. var lhs = is_lhs(node, parent);
  9608. if (lhs) return lhs;
  9609. if (!immutable
  9610. && parent instanceof AST_Call
  9611. && parent.expression === node
  9612. && !(value instanceof AST_Arrow)
  9613. && !(value instanceof AST_Class)
  9614. && !parent.is_expr_pure(compressor)
  9615. && (!(value instanceof AST_Function)
  9616. || !(parent instanceof AST_New) && value.contains_this())) {
  9617. return true;
  9618. }
  9619. if (parent instanceof AST_Array) {
  9620. return is_modified(compressor, tw, parent, parent, level + 1);
  9621. }
  9622. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  9623. var obj = tw.parent(level + 1);
  9624. return is_modified(compressor, tw, obj, obj, level + 2);
  9625. }
  9626. if (parent instanceof AST_PropAccess && parent.expression === node) {
  9627. var prop = read_property(value, parent.property);
  9628. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  9629. }
  9630. }
  9631. (function(def_reduce_vars) {
  9632. def_reduce_vars(AST_Node, noop);
  9633. function reset_def(compressor, def) {
  9634. def.assignments = 0;
  9635. def.chained = false;
  9636. def.direct_access = false;
  9637. def.escaped = 0;
  9638. def.recursive_refs = 0;
  9639. def.references = [];
  9640. def.single_use = undefined;
  9641. if (def.scope.pinned()) {
  9642. def.fixed = false;
  9643. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  9644. def.fixed = def.init;
  9645. } else {
  9646. def.fixed = false;
  9647. }
  9648. }
  9649. function reset_variables(tw, compressor, node) {
  9650. node.variables.forEach(function(def) {
  9651. reset_def(compressor, def);
  9652. if (def.fixed === null) {
  9653. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  9654. mark(tw, def, true);
  9655. } else if (def.fixed) {
  9656. tw.loop_ids.set(def.id, tw.in_loop);
  9657. mark(tw, def, true);
  9658. }
  9659. });
  9660. }
  9661. function reset_block_variables(compressor, node) {
  9662. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  9663. reset_def(compressor, def);
  9664. });
  9665. }
  9666. function push(tw) {
  9667. tw.safe_ids = Object.create(tw.safe_ids);
  9668. }
  9669. function pop(tw) {
  9670. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  9671. }
  9672. function mark(tw, def, safe) {
  9673. tw.safe_ids[def.id] = safe;
  9674. }
  9675. function safe_to_read(tw, def) {
  9676. if (def.single_use == "m") return false;
  9677. if (tw.safe_ids[def.id]) {
  9678. if (def.fixed == null) {
  9679. var orig = def.orig[0];
  9680. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  9681. def.fixed = make_node(AST_Undefined, orig);
  9682. }
  9683. return true;
  9684. }
  9685. return def.fixed instanceof AST_Defun;
  9686. }
  9687. function safe_to_assign(tw, def, scope, value) {
  9688. if (def.fixed === undefined) return true;
  9689. let def_safe_ids;
  9690. if (def.fixed === null
  9691. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  9692. ) {
  9693. def_safe_ids[def.id] = false;
  9694. tw.defs_to_safe_ids.delete(def.id);
  9695. return true;
  9696. }
  9697. if (!HOP(tw.safe_ids, def.id)) return false;
  9698. if (!safe_to_read(tw, def)) return false;
  9699. if (def.fixed === false) return false;
  9700. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  9701. if (def.fixed instanceof AST_Defun) {
  9702. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  9703. }
  9704. return def.orig.every((sym) => {
  9705. return !(sym instanceof AST_SymbolConst
  9706. || sym instanceof AST_SymbolDefun
  9707. || sym instanceof AST_SymbolLambda);
  9708. });
  9709. }
  9710. function ref_once(tw, compressor, def) {
  9711. return compressor.option("unused")
  9712. && !def.scope.pinned()
  9713. && def.references.length - def.recursive_refs == 1
  9714. && tw.loop_ids.get(def.id) === tw.in_loop;
  9715. }
  9716. function is_immutable(value) {
  9717. if (!value) return false;
  9718. return value.is_constant()
  9719. || value instanceof AST_Lambda
  9720. || value instanceof AST_This;
  9721. }
  9722. function mark_escaped(tw, d, scope, node, value, level, depth) {
  9723. var parent = tw.parent(level);
  9724. if (value) {
  9725. if (value.is_constant()) return;
  9726. if (value instanceof AST_ClassExpression) return;
  9727. }
  9728. if (parent instanceof AST_Assign && parent.operator == "=" && node === parent.right
  9729. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  9730. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  9731. || parent instanceof AST_VarDef && node === parent.value
  9732. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope) {
  9733. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  9734. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  9735. return;
  9736. } else if (parent instanceof AST_Array
  9737. || parent instanceof AST_Await
  9738. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  9739. || parent instanceof AST_Conditional && node !== parent.condition
  9740. || parent instanceof AST_Expansion
  9741. || parent instanceof AST_Sequence && node === parent.tail_node()) {
  9742. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  9743. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  9744. var obj = tw.parent(level + 1);
  9745. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  9746. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  9747. value = read_property(value, parent.property);
  9748. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  9749. if (value) return;
  9750. }
  9751. if (level > 0) return;
  9752. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  9753. if (parent instanceof AST_SimpleStatement) return;
  9754. d.direct_access = true;
  9755. }
  9756. const suppress = node => walk(node, node => {
  9757. if (!(node instanceof AST_Symbol)) return;
  9758. var d = node.definition();
  9759. if (!d) return;
  9760. if (node instanceof AST_SymbolRef) d.references.push(node);
  9761. d.fixed = false;
  9762. });
  9763. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  9764. push(tw);
  9765. reset_variables(tw, compressor, this);
  9766. descend();
  9767. pop(tw);
  9768. return true;
  9769. });
  9770. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  9771. var node = this;
  9772. if (node.left instanceof AST_Destructuring) {
  9773. suppress(node.left);
  9774. return;
  9775. }
  9776. var sym = node.left;
  9777. if (!(sym instanceof AST_SymbolRef)) return;
  9778. var def = sym.definition();
  9779. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  9780. def.assignments++;
  9781. if (!safe) return;
  9782. var fixed = def.fixed;
  9783. if (!fixed && node.operator != "=") return;
  9784. var eq = node.operator == "=";
  9785. var value = eq ? node.right : node;
  9786. if (is_modified(compressor, tw, node, value, 0)) return;
  9787. def.references.push(sym);
  9788. if (!eq) def.chained = true;
  9789. def.fixed = eq ? function() {
  9790. return node.right;
  9791. } : function() {
  9792. return make_node(AST_Binary, node, {
  9793. operator: node.operator.slice(0, -1),
  9794. left: fixed instanceof AST_Node ? fixed : fixed(),
  9795. right: node.right
  9796. });
  9797. };
  9798. mark(tw, def, false);
  9799. node.right.walk(tw);
  9800. mark(tw, def, true);
  9801. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  9802. return true;
  9803. });
  9804. def_reduce_vars(AST_Binary, function(tw) {
  9805. if (!lazy_op.has(this.operator)) return;
  9806. this.left.walk(tw);
  9807. push(tw);
  9808. this.right.walk(tw);
  9809. pop(tw);
  9810. return true;
  9811. });
  9812. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  9813. reset_block_variables(compressor, this);
  9814. });
  9815. def_reduce_vars(AST_Case, function(tw) {
  9816. push(tw);
  9817. this.expression.walk(tw);
  9818. pop(tw);
  9819. push(tw);
  9820. walk_body(this, tw);
  9821. pop(tw);
  9822. return true;
  9823. });
  9824. def_reduce_vars(AST_Class, function(tw, descend) {
  9825. clear_flag(this, INLINED);
  9826. push(tw);
  9827. descend();
  9828. pop(tw);
  9829. return true;
  9830. });
  9831. def_reduce_vars(AST_Conditional, function(tw) {
  9832. this.condition.walk(tw);
  9833. push(tw);
  9834. this.consequent.walk(tw);
  9835. pop(tw);
  9836. push(tw);
  9837. this.alternative.walk(tw);
  9838. pop(tw);
  9839. return true;
  9840. });
  9841. def_reduce_vars(AST_Chain, function(tw, descend) {
  9842. // Chains' conditions apply left-to-right, cumulatively.
  9843. // If we walk normally we don't go in that order because we would pop before pushing again
  9844. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  9845. // Then we pop everything when they are done being walked.
  9846. const safe_ids = tw.safe_ids;
  9847. descend();
  9848. // Unroll back to start
  9849. tw.safe_ids = safe_ids;
  9850. return true;
  9851. });
  9852. def_reduce_vars(AST_Call, function (tw) {
  9853. // TODO this block should just be { return } but
  9854. // for some reason the _walk function of AST_Call walks the callee last
  9855. this.expression.walk(tw);
  9856. if (this.optional) {
  9857. // Never pop -- it's popped at AST_Chain above
  9858. push(tw);
  9859. }
  9860. for (const arg of this.args) arg.walk(tw);
  9861. return true;
  9862. });
  9863. def_reduce_vars(AST_PropAccess, function (tw) {
  9864. if (!this.optional) return;
  9865. this.expression.walk(tw);
  9866. // Never pop -- it's popped at AST_Chain above
  9867. push(tw);
  9868. if (this.property instanceof AST_Node) this.property.walk(tw);
  9869. return true;
  9870. });
  9871. def_reduce_vars(AST_Default, function(tw, descend) {
  9872. push(tw);
  9873. descend();
  9874. pop(tw);
  9875. return true;
  9876. });
  9877. function mark_lambda(tw, descend, compressor) {
  9878. clear_flag(this, INLINED);
  9879. push(tw);
  9880. reset_variables(tw, compressor, this);
  9881. if (this.uses_arguments) {
  9882. descend();
  9883. pop(tw);
  9884. return;
  9885. }
  9886. var iife;
  9887. if (!this.name
  9888. && (iife = tw.parent()) instanceof AST_Call
  9889. && iife.expression === this
  9890. && !iife.args.some(arg => arg instanceof AST_Expansion)
  9891. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  9892. ) {
  9893. // Virtually turn IIFE parameters into variable definitions:
  9894. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  9895. // So existing transformation rules can work on them.
  9896. this.argnames.forEach((arg, i) => {
  9897. if (!arg.definition) return;
  9898. var d = arg.definition();
  9899. // Avoid setting fixed when there's more than one origin for a variable value
  9900. if (d.orig.length > 1) return;
  9901. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  9902. d.fixed = function() {
  9903. return iife.args[i] || make_node(AST_Undefined, iife);
  9904. };
  9905. tw.loop_ids.set(d.id, tw.in_loop);
  9906. mark(tw, d, true);
  9907. } else {
  9908. d.fixed = false;
  9909. }
  9910. });
  9911. }
  9912. descend();
  9913. pop(tw);
  9914. return true;
  9915. }
  9916. def_reduce_vars(AST_Lambda, mark_lambda);
  9917. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  9918. reset_block_variables(compressor, this);
  9919. const saved_loop = tw.in_loop;
  9920. tw.in_loop = this;
  9921. push(tw);
  9922. this.body.walk(tw);
  9923. if (has_break_or_continue(this)) {
  9924. pop(tw);
  9925. push(tw);
  9926. }
  9927. this.condition.walk(tw);
  9928. pop(tw);
  9929. tw.in_loop = saved_loop;
  9930. return true;
  9931. });
  9932. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  9933. reset_block_variables(compressor, this);
  9934. if (this.init) this.init.walk(tw);
  9935. const saved_loop = tw.in_loop;
  9936. tw.in_loop = this;
  9937. push(tw);
  9938. if (this.condition) this.condition.walk(tw);
  9939. this.body.walk(tw);
  9940. if (this.step) {
  9941. if (has_break_or_continue(this)) {
  9942. pop(tw);
  9943. push(tw);
  9944. }
  9945. this.step.walk(tw);
  9946. }
  9947. pop(tw);
  9948. tw.in_loop = saved_loop;
  9949. return true;
  9950. });
  9951. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  9952. reset_block_variables(compressor, this);
  9953. suppress(this.init);
  9954. this.object.walk(tw);
  9955. const saved_loop = tw.in_loop;
  9956. tw.in_loop = this;
  9957. push(tw);
  9958. this.body.walk(tw);
  9959. pop(tw);
  9960. tw.in_loop = saved_loop;
  9961. return true;
  9962. });
  9963. def_reduce_vars(AST_If, function(tw) {
  9964. this.condition.walk(tw);
  9965. push(tw);
  9966. this.body.walk(tw);
  9967. pop(tw);
  9968. if (this.alternative) {
  9969. push(tw);
  9970. this.alternative.walk(tw);
  9971. pop(tw);
  9972. }
  9973. return true;
  9974. });
  9975. def_reduce_vars(AST_LabeledStatement, function(tw) {
  9976. push(tw);
  9977. this.body.walk(tw);
  9978. pop(tw);
  9979. return true;
  9980. });
  9981. def_reduce_vars(AST_SymbolCatch, function() {
  9982. this.definition().fixed = false;
  9983. });
  9984. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  9985. var d = this.definition();
  9986. d.references.push(this);
  9987. if (d.references.length == 1
  9988. && !d.fixed
  9989. && d.orig[0] instanceof AST_SymbolDefun) {
  9990. tw.loop_ids.set(d.id, tw.in_loop);
  9991. }
  9992. var fixed_value;
  9993. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  9994. d.fixed = false;
  9995. } else if (d.fixed) {
  9996. fixed_value = this.fixed_value();
  9997. if (
  9998. fixed_value instanceof AST_Lambda
  9999. && recursive_ref(tw, d)
  10000. ) {
  10001. d.recursive_refs++;
  10002. } else if (fixed_value
  10003. && !compressor.exposed(d)
  10004. && ref_once(tw, compressor, d)
  10005. ) {
  10006. d.single_use =
  10007. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  10008. || fixed_value instanceof AST_Class
  10009. || d.scope === this.scope && fixed_value.is_constant_expression();
  10010. } else {
  10011. d.single_use = false;
  10012. }
  10013. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  10014. if (d.single_use) {
  10015. d.single_use = "m";
  10016. } else {
  10017. d.fixed = false;
  10018. }
  10019. }
  10020. }
  10021. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  10022. });
  10023. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  10024. this.globals.forEach(function(def) {
  10025. reset_def(compressor, def);
  10026. });
  10027. reset_variables(tw, compressor, this);
  10028. });
  10029. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  10030. reset_block_variables(compressor, this);
  10031. push(tw);
  10032. walk_body(this, tw);
  10033. pop(tw);
  10034. if (this.bcatch) {
  10035. push(tw);
  10036. this.bcatch.walk(tw);
  10037. pop(tw);
  10038. }
  10039. if (this.bfinally) this.bfinally.walk(tw);
  10040. return true;
  10041. });
  10042. def_reduce_vars(AST_Unary, function(tw) {
  10043. var node = this;
  10044. if (node.operator !== "++" && node.operator !== "--") return;
  10045. var exp = node.expression;
  10046. if (!(exp instanceof AST_SymbolRef)) return;
  10047. var def = exp.definition();
  10048. var safe = safe_to_assign(tw, def, exp.scope, true);
  10049. def.assignments++;
  10050. if (!safe) return;
  10051. var fixed = def.fixed;
  10052. if (!fixed) return;
  10053. def.references.push(exp);
  10054. def.chained = true;
  10055. def.fixed = function() {
  10056. return make_node(AST_Binary, node, {
  10057. operator: node.operator.slice(0, -1),
  10058. left: make_node(AST_UnaryPrefix, node, {
  10059. operator: "+",
  10060. expression: fixed instanceof AST_Node ? fixed : fixed()
  10061. }),
  10062. right: make_node(AST_Number, node, {
  10063. value: 1
  10064. })
  10065. });
  10066. };
  10067. mark(tw, def, true);
  10068. return true;
  10069. });
  10070. def_reduce_vars(AST_VarDef, function(tw, descend) {
  10071. var node = this;
  10072. if (node.name instanceof AST_Destructuring) {
  10073. suppress(node.name);
  10074. return;
  10075. }
  10076. var d = node.name.definition();
  10077. if (node.value) {
  10078. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  10079. d.fixed = function() {
  10080. return node.value;
  10081. };
  10082. tw.loop_ids.set(d.id, tw.in_loop);
  10083. mark(tw, d, false);
  10084. descend();
  10085. mark(tw, d, true);
  10086. return true;
  10087. } else {
  10088. d.fixed = false;
  10089. }
  10090. }
  10091. });
  10092. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  10093. reset_block_variables(compressor, this);
  10094. const saved_loop = tw.in_loop;
  10095. tw.in_loop = this;
  10096. push(tw);
  10097. descend();
  10098. pop(tw);
  10099. tw.in_loop = saved_loop;
  10100. return true;
  10101. });
  10102. })(function(node, func) {
  10103. node.DEFMETHOD("reduce_vars", func);
  10104. });
  10105. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  10106. const self = this;
  10107. const reduce_vars = compressor.option("reduce_vars");
  10108. const preparation = new TreeWalker(function(node, descend) {
  10109. clear_flag(node, CLEAR_BETWEEN_PASSES);
  10110. if (reduce_vars) {
  10111. if (compressor.top_retain
  10112. && node instanceof AST_Defun // Only functions are retained
  10113. && preparation.parent() === self
  10114. ) {
  10115. set_flag(node, TOP);
  10116. }
  10117. return node.reduce_vars(preparation, descend, compressor);
  10118. }
  10119. });
  10120. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  10121. // properly assigned before use:
  10122. // - `push()` & `pop()` when visiting conditional branches
  10123. preparation.safe_ids = Object.create(null);
  10124. preparation.in_loop = null;
  10125. preparation.loop_ids = new Map();
  10126. preparation.defs_to_safe_ids = new Map();
  10127. self.walk(preparation);
  10128. });
  10129. AST_Symbol.DEFMETHOD("fixed_value", function() {
  10130. var fixed = this.thedef.fixed;
  10131. if (!fixed || fixed instanceof AST_Node) return fixed;
  10132. return fixed();
  10133. });
  10134. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  10135. var orig = this.definition().orig;
  10136. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  10137. });
  10138. function is_func_expr(node) {
  10139. return node instanceof AST_Arrow || node instanceof AST_Function;
  10140. }
  10141. function is_lhs_read_only(lhs) {
  10142. if (lhs instanceof AST_This) return true;
  10143. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  10144. if (lhs instanceof AST_PropAccess) {
  10145. lhs = lhs.expression;
  10146. if (lhs instanceof AST_SymbolRef) {
  10147. if (lhs.is_immutable()) return false;
  10148. lhs = lhs.fixed_value();
  10149. }
  10150. if (!lhs) return true;
  10151. if (lhs instanceof AST_RegExp) return false;
  10152. if (lhs instanceof AST_Constant) return true;
  10153. return is_lhs_read_only(lhs);
  10154. }
  10155. return false;
  10156. }
  10157. function is_ref_of(ref, type) {
  10158. if (!(ref instanceof AST_SymbolRef)) return false;
  10159. var orig = ref.definition().orig;
  10160. for (var i = orig.length; --i >= 0;) {
  10161. if (orig[i] instanceof type) return true;
  10162. }
  10163. }
  10164. function find_scope(tw) {
  10165. for (let i = 0;;i++) {
  10166. const p = tw.parent(i);
  10167. if (p instanceof AST_Toplevel) return p;
  10168. if (p instanceof AST_Lambda) return p;
  10169. if (p.block_scope) return p.block_scope;
  10170. }
  10171. }
  10172. function find_variable(compressor, name) {
  10173. var scope, i = 0;
  10174. while (scope = compressor.parent(i++)) {
  10175. if (scope instanceof AST_Scope) break;
  10176. if (scope instanceof AST_Catch && scope.argname) {
  10177. scope = scope.argname.definition().scope;
  10178. break;
  10179. }
  10180. }
  10181. return scope.find_variable(name);
  10182. }
  10183. function make_sequence(orig, expressions) {
  10184. if (expressions.length == 1) return expressions[0];
  10185. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  10186. return make_node(AST_Sequence, orig, {
  10187. expressions: expressions.reduce(merge_sequence, [])
  10188. });
  10189. }
  10190. function make_node_from_constant(val, orig) {
  10191. switch (typeof val) {
  10192. case "string":
  10193. return make_node(AST_String, orig, {
  10194. value: val
  10195. });
  10196. case "number":
  10197. if (isNaN(val)) return make_node(AST_NaN, orig);
  10198. if (isFinite(val)) {
  10199. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  10200. operator: "-",
  10201. expression: make_node(AST_Number, orig, { value: -val })
  10202. }) : make_node(AST_Number, orig, { value: val });
  10203. }
  10204. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  10205. operator: "-",
  10206. expression: make_node(AST_Infinity, orig)
  10207. }) : make_node(AST_Infinity, orig);
  10208. case "boolean":
  10209. return make_node(val ? AST_True : AST_False, orig);
  10210. case "undefined":
  10211. return make_node(AST_Undefined, orig);
  10212. default:
  10213. if (val === null) {
  10214. return make_node(AST_Null, orig, { value: null });
  10215. }
  10216. if (val instanceof RegExp) {
  10217. return make_node(AST_RegExp, orig, {
  10218. value: {
  10219. source: regexp_source_fix(val.source),
  10220. flags: val.flags
  10221. }
  10222. });
  10223. }
  10224. throw new Error(string_template("Can't handle constant of type: {type}", {
  10225. type: typeof val
  10226. }));
  10227. }
  10228. }
  10229. // we shouldn't compress (1,func)(something) to
  10230. // func(something) because that changes the meaning of
  10231. // the func (becomes lexical instead of global).
  10232. function maintain_this_binding(parent, orig, val) {
  10233. if (parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  10234. || parent instanceof AST_Call && parent.expression === orig
  10235. && (val instanceof AST_PropAccess || val instanceof AST_SymbolRef && val.name == "eval")) {
  10236. return make_sequence(orig, [ make_node(AST_Number, orig, { value: 0 }), val ]);
  10237. }
  10238. return val;
  10239. }
  10240. function merge_sequence(array, node) {
  10241. if (node instanceof AST_Sequence) {
  10242. array.push(...node.expressions);
  10243. } else {
  10244. array.push(node);
  10245. }
  10246. return array;
  10247. }
  10248. function as_statement_array(thing) {
  10249. if (thing === null) return [];
  10250. if (thing instanceof AST_BlockStatement) return thing.body;
  10251. if (thing instanceof AST_EmptyStatement) return [];
  10252. if (thing instanceof AST_Statement) return [ thing ];
  10253. throw new Error("Can't convert thing to statement array");
  10254. }
  10255. function is_empty(thing) {
  10256. if (thing === null) return true;
  10257. if (thing instanceof AST_EmptyStatement) return true;
  10258. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  10259. return false;
  10260. }
  10261. function can_be_evicted_from_block(node) {
  10262. return !(
  10263. node instanceof AST_DefClass ||
  10264. node instanceof AST_Defun ||
  10265. node instanceof AST_Let ||
  10266. node instanceof AST_Const ||
  10267. node instanceof AST_Export ||
  10268. node instanceof AST_Import
  10269. );
  10270. }
  10271. function loop_body(x) {
  10272. if (x instanceof AST_IterationStatement) {
  10273. return x.body instanceof AST_BlockStatement ? x.body : x;
  10274. }
  10275. return x;
  10276. }
  10277. function is_iife_call(node) {
  10278. // Used to determine whether the node can benefit from negation.
  10279. // Not the case with arrow functions (you need an extra set of parens).
  10280. if (node.TYPE != "Call") return false;
  10281. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  10282. }
  10283. function is_undeclared_ref(node) {
  10284. return node instanceof AST_SymbolRef && node.definition().undeclared;
  10285. }
  10286. 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");
  10287. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  10288. return !this.definition().undeclared
  10289. || compressor.option("unsafe") && global_names.has(this.name);
  10290. });
  10291. var identifier_atom = makePredicate("Infinity NaN undefined");
  10292. function is_identifier_atom(node) {
  10293. return node instanceof AST_Infinity
  10294. || node instanceof AST_NaN
  10295. || node instanceof AST_Undefined;
  10296. }
  10297. // Tighten a bunch of statements together. Used whenever there is a block.
  10298. function tighten_body(statements, compressor) {
  10299. var in_loop, in_try;
  10300. var scope = compressor.find_parent(AST_Scope).get_defun_scope();
  10301. find_loop_scope_try();
  10302. var CHANGED, max_iter = 10;
  10303. do {
  10304. CHANGED = false;
  10305. eliminate_spurious_blocks(statements);
  10306. if (compressor.option("dead_code")) {
  10307. eliminate_dead_code(statements, compressor);
  10308. }
  10309. if (compressor.option("if_return")) {
  10310. handle_if_return(statements, compressor);
  10311. }
  10312. if (compressor.sequences_limit > 0) {
  10313. sequencesize(statements, compressor);
  10314. sequencesize_2(statements, compressor);
  10315. }
  10316. if (compressor.option("join_vars")) {
  10317. join_consecutive_vars(statements);
  10318. }
  10319. if (compressor.option("collapse_vars")) {
  10320. collapse(statements, compressor);
  10321. }
  10322. } while (CHANGED && max_iter-- > 0);
  10323. function find_loop_scope_try() {
  10324. var node = compressor.self(), level = 0;
  10325. do {
  10326. if (node instanceof AST_Catch || node instanceof AST_Finally) {
  10327. level++;
  10328. } else if (node instanceof AST_IterationStatement) {
  10329. in_loop = true;
  10330. } else if (node instanceof AST_Scope) {
  10331. scope = node;
  10332. break;
  10333. } else if (node instanceof AST_Try) {
  10334. in_try = true;
  10335. }
  10336. } while (node = compressor.parent(level++));
  10337. }
  10338. // Search from right to left for assignment-like expressions:
  10339. // - `var a = x;`
  10340. // - `a = x;`
  10341. // - `++a`
  10342. // For each candidate, scan from left to right for first usage, then try
  10343. // to fold assignment into the site for compression.
  10344. // Will not attempt to collapse assignments into or past code blocks
  10345. // which are not sequentially executed, e.g. loops and conditionals.
  10346. function collapse(statements, compressor) {
  10347. if (scope.pinned()) return statements;
  10348. var args;
  10349. var candidates = [];
  10350. var stat_index = statements.length;
  10351. var scanner = new TreeTransformer(function(node) {
  10352. if (abort) return node;
  10353. // Skip nodes before `candidate` as quickly as possible
  10354. if (!hit) {
  10355. if (node !== hit_stack[hit_index]) return node;
  10356. hit_index++;
  10357. if (hit_index < hit_stack.length) return handle_custom_scan_order(node);
  10358. hit = true;
  10359. stop_after = find_stop(node, 0);
  10360. if (stop_after === node) abort = true;
  10361. return node;
  10362. }
  10363. // Stop immediately if these node types are encountered
  10364. var parent = scanner.parent();
  10365. if (node instanceof AST_Assign && node.operator != "=" && lhs.equivalent_to(node.left)
  10366. || node instanceof AST_Await
  10367. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  10368. || node instanceof AST_Debugger
  10369. || node instanceof AST_Destructuring
  10370. || node instanceof AST_Expansion
  10371. && node.expression instanceof AST_Symbol
  10372. && node.expression.definition().references.length > 1
  10373. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  10374. || node instanceof AST_LoopControl
  10375. || node instanceof AST_Try
  10376. || node instanceof AST_With
  10377. || node instanceof AST_Yield
  10378. || node instanceof AST_Export
  10379. || node instanceof AST_Class
  10380. || parent instanceof AST_For && node !== parent.init
  10381. || !replace_all
  10382. && (
  10383. node instanceof AST_SymbolRef
  10384. && !node.is_declared(compressor)
  10385. && !pure_prop_access_globals.has(node))
  10386. || node instanceof AST_SymbolRef
  10387. && parent instanceof AST_Call
  10388. && has_annotation(parent, _NOINLINE)
  10389. ) {
  10390. abort = true;
  10391. return node;
  10392. }
  10393. // Stop only if candidate is found within conditional branches
  10394. if (!stop_if_hit && (!lhs_local || !replace_all)
  10395. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  10396. || parent instanceof AST_Conditional && parent.condition !== node
  10397. || parent instanceof AST_If && parent.condition !== node)) {
  10398. stop_if_hit = parent;
  10399. }
  10400. // Replace variable with assignment when found
  10401. if (can_replace
  10402. && !(node instanceof AST_SymbolDeclaration)
  10403. && lhs.equivalent_to(node)
  10404. ) {
  10405. if (stop_if_hit) {
  10406. abort = true;
  10407. return node;
  10408. }
  10409. if (is_lhs(node, parent)) {
  10410. if (value_def) replaced++;
  10411. return node;
  10412. } else {
  10413. replaced++;
  10414. if (value_def && candidate instanceof AST_VarDef) return node;
  10415. }
  10416. CHANGED = abort = true;
  10417. if (candidate instanceof AST_UnaryPostfix) {
  10418. return make_node(AST_UnaryPrefix, candidate, candidate);
  10419. }
  10420. if (candidate instanceof AST_VarDef) {
  10421. var def = candidate.name.definition();
  10422. var value = candidate.value;
  10423. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  10424. def.replaced++;
  10425. if (funarg && is_identifier_atom(value)) {
  10426. return value.transform(compressor);
  10427. } else {
  10428. return maintain_this_binding(parent, node, value);
  10429. }
  10430. }
  10431. return make_node(AST_Assign, candidate, {
  10432. operator: "=",
  10433. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  10434. right: value
  10435. });
  10436. }
  10437. clear_flag(candidate, WRITE_ONLY);
  10438. return candidate;
  10439. }
  10440. // These node types have child nodes that execute sequentially,
  10441. // but are otherwise not safe to scan into or beyond them.
  10442. var sym;
  10443. if (node instanceof AST_Call
  10444. || node instanceof AST_Exit
  10445. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  10446. || node instanceof AST_PropAccess
  10447. && (side_effects || node.expression.may_throw_on_access(compressor))
  10448. || node instanceof AST_SymbolRef
  10449. && (lvalues.get(node.name) || side_effects && may_modify(node))
  10450. || node instanceof AST_VarDef && node.value
  10451. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  10452. || (sym = is_lhs(node.left, node))
  10453. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  10454. || may_throw
  10455. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  10456. stop_after = node;
  10457. if (node instanceof AST_Scope) abort = true;
  10458. }
  10459. return handle_custom_scan_order(node);
  10460. }, function(node) {
  10461. if (abort) return;
  10462. if (stop_after === node) abort = true;
  10463. if (stop_if_hit === node) stop_if_hit = null;
  10464. });
  10465. var multi_replacer = new TreeTransformer(function(node) {
  10466. if (abort) return node;
  10467. // Skip nodes before `candidate` as quickly as possible
  10468. if (!hit) {
  10469. if (node !== hit_stack[hit_index]) return node;
  10470. hit_index++;
  10471. if (hit_index < hit_stack.length) return;
  10472. hit = true;
  10473. return node;
  10474. }
  10475. // Replace variable when found
  10476. if (node instanceof AST_SymbolRef
  10477. && node.name == def.name) {
  10478. if (!--replaced) abort = true;
  10479. if (is_lhs(node, multi_replacer.parent())) return node;
  10480. def.replaced++;
  10481. value_def.replaced--;
  10482. return candidate.value;
  10483. }
  10484. // Skip (non-executed) functions and (leading) default case in switch statements
  10485. if (node instanceof AST_Default || node instanceof AST_Scope) return node;
  10486. });
  10487. while (--stat_index >= 0) {
  10488. // Treat parameters as collapsible in IIFE, i.e.
  10489. // function(a, b){ ... }(x());
  10490. // would be translated into equivalent assignments:
  10491. // var a = x(), b = undefined;
  10492. if (stat_index == 0 && compressor.option("unused")) extract_args();
  10493. // Find collapsible assignments
  10494. var hit_stack = [];
  10495. extract_candidates(statements[stat_index]);
  10496. while (candidates.length > 0) {
  10497. hit_stack = candidates.pop();
  10498. var hit_index = 0;
  10499. var candidate = hit_stack[hit_stack.length - 1];
  10500. var value_def = null;
  10501. var stop_after = null;
  10502. var stop_if_hit = null;
  10503. var lhs = get_lhs(candidate);
  10504. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor)) continue;
  10505. // Locate symbols which may execute code outside of scanning range
  10506. var lvalues = get_lvalues(candidate);
  10507. var lhs_local = is_lhs_local(lhs);
  10508. if (lhs instanceof AST_SymbolRef) lvalues.set(lhs.name, false);
  10509. var side_effects = value_has_side_effects(candidate);
  10510. var replace_all = replace_all_symbols();
  10511. var may_throw = candidate.may_throw(compressor);
  10512. var funarg = candidate.name instanceof AST_SymbolFunarg;
  10513. var hit = funarg;
  10514. var abort = false, replaced = 0, can_replace = !args || !hit;
  10515. if (!can_replace) {
  10516. for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
  10517. args[j].transform(scanner);
  10518. }
  10519. can_replace = true;
  10520. }
  10521. for (var i = stat_index; !abort && i < statements.length; i++) {
  10522. statements[i].transform(scanner);
  10523. }
  10524. if (value_def) {
  10525. var def = candidate.name.definition();
  10526. if (abort && def.references.length - def.replaced > replaced) replaced = false;
  10527. else {
  10528. abort = false;
  10529. hit_index = 0;
  10530. hit = funarg;
  10531. for (var i = stat_index; !abort && i < statements.length; i++) {
  10532. statements[i].transform(multi_replacer);
  10533. }
  10534. value_def.single_use = false;
  10535. }
  10536. }
  10537. if (replaced && !remove_candidate(candidate)) statements.splice(stat_index, 1);
  10538. }
  10539. }
  10540. function handle_custom_scan_order(node) {
  10541. // Skip (non-executed) functions
  10542. if (node instanceof AST_Scope) return node;
  10543. // Scan case expressions first in a switch statement
  10544. if (node instanceof AST_Switch) {
  10545. node.expression = node.expression.transform(scanner);
  10546. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  10547. var branch = node.body[i];
  10548. if (branch instanceof AST_Case) {
  10549. if (!hit) {
  10550. if (branch !== hit_stack[hit_index]) continue;
  10551. hit_index++;
  10552. }
  10553. branch.expression = branch.expression.transform(scanner);
  10554. if (!replace_all) break;
  10555. }
  10556. }
  10557. abort = true;
  10558. return node;
  10559. }
  10560. }
  10561. function redefined_within_scope(def, scope) {
  10562. if (def.global) return false;
  10563. let cur_scope = def.scope;
  10564. while (cur_scope && cur_scope !== scope) {
  10565. if (cur_scope.variables.has(def.name)) return true;
  10566. cur_scope = cur_scope.parent_scope;
  10567. }
  10568. return false;
  10569. }
  10570. function has_overlapping_symbol(fn, arg, fn_strict) {
  10571. var found = false, scan_this = !(fn instanceof AST_Arrow);
  10572. arg.walk(new TreeWalker(function(node, descend) {
  10573. if (found) return true;
  10574. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  10575. var s = node.definition().scope;
  10576. if (s !== scope) while (s = s.parent_scope) {
  10577. if (s === scope) return true;
  10578. }
  10579. return found = true;
  10580. }
  10581. if ((fn_strict || scan_this) && node instanceof AST_This) {
  10582. return found = true;
  10583. }
  10584. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  10585. var prev = scan_this;
  10586. scan_this = false;
  10587. descend();
  10588. scan_this = prev;
  10589. return true;
  10590. }
  10591. }));
  10592. return found;
  10593. }
  10594. function extract_args() {
  10595. var iife, fn = compressor.self();
  10596. if (is_func_expr(fn)
  10597. && !fn.name
  10598. && !fn.uses_arguments
  10599. && !fn.pinned()
  10600. && (iife = compressor.parent()) instanceof AST_Call
  10601. && iife.expression === fn
  10602. && iife.args.every((arg) => !(arg instanceof AST_Expansion))
  10603. ) {
  10604. var fn_strict = compressor.has_directive("use strict");
  10605. if (fn_strict && !member(fn_strict, fn.body)) fn_strict = false;
  10606. var len = fn.argnames.length;
  10607. args = iife.args.slice(len);
  10608. var names = new Set();
  10609. for (var i = len; --i >= 0;) {
  10610. var sym = fn.argnames[i];
  10611. var arg = iife.args[i];
  10612. // The following two line fix is a duplicate of the fix at
  10613. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  10614. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  10615. // Might be doing the exact same thing.
  10616. const def = sym.definition && sym.definition();
  10617. const is_reassigned = def && def.orig.length > 1;
  10618. if (is_reassigned) continue;
  10619. args.unshift(make_node(AST_VarDef, sym, {
  10620. name: sym,
  10621. value: arg
  10622. }));
  10623. if (names.has(sym.name)) continue;
  10624. names.add(sym.name);
  10625. if (sym instanceof AST_Expansion) {
  10626. var elements = iife.args.slice(i);
  10627. if (elements.every((arg) =>
  10628. !has_overlapping_symbol(fn, arg, fn_strict)
  10629. )) {
  10630. candidates.unshift([ make_node(AST_VarDef, sym, {
  10631. name: sym.expression,
  10632. value: make_node(AST_Array, iife, {
  10633. elements: elements
  10634. })
  10635. }) ]);
  10636. }
  10637. } else {
  10638. if (!arg) {
  10639. arg = make_node(AST_Undefined, sym).transform(compressor);
  10640. } else if (arg instanceof AST_Lambda && arg.pinned()
  10641. || has_overlapping_symbol(fn, arg, fn_strict)
  10642. ) {
  10643. arg = null;
  10644. }
  10645. if (arg) candidates.unshift([ make_node(AST_VarDef, sym, {
  10646. name: sym,
  10647. value: arg
  10648. }) ]);
  10649. }
  10650. }
  10651. }
  10652. }
  10653. function extract_candidates(expr) {
  10654. hit_stack.push(expr);
  10655. if (expr instanceof AST_Assign) {
  10656. if (!expr.left.has_side_effects(compressor)) {
  10657. candidates.push(hit_stack.slice());
  10658. }
  10659. extract_candidates(expr.right);
  10660. } else if (expr instanceof AST_Binary) {
  10661. extract_candidates(expr.left);
  10662. extract_candidates(expr.right);
  10663. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  10664. extract_candidates(expr.expression);
  10665. expr.args.forEach(extract_candidates);
  10666. } else if (expr instanceof AST_Case) {
  10667. extract_candidates(expr.expression);
  10668. } else if (expr instanceof AST_Conditional) {
  10669. extract_candidates(expr.condition);
  10670. extract_candidates(expr.consequent);
  10671. extract_candidates(expr.alternative);
  10672. } else if (expr instanceof AST_Definitions) {
  10673. var len = expr.definitions.length;
  10674. // limit number of trailing variable definitions for consideration
  10675. var i = len - 200;
  10676. if (i < 0) i = 0;
  10677. for (; i < len; i++) {
  10678. extract_candidates(expr.definitions[i]);
  10679. }
  10680. } else if (expr instanceof AST_DWLoop) {
  10681. extract_candidates(expr.condition);
  10682. if (!(expr.body instanceof AST_Block)) {
  10683. extract_candidates(expr.body);
  10684. }
  10685. } else if (expr instanceof AST_Exit) {
  10686. if (expr.value) extract_candidates(expr.value);
  10687. } else if (expr instanceof AST_For) {
  10688. if (expr.init) extract_candidates(expr.init);
  10689. if (expr.condition) extract_candidates(expr.condition);
  10690. if (expr.step) extract_candidates(expr.step);
  10691. if (!(expr.body instanceof AST_Block)) {
  10692. extract_candidates(expr.body);
  10693. }
  10694. } else if (expr instanceof AST_ForIn) {
  10695. extract_candidates(expr.object);
  10696. if (!(expr.body instanceof AST_Block)) {
  10697. extract_candidates(expr.body);
  10698. }
  10699. } else if (expr instanceof AST_If) {
  10700. extract_candidates(expr.condition);
  10701. if (!(expr.body instanceof AST_Block)) {
  10702. extract_candidates(expr.body);
  10703. }
  10704. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  10705. extract_candidates(expr.alternative);
  10706. }
  10707. } else if (expr instanceof AST_Sequence) {
  10708. expr.expressions.forEach(extract_candidates);
  10709. } else if (expr instanceof AST_SimpleStatement) {
  10710. extract_candidates(expr.body);
  10711. } else if (expr instanceof AST_Switch) {
  10712. extract_candidates(expr.expression);
  10713. expr.body.forEach(extract_candidates);
  10714. } else if (expr instanceof AST_Unary) {
  10715. if (expr.operator == "++" || expr.operator == "--") {
  10716. candidates.push(hit_stack.slice());
  10717. }
  10718. } else if (expr instanceof AST_VarDef) {
  10719. if (expr.value) {
  10720. candidates.push(hit_stack.slice());
  10721. extract_candidates(expr.value);
  10722. }
  10723. }
  10724. hit_stack.pop();
  10725. }
  10726. function find_stop(node, level, write_only) {
  10727. var parent = scanner.parent(level);
  10728. if (parent instanceof AST_Assign) {
  10729. if (write_only
  10730. && !(parent.left instanceof AST_PropAccess
  10731. || lvalues.has(parent.left.name))) {
  10732. return find_stop(parent, level + 1, write_only);
  10733. }
  10734. return node;
  10735. }
  10736. if (parent instanceof AST_Binary) {
  10737. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  10738. return find_stop(parent, level + 1, write_only);
  10739. }
  10740. return node;
  10741. }
  10742. if (parent instanceof AST_Call) return node;
  10743. if (parent instanceof AST_Case) return node;
  10744. if (parent instanceof AST_Conditional) {
  10745. if (write_only && parent.condition === node) {
  10746. return find_stop(parent, level + 1, write_only);
  10747. }
  10748. return node;
  10749. }
  10750. if (parent instanceof AST_Definitions) {
  10751. return find_stop(parent, level + 1, true);
  10752. }
  10753. if (parent instanceof AST_Exit) {
  10754. return write_only ? find_stop(parent, level + 1, write_only) : node;
  10755. }
  10756. if (parent instanceof AST_If) {
  10757. if (write_only && parent.condition === node) {
  10758. return find_stop(parent, level + 1, write_only);
  10759. }
  10760. return node;
  10761. }
  10762. if (parent instanceof AST_IterationStatement) return node;
  10763. if (parent instanceof AST_Sequence) {
  10764. return find_stop(parent, level + 1, parent.tail_node() !== node);
  10765. }
  10766. if (parent instanceof AST_SimpleStatement) {
  10767. return find_stop(parent, level + 1, true);
  10768. }
  10769. if (parent instanceof AST_Switch) return node;
  10770. if (parent instanceof AST_VarDef) return node;
  10771. return null;
  10772. }
  10773. function mangleable_var(var_def) {
  10774. var value = var_def.value;
  10775. if (!(value instanceof AST_SymbolRef)) return;
  10776. if (value.name == "arguments") return;
  10777. var def = value.definition();
  10778. if (def.undeclared) return;
  10779. return value_def = def;
  10780. }
  10781. function get_lhs(expr) {
  10782. if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  10783. var def = expr.name.definition();
  10784. if (!member(expr.name, def.orig)) return;
  10785. var referenced = def.references.length - def.replaced;
  10786. if (!referenced) return;
  10787. var declared = def.orig.length - def.eliminated;
  10788. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  10789. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  10790. return make_node(AST_SymbolRef, expr.name, expr.name);
  10791. }
  10792. } else {
  10793. const lhs = expr[expr instanceof AST_Assign ? "left" : "expression"];
  10794. return !is_ref_of(lhs, AST_SymbolConst)
  10795. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  10796. }
  10797. }
  10798. function get_rvalue(expr) {
  10799. return expr[expr instanceof AST_Assign ? "right" : "value"];
  10800. }
  10801. function get_lvalues(expr) {
  10802. var lvalues = new Map();
  10803. if (expr instanceof AST_Unary) return lvalues;
  10804. var tw = new TreeWalker(function(node) {
  10805. var sym = node;
  10806. while (sym instanceof AST_PropAccess) sym = sym.expression;
  10807. if (sym instanceof AST_SymbolRef || sym instanceof AST_This) {
  10808. lvalues.set(sym.name, lvalues.get(sym.name) || is_modified(compressor, tw, node, node, 0));
  10809. }
  10810. });
  10811. get_rvalue(expr).walk(tw);
  10812. return lvalues;
  10813. }
  10814. function remove_candidate(expr) {
  10815. if (expr.name instanceof AST_SymbolFunarg) {
  10816. var iife = compressor.parent(), argnames = compressor.self().argnames;
  10817. var index = argnames.indexOf(expr.name);
  10818. if (index < 0) {
  10819. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  10820. } else {
  10821. var args = iife.args;
  10822. if (args[index]) args[index] = make_node(AST_Number, args[index], {
  10823. value: 0
  10824. });
  10825. }
  10826. return true;
  10827. }
  10828. var found = false;
  10829. return statements[stat_index].transform(new TreeTransformer(function(node, descend, in_list) {
  10830. if (found) return node;
  10831. if (node === expr || node.body === expr) {
  10832. found = true;
  10833. if (node instanceof AST_VarDef) {
  10834. node.value = node.name instanceof AST_SymbolConst
  10835. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  10836. : null;
  10837. return node;
  10838. }
  10839. return in_list ? MAP.skip : null;
  10840. }
  10841. }, function(node) {
  10842. if (node instanceof AST_Sequence) switch (node.expressions.length) {
  10843. case 0: return null;
  10844. case 1: return node.expressions[0];
  10845. }
  10846. }));
  10847. }
  10848. function is_lhs_local(lhs) {
  10849. while (lhs instanceof AST_PropAccess) lhs = lhs.expression;
  10850. return lhs instanceof AST_SymbolRef
  10851. && lhs.definition().scope === scope
  10852. && !(in_loop
  10853. && (lvalues.has(lhs.name)
  10854. || candidate instanceof AST_Unary
  10855. || candidate instanceof AST_Assign && candidate.operator != "="));
  10856. }
  10857. function value_has_side_effects(expr) {
  10858. if (expr instanceof AST_Unary) return unary_side_effects.has(expr.operator);
  10859. return get_rvalue(expr).has_side_effects(compressor);
  10860. }
  10861. function replace_all_symbols() {
  10862. if (side_effects) return false;
  10863. if (value_def) return true;
  10864. if (lhs instanceof AST_SymbolRef) {
  10865. var def = lhs.definition();
  10866. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  10867. return true;
  10868. }
  10869. }
  10870. return false;
  10871. }
  10872. function may_modify(sym) {
  10873. if (!sym.definition) return true; // AST_Destructuring
  10874. var def = sym.definition();
  10875. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun) return false;
  10876. if (def.scope.get_defun_scope() !== scope) return true;
  10877. return !def.references.every((ref) => {
  10878. var s = ref.scope.get_defun_scope();
  10879. // "block" scope within AST_Catch
  10880. if (s.TYPE == "Scope") s = s.parent_scope;
  10881. return s === scope;
  10882. });
  10883. }
  10884. function side_effects_external(node, lhs) {
  10885. if (node instanceof AST_Assign) return side_effects_external(node.left, true);
  10886. if (node instanceof AST_Unary) return side_effects_external(node.expression, true);
  10887. if (node instanceof AST_VarDef) return node.value && side_effects_external(node.value);
  10888. if (lhs) {
  10889. if (node instanceof AST_Dot) return side_effects_external(node.expression, true);
  10890. if (node instanceof AST_Sub) return side_effects_external(node.expression, true);
  10891. if (node instanceof AST_SymbolRef) return node.definition().scope !== scope;
  10892. }
  10893. return false;
  10894. }
  10895. }
  10896. function eliminate_spurious_blocks(statements) {
  10897. var seen_dirs = [];
  10898. for (var i = 0; i < statements.length;) {
  10899. var stat = statements[i];
  10900. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  10901. CHANGED = true;
  10902. eliminate_spurious_blocks(stat.body);
  10903. statements.splice(i, 1, ...stat.body);
  10904. i += stat.body.length;
  10905. } else if (stat instanceof AST_EmptyStatement) {
  10906. CHANGED = true;
  10907. statements.splice(i, 1);
  10908. } else if (stat instanceof AST_Directive) {
  10909. if (seen_dirs.indexOf(stat.value) < 0) {
  10910. i++;
  10911. seen_dirs.push(stat.value);
  10912. } else {
  10913. CHANGED = true;
  10914. statements.splice(i, 1);
  10915. }
  10916. } else i++;
  10917. }
  10918. }
  10919. function handle_if_return(statements, compressor) {
  10920. var self = compressor.self();
  10921. var multiple_if_returns = has_multiple_if_returns(statements);
  10922. var in_lambda = self instanceof AST_Lambda;
  10923. for (var i = statements.length; --i >= 0;) {
  10924. var stat = statements[i];
  10925. var j = next_index(i);
  10926. var next = statements[j];
  10927. if (in_lambda && !next && stat instanceof AST_Return) {
  10928. if (!stat.value) {
  10929. CHANGED = true;
  10930. statements.splice(i, 1);
  10931. continue;
  10932. }
  10933. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  10934. CHANGED = true;
  10935. statements[i] = make_node(AST_SimpleStatement, stat, {
  10936. body: stat.value.expression
  10937. });
  10938. continue;
  10939. }
  10940. }
  10941. if (stat instanceof AST_If) {
  10942. var ab = aborts(stat.body);
  10943. if (can_merge_flow(ab)) {
  10944. if (ab.label) {
  10945. remove(ab.label.thedef.references, ab);
  10946. }
  10947. CHANGED = true;
  10948. stat = stat.clone();
  10949. stat.condition = stat.condition.negate(compressor);
  10950. var body = as_statement_array_with_return(stat.body, ab);
  10951. stat.body = make_node(AST_BlockStatement, stat, {
  10952. body: as_statement_array(stat.alternative).concat(extract_functions())
  10953. });
  10954. stat.alternative = make_node(AST_BlockStatement, stat, {
  10955. body: body
  10956. });
  10957. statements[i] = stat.transform(compressor);
  10958. continue;
  10959. }
  10960. var ab = aborts(stat.alternative);
  10961. if (can_merge_flow(ab)) {
  10962. if (ab.label) {
  10963. remove(ab.label.thedef.references, ab);
  10964. }
  10965. CHANGED = true;
  10966. stat = stat.clone();
  10967. stat.body = make_node(AST_BlockStatement, stat.body, {
  10968. body: as_statement_array(stat.body).concat(extract_functions())
  10969. });
  10970. var body = as_statement_array_with_return(stat.alternative, ab);
  10971. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  10972. body: body
  10973. });
  10974. statements[i] = stat.transform(compressor);
  10975. continue;
  10976. }
  10977. }
  10978. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  10979. var value = stat.body.value;
  10980. //---
  10981. // pretty silly case, but:
  10982. // if (foo()) return; return; ==> foo(); return;
  10983. if (!value && !stat.alternative
  10984. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  10985. CHANGED = true;
  10986. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  10987. body: stat.condition
  10988. });
  10989. continue;
  10990. }
  10991. //---
  10992. // if (foo()) return x; return y; ==> return foo() ? x : y;
  10993. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  10994. CHANGED = true;
  10995. stat = stat.clone();
  10996. stat.alternative = next;
  10997. statements[i] = stat.transform(compressor);
  10998. statements.splice(j, 1);
  10999. continue;
  11000. }
  11001. //---
  11002. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  11003. if (value && !stat.alternative
  11004. && (!next && in_lambda && multiple_if_returns
  11005. || next instanceof AST_Return)) {
  11006. CHANGED = true;
  11007. stat = stat.clone();
  11008. stat.alternative = next || make_node(AST_Return, stat, {
  11009. value: null
  11010. });
  11011. statements[i] = stat.transform(compressor);
  11012. if (next) statements.splice(j, 1);
  11013. continue;
  11014. }
  11015. //---
  11016. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  11017. //
  11018. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  11019. // however, with sequences on this helps producing slightly better output for
  11020. // the example code.
  11021. var prev = statements[prev_index(i)];
  11022. if (compressor.option("sequences") && in_lambda && !stat.alternative
  11023. && prev instanceof AST_If && prev.body instanceof AST_Return
  11024. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  11025. CHANGED = true;
  11026. stat = stat.clone();
  11027. stat.alternative = make_node(AST_BlockStatement, next, {
  11028. body: [
  11029. next,
  11030. make_node(AST_Return, next, {
  11031. value: null
  11032. })
  11033. ]
  11034. });
  11035. statements[i] = stat.transform(compressor);
  11036. statements.splice(j, 1);
  11037. continue;
  11038. }
  11039. }
  11040. }
  11041. function has_multiple_if_returns(statements) {
  11042. var n = 0;
  11043. for (var i = statements.length; --i >= 0;) {
  11044. var stat = statements[i];
  11045. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  11046. if (++n > 1) return true;
  11047. }
  11048. }
  11049. return false;
  11050. }
  11051. function is_return_void(value) {
  11052. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  11053. }
  11054. function can_merge_flow(ab) {
  11055. if (!ab) return false;
  11056. for (var j = i + 1, len = statements.length; j < len; j++) {
  11057. var stat = statements[j];
  11058. if (stat instanceof AST_Const || stat instanceof AST_Let) return false;
  11059. }
  11060. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  11061. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  11062. || ab instanceof AST_Continue && self === loop_body(lct)
  11063. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  11064. }
  11065. function extract_functions() {
  11066. var tail = statements.slice(i + 1);
  11067. statements.length = i + 1;
  11068. return tail.filter(function(stat) {
  11069. if (stat instanceof AST_Defun) {
  11070. statements.push(stat);
  11071. return false;
  11072. }
  11073. return true;
  11074. });
  11075. }
  11076. function as_statement_array_with_return(node, ab) {
  11077. var body = as_statement_array(node).slice(0, -1);
  11078. if (ab.value) {
  11079. body.push(make_node(AST_SimpleStatement, ab.value, {
  11080. body: ab.value.expression
  11081. }));
  11082. }
  11083. return body;
  11084. }
  11085. function next_index(i) {
  11086. for (var j = i + 1, len = statements.length; j < len; j++) {
  11087. var stat = statements[j];
  11088. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  11089. break;
  11090. }
  11091. }
  11092. return j;
  11093. }
  11094. function prev_index(i) {
  11095. for (var j = i; --j >= 0;) {
  11096. var stat = statements[j];
  11097. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  11098. break;
  11099. }
  11100. }
  11101. return j;
  11102. }
  11103. }
  11104. function eliminate_dead_code(statements, compressor) {
  11105. var has_quit;
  11106. var self = compressor.self();
  11107. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  11108. var stat = statements[i];
  11109. if (stat instanceof AST_LoopControl) {
  11110. var lct = compressor.loopcontrol_target(stat);
  11111. if (stat instanceof AST_Break
  11112. && !(lct instanceof AST_IterationStatement)
  11113. && loop_body(lct) === self
  11114. || stat instanceof AST_Continue
  11115. && loop_body(lct) === self) {
  11116. if (stat.label) {
  11117. remove(stat.label.thedef.references, stat);
  11118. }
  11119. } else {
  11120. statements[n++] = stat;
  11121. }
  11122. } else {
  11123. statements[n++] = stat;
  11124. }
  11125. if (aborts(stat)) {
  11126. has_quit = statements.slice(i + 1);
  11127. break;
  11128. }
  11129. }
  11130. statements.length = n;
  11131. CHANGED = n != len;
  11132. if (has_quit) has_quit.forEach(function(stat) {
  11133. trim_unreachable_code(compressor, stat, statements);
  11134. });
  11135. }
  11136. function declarations_only(node) {
  11137. return node.definitions.every((var_def) =>
  11138. !var_def.value
  11139. );
  11140. }
  11141. function sequencesize(statements, compressor) {
  11142. if (statements.length < 2) return;
  11143. var seq = [], n = 0;
  11144. function push_seq() {
  11145. if (!seq.length) return;
  11146. var body = make_sequence(seq[0], seq);
  11147. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  11148. seq = [];
  11149. }
  11150. for (var i = 0, len = statements.length; i < len; i++) {
  11151. var stat = statements[i];
  11152. if (stat instanceof AST_SimpleStatement) {
  11153. if (seq.length >= compressor.sequences_limit) push_seq();
  11154. var body = stat.body;
  11155. if (seq.length > 0) body = body.drop_side_effect_free(compressor);
  11156. if (body) merge_sequence(seq, body);
  11157. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  11158. || stat instanceof AST_Defun) {
  11159. statements[n++] = stat;
  11160. } else {
  11161. push_seq();
  11162. statements[n++] = stat;
  11163. }
  11164. }
  11165. push_seq();
  11166. statements.length = n;
  11167. if (n != len) CHANGED = true;
  11168. }
  11169. function to_simple_statement(block, decls) {
  11170. if (!(block instanceof AST_BlockStatement)) return block;
  11171. var stat = null;
  11172. for (var i = 0, len = block.body.length; i < len; i++) {
  11173. var line = block.body[i];
  11174. if (line instanceof AST_Var && declarations_only(line)) {
  11175. decls.push(line);
  11176. } else if (stat) {
  11177. return false;
  11178. } else {
  11179. stat = line;
  11180. }
  11181. }
  11182. return stat;
  11183. }
  11184. function sequencesize_2(statements, compressor) {
  11185. function cons_seq(right) {
  11186. n--;
  11187. CHANGED = true;
  11188. var left = prev.body;
  11189. return make_sequence(left, [ left, right ]).transform(compressor);
  11190. }
  11191. var n = 0, prev;
  11192. for (var i = 0; i < statements.length; i++) {
  11193. var stat = statements[i];
  11194. if (prev) {
  11195. if (stat instanceof AST_Exit) {
  11196. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  11197. } else if (stat instanceof AST_For) {
  11198. if (!(stat.init instanceof AST_Definitions)) {
  11199. const abort = walk(prev.body, node => {
  11200. if (node instanceof AST_Scope) return true;
  11201. if (
  11202. node instanceof AST_Binary
  11203. && node.operator === "in"
  11204. ) {
  11205. return walk_abort;
  11206. }
  11207. });
  11208. if (!abort) {
  11209. if (stat.init) stat.init = cons_seq(stat.init);
  11210. else {
  11211. stat.init = prev.body;
  11212. n--;
  11213. CHANGED = true;
  11214. }
  11215. }
  11216. }
  11217. } else if (stat instanceof AST_ForIn) {
  11218. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  11219. stat.object = cons_seq(stat.object);
  11220. }
  11221. } else if (stat instanceof AST_If) {
  11222. stat.condition = cons_seq(stat.condition);
  11223. } else if (stat instanceof AST_Switch) {
  11224. stat.expression = cons_seq(stat.expression);
  11225. } else if (stat instanceof AST_With) {
  11226. stat.expression = cons_seq(stat.expression);
  11227. }
  11228. }
  11229. if (compressor.option("conditionals") && stat instanceof AST_If) {
  11230. var decls = [];
  11231. var body = to_simple_statement(stat.body, decls);
  11232. var alt = to_simple_statement(stat.alternative, decls);
  11233. if (body !== false && alt !== false && decls.length > 0) {
  11234. var len = decls.length;
  11235. decls.push(make_node(AST_If, stat, {
  11236. condition: stat.condition,
  11237. body: body || make_node(AST_EmptyStatement, stat.body),
  11238. alternative: alt
  11239. }));
  11240. decls.unshift(n, 1);
  11241. [].splice.apply(statements, decls);
  11242. i += len;
  11243. n += len + 1;
  11244. prev = null;
  11245. CHANGED = true;
  11246. continue;
  11247. }
  11248. }
  11249. statements[n++] = stat;
  11250. prev = stat instanceof AST_SimpleStatement ? stat : null;
  11251. }
  11252. statements.length = n;
  11253. }
  11254. function join_object_assignments(defn, body) {
  11255. if (!(defn instanceof AST_Definitions)) return;
  11256. var def = defn.definitions[defn.definitions.length - 1];
  11257. if (!(def.value instanceof AST_Object)) return;
  11258. var exprs;
  11259. if (body instanceof AST_Assign) {
  11260. exprs = [ body ];
  11261. } else if (body instanceof AST_Sequence) {
  11262. exprs = body.expressions.slice();
  11263. }
  11264. if (!exprs) return;
  11265. var trimmed = false;
  11266. do {
  11267. var node = exprs[0];
  11268. if (!(node instanceof AST_Assign)) break;
  11269. if (node.operator != "=") break;
  11270. if (!(node.left instanceof AST_PropAccess)) break;
  11271. var sym = node.left.expression;
  11272. if (!(sym instanceof AST_SymbolRef)) break;
  11273. if (def.name.name != sym.name) break;
  11274. if (!node.right.is_constant_expression(scope)) break;
  11275. var prop = node.left.property;
  11276. if (prop instanceof AST_Node) {
  11277. prop = prop.evaluate(compressor);
  11278. }
  11279. if (prop instanceof AST_Node) break;
  11280. prop = "" + prop;
  11281. var diff = compressor.option("ecma") < 2015
  11282. && compressor.has_directive("use strict") ? function(node) {
  11283. return node.key != prop && (node.key && node.key.name != prop);
  11284. } : function(node) {
  11285. return node.key && node.key.name != prop;
  11286. };
  11287. if (!def.value.properties.every(diff)) break;
  11288. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  11289. if (!p) {
  11290. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  11291. key: prop,
  11292. value: node.right
  11293. }));
  11294. } else {
  11295. p.value = new AST_Sequence({
  11296. start: p.start,
  11297. expressions: [p.value.clone(), node.right.clone()],
  11298. end: p.end
  11299. });
  11300. }
  11301. exprs.shift();
  11302. trimmed = true;
  11303. } while (exprs.length);
  11304. return trimmed && exprs;
  11305. }
  11306. function join_consecutive_vars(statements) {
  11307. var defs;
  11308. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  11309. var stat = statements[i];
  11310. var prev = statements[j];
  11311. if (stat instanceof AST_Definitions) {
  11312. if (prev && prev.TYPE == stat.TYPE) {
  11313. prev.definitions = prev.definitions.concat(stat.definitions);
  11314. CHANGED = true;
  11315. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  11316. defs.definitions = defs.definitions.concat(stat.definitions);
  11317. CHANGED = true;
  11318. } else {
  11319. statements[++j] = stat;
  11320. defs = stat;
  11321. }
  11322. } else if (stat instanceof AST_Exit) {
  11323. stat.value = extract_object_assignments(stat.value);
  11324. } else if (stat instanceof AST_For) {
  11325. var exprs = join_object_assignments(prev, stat.init);
  11326. if (exprs) {
  11327. CHANGED = true;
  11328. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  11329. statements[++j] = stat;
  11330. } else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  11331. if (stat.init) {
  11332. prev.definitions = prev.definitions.concat(stat.init.definitions);
  11333. }
  11334. stat.init = prev;
  11335. statements[j] = stat;
  11336. CHANGED = true;
  11337. } else if (defs && stat.init && defs.TYPE == stat.init.TYPE && declarations_only(stat.init)) {
  11338. defs.definitions = defs.definitions.concat(stat.init.definitions);
  11339. stat.init = null;
  11340. statements[++j] = stat;
  11341. CHANGED = true;
  11342. } else {
  11343. statements[++j] = stat;
  11344. }
  11345. } else if (stat instanceof AST_ForIn) {
  11346. stat.object = extract_object_assignments(stat.object);
  11347. } else if (stat instanceof AST_If) {
  11348. stat.condition = extract_object_assignments(stat.condition);
  11349. } else if (stat instanceof AST_SimpleStatement) {
  11350. var exprs = join_object_assignments(prev, stat.body);
  11351. if (exprs) {
  11352. CHANGED = true;
  11353. if (!exprs.length) continue;
  11354. stat.body = make_sequence(stat.body, exprs);
  11355. }
  11356. statements[++j] = stat;
  11357. } else if (stat instanceof AST_Switch) {
  11358. stat.expression = extract_object_assignments(stat.expression);
  11359. } else if (stat instanceof AST_With) {
  11360. stat.expression = extract_object_assignments(stat.expression);
  11361. } else {
  11362. statements[++j] = stat;
  11363. }
  11364. }
  11365. statements.length = j + 1;
  11366. function extract_object_assignments(value) {
  11367. statements[++j] = stat;
  11368. var exprs = join_object_assignments(prev, value);
  11369. if (exprs) {
  11370. CHANGED = true;
  11371. if (exprs.length) {
  11372. return make_sequence(value, exprs);
  11373. } else if (value instanceof AST_Sequence) {
  11374. return value.tail_node().left;
  11375. } else {
  11376. return value.left;
  11377. }
  11378. }
  11379. return value;
  11380. }
  11381. }
  11382. }
  11383. function trim_unreachable_code(compressor, stat, target) {
  11384. walk(stat, node => {
  11385. if (node instanceof AST_Var) {
  11386. node.remove_initializers();
  11387. target.push(node);
  11388. return true;
  11389. }
  11390. if (
  11391. node instanceof AST_Defun
  11392. && (node === stat || !compressor.has_directive("use strict"))
  11393. ) {
  11394. target.push(node === stat ? node : make_node(AST_Var, node, {
  11395. definitions: [
  11396. make_node(AST_VarDef, node, {
  11397. name: make_node(AST_SymbolVar, node.name, node.name),
  11398. value: null
  11399. })
  11400. ]
  11401. }));
  11402. return true;
  11403. }
  11404. if (node instanceof AST_Export || node instanceof AST_Import) {
  11405. target.push(node);
  11406. return true;
  11407. }
  11408. if (node instanceof AST_Scope) {
  11409. return true;
  11410. }
  11411. });
  11412. }
  11413. function get_value(key) {
  11414. if (key instanceof AST_Constant) {
  11415. return key.getValue();
  11416. }
  11417. if (key instanceof AST_UnaryPrefix
  11418. && key.operator == "void"
  11419. && key.expression instanceof AST_Constant) {
  11420. return;
  11421. }
  11422. return key;
  11423. }
  11424. function is_undefined(node, compressor) {
  11425. return (
  11426. has_flag(node, UNDEFINED)
  11427. || node instanceof AST_Undefined
  11428. || node instanceof AST_UnaryPrefix
  11429. && node.operator == "void"
  11430. && !node.expression.has_side_effects(compressor)
  11431. );
  11432. }
  11433. // may_throw_on_access()
  11434. // returns true if this node may be null, undefined or contain `AST_Accessor`
  11435. (function(def_may_throw_on_access) {
  11436. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  11437. return !compressor.option("pure_getters")
  11438. || this._dot_throw(compressor);
  11439. });
  11440. function is_strict(compressor) {
  11441. return /strict/.test(compressor.option("pure_getters"));
  11442. }
  11443. def_may_throw_on_access(AST_Node, is_strict);
  11444. def_may_throw_on_access(AST_Null, return_true);
  11445. def_may_throw_on_access(AST_Undefined, return_true);
  11446. def_may_throw_on_access(AST_Constant, return_false);
  11447. def_may_throw_on_access(AST_Array, return_false);
  11448. def_may_throw_on_access(AST_Object, function(compressor) {
  11449. if (!is_strict(compressor)) return false;
  11450. for (var i = this.properties.length; --i >=0;)
  11451. if (this.properties[i]._dot_throw(compressor)) return true;
  11452. return false;
  11453. });
  11454. // Do not be as strict with classes as we are with objects.
  11455. // Hopefully the community is not going to abuse static getters and setters.
  11456. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  11457. def_may_throw_on_access(AST_Class, return_false);
  11458. def_may_throw_on_access(AST_ObjectProperty, return_false);
  11459. def_may_throw_on_access(AST_ObjectGetter, return_true);
  11460. def_may_throw_on_access(AST_Expansion, function(compressor) {
  11461. return this.expression._dot_throw(compressor);
  11462. });
  11463. def_may_throw_on_access(AST_Function, return_false);
  11464. def_may_throw_on_access(AST_Arrow, return_false);
  11465. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  11466. def_may_throw_on_access(AST_UnaryPrefix, function() {
  11467. return this.operator == "void";
  11468. });
  11469. def_may_throw_on_access(AST_Binary, function(compressor) {
  11470. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  11471. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  11472. });
  11473. def_may_throw_on_access(AST_Assign, function(compressor) {
  11474. return this.operator == "="
  11475. && this.right._dot_throw(compressor);
  11476. });
  11477. def_may_throw_on_access(AST_Conditional, function(compressor) {
  11478. return this.consequent._dot_throw(compressor)
  11479. || this.alternative._dot_throw(compressor);
  11480. });
  11481. def_may_throw_on_access(AST_Dot, function(compressor) {
  11482. if (!is_strict(compressor)) return false;
  11483. if (this.expression instanceof AST_Function && this.property == "prototype") return false;
  11484. return true;
  11485. });
  11486. def_may_throw_on_access(AST_Chain, function(compressor) {
  11487. return this.expression._dot_throw(compressor);
  11488. });
  11489. def_may_throw_on_access(AST_Sequence, function(compressor) {
  11490. return this.tail_node()._dot_throw(compressor);
  11491. });
  11492. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  11493. if (this.name === "arguments") return false;
  11494. if (has_flag(this, UNDEFINED)) return true;
  11495. if (!is_strict(compressor)) return false;
  11496. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  11497. if (this.is_immutable()) return false;
  11498. var fixed = this.fixed_value();
  11499. return !fixed || fixed._dot_throw(compressor);
  11500. });
  11501. })(function(node, func) {
  11502. node.DEFMETHOD("_dot_throw", func);
  11503. });
  11504. /* -----[ boolean/negation helpers ]----- */
  11505. // methods to determine whether an expression has a boolean result type
  11506. (function(def_is_boolean) {
  11507. const unary_bool = makePredicate("! delete");
  11508. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  11509. def_is_boolean(AST_Node, return_false);
  11510. def_is_boolean(AST_UnaryPrefix, function() {
  11511. return unary_bool.has(this.operator);
  11512. });
  11513. def_is_boolean(AST_Binary, function() {
  11514. return binary_bool.has(this.operator)
  11515. || lazy_op.has(this.operator)
  11516. && this.left.is_boolean()
  11517. && this.right.is_boolean();
  11518. });
  11519. def_is_boolean(AST_Conditional, function() {
  11520. return this.consequent.is_boolean() && this.alternative.is_boolean();
  11521. });
  11522. def_is_boolean(AST_Assign, function() {
  11523. return this.operator == "=" && this.right.is_boolean();
  11524. });
  11525. def_is_boolean(AST_Sequence, function() {
  11526. return this.tail_node().is_boolean();
  11527. });
  11528. def_is_boolean(AST_True, return_true);
  11529. def_is_boolean(AST_False, return_true);
  11530. })(function(node, func) {
  11531. node.DEFMETHOD("is_boolean", func);
  11532. });
  11533. // methods to determine if an expression has a numeric result type
  11534. (function(def_is_number) {
  11535. def_is_number(AST_Node, return_false);
  11536. def_is_number(AST_Number, return_true);
  11537. var unary = makePredicate("+ - ~ ++ --");
  11538. def_is_number(AST_Unary, function() {
  11539. return unary.has(this.operator);
  11540. });
  11541. var binary = makePredicate("- * / % & | ^ << >> >>>");
  11542. def_is_number(AST_Binary, function(compressor) {
  11543. return binary.has(this.operator) || this.operator == "+"
  11544. && this.left.is_number(compressor)
  11545. && this.right.is_number(compressor);
  11546. });
  11547. def_is_number(AST_Assign, function(compressor) {
  11548. return binary.has(this.operator.slice(0, -1))
  11549. || this.operator == "=" && this.right.is_number(compressor);
  11550. });
  11551. def_is_number(AST_Sequence, function(compressor) {
  11552. return this.tail_node().is_number(compressor);
  11553. });
  11554. def_is_number(AST_Conditional, function(compressor) {
  11555. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  11556. });
  11557. })(function(node, func) {
  11558. node.DEFMETHOD("is_number", func);
  11559. });
  11560. // methods to determine if an expression has a string result type
  11561. (function(def_is_string) {
  11562. def_is_string(AST_Node, return_false);
  11563. def_is_string(AST_String, return_true);
  11564. def_is_string(AST_TemplateString, return_true);
  11565. def_is_string(AST_UnaryPrefix, function() {
  11566. return this.operator == "typeof";
  11567. });
  11568. def_is_string(AST_Binary, function(compressor) {
  11569. return this.operator == "+" &&
  11570. (this.left.is_string(compressor) || this.right.is_string(compressor));
  11571. });
  11572. def_is_string(AST_Assign, function(compressor) {
  11573. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  11574. });
  11575. def_is_string(AST_Sequence, function(compressor) {
  11576. return this.tail_node().is_string(compressor);
  11577. });
  11578. def_is_string(AST_Conditional, function(compressor) {
  11579. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  11580. });
  11581. })(function(node, func) {
  11582. node.DEFMETHOD("is_string", func);
  11583. });
  11584. var lazy_op = makePredicate("&& || ??");
  11585. var unary_side_effects = makePredicate("delete ++ --");
  11586. function is_lhs(node, parent) {
  11587. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  11588. if (parent instanceof AST_Assign && parent.left === node) return node;
  11589. }
  11590. (function(def_find_defs) {
  11591. function to_node(value, orig) {
  11592. if (value instanceof AST_Node) return make_node(value.CTOR, orig, value);
  11593. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  11594. elements: value.map(function(value) {
  11595. return to_node(value, orig);
  11596. })
  11597. });
  11598. if (value && typeof value == "object") {
  11599. var props = [];
  11600. for (var key in value) if (HOP(value, key)) {
  11601. props.push(make_node(AST_ObjectKeyVal, orig, {
  11602. key: key,
  11603. value: to_node(value[key], orig)
  11604. }));
  11605. }
  11606. return make_node(AST_Object, orig, {
  11607. properties: props
  11608. });
  11609. }
  11610. return make_node_from_constant(value, orig);
  11611. }
  11612. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  11613. if (!compressor.option("global_defs")) return this;
  11614. this.figure_out_scope({ ie8: compressor.option("ie8") });
  11615. return this.transform(new TreeTransformer(function(node) {
  11616. var def = node._find_defs(compressor, "");
  11617. if (!def) return;
  11618. var level = 0, child = node, parent;
  11619. while (parent = this.parent(level++)) {
  11620. if (!(parent instanceof AST_PropAccess)) break;
  11621. if (parent.expression !== child) break;
  11622. child = parent;
  11623. }
  11624. if (is_lhs(child, parent)) {
  11625. return;
  11626. }
  11627. return def;
  11628. }));
  11629. });
  11630. def_find_defs(AST_Node, noop);
  11631. def_find_defs(AST_Chain, function(compressor, suffix) {
  11632. return this.expression._find_defs(compressor, suffix);
  11633. });
  11634. def_find_defs(AST_Dot, function(compressor, suffix) {
  11635. return this.expression._find_defs(compressor, "." + this.property + suffix);
  11636. });
  11637. def_find_defs(AST_SymbolDeclaration, function() {
  11638. if (!this.global()) return;
  11639. });
  11640. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  11641. if (!this.global()) return;
  11642. var defines = compressor.option("global_defs");
  11643. var name = this.name + suffix;
  11644. if (HOP(defines, name)) return to_node(defines[name], this);
  11645. });
  11646. })(function(node, func) {
  11647. node.DEFMETHOD("_find_defs", func);
  11648. });
  11649. function best_of_expression(ast1, ast2) {
  11650. return ast1.size() > ast2.size() ? ast2 : ast1;
  11651. }
  11652. function best_of_statement(ast1, ast2) {
  11653. return best_of_expression(
  11654. make_node(AST_SimpleStatement, ast1, {
  11655. body: ast1
  11656. }),
  11657. make_node(AST_SimpleStatement, ast2, {
  11658. body: ast2
  11659. })
  11660. ).body;
  11661. }
  11662. function best_of(compressor, ast1, ast2) {
  11663. return (first_in_statement(compressor) ? best_of_statement : best_of_expression)(ast1, ast2);
  11664. }
  11665. function convert_to_predicate(obj) {
  11666. const out = new Map();
  11667. for (var key of Object.keys(obj)) {
  11668. out.set(key, makePredicate(obj[key]));
  11669. }
  11670. return out;
  11671. }
  11672. var object_fns = [
  11673. "constructor",
  11674. "toString",
  11675. "valueOf",
  11676. ];
  11677. var native_fns = convert_to_predicate({
  11678. Array: [
  11679. "indexOf",
  11680. "join",
  11681. "lastIndexOf",
  11682. "slice",
  11683. ].concat(object_fns),
  11684. Boolean: object_fns,
  11685. Function: object_fns,
  11686. Number: [
  11687. "toExponential",
  11688. "toFixed",
  11689. "toPrecision",
  11690. ].concat(object_fns),
  11691. Object: object_fns,
  11692. RegExp: [
  11693. "test",
  11694. ].concat(object_fns),
  11695. String: [
  11696. "charAt",
  11697. "charCodeAt",
  11698. "concat",
  11699. "indexOf",
  11700. "italics",
  11701. "lastIndexOf",
  11702. "match",
  11703. "replace",
  11704. "search",
  11705. "slice",
  11706. "split",
  11707. "substr",
  11708. "substring",
  11709. "toLowerCase",
  11710. "toUpperCase",
  11711. "trim",
  11712. ].concat(object_fns),
  11713. });
  11714. var static_fns = convert_to_predicate({
  11715. Array: [
  11716. "isArray",
  11717. ],
  11718. Math: [
  11719. "abs",
  11720. "acos",
  11721. "asin",
  11722. "atan",
  11723. "ceil",
  11724. "cos",
  11725. "exp",
  11726. "floor",
  11727. "log",
  11728. "round",
  11729. "sin",
  11730. "sqrt",
  11731. "tan",
  11732. "atan2",
  11733. "pow",
  11734. "max",
  11735. "min",
  11736. ],
  11737. Number: [
  11738. "isFinite",
  11739. "isNaN",
  11740. ],
  11741. Object: [
  11742. "create",
  11743. "getOwnPropertyDescriptor",
  11744. "getOwnPropertyNames",
  11745. "getPrototypeOf",
  11746. "isExtensible",
  11747. "isFrozen",
  11748. "isSealed",
  11749. "keys",
  11750. ],
  11751. String: [
  11752. "fromCharCode",
  11753. ],
  11754. });
  11755. // methods to evaluate a constant expression
  11756. (function(def_eval) {
  11757. // If the node has been successfully reduced to a constant,
  11758. // then its value is returned; otherwise the element itself
  11759. // is returned.
  11760. // They can be distinguished as constant value is never a
  11761. // descendant of AST_Node.
  11762. AST_Node.DEFMETHOD("evaluate", function(compressor) {
  11763. if (!compressor.option("evaluate")) return this;
  11764. var val = this._eval(compressor, 1);
  11765. if (!val || val instanceof RegExp) return val;
  11766. if (typeof val == "function" || typeof val == "object") return this;
  11767. return val;
  11768. });
  11769. var unaryPrefix = makePredicate("! ~ - + void");
  11770. AST_Node.DEFMETHOD("is_constant", function() {
  11771. // Accomodate when compress option evaluate=false
  11772. // as well as the common constant expressions !0 and -1
  11773. if (this instanceof AST_Constant) {
  11774. return !(this instanceof AST_RegExp);
  11775. } else {
  11776. return this instanceof AST_UnaryPrefix
  11777. && this.expression instanceof AST_Constant
  11778. && unaryPrefix.has(this.operator);
  11779. }
  11780. });
  11781. def_eval(AST_Statement, function() {
  11782. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  11783. });
  11784. def_eval(AST_Lambda, return_this);
  11785. def_eval(AST_Class, return_this);
  11786. def_eval(AST_Node, return_this);
  11787. def_eval(AST_Constant, function() {
  11788. return this.getValue();
  11789. });
  11790. def_eval(AST_BigInt, return_this);
  11791. def_eval(AST_RegExp, function(compressor) {
  11792. let evaluated = compressor.evaluated_regexps.get(this);
  11793. if (evaluated === undefined) {
  11794. try {
  11795. evaluated = (0, eval)(this.print_to_string());
  11796. } catch (e) {
  11797. evaluated = null;
  11798. }
  11799. compressor.evaluated_regexps.set(this, evaluated);
  11800. }
  11801. return evaluated || this;
  11802. });
  11803. def_eval(AST_TemplateString, function() {
  11804. if (this.segments.length !== 1) return this;
  11805. return this.segments[0].value;
  11806. });
  11807. def_eval(AST_Function, function(compressor) {
  11808. if (compressor.option("unsafe")) {
  11809. var fn = function() {};
  11810. fn.node = this;
  11811. fn.toString = function() {
  11812. return this.node.print_to_string();
  11813. };
  11814. return fn;
  11815. }
  11816. return this;
  11817. });
  11818. def_eval(AST_Array, function(compressor, depth) {
  11819. if (compressor.option("unsafe")) {
  11820. var elements = [];
  11821. for (var i = 0, len = this.elements.length; i < len; i++) {
  11822. var element = this.elements[i];
  11823. var value = element._eval(compressor, depth);
  11824. if (element === value) return this;
  11825. elements.push(value);
  11826. }
  11827. return elements;
  11828. }
  11829. return this;
  11830. });
  11831. def_eval(AST_Object, function(compressor, depth) {
  11832. if (compressor.option("unsafe")) {
  11833. var val = {};
  11834. for (var i = 0, len = this.properties.length; i < len; i++) {
  11835. var prop = this.properties[i];
  11836. if (prop instanceof AST_Expansion) return this;
  11837. var key = prop.key;
  11838. if (key instanceof AST_Symbol) {
  11839. key = key.name;
  11840. } else if (key instanceof AST_Node) {
  11841. key = key._eval(compressor, depth);
  11842. if (key === prop.key) return this;
  11843. }
  11844. if (typeof Object.prototype[key] === "function") {
  11845. return this;
  11846. }
  11847. if (prop.value instanceof AST_Function) continue;
  11848. val[key] = prop.value._eval(compressor, depth);
  11849. if (val[key] === prop.value) return this;
  11850. }
  11851. return val;
  11852. }
  11853. return this;
  11854. });
  11855. var non_converting_unary = makePredicate("! typeof void");
  11856. def_eval(AST_UnaryPrefix, function(compressor, depth) {
  11857. var e = this.expression;
  11858. // Function would be evaluated to an array and so typeof would
  11859. // incorrectly return 'object'. Hence making is a special case.
  11860. if (compressor.option("typeofs")
  11861. && this.operator == "typeof"
  11862. && (e instanceof AST_Lambda
  11863. || e instanceof AST_SymbolRef
  11864. && e.fixed_value() instanceof AST_Lambda)) {
  11865. return typeof function() {};
  11866. }
  11867. if (!non_converting_unary.has(this.operator)) depth++;
  11868. e = e._eval(compressor, depth);
  11869. if (e === this.expression) return this;
  11870. switch (this.operator) {
  11871. case "!": return !e;
  11872. case "typeof":
  11873. // typeof <RegExp> returns "object" or "function" on different platforms
  11874. // so cannot evaluate reliably
  11875. if (e instanceof RegExp) return this;
  11876. return typeof e;
  11877. case "void": return void e;
  11878. case "~": return ~e;
  11879. case "-": return -e;
  11880. case "+": return +e;
  11881. }
  11882. return this;
  11883. });
  11884. var non_converting_binary = makePredicate("&& || ?? === !==");
  11885. const identity_comparison = makePredicate("== != === !==");
  11886. const has_identity = value =>
  11887. typeof value === "object"
  11888. || typeof value === "function"
  11889. || typeof value === "symbol";
  11890. def_eval(AST_Binary, function(compressor, depth) {
  11891. if (!non_converting_binary.has(this.operator)) depth++;
  11892. var left = this.left._eval(compressor, depth);
  11893. if (left === this.left) return this;
  11894. var right = this.right._eval(compressor, depth);
  11895. if (right === this.right) return this;
  11896. var result;
  11897. if (
  11898. left != null
  11899. && right != null
  11900. && identity_comparison.has(this.operator)
  11901. && has_identity(left)
  11902. && has_identity(right)
  11903. && typeof left === typeof right
  11904. ) {
  11905. // Do not compare by reference
  11906. return this;
  11907. }
  11908. switch (this.operator) {
  11909. case "&&" : result = left && right; break;
  11910. case "||" : result = left || right; break;
  11911. case "??" : result = left != null ? left : right; break;
  11912. case "|" : result = left | right; break;
  11913. case "&" : result = left & right; break;
  11914. case "^" : result = left ^ right; break;
  11915. case "+" : result = left + right; break;
  11916. case "*" : result = left * right; break;
  11917. case "**" : result = Math.pow(left, right); break;
  11918. case "/" : result = left / right; break;
  11919. case "%" : result = left % right; break;
  11920. case "-" : result = left - right; break;
  11921. case "<<" : result = left << right; break;
  11922. case ">>" : result = left >> right; break;
  11923. case ">>>" : result = left >>> right; break;
  11924. case "==" : result = left == right; break;
  11925. case "===" : result = left === right; break;
  11926. case "!=" : result = left != right; break;
  11927. case "!==" : result = left !== right; break;
  11928. case "<" : result = left < right; break;
  11929. case "<=" : result = left <= right; break;
  11930. case ">" : result = left > right; break;
  11931. case ">=" : result = left >= right; break;
  11932. default:
  11933. return this;
  11934. }
  11935. if (isNaN(result) && compressor.find_parent(AST_With)) {
  11936. // leave original expression as is
  11937. return this;
  11938. }
  11939. return result;
  11940. });
  11941. def_eval(AST_Conditional, function(compressor, depth) {
  11942. var condition = this.condition._eval(compressor, depth);
  11943. if (condition === this.condition) return this;
  11944. var node = condition ? this.consequent : this.alternative;
  11945. var value = node._eval(compressor, depth);
  11946. return value === node ? this : value;
  11947. });
  11948. // Set of AST_SymbolRef which are currently being evaluated.
  11949. // Avoids infinite recursion of ._eval()
  11950. const reentrant_ref_eval = new Set();
  11951. def_eval(AST_SymbolRef, function(compressor, depth) {
  11952. if (reentrant_ref_eval.has(this)) return this;
  11953. var fixed = this.fixed_value();
  11954. if (!fixed) return this;
  11955. reentrant_ref_eval.add(this);
  11956. const value = fixed._eval(compressor, depth);
  11957. reentrant_ref_eval.delete(this);
  11958. if (value === fixed) return this;
  11959. if (value && typeof value == "object") {
  11960. var escaped = this.definition().escaped;
  11961. if (escaped && depth > escaped) return this;
  11962. }
  11963. return value;
  11964. });
  11965. var global_objs = { Array, Math, Number, Object, String };
  11966. var static_values = convert_to_predicate({
  11967. Math: [
  11968. "E",
  11969. "LN10",
  11970. "LN2",
  11971. "LOG2E",
  11972. "LOG10E",
  11973. "PI",
  11974. "SQRT1_2",
  11975. "SQRT2",
  11976. ],
  11977. Number: [
  11978. "MAX_VALUE",
  11979. "MIN_VALUE",
  11980. "NaN",
  11981. "NEGATIVE_INFINITY",
  11982. "POSITIVE_INFINITY",
  11983. ],
  11984. });
  11985. def_eval(AST_PropAccess, function(compressor, depth) {
  11986. if (this.optional) {
  11987. const obj = this.expression._eval(compressor, depth);
  11988. if (obj == null) return undefined;
  11989. }
  11990. if (compressor.option("unsafe")) {
  11991. var key = this.property;
  11992. if (key instanceof AST_Node) {
  11993. key = key._eval(compressor, depth);
  11994. if (key === this.property) return this;
  11995. }
  11996. var exp = this.expression;
  11997. var val;
  11998. if (is_undeclared_ref(exp)) {
  11999. var aa;
  12000. var first_arg = exp.name === "hasOwnProperty"
  12001. && key === "call"
  12002. && (aa = compressor.parent() && compressor.parent().args)
  12003. && (aa && aa[0]
  12004. && aa[0].evaluate(compressor));
  12005. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  12006. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  12007. return this.clone();
  12008. }
  12009. var static_value = static_values.get(exp.name);
  12010. if (!static_value || !static_value.has(key)) return this;
  12011. val = global_objs[exp.name];
  12012. } else {
  12013. val = exp._eval(compressor, depth + 1);
  12014. if (!val || val === exp || !HOP(val, key)) return this;
  12015. if (typeof val == "function") switch (key) {
  12016. case "name":
  12017. return val.node.name ? val.node.name.name : "";
  12018. case "length":
  12019. return val.node.argnames.length;
  12020. default:
  12021. return this;
  12022. }
  12023. }
  12024. return val[key];
  12025. }
  12026. return this;
  12027. });
  12028. def_eval(AST_Chain, function(compressor, depth) {
  12029. const evaluated = this.expression._eval(compressor, depth);
  12030. return evaluated === this.expression ? this : evaluated;
  12031. });
  12032. def_eval(AST_Call, function(compressor, depth) {
  12033. var exp = this.expression;
  12034. if (this.optional) {
  12035. const callee = this.expression._eval(compressor, depth);
  12036. if (callee == null) return undefined;
  12037. }
  12038. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  12039. var key = exp.property;
  12040. if (key instanceof AST_Node) {
  12041. key = key._eval(compressor, depth);
  12042. if (key === exp.property) return this;
  12043. }
  12044. var val;
  12045. var e = exp.expression;
  12046. if (is_undeclared_ref(e)) {
  12047. var first_arg =
  12048. e.name === "hasOwnProperty" &&
  12049. key === "call" &&
  12050. (this.args[0] && this.args[0].evaluate(compressor));
  12051. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  12052. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  12053. return this.clone();
  12054. }
  12055. var static_fn = static_fns.get(e.name);
  12056. if (!static_fn || !static_fn.has(key)) return this;
  12057. val = global_objs[e.name];
  12058. } else {
  12059. val = e._eval(compressor, depth + 1);
  12060. if (val === e || !val) return this;
  12061. var native_fn = native_fns.get(val.constructor.name);
  12062. if (!native_fn || !native_fn.has(key)) return this;
  12063. }
  12064. var args = [];
  12065. for (var i = 0, len = this.args.length; i < len; i++) {
  12066. var arg = this.args[i];
  12067. var value = arg._eval(compressor, depth);
  12068. if (arg === value) return this;
  12069. args.push(value);
  12070. }
  12071. try {
  12072. return val[key].apply(val, args);
  12073. } catch (ex) {
  12074. // We don't really care
  12075. }
  12076. }
  12077. return this;
  12078. });
  12079. def_eval(AST_New, return_this);
  12080. })(function(node, func) {
  12081. node.DEFMETHOD("_eval", func);
  12082. });
  12083. // method to negate an expression
  12084. (function(def_negate) {
  12085. function basic_negation(exp) {
  12086. return make_node(AST_UnaryPrefix, exp, {
  12087. operator: "!",
  12088. expression: exp
  12089. });
  12090. }
  12091. function best(orig, alt, first_in_statement) {
  12092. var negated = basic_negation(orig);
  12093. if (first_in_statement) {
  12094. var stat = make_node(AST_SimpleStatement, alt, {
  12095. body: alt
  12096. });
  12097. return best_of_expression(negated, stat) === stat ? alt : negated;
  12098. }
  12099. return best_of_expression(negated, alt);
  12100. }
  12101. def_negate(AST_Node, function() {
  12102. return basic_negation(this);
  12103. });
  12104. def_negate(AST_Statement, function() {
  12105. throw new Error("Cannot negate a statement");
  12106. });
  12107. def_negate(AST_Function, function() {
  12108. return basic_negation(this);
  12109. });
  12110. def_negate(AST_Arrow, function() {
  12111. return basic_negation(this);
  12112. });
  12113. def_negate(AST_UnaryPrefix, function() {
  12114. if (this.operator == "!")
  12115. return this.expression;
  12116. return basic_negation(this);
  12117. });
  12118. def_negate(AST_Sequence, function(compressor) {
  12119. var expressions = this.expressions.slice();
  12120. expressions.push(expressions.pop().negate(compressor));
  12121. return make_sequence(this, expressions);
  12122. });
  12123. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  12124. var self = this.clone();
  12125. self.consequent = self.consequent.negate(compressor);
  12126. self.alternative = self.alternative.negate(compressor);
  12127. return best(this, self, first_in_statement);
  12128. });
  12129. def_negate(AST_Binary, function(compressor, first_in_statement) {
  12130. var self = this.clone(), op = this.operator;
  12131. if (compressor.option("unsafe_comps")) {
  12132. switch (op) {
  12133. case "<=" : self.operator = ">" ; return self;
  12134. case "<" : self.operator = ">=" ; return self;
  12135. case ">=" : self.operator = "<" ; return self;
  12136. case ">" : self.operator = "<=" ; return self;
  12137. }
  12138. }
  12139. switch (op) {
  12140. case "==" : self.operator = "!="; return self;
  12141. case "!=" : self.operator = "=="; return self;
  12142. case "===": self.operator = "!=="; return self;
  12143. case "!==": self.operator = "==="; return self;
  12144. case "&&":
  12145. self.operator = "||";
  12146. self.left = self.left.negate(compressor, first_in_statement);
  12147. self.right = self.right.negate(compressor);
  12148. return best(this, self, first_in_statement);
  12149. case "||":
  12150. self.operator = "&&";
  12151. self.left = self.left.negate(compressor, first_in_statement);
  12152. self.right = self.right.negate(compressor);
  12153. return best(this, self, first_in_statement);
  12154. case "??":
  12155. self.right = self.right.negate(compressor);
  12156. return best(this, self, first_in_statement);
  12157. }
  12158. return basic_negation(this);
  12159. });
  12160. })(function(node, func) {
  12161. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  12162. return func.call(this, compressor, first_in_statement);
  12163. });
  12164. });
  12165. 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");
  12166. AST_Call.DEFMETHOD("is_expr_pure", function(compressor) {
  12167. if (compressor.option("unsafe")) {
  12168. var expr = this.expression;
  12169. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  12170. if (
  12171. expr.expression && expr.expression.name === "hasOwnProperty" &&
  12172. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  12173. ) {
  12174. return false;
  12175. }
  12176. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  12177. let static_fn;
  12178. if (expr instanceof AST_Dot
  12179. && is_undeclared_ref(expr.expression)
  12180. && (static_fn = static_fns.get(expr.expression.name))
  12181. && static_fn.has(expr.property)) {
  12182. return true;
  12183. }
  12184. }
  12185. return !!has_annotation(this, _PURE) || !compressor.pure_funcs(this);
  12186. });
  12187. AST_Node.DEFMETHOD("is_call_pure", return_false);
  12188. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  12189. if (!compressor.option("unsafe")) return;
  12190. const expr = this.expression;
  12191. let map;
  12192. if (expr instanceof AST_Array) {
  12193. map = native_fns.get("Array");
  12194. } else if (expr.is_boolean()) {
  12195. map = native_fns.get("Boolean");
  12196. } else if (expr.is_number(compressor)) {
  12197. map = native_fns.get("Number");
  12198. } else if (expr instanceof AST_RegExp) {
  12199. map = native_fns.get("RegExp");
  12200. } else if (expr.is_string(compressor)) {
  12201. map = native_fns.get("String");
  12202. } else if (!this.may_throw_on_access(compressor)) {
  12203. map = native_fns.get("Object");
  12204. }
  12205. return map && map.has(this.property);
  12206. });
  12207. const pure_prop_access_globals = new Set([
  12208. "Number",
  12209. "String",
  12210. "Array",
  12211. "Object",
  12212. "Function",
  12213. "Promise",
  12214. ]);
  12215. // determine if expression has side effects
  12216. (function(def_has_side_effects) {
  12217. def_has_side_effects(AST_Node, return_true);
  12218. def_has_side_effects(AST_EmptyStatement, return_false);
  12219. def_has_side_effects(AST_Constant, return_false);
  12220. def_has_side_effects(AST_This, return_false);
  12221. function any(list, compressor) {
  12222. for (var i = list.length; --i >= 0;)
  12223. if (list[i].has_side_effects(compressor))
  12224. return true;
  12225. return false;
  12226. }
  12227. def_has_side_effects(AST_Block, function(compressor) {
  12228. return any(this.body, compressor);
  12229. });
  12230. def_has_side_effects(AST_Call, function(compressor) {
  12231. if (
  12232. !this.is_expr_pure(compressor)
  12233. && (!this.expression.is_call_pure(compressor)
  12234. || this.expression.has_side_effects(compressor))
  12235. ) {
  12236. return true;
  12237. }
  12238. return any(this.args, compressor);
  12239. });
  12240. def_has_side_effects(AST_Switch, function(compressor) {
  12241. return this.expression.has_side_effects(compressor)
  12242. || any(this.body, compressor);
  12243. });
  12244. def_has_side_effects(AST_Case, function(compressor) {
  12245. return this.expression.has_side_effects(compressor)
  12246. || any(this.body, compressor);
  12247. });
  12248. def_has_side_effects(AST_Try, function(compressor) {
  12249. return any(this.body, compressor)
  12250. || this.bcatch && this.bcatch.has_side_effects(compressor)
  12251. || this.bfinally && this.bfinally.has_side_effects(compressor);
  12252. });
  12253. def_has_side_effects(AST_If, function(compressor) {
  12254. return this.condition.has_side_effects(compressor)
  12255. || this.body && this.body.has_side_effects(compressor)
  12256. || this.alternative && this.alternative.has_side_effects(compressor);
  12257. });
  12258. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  12259. return this.body.has_side_effects(compressor);
  12260. });
  12261. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  12262. return this.body.has_side_effects(compressor);
  12263. });
  12264. def_has_side_effects(AST_Lambda, return_false);
  12265. def_has_side_effects(AST_Class, function (compressor) {
  12266. if (this.extends && this.extends.has_side_effects(compressor)) {
  12267. return true;
  12268. }
  12269. return any(this.properties, compressor);
  12270. });
  12271. def_has_side_effects(AST_Binary, function(compressor) {
  12272. return this.left.has_side_effects(compressor)
  12273. || this.right.has_side_effects(compressor);
  12274. });
  12275. def_has_side_effects(AST_Assign, return_true);
  12276. def_has_side_effects(AST_Conditional, function(compressor) {
  12277. return this.condition.has_side_effects(compressor)
  12278. || this.consequent.has_side_effects(compressor)
  12279. || this.alternative.has_side_effects(compressor);
  12280. });
  12281. def_has_side_effects(AST_Unary, function(compressor) {
  12282. return unary_side_effects.has(this.operator)
  12283. || this.expression.has_side_effects(compressor);
  12284. });
  12285. def_has_side_effects(AST_SymbolRef, function(compressor) {
  12286. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12287. });
  12288. def_has_side_effects(AST_SymbolClassProperty, return_false);
  12289. def_has_side_effects(AST_SymbolDeclaration, return_false);
  12290. def_has_side_effects(AST_Object, function(compressor) {
  12291. return any(this.properties, compressor);
  12292. });
  12293. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  12294. return (
  12295. this.computed_key() && this.key.has_side_effects(compressor)
  12296. || this.value.has_side_effects(compressor)
  12297. );
  12298. });
  12299. def_has_side_effects(AST_ClassProperty, function(compressor) {
  12300. return (
  12301. this.computed_key() && this.key.has_side_effects(compressor)
  12302. || this.static && this.value && this.value.has_side_effects(compressor)
  12303. );
  12304. });
  12305. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  12306. return this.computed_key() && this.key.has_side_effects(compressor);
  12307. });
  12308. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  12309. return this.computed_key() && this.key.has_side_effects(compressor);
  12310. });
  12311. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  12312. return this.computed_key() && this.key.has_side_effects(compressor);
  12313. });
  12314. def_has_side_effects(AST_Array, function(compressor) {
  12315. return any(this.elements, compressor);
  12316. });
  12317. def_has_side_effects(AST_Dot, function(compressor) {
  12318. return !this.optional && this.expression.may_throw_on_access(compressor)
  12319. || this.expression.has_side_effects(compressor);
  12320. });
  12321. def_has_side_effects(AST_Sub, function(compressor) {
  12322. if (this.optional && is_nullish(this.expression)) {
  12323. return false;
  12324. }
  12325. return !this.optional && this.expression.may_throw_on_access(compressor)
  12326. || this.expression.has_side_effects(compressor)
  12327. || this.property.has_side_effects(compressor);
  12328. });
  12329. def_has_side_effects(AST_Chain, function (compressor) {
  12330. return this.expression.has_side_effects(compressor);
  12331. });
  12332. def_has_side_effects(AST_Sequence, function(compressor) {
  12333. return any(this.expressions, compressor);
  12334. });
  12335. def_has_side_effects(AST_Definitions, function(compressor) {
  12336. return any(this.definitions, compressor);
  12337. });
  12338. def_has_side_effects(AST_VarDef, function() {
  12339. return this.value;
  12340. });
  12341. def_has_side_effects(AST_TemplateSegment, return_false);
  12342. def_has_side_effects(AST_TemplateString, function(compressor) {
  12343. return any(this.segments, compressor);
  12344. });
  12345. })(function(node, func) {
  12346. node.DEFMETHOD("has_side_effects", func);
  12347. });
  12348. // determine if expression may throw
  12349. (function(def_may_throw) {
  12350. def_may_throw(AST_Node, return_true);
  12351. def_may_throw(AST_Constant, return_false);
  12352. def_may_throw(AST_EmptyStatement, return_false);
  12353. def_may_throw(AST_Lambda, return_false);
  12354. def_may_throw(AST_SymbolDeclaration, return_false);
  12355. def_may_throw(AST_This, return_false);
  12356. function any(list, compressor) {
  12357. for (var i = list.length; --i >= 0;)
  12358. if (list[i].may_throw(compressor))
  12359. return true;
  12360. return false;
  12361. }
  12362. def_may_throw(AST_Class, function(compressor) {
  12363. if (this.extends && this.extends.may_throw(compressor)) return true;
  12364. return any(this.properties, compressor);
  12365. });
  12366. def_may_throw(AST_Array, function(compressor) {
  12367. return any(this.elements, compressor);
  12368. });
  12369. def_may_throw(AST_Assign, function(compressor) {
  12370. if (this.right.may_throw(compressor)) return true;
  12371. if (!compressor.has_directive("use strict")
  12372. && this.operator == "="
  12373. && this.left instanceof AST_SymbolRef) {
  12374. return false;
  12375. }
  12376. return this.left.may_throw(compressor);
  12377. });
  12378. def_may_throw(AST_Binary, function(compressor) {
  12379. return this.left.may_throw(compressor)
  12380. || this.right.may_throw(compressor);
  12381. });
  12382. def_may_throw(AST_Block, function(compressor) {
  12383. return any(this.body, compressor);
  12384. });
  12385. def_may_throw(AST_Call, function(compressor) {
  12386. if (this.optional && is_nullish(this.expression)) return false;
  12387. if (any(this.args, compressor)) return true;
  12388. if (this.is_expr_pure(compressor)) return false;
  12389. if (this.expression.may_throw(compressor)) return true;
  12390. return !(this.expression instanceof AST_Lambda)
  12391. || any(this.expression.body, compressor);
  12392. });
  12393. def_may_throw(AST_Case, function(compressor) {
  12394. return this.expression.may_throw(compressor)
  12395. || any(this.body, compressor);
  12396. });
  12397. def_may_throw(AST_Conditional, function(compressor) {
  12398. return this.condition.may_throw(compressor)
  12399. || this.consequent.may_throw(compressor)
  12400. || this.alternative.may_throw(compressor);
  12401. });
  12402. def_may_throw(AST_Definitions, function(compressor) {
  12403. return any(this.definitions, compressor);
  12404. });
  12405. def_may_throw(AST_If, function(compressor) {
  12406. return this.condition.may_throw(compressor)
  12407. || this.body && this.body.may_throw(compressor)
  12408. || this.alternative && this.alternative.may_throw(compressor);
  12409. });
  12410. def_may_throw(AST_LabeledStatement, function(compressor) {
  12411. return this.body.may_throw(compressor);
  12412. });
  12413. def_may_throw(AST_Object, function(compressor) {
  12414. return any(this.properties, compressor);
  12415. });
  12416. def_may_throw(AST_ObjectProperty, function(compressor) {
  12417. // TODO key may throw too
  12418. return this.value.may_throw(compressor);
  12419. });
  12420. def_may_throw(AST_ClassProperty, function(compressor) {
  12421. return (
  12422. this.computed_key() && this.key.may_throw(compressor)
  12423. || this.static && this.value && this.value.may_throw(compressor)
  12424. );
  12425. });
  12426. def_may_throw(AST_ConciseMethod, function(compressor) {
  12427. return this.computed_key() && this.key.may_throw(compressor);
  12428. });
  12429. def_may_throw(AST_ObjectGetter, function(compressor) {
  12430. return this.computed_key() && this.key.may_throw(compressor);
  12431. });
  12432. def_may_throw(AST_ObjectSetter, function(compressor) {
  12433. return this.computed_key() && this.key.may_throw(compressor);
  12434. });
  12435. def_may_throw(AST_Return, function(compressor) {
  12436. return this.value && this.value.may_throw(compressor);
  12437. });
  12438. def_may_throw(AST_Sequence, function(compressor) {
  12439. return any(this.expressions, compressor);
  12440. });
  12441. def_may_throw(AST_SimpleStatement, function(compressor) {
  12442. return this.body.may_throw(compressor);
  12443. });
  12444. def_may_throw(AST_Dot, function(compressor) {
  12445. return !this.optional && this.expression.may_throw_on_access(compressor)
  12446. || this.expression.may_throw(compressor);
  12447. });
  12448. def_may_throw(AST_Sub, function(compressor) {
  12449. if (this.optional && is_nullish(this.expression)) return false;
  12450. return !this.optional && this.expression.may_throw_on_access(compressor)
  12451. || this.expression.may_throw(compressor)
  12452. || this.property.may_throw(compressor);
  12453. });
  12454. def_may_throw(AST_Chain, function(compressor) {
  12455. return this.expression.may_throw(compressor);
  12456. });
  12457. def_may_throw(AST_Switch, function(compressor) {
  12458. return this.expression.may_throw(compressor)
  12459. || any(this.body, compressor);
  12460. });
  12461. def_may_throw(AST_SymbolRef, function(compressor) {
  12462. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12463. });
  12464. def_may_throw(AST_SymbolClassProperty, return_false);
  12465. def_may_throw(AST_Try, function(compressor) {
  12466. return this.bcatch ? this.bcatch.may_throw(compressor) : any(this.body, compressor)
  12467. || this.bfinally && this.bfinally.may_throw(compressor);
  12468. });
  12469. def_may_throw(AST_Unary, function(compressor) {
  12470. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12471. return false;
  12472. return this.expression.may_throw(compressor);
  12473. });
  12474. def_may_throw(AST_VarDef, function(compressor) {
  12475. if (!this.value) return false;
  12476. return this.value.may_throw(compressor);
  12477. });
  12478. })(function(node, func) {
  12479. node.DEFMETHOD("may_throw", func);
  12480. });
  12481. // determine if expression is constant
  12482. (function(def_is_constant_expression) {
  12483. function all_refs_local(scope) {
  12484. let result = true;
  12485. walk(this, node => {
  12486. if (node instanceof AST_SymbolRef) {
  12487. if (has_flag(this, INLINED)) {
  12488. result = false;
  12489. return walk_abort;
  12490. }
  12491. var def = node.definition();
  12492. if (
  12493. member(def, this.enclosed)
  12494. && !this.variables.has(def.name)
  12495. ) {
  12496. if (scope) {
  12497. var scope_def = scope.find_variable(node);
  12498. if (def.undeclared ? !scope_def : scope_def === def) {
  12499. result = "f";
  12500. return true;
  12501. }
  12502. }
  12503. result = false;
  12504. return walk_abort;
  12505. }
  12506. return true;
  12507. }
  12508. if (node instanceof AST_This && this instanceof AST_Arrow) {
  12509. // TODO check arguments too!
  12510. result = false;
  12511. return walk_abort;
  12512. }
  12513. });
  12514. return result;
  12515. }
  12516. def_is_constant_expression(AST_Node, return_false);
  12517. def_is_constant_expression(AST_Constant, return_true);
  12518. def_is_constant_expression(AST_Class, function(scope) {
  12519. if (this.extends && !this.extends.is_constant_expression(scope)) {
  12520. return false;
  12521. }
  12522. for (const prop of this.properties) {
  12523. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  12524. return false;
  12525. }
  12526. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  12527. return false;
  12528. }
  12529. }
  12530. return all_refs_local.call(this, scope);
  12531. });
  12532. def_is_constant_expression(AST_Lambda, all_refs_local);
  12533. def_is_constant_expression(AST_Unary, function() {
  12534. return this.expression.is_constant_expression();
  12535. });
  12536. def_is_constant_expression(AST_Binary, function() {
  12537. return this.left.is_constant_expression()
  12538. && this.right.is_constant_expression();
  12539. });
  12540. def_is_constant_expression(AST_Array, function() {
  12541. return this.elements.every((l) => l.is_constant_expression());
  12542. });
  12543. def_is_constant_expression(AST_Object, function() {
  12544. return this.properties.every((l) => l.is_constant_expression());
  12545. });
  12546. def_is_constant_expression(AST_ObjectProperty, function() {
  12547. return !(this.key instanceof AST_Node) && this.value.is_constant_expression();
  12548. });
  12549. })(function(node, func) {
  12550. node.DEFMETHOD("is_constant_expression", func);
  12551. });
  12552. // tell me if a statement aborts
  12553. function aborts(thing) {
  12554. return thing && thing.aborts();
  12555. }
  12556. (function(def_aborts) {
  12557. def_aborts(AST_Statement, return_null);
  12558. def_aborts(AST_Jump, return_this);
  12559. function block_aborts() {
  12560. for (var i = 0; i < this.body.length; i++) {
  12561. if (aborts(this.body[i])) {
  12562. return this.body[i];
  12563. }
  12564. }
  12565. return null;
  12566. }
  12567. def_aborts(AST_Import, function() { return null; });
  12568. def_aborts(AST_BlockStatement, block_aborts);
  12569. def_aborts(AST_SwitchBranch, block_aborts);
  12570. def_aborts(AST_If, function() {
  12571. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  12572. });
  12573. })(function(node, func) {
  12574. node.DEFMETHOD("aborts", func);
  12575. });
  12576. /* -----[ optimizers ]----- */
  12577. var directives = new Set(["use asm", "use strict"]);
  12578. def_optimize(AST_Directive, function(self, compressor) {
  12579. if (compressor.option("directives")
  12580. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  12581. return make_node(AST_EmptyStatement, self);
  12582. }
  12583. return self;
  12584. });
  12585. def_optimize(AST_Debugger, function(self, compressor) {
  12586. if (compressor.option("drop_debugger"))
  12587. return make_node(AST_EmptyStatement, self);
  12588. return self;
  12589. });
  12590. def_optimize(AST_LabeledStatement, function(self, compressor) {
  12591. if (self.body instanceof AST_Break
  12592. && compressor.loopcontrol_target(self.body) === self.body) {
  12593. return make_node(AST_EmptyStatement, self);
  12594. }
  12595. return self.label.references.length == 0 ? self.body : self;
  12596. });
  12597. def_optimize(AST_Block, function(self, compressor) {
  12598. tighten_body(self.body, compressor);
  12599. return self;
  12600. });
  12601. function can_be_extracted_from_if_block(node) {
  12602. return !(
  12603. node instanceof AST_Const
  12604. || node instanceof AST_Let
  12605. || node instanceof AST_Class
  12606. );
  12607. }
  12608. def_optimize(AST_BlockStatement, function(self, compressor) {
  12609. tighten_body(self.body, compressor);
  12610. switch (self.body.length) {
  12611. case 1:
  12612. if (!compressor.has_directive("use strict")
  12613. && compressor.parent() instanceof AST_If
  12614. && can_be_extracted_from_if_block(self.body[0])
  12615. || can_be_evicted_from_block(self.body[0])) {
  12616. return self.body[0];
  12617. }
  12618. break;
  12619. case 0: return make_node(AST_EmptyStatement, self);
  12620. }
  12621. return self;
  12622. });
  12623. function opt_AST_Lambda(self, compressor) {
  12624. tighten_body(self.body, compressor);
  12625. if (compressor.option("side_effects")
  12626. && self.body.length == 1
  12627. && self.body[0] === compressor.has_directive("use strict")) {
  12628. self.body.length = 0;
  12629. }
  12630. return self;
  12631. }
  12632. def_optimize(AST_Lambda, opt_AST_Lambda);
  12633. const r_keep_assign = /keep_assign/;
  12634. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  12635. if (!compressor.option("unused")) return;
  12636. if (compressor.has_directive("use asm")) return;
  12637. var self = this;
  12638. if (self.pinned()) return;
  12639. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  12640. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  12641. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  12642. if (node instanceof AST_Assign
  12643. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  12644. ) {
  12645. return node.left;
  12646. }
  12647. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  12648. return node.expression;
  12649. }
  12650. };
  12651. var in_use_ids = new Map();
  12652. var fixed_ids = new Map();
  12653. if (self instanceof AST_Toplevel && compressor.top_retain) {
  12654. self.variables.forEach(function(def) {
  12655. if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
  12656. in_use_ids.set(def.id, def);
  12657. }
  12658. });
  12659. }
  12660. var var_defs_by_id = new Map();
  12661. var initializations = new Map();
  12662. // pass 1: find out which symbols are directly used in
  12663. // this scope (not in nested scopes).
  12664. var scope = this;
  12665. var tw = new TreeWalker(function(node, descend) {
  12666. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  12667. node.argnames.forEach(function(argname) {
  12668. if (!(argname instanceof AST_SymbolDeclaration)) return;
  12669. var def = argname.definition();
  12670. if (!in_use_ids.has(def.id)) {
  12671. in_use_ids.set(def.id, def);
  12672. }
  12673. });
  12674. }
  12675. if (node === self) return;
  12676. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  12677. var node_def = node.name.definition();
  12678. const in_export = tw.parent() instanceof AST_Export;
  12679. if (in_export || !drop_funcs && scope === self) {
  12680. if (node_def.global && !in_use_ids.has(node_def.id)) {
  12681. in_use_ids.set(node_def.id, node_def);
  12682. }
  12683. }
  12684. if (node instanceof AST_DefClass) {
  12685. if (
  12686. node.extends
  12687. && (node.extends.has_side_effects(compressor)
  12688. || node.extends.may_throw(compressor))
  12689. ) {
  12690. node.extends.walk(tw);
  12691. }
  12692. for (const prop of node.properties) {
  12693. if (
  12694. prop.has_side_effects(compressor) ||
  12695. prop.may_throw(compressor)
  12696. ) {
  12697. prop.walk(tw);
  12698. }
  12699. }
  12700. }
  12701. map_add(initializations, node_def.id, node);
  12702. return true; // don't go in nested scopes
  12703. }
  12704. if (node instanceof AST_SymbolFunarg && scope === self) {
  12705. map_add(var_defs_by_id, node.definition().id, node);
  12706. }
  12707. if (node instanceof AST_Definitions && scope === self) {
  12708. const in_export = tw.parent() instanceof AST_Export;
  12709. node.definitions.forEach(function(def) {
  12710. if (def.name instanceof AST_SymbolVar) {
  12711. map_add(var_defs_by_id, def.name.definition().id, def);
  12712. }
  12713. if (in_export || !drop_vars) {
  12714. walk(def.name, node => {
  12715. if (node instanceof AST_SymbolDeclaration) {
  12716. const def = node.definition();
  12717. if (
  12718. (in_export || def.global)
  12719. && !in_use_ids.has(def.id)
  12720. ) {
  12721. in_use_ids.set(def.id, def);
  12722. }
  12723. }
  12724. });
  12725. }
  12726. if (def.value) {
  12727. if (def.name instanceof AST_Destructuring) {
  12728. def.walk(tw);
  12729. } else {
  12730. var node_def = def.name.definition();
  12731. map_add(initializations, node_def.id, def.value);
  12732. if (!node_def.chained && def.name.fixed_value() === def.value) {
  12733. fixed_ids.set(node_def.id, def);
  12734. }
  12735. }
  12736. if (def.value.has_side_effects(compressor)) {
  12737. def.value.walk(tw);
  12738. }
  12739. }
  12740. });
  12741. return true;
  12742. }
  12743. return scan_ref_scoped(node, descend);
  12744. });
  12745. self.walk(tw);
  12746. // pass 2: for every used symbol we need to walk its
  12747. // initialization code to figure out if it uses other
  12748. // symbols (that may not be in_use).
  12749. tw = new TreeWalker(scan_ref_scoped);
  12750. in_use_ids.forEach(function (def) {
  12751. var init = initializations.get(def.id);
  12752. if (init) init.forEach(function(init) {
  12753. init.walk(tw);
  12754. });
  12755. });
  12756. // pass 3: we should drop declarations not in_use
  12757. var tt = new TreeTransformer(
  12758. function before(node, descend, in_list) {
  12759. var parent = tt.parent();
  12760. if (drop_vars) {
  12761. const sym = assign_as_unused(node);
  12762. if (sym instanceof AST_SymbolRef) {
  12763. var def = sym.definition();
  12764. var in_use = in_use_ids.has(def.id);
  12765. if (node instanceof AST_Assign) {
  12766. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  12767. return maintain_this_binding(parent, node, node.right.transform(tt));
  12768. }
  12769. } else if (!in_use) return in_list ? MAP.skip : make_node(AST_Number, node, {
  12770. value: 0
  12771. });
  12772. }
  12773. }
  12774. if (scope !== self) return;
  12775. var def;
  12776. if (node.name
  12777. && (node instanceof AST_ClassExpression
  12778. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  12779. || node instanceof AST_Function
  12780. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  12781. // any declarations with same name will overshadow
  12782. // name of this anonymous function and can therefore
  12783. // never be used anywhere
  12784. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  12785. }
  12786. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  12787. var trim = !compressor.option("keep_fargs");
  12788. for (var a = node.argnames, i = a.length; --i >= 0;) {
  12789. var sym = a[i];
  12790. if (sym instanceof AST_Expansion) {
  12791. sym = sym.expression;
  12792. }
  12793. if (sym instanceof AST_DefaultAssign) {
  12794. sym = sym.left;
  12795. }
  12796. // Do not drop destructuring arguments.
  12797. // They constitute a type assertion, so dropping
  12798. // them would stop that TypeError which would happen
  12799. // if someone called it with an incorrectly formatted
  12800. // parameter.
  12801. if (!(sym instanceof AST_Destructuring) && !in_use_ids.has(sym.definition().id)) {
  12802. set_flag(sym, UNUSED);
  12803. if (trim) {
  12804. a.pop();
  12805. }
  12806. } else {
  12807. trim = false;
  12808. }
  12809. }
  12810. }
  12811. if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
  12812. const def = node.name.definition();
  12813. let keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  12814. if (!keep) {
  12815. def.eliminated++;
  12816. if (node instanceof AST_DefClass) {
  12817. // Classes might have extends with side effects
  12818. const side_effects = node.drop_side_effect_free(compressor);
  12819. if (side_effects) {
  12820. return make_node(AST_SimpleStatement, node, {
  12821. body: side_effects
  12822. });
  12823. }
  12824. }
  12825. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  12826. }
  12827. }
  12828. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  12829. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  12830. // place uninitialized names at the start
  12831. var body = [], head = [], tail = [];
  12832. // for unused names whose initialization has
  12833. // side effects, we can cascade the init. code
  12834. // into the next one, or next statement.
  12835. var side_effects = [];
  12836. node.definitions.forEach(function(def) {
  12837. if (def.value) def.value = def.value.transform(tt);
  12838. var is_destructure = def.name instanceof AST_Destructuring;
  12839. var sym = is_destructure
  12840. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  12841. : def.name.definition();
  12842. if (drop_block && sym.global) return tail.push(def);
  12843. if (!(drop_vars || drop_block)
  12844. || is_destructure
  12845. && (def.name.names.length
  12846. || def.name.is_array
  12847. || compressor.option("pure_getters") != true)
  12848. || in_use_ids.has(sym.id)
  12849. ) {
  12850. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  12851. def.value = def.value.drop_side_effect_free(compressor);
  12852. }
  12853. if (def.name instanceof AST_SymbolVar) {
  12854. var var_defs = var_defs_by_id.get(sym.id);
  12855. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  12856. if (def.value) {
  12857. var ref = make_node(AST_SymbolRef, def.name, def.name);
  12858. sym.references.push(ref);
  12859. var assign = make_node(AST_Assign, def, {
  12860. operator: "=",
  12861. left: ref,
  12862. right: def.value
  12863. });
  12864. if (fixed_ids.get(sym.id) === def) {
  12865. fixed_ids.set(sym.id, assign);
  12866. }
  12867. side_effects.push(assign.transform(tt));
  12868. }
  12869. remove(var_defs, def);
  12870. sym.eliminated++;
  12871. return;
  12872. }
  12873. }
  12874. if (def.value) {
  12875. if (side_effects.length > 0) {
  12876. if (tail.length > 0) {
  12877. side_effects.push(def.value);
  12878. def.value = make_sequence(def.value, side_effects);
  12879. } else {
  12880. body.push(make_node(AST_SimpleStatement, node, {
  12881. body: make_sequence(node, side_effects)
  12882. }));
  12883. }
  12884. side_effects = [];
  12885. }
  12886. tail.push(def);
  12887. } else {
  12888. head.push(def);
  12889. }
  12890. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  12891. var value = def.value && def.value.drop_side_effect_free(compressor);
  12892. if (value) side_effects.push(value);
  12893. def.value = null;
  12894. head.push(def);
  12895. } else {
  12896. var value = def.value && def.value.drop_side_effect_free(compressor);
  12897. if (value) {
  12898. side_effects.push(value);
  12899. }
  12900. sym.eliminated++;
  12901. }
  12902. });
  12903. if (head.length > 0 || tail.length > 0) {
  12904. node.definitions = head.concat(tail);
  12905. body.push(node);
  12906. }
  12907. if (side_effects.length > 0) {
  12908. body.push(make_node(AST_SimpleStatement, node, {
  12909. body: make_sequence(node, side_effects)
  12910. }));
  12911. }
  12912. switch (body.length) {
  12913. case 0:
  12914. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  12915. case 1:
  12916. return body[0];
  12917. default:
  12918. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  12919. body: body
  12920. });
  12921. }
  12922. }
  12923. // certain combination of unused name + side effect leads to:
  12924. // https://github.com/mishoo/UglifyJS2/issues/44
  12925. // https://github.com/mishoo/UglifyJS2/issues/1830
  12926. // https://github.com/mishoo/UglifyJS2/issues/1838
  12927. // that's an invalid AST.
  12928. // We fix it at this stage by moving the `var` outside the `for`.
  12929. if (node instanceof AST_For) {
  12930. descend(node, this);
  12931. var block;
  12932. if (node.init instanceof AST_BlockStatement) {
  12933. block = node.init;
  12934. node.init = block.body.pop();
  12935. block.body.push(node);
  12936. }
  12937. if (node.init instanceof AST_SimpleStatement) {
  12938. node.init = node.init.body;
  12939. } else if (is_empty(node.init)) {
  12940. node.init = null;
  12941. }
  12942. return !block ? node : in_list ? MAP.splice(block.body) : block;
  12943. }
  12944. if (node instanceof AST_LabeledStatement
  12945. && node.body instanceof AST_For
  12946. ) {
  12947. descend(node, this);
  12948. if (node.body instanceof AST_BlockStatement) {
  12949. var block = node.body;
  12950. node.body = block.body.pop();
  12951. block.body.push(node);
  12952. return in_list ? MAP.splice(block.body) : block;
  12953. }
  12954. return node;
  12955. }
  12956. if (node instanceof AST_BlockStatement) {
  12957. descend(node, this);
  12958. if (in_list && node.body.every(can_be_evicted_from_block)) {
  12959. return MAP.splice(node.body);
  12960. }
  12961. return node;
  12962. }
  12963. if (node instanceof AST_Scope) {
  12964. const save_scope = scope;
  12965. scope = node;
  12966. descend(node, this);
  12967. scope = save_scope;
  12968. return node;
  12969. }
  12970. }
  12971. );
  12972. self.transform(tt);
  12973. function scan_ref_scoped(node, descend) {
  12974. var node_def;
  12975. const sym = assign_as_unused(node);
  12976. if (sym instanceof AST_SymbolRef
  12977. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  12978. && self.variables.get(sym.name) === (node_def = sym.definition())
  12979. ) {
  12980. if (node instanceof AST_Assign) {
  12981. node.right.walk(tw);
  12982. if (!node_def.chained && node.left.fixed_value() === node.right) {
  12983. fixed_ids.set(node_def.id, node);
  12984. }
  12985. }
  12986. return true;
  12987. }
  12988. if (node instanceof AST_SymbolRef) {
  12989. node_def = node.definition();
  12990. if (!in_use_ids.has(node_def.id)) {
  12991. in_use_ids.set(node_def.id, node_def);
  12992. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  12993. const redef = node_def.scope.is_block_scope()
  12994. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  12995. if (redef) in_use_ids.set(redef.id, redef);
  12996. }
  12997. }
  12998. return true;
  12999. }
  13000. if (node instanceof AST_Scope) {
  13001. var save_scope = scope;
  13002. scope = node;
  13003. descend();
  13004. scope = save_scope;
  13005. return true;
  13006. }
  13007. }
  13008. });
  13009. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  13010. var self = this;
  13011. if (compressor.has_directive("use asm")) return self;
  13012. // Hoisting makes no sense in an arrow func
  13013. if (!Array.isArray(self.body)) return self;
  13014. var hoist_funs = compressor.option("hoist_funs");
  13015. var hoist_vars = compressor.option("hoist_vars");
  13016. if (hoist_funs || hoist_vars) {
  13017. var dirs = [];
  13018. var hoisted = [];
  13019. var vars = new Map(), vars_found = 0, var_decl = 0;
  13020. // let's count var_decl first, we seem to waste a lot of
  13021. // space if we hoist `var` when there's only one.
  13022. walk(self, node => {
  13023. if (node instanceof AST_Scope && node !== self)
  13024. return true;
  13025. if (node instanceof AST_Var) {
  13026. ++var_decl;
  13027. return true;
  13028. }
  13029. });
  13030. hoist_vars = hoist_vars && var_decl > 1;
  13031. var tt = new TreeTransformer(
  13032. function before(node) {
  13033. if (node !== self) {
  13034. if (node instanceof AST_Directive) {
  13035. dirs.push(node);
  13036. return make_node(AST_EmptyStatement, node);
  13037. }
  13038. if (hoist_funs && node instanceof AST_Defun
  13039. && !(tt.parent() instanceof AST_Export)
  13040. && tt.parent() === self) {
  13041. hoisted.push(node);
  13042. return make_node(AST_EmptyStatement, node);
  13043. }
  13044. if (
  13045. hoist_vars
  13046. && node instanceof AST_Var
  13047. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  13048. ) {
  13049. node.definitions.forEach(function(def) {
  13050. vars.set(def.name.name, def);
  13051. ++vars_found;
  13052. });
  13053. var seq = node.to_assignments(compressor);
  13054. var p = tt.parent();
  13055. if (p instanceof AST_ForIn && p.init === node) {
  13056. if (seq == null) {
  13057. var def = node.definitions[0].name;
  13058. return make_node(AST_SymbolRef, def, def);
  13059. }
  13060. return seq;
  13061. }
  13062. if (p instanceof AST_For && p.init === node) {
  13063. return seq;
  13064. }
  13065. if (!seq) return make_node(AST_EmptyStatement, node);
  13066. return make_node(AST_SimpleStatement, node, {
  13067. body: seq
  13068. });
  13069. }
  13070. if (node instanceof AST_Scope)
  13071. return node; // to avoid descending in nested scopes
  13072. }
  13073. }
  13074. );
  13075. self = self.transform(tt);
  13076. if (vars_found > 0) {
  13077. // collect only vars which don't show up in self's arguments list
  13078. var defs = [];
  13079. const is_lambda = self instanceof AST_Lambda;
  13080. const args_as_names = is_lambda ? self.args_as_names() : null;
  13081. vars.forEach((def, name) => {
  13082. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  13083. vars.delete(name);
  13084. } else {
  13085. def = def.clone();
  13086. def.value = null;
  13087. defs.push(def);
  13088. vars.set(name, def);
  13089. }
  13090. });
  13091. if (defs.length > 0) {
  13092. // try to merge in assignments
  13093. for (var i = 0; i < self.body.length;) {
  13094. if (self.body[i] instanceof AST_SimpleStatement) {
  13095. var expr = self.body[i].body, sym, assign;
  13096. if (expr instanceof AST_Assign
  13097. && expr.operator == "="
  13098. && (sym = expr.left) instanceof AST_Symbol
  13099. && vars.has(sym.name)
  13100. ) {
  13101. var def = vars.get(sym.name);
  13102. if (def.value) break;
  13103. def.value = expr.right;
  13104. remove(defs, def);
  13105. defs.push(def);
  13106. self.body.splice(i, 1);
  13107. continue;
  13108. }
  13109. if (expr instanceof AST_Sequence
  13110. && (assign = expr.expressions[0]) instanceof AST_Assign
  13111. && assign.operator == "="
  13112. && (sym = assign.left) instanceof AST_Symbol
  13113. && vars.has(sym.name)
  13114. ) {
  13115. var def = vars.get(sym.name);
  13116. if (def.value) break;
  13117. def.value = assign.right;
  13118. remove(defs, def);
  13119. defs.push(def);
  13120. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  13121. continue;
  13122. }
  13123. }
  13124. if (self.body[i] instanceof AST_EmptyStatement) {
  13125. self.body.splice(i, 1);
  13126. continue;
  13127. }
  13128. if (self.body[i] instanceof AST_BlockStatement) {
  13129. self.body.splice(i, 1, ...self.body[i].body);
  13130. continue;
  13131. }
  13132. break;
  13133. }
  13134. defs = make_node(AST_Var, self, {
  13135. definitions: defs
  13136. });
  13137. hoisted.push(defs);
  13138. }
  13139. }
  13140. self.body = dirs.concat(hoisted, self.body);
  13141. }
  13142. return self;
  13143. });
  13144. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  13145. var self = this;
  13146. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  13147. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  13148. var defs_by_id = new Map();
  13149. var hoister = new TreeTransformer(function(node, descend) {
  13150. if (node instanceof AST_Definitions
  13151. && hoister.parent() instanceof AST_Export) return node;
  13152. if (node instanceof AST_VarDef) {
  13153. const sym = node.name;
  13154. let def;
  13155. let value;
  13156. if (sym.scope === self
  13157. && (def = sym.definition()).escaped != 1
  13158. && !def.assignments
  13159. && !def.direct_access
  13160. && !def.single_use
  13161. && !compressor.exposed(def)
  13162. && !top_retain(def)
  13163. && (value = sym.fixed_value()) === node.value
  13164. && value instanceof AST_Object
  13165. && !value.properties.some(prop =>
  13166. prop instanceof AST_Expansion || prop.computed_key()
  13167. )
  13168. ) {
  13169. descend(node, this);
  13170. const defs = new Map();
  13171. const assignments = [];
  13172. value.properties.forEach(({ key, value }) => {
  13173. const scope = find_scope(hoister);
  13174. const symbol = self.create_symbol(sym.CTOR, {
  13175. source: sym,
  13176. scope,
  13177. conflict_scopes: new Set([
  13178. scope,
  13179. ...sym.definition().references.map(ref => ref.scope)
  13180. ]),
  13181. tentative_name: sym.name + "_" + key
  13182. });
  13183. defs.set(String(key), symbol.definition());
  13184. assignments.push(make_node(AST_VarDef, node, {
  13185. name: symbol,
  13186. value
  13187. }));
  13188. });
  13189. defs_by_id.set(def.id, defs);
  13190. return MAP.splice(assignments);
  13191. }
  13192. } else if (node instanceof AST_PropAccess
  13193. && node.expression instanceof AST_SymbolRef
  13194. ) {
  13195. const defs = defs_by_id.get(node.expression.definition().id);
  13196. if (defs) {
  13197. const def = defs.get(String(get_value(node.property)));
  13198. const sym = make_node(AST_SymbolRef, node, {
  13199. name: def.name,
  13200. scope: node.expression.scope,
  13201. thedef: def
  13202. });
  13203. sym.reference({});
  13204. return sym;
  13205. }
  13206. }
  13207. });
  13208. return self.transform(hoister);
  13209. });
  13210. // drop_side_effect_free()
  13211. // remove side-effect-free parts which only affects return value
  13212. (function(def_drop_side_effect_free) {
  13213. // Drop side-effect-free elements from an array of expressions.
  13214. // Returns an array of expressions with side-effects or null
  13215. // if all elements were dropped. Note: original array may be
  13216. // returned if nothing changed.
  13217. function trim(nodes, compressor, first_in_statement) {
  13218. var len = nodes.length;
  13219. if (!len) return null;
  13220. var ret = [], changed = false;
  13221. for (var i = 0; i < len; i++) {
  13222. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  13223. changed |= node !== nodes[i];
  13224. if (node) {
  13225. ret.push(node);
  13226. first_in_statement = false;
  13227. }
  13228. }
  13229. return changed ? ret.length ? ret : null : nodes;
  13230. }
  13231. def_drop_side_effect_free(AST_Node, return_this);
  13232. def_drop_side_effect_free(AST_Constant, return_null);
  13233. def_drop_side_effect_free(AST_This, return_null);
  13234. def_drop_side_effect_free(AST_Call, function(compressor, first_in_statement) {
  13235. if (this.optional && is_nullish(this.expression)) {
  13236. return make_node(AST_Undefined, this);
  13237. }
  13238. if (!this.is_expr_pure(compressor)) {
  13239. if (this.expression.is_call_pure(compressor)) {
  13240. var exprs = this.args.slice();
  13241. exprs.unshift(this.expression.expression);
  13242. exprs = trim(exprs, compressor, first_in_statement);
  13243. return exprs && make_sequence(this, exprs);
  13244. }
  13245. if (is_func_expr(this.expression)
  13246. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  13247. var node = this.clone();
  13248. node.expression.process_expression(false, compressor);
  13249. return node;
  13250. }
  13251. return this;
  13252. }
  13253. var args = trim(this.args, compressor, first_in_statement);
  13254. return args && make_sequence(this, args);
  13255. });
  13256. def_drop_side_effect_free(AST_Accessor, return_null);
  13257. def_drop_side_effect_free(AST_Function, return_null);
  13258. def_drop_side_effect_free(AST_Arrow, return_null);
  13259. def_drop_side_effect_free(AST_Class, function (compressor) {
  13260. const with_effects = [];
  13261. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  13262. if (trimmed_extends) with_effects.push(trimmed_extends);
  13263. for (const prop of this.properties) {
  13264. const trimmed_prop = prop.drop_side_effect_free(compressor);
  13265. if (trimmed_prop) with_effects.push(trimmed_prop);
  13266. }
  13267. if (!with_effects.length) return null;
  13268. return make_sequence(this, with_effects);
  13269. });
  13270. def_drop_side_effect_free(AST_Binary, function(compressor, first_in_statement) {
  13271. var right = this.right.drop_side_effect_free(compressor);
  13272. if (!right) return this.left.drop_side_effect_free(compressor, first_in_statement);
  13273. if (lazy_op.has(this.operator)) {
  13274. if (right === this.right) return this;
  13275. var node = this.clone();
  13276. node.right = right;
  13277. return node;
  13278. } else {
  13279. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  13280. if (!left) return this.right.drop_side_effect_free(compressor, first_in_statement);
  13281. return make_sequence(this, [ left, right ]);
  13282. }
  13283. });
  13284. def_drop_side_effect_free(AST_Assign, function(compressor) {
  13285. var left = this.left;
  13286. if (left.has_side_effects(compressor)
  13287. || compressor.has_directive("use strict")
  13288. && left instanceof AST_PropAccess
  13289. && left.expression.is_constant()) {
  13290. return this;
  13291. }
  13292. set_flag(this, WRITE_ONLY);
  13293. while (left instanceof AST_PropAccess) {
  13294. left = left.expression;
  13295. }
  13296. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  13297. return this.right.drop_side_effect_free(compressor);
  13298. }
  13299. return this;
  13300. });
  13301. def_drop_side_effect_free(AST_Conditional, function(compressor) {
  13302. var consequent = this.consequent.drop_side_effect_free(compressor);
  13303. var alternative = this.alternative.drop_side_effect_free(compressor);
  13304. if (consequent === this.consequent && alternative === this.alternative) return this;
  13305. if (!consequent) return alternative ? make_node(AST_Binary, this, {
  13306. operator: "||",
  13307. left: this.condition,
  13308. right: alternative
  13309. }) : this.condition.drop_side_effect_free(compressor);
  13310. if (!alternative) return make_node(AST_Binary, this, {
  13311. operator: "&&",
  13312. left: this.condition,
  13313. right: consequent
  13314. });
  13315. var node = this.clone();
  13316. node.consequent = consequent;
  13317. node.alternative = alternative;
  13318. return node;
  13319. });
  13320. def_drop_side_effect_free(AST_Unary, function(compressor, first_in_statement) {
  13321. if (unary_side_effects.has(this.operator)) {
  13322. if (!this.expression.has_side_effects(compressor)) {
  13323. set_flag(this, WRITE_ONLY);
  13324. } else {
  13325. clear_flag(this, WRITE_ONLY);
  13326. }
  13327. return this;
  13328. }
  13329. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef) return null;
  13330. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13331. if (first_in_statement && expression && is_iife_call(expression)) {
  13332. if (expression === this.expression && this.operator == "!") return this;
  13333. return expression.negate(compressor, first_in_statement);
  13334. }
  13335. return expression;
  13336. });
  13337. def_drop_side_effect_free(AST_SymbolRef, function(compressor) {
  13338. const safe_access = this.is_declared(compressor)
  13339. || pure_prop_access_globals.has(this.name);
  13340. return safe_access ? null : this;
  13341. });
  13342. def_drop_side_effect_free(AST_Object, function(compressor, first_in_statement) {
  13343. var values = trim(this.properties, compressor, first_in_statement);
  13344. return values && make_sequence(this, values);
  13345. });
  13346. def_drop_side_effect_free(AST_ObjectProperty, function(compressor, first_in_statement) {
  13347. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  13348. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  13349. const value = this.value.drop_side_effect_free(compressor, first_in_statement);
  13350. if (key && value) {
  13351. return make_sequence(this, [key, value]);
  13352. }
  13353. return key || value;
  13354. });
  13355. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  13356. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  13357. const value = this.static && this.value
  13358. && this.value.drop_side_effect_free(compressor);
  13359. if (key && value) return make_sequence(this, [key, value]);
  13360. return key || value || null;
  13361. });
  13362. def_drop_side_effect_free(AST_ConciseMethod, function () {
  13363. return this.computed_key() ? this.key : null;
  13364. });
  13365. def_drop_side_effect_free(AST_ObjectGetter, function () {
  13366. return this.computed_key() ? this.key : null;
  13367. });
  13368. def_drop_side_effect_free(AST_ObjectSetter, function () {
  13369. return this.computed_key() ? this.key : null;
  13370. });
  13371. def_drop_side_effect_free(AST_Array, function(compressor, first_in_statement) {
  13372. var values = trim(this.elements, compressor, first_in_statement);
  13373. return values && make_sequence(this, values);
  13374. });
  13375. def_drop_side_effect_free(AST_Dot, function(compressor, first_in_statement) {
  13376. if (this.optional) {
  13377. return is_nullish(this.expression) ? make_node(AST_Undefined, this) : this;
  13378. }
  13379. if (this.expression.may_throw_on_access(compressor)) return this;
  13380. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13381. });
  13382. def_drop_side_effect_free(AST_Sub, function(compressor, first_in_statement) {
  13383. if (this.optional) {
  13384. return is_nullish(this.expression) ? make_node(AST_Undefined, this): this;
  13385. }
  13386. if (this.expression.may_throw_on_access(compressor)) return this;
  13387. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13388. if (!expression) return this.property.drop_side_effect_free(compressor, first_in_statement);
  13389. var property = this.property.drop_side_effect_free(compressor);
  13390. if (!property) return expression;
  13391. return make_sequence(this, [ expression, property ]);
  13392. });
  13393. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  13394. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13395. });
  13396. def_drop_side_effect_free(AST_Sequence, function(compressor) {
  13397. var last = this.tail_node();
  13398. var expr = last.drop_side_effect_free(compressor);
  13399. if (expr === last) return this;
  13400. var expressions = this.expressions.slice(0, -1);
  13401. if (expr) expressions.push(expr);
  13402. if (!expressions.length) {
  13403. return make_node(AST_Number, this, { value: 0 });
  13404. }
  13405. return make_sequence(this, expressions);
  13406. });
  13407. def_drop_side_effect_free(AST_Expansion, function(compressor, first_in_statement) {
  13408. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13409. });
  13410. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  13411. def_drop_side_effect_free(AST_TemplateString, function(compressor) {
  13412. var values = trim(this.segments, compressor, first_in_statement);
  13413. return values && make_sequence(this, values);
  13414. });
  13415. })(function(node, func) {
  13416. node.DEFMETHOD("drop_side_effect_free", func);
  13417. });
  13418. def_optimize(AST_SimpleStatement, function(self, compressor) {
  13419. if (compressor.option("side_effects")) {
  13420. var body = self.body;
  13421. var node = body.drop_side_effect_free(compressor, true);
  13422. if (!node) {
  13423. return make_node(AST_EmptyStatement, self);
  13424. }
  13425. if (node !== body) {
  13426. return make_node(AST_SimpleStatement, self, { body: node });
  13427. }
  13428. }
  13429. return self;
  13430. });
  13431. def_optimize(AST_While, function(self, compressor) {
  13432. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  13433. });
  13434. function has_break_or_continue(loop, parent) {
  13435. var found = false;
  13436. var tw = new TreeWalker(function(node) {
  13437. if (found || node instanceof AST_Scope) return true;
  13438. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  13439. return found = true;
  13440. }
  13441. });
  13442. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  13443. tw.push(loop);
  13444. loop.body.walk(tw);
  13445. return found;
  13446. }
  13447. def_optimize(AST_Do, function(self, compressor) {
  13448. if (!compressor.option("loops")) return self;
  13449. var cond = self.condition.tail_node().evaluate(compressor);
  13450. if (!(cond instanceof AST_Node)) {
  13451. if (cond) return make_node(AST_For, self, {
  13452. body: make_node(AST_BlockStatement, self.body, {
  13453. body: [
  13454. self.body,
  13455. make_node(AST_SimpleStatement, self.condition, {
  13456. body: self.condition
  13457. })
  13458. ]
  13459. })
  13460. }).optimize(compressor);
  13461. if (!has_break_or_continue(self, compressor.parent())) {
  13462. return make_node(AST_BlockStatement, self.body, {
  13463. body: [
  13464. self.body,
  13465. make_node(AST_SimpleStatement, self.condition, {
  13466. body: self.condition
  13467. })
  13468. ]
  13469. }).optimize(compressor);
  13470. }
  13471. }
  13472. return self;
  13473. });
  13474. function if_break_in_loop(self, compressor) {
  13475. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  13476. if (compressor.option("dead_code") && is_break(first)) {
  13477. var body = [];
  13478. if (self.init instanceof AST_Statement) {
  13479. body.push(self.init);
  13480. } else if (self.init) {
  13481. body.push(make_node(AST_SimpleStatement, self.init, {
  13482. body: self.init
  13483. }));
  13484. }
  13485. if (self.condition) {
  13486. body.push(make_node(AST_SimpleStatement, self.condition, {
  13487. body: self.condition
  13488. }));
  13489. }
  13490. trim_unreachable_code(compressor, self.body, body);
  13491. return make_node(AST_BlockStatement, self, {
  13492. body: body
  13493. });
  13494. }
  13495. if (first instanceof AST_If) {
  13496. if (is_break(first.body)) {
  13497. if (self.condition) {
  13498. self.condition = make_node(AST_Binary, self.condition, {
  13499. left: self.condition,
  13500. operator: "&&",
  13501. right: first.condition.negate(compressor),
  13502. });
  13503. } else {
  13504. self.condition = first.condition.negate(compressor);
  13505. }
  13506. drop_it(first.alternative);
  13507. } else if (is_break(first.alternative)) {
  13508. if (self.condition) {
  13509. self.condition = make_node(AST_Binary, self.condition, {
  13510. left: self.condition,
  13511. operator: "&&",
  13512. right: first.condition,
  13513. });
  13514. } else {
  13515. self.condition = first.condition;
  13516. }
  13517. drop_it(first.body);
  13518. }
  13519. }
  13520. return self;
  13521. function is_break(node) {
  13522. return node instanceof AST_Break
  13523. && compressor.loopcontrol_target(node) === compressor.self();
  13524. }
  13525. function drop_it(rest) {
  13526. rest = as_statement_array(rest);
  13527. if (self.body instanceof AST_BlockStatement) {
  13528. self.body = self.body.clone();
  13529. self.body.body = rest.concat(self.body.body.slice(1));
  13530. self.body = self.body.transform(compressor);
  13531. } else {
  13532. self.body = make_node(AST_BlockStatement, self.body, {
  13533. body: rest
  13534. }).transform(compressor);
  13535. }
  13536. self = if_break_in_loop(self, compressor);
  13537. }
  13538. }
  13539. def_optimize(AST_For, function(self, compressor) {
  13540. if (!compressor.option("loops")) return self;
  13541. if (compressor.option("side_effects") && self.init) {
  13542. self.init = self.init.drop_side_effect_free(compressor);
  13543. }
  13544. if (self.condition) {
  13545. var cond = self.condition.evaluate(compressor);
  13546. if (!(cond instanceof AST_Node)) {
  13547. if (cond) self.condition = null;
  13548. else if (!compressor.option("dead_code")) {
  13549. var orig = self.condition;
  13550. self.condition = make_node_from_constant(cond, self.condition);
  13551. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  13552. }
  13553. }
  13554. if (compressor.option("dead_code")) {
  13555. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  13556. if (!cond) {
  13557. var body = [];
  13558. trim_unreachable_code(compressor, self.body, body);
  13559. if (self.init instanceof AST_Statement) {
  13560. body.push(self.init);
  13561. } else if (self.init) {
  13562. body.push(make_node(AST_SimpleStatement, self.init, {
  13563. body: self.init
  13564. }));
  13565. }
  13566. body.push(make_node(AST_SimpleStatement, self.condition, {
  13567. body: self.condition
  13568. }));
  13569. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  13570. }
  13571. }
  13572. }
  13573. return if_break_in_loop(self, compressor);
  13574. });
  13575. def_optimize(AST_If, function(self, compressor) {
  13576. if (is_empty(self.alternative)) self.alternative = null;
  13577. if (!compressor.option("conditionals")) return self;
  13578. // if condition can be statically determined, drop
  13579. // one of the blocks. note, statically determined implies
  13580. // “has no side effects”; also it doesn't work for cases like
  13581. // `x && true`, though it probably should.
  13582. var cond = self.condition.evaluate(compressor);
  13583. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  13584. var orig = self.condition;
  13585. self.condition = make_node_from_constant(cond, orig);
  13586. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  13587. }
  13588. if (compressor.option("dead_code")) {
  13589. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  13590. if (!cond) {
  13591. var body = [];
  13592. trim_unreachable_code(compressor, self.body, body);
  13593. body.push(make_node(AST_SimpleStatement, self.condition, {
  13594. body: self.condition
  13595. }));
  13596. if (self.alternative) body.push(self.alternative);
  13597. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  13598. } else if (!(cond instanceof AST_Node)) {
  13599. var body = [];
  13600. body.push(make_node(AST_SimpleStatement, self.condition, {
  13601. body: self.condition
  13602. }));
  13603. body.push(self.body);
  13604. if (self.alternative) {
  13605. trim_unreachable_code(compressor, self.alternative, body);
  13606. }
  13607. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  13608. }
  13609. }
  13610. var negated = self.condition.negate(compressor);
  13611. var self_condition_length = self.condition.size();
  13612. var negated_length = negated.size();
  13613. var negated_is_best = negated_length < self_condition_length;
  13614. if (self.alternative && negated_is_best) {
  13615. negated_is_best = false; // because we already do the switch here.
  13616. // no need to swap values of self_condition_length and negated_length
  13617. // here because they are only used in an equality comparison later on.
  13618. self.condition = negated;
  13619. var tmp = self.body;
  13620. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  13621. self.alternative = tmp;
  13622. }
  13623. if (is_empty(self.body) && is_empty(self.alternative)) {
  13624. return make_node(AST_SimpleStatement, self.condition, {
  13625. body: self.condition.clone()
  13626. }).optimize(compressor);
  13627. }
  13628. if (self.body instanceof AST_SimpleStatement
  13629. && self.alternative instanceof AST_SimpleStatement) {
  13630. return make_node(AST_SimpleStatement, self, {
  13631. body: make_node(AST_Conditional, self, {
  13632. condition : self.condition,
  13633. consequent : self.body.body,
  13634. alternative : self.alternative.body
  13635. })
  13636. }).optimize(compressor);
  13637. }
  13638. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  13639. if (self_condition_length === negated_length && !negated_is_best
  13640. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  13641. // although the code length of self.condition and negated are the same,
  13642. // negated does not require additional surrounding parentheses.
  13643. // see https://github.com/mishoo/UglifyJS2/issues/979
  13644. negated_is_best = true;
  13645. }
  13646. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  13647. body: make_node(AST_Binary, self, {
  13648. operator : "||",
  13649. left : negated,
  13650. right : self.body.body
  13651. })
  13652. }).optimize(compressor);
  13653. return make_node(AST_SimpleStatement, self, {
  13654. body: make_node(AST_Binary, self, {
  13655. operator : "&&",
  13656. left : self.condition,
  13657. right : self.body.body
  13658. })
  13659. }).optimize(compressor);
  13660. }
  13661. if (self.body instanceof AST_EmptyStatement
  13662. && self.alternative instanceof AST_SimpleStatement) {
  13663. return make_node(AST_SimpleStatement, self, {
  13664. body: make_node(AST_Binary, self, {
  13665. operator : "||",
  13666. left : self.condition,
  13667. right : self.alternative.body
  13668. })
  13669. }).optimize(compressor);
  13670. }
  13671. if (self.body instanceof AST_Exit
  13672. && self.alternative instanceof AST_Exit
  13673. && self.body.TYPE == self.alternative.TYPE) {
  13674. return make_node(self.body.CTOR, self, {
  13675. value: make_node(AST_Conditional, self, {
  13676. condition : self.condition,
  13677. consequent : self.body.value || make_node(AST_Undefined, self.body),
  13678. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  13679. }).transform(compressor)
  13680. }).optimize(compressor);
  13681. }
  13682. if (self.body instanceof AST_If
  13683. && !self.body.alternative
  13684. && !self.alternative) {
  13685. self = make_node(AST_If, self, {
  13686. condition: make_node(AST_Binary, self.condition, {
  13687. operator: "&&",
  13688. left: self.condition,
  13689. right: self.body.condition
  13690. }),
  13691. body: self.body.body,
  13692. alternative: null
  13693. });
  13694. }
  13695. if (aborts(self.body)) {
  13696. if (self.alternative) {
  13697. var alt = self.alternative;
  13698. self.alternative = null;
  13699. return make_node(AST_BlockStatement, self, {
  13700. body: [ self, alt ]
  13701. }).optimize(compressor);
  13702. }
  13703. }
  13704. if (aborts(self.alternative)) {
  13705. var body = self.body;
  13706. self.body = self.alternative;
  13707. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  13708. self.alternative = null;
  13709. return make_node(AST_BlockStatement, self, {
  13710. body: [ self, body ]
  13711. }).optimize(compressor);
  13712. }
  13713. return self;
  13714. });
  13715. def_optimize(AST_Switch, function(self, compressor) {
  13716. if (!compressor.option("switches")) return self;
  13717. var branch;
  13718. var value = self.expression.evaluate(compressor);
  13719. if (!(value instanceof AST_Node)) {
  13720. var orig = self.expression;
  13721. self.expression = make_node_from_constant(value, orig);
  13722. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  13723. }
  13724. if (!compressor.option("dead_code")) return self;
  13725. if (value instanceof AST_Node) {
  13726. value = self.expression.tail_node().evaluate(compressor);
  13727. }
  13728. var decl = [];
  13729. var body = [];
  13730. var default_branch;
  13731. var exact_match;
  13732. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  13733. branch = self.body[i];
  13734. if (branch instanceof AST_Default) {
  13735. if (!default_branch) {
  13736. default_branch = branch;
  13737. } else {
  13738. eliminate_branch(branch, body[body.length - 1]);
  13739. }
  13740. } else if (!(value instanceof AST_Node)) {
  13741. var exp = branch.expression.evaluate(compressor);
  13742. if (!(exp instanceof AST_Node) && exp !== value) {
  13743. eliminate_branch(branch, body[body.length - 1]);
  13744. continue;
  13745. }
  13746. if (exp instanceof AST_Node) exp = branch.expression.tail_node().evaluate(compressor);
  13747. if (exp === value) {
  13748. exact_match = branch;
  13749. if (default_branch) {
  13750. var default_index = body.indexOf(default_branch);
  13751. body.splice(default_index, 1);
  13752. eliminate_branch(default_branch, body[default_index - 1]);
  13753. default_branch = null;
  13754. }
  13755. }
  13756. }
  13757. if (aborts(branch)) {
  13758. var prev = body[body.length - 1];
  13759. if (aborts(prev) && prev.body.length == branch.body.length
  13760. && make_node(AST_BlockStatement, prev, prev).equivalent_to(make_node(AST_BlockStatement, branch, branch))) {
  13761. prev.body = [];
  13762. }
  13763. }
  13764. body.push(branch);
  13765. }
  13766. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  13767. if (body.length > 0) {
  13768. body[0].body = decl.concat(body[0].body);
  13769. }
  13770. self.body = body;
  13771. while (branch = body[body.length - 1]) {
  13772. var stat = branch.body[branch.body.length - 1];
  13773. if (stat instanceof AST_Break && compressor.loopcontrol_target(stat) === self)
  13774. branch.body.pop();
  13775. if (branch.body.length || branch instanceof AST_Case
  13776. && (default_branch || branch.expression.has_side_effects(compressor))) break;
  13777. if (body.pop() === default_branch) default_branch = null;
  13778. }
  13779. if (body.length == 0) {
  13780. return make_node(AST_BlockStatement, self, {
  13781. body: decl.concat(make_node(AST_SimpleStatement, self.expression, {
  13782. body: self.expression
  13783. }))
  13784. }).optimize(compressor);
  13785. }
  13786. if (body.length == 1 && (body[0] === exact_match || body[0] === default_branch)) {
  13787. var has_break = false;
  13788. var tw = new TreeWalker(function(node) {
  13789. if (has_break
  13790. || node instanceof AST_Lambda
  13791. || node instanceof AST_SimpleStatement) return true;
  13792. if (node instanceof AST_Break && tw.loopcontrol_target(node) === self)
  13793. has_break = true;
  13794. });
  13795. self.walk(tw);
  13796. if (!has_break) {
  13797. var statements = body[0].body.slice();
  13798. var exp = body[0].expression;
  13799. if (exp) statements.unshift(make_node(AST_SimpleStatement, exp, {
  13800. body: exp
  13801. }));
  13802. statements.unshift(make_node(AST_SimpleStatement, self.expression, {
  13803. body:self.expression
  13804. }));
  13805. return make_node(AST_BlockStatement, self, {
  13806. body: statements
  13807. }).optimize(compressor);
  13808. }
  13809. }
  13810. return self;
  13811. function eliminate_branch(branch, prev) {
  13812. if (prev && !aborts(prev)) {
  13813. prev.body = prev.body.concat(branch.body);
  13814. } else {
  13815. trim_unreachable_code(compressor, branch, decl);
  13816. }
  13817. }
  13818. });
  13819. def_optimize(AST_Try, function(self, compressor) {
  13820. tighten_body(self.body, compressor);
  13821. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  13822. if (compressor.option("dead_code") && self.body.every(is_empty)) {
  13823. var body = [];
  13824. if (self.bcatch) {
  13825. trim_unreachable_code(compressor, self.bcatch, body);
  13826. }
  13827. if (self.bfinally) body.push(...self.bfinally.body);
  13828. return make_node(AST_BlockStatement, self, {
  13829. body: body
  13830. }).optimize(compressor);
  13831. }
  13832. return self;
  13833. });
  13834. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  13835. var decls = [];
  13836. this.definitions.forEach(function(def) {
  13837. if (def.name instanceof AST_SymbolDeclaration) {
  13838. def.value = null;
  13839. decls.push(def);
  13840. } else {
  13841. walk(def.name, node => {
  13842. if (node instanceof AST_SymbolDeclaration) {
  13843. decls.push(make_node(AST_VarDef, def, {
  13844. name: node,
  13845. value: null
  13846. }));
  13847. }
  13848. });
  13849. }
  13850. });
  13851. this.definitions = decls;
  13852. });
  13853. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  13854. var reduce_vars = compressor.option("reduce_vars");
  13855. var assignments = [];
  13856. for (const def of this.definitions) {
  13857. if (def.value) {
  13858. var name = make_node(AST_SymbolRef, def.name, def.name);
  13859. assignments.push(make_node(AST_Assign, def, {
  13860. operator : "=",
  13861. left : name,
  13862. right : def.value
  13863. }));
  13864. if (reduce_vars) name.definition().fixed = false;
  13865. } else if (def.value) {
  13866. // Because it's a destructuring, do not turn into an assignment.
  13867. var varDef = make_node(AST_VarDef, def, {
  13868. name: def.name,
  13869. value: def.value
  13870. });
  13871. var var_ = make_node(AST_Var, def, {
  13872. definitions: [ varDef ]
  13873. });
  13874. assignments.push(var_);
  13875. }
  13876. const thedef = def.name.definition();
  13877. thedef.eliminated++;
  13878. thedef.replaced--;
  13879. }
  13880. if (assignments.length == 0) return null;
  13881. return make_sequence(this, assignments);
  13882. });
  13883. def_optimize(AST_Definitions, function(self) {
  13884. if (self.definitions.length == 0)
  13885. return make_node(AST_EmptyStatement, self);
  13886. return self;
  13887. });
  13888. def_optimize(AST_Import, function(self) {
  13889. return self;
  13890. });
  13891. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  13892. function retain_top_func(fn, compressor) {
  13893. return compressor.top_retain
  13894. && fn instanceof AST_Defun
  13895. && has_flag(fn, TOP)
  13896. && fn.name
  13897. && compressor.top_retain(fn.name);
  13898. }
  13899. def_optimize(AST_Call, function(self, compressor) {
  13900. var exp = self.expression;
  13901. var fn = exp;
  13902. inline_array_like_spread(self.args);
  13903. var simple_args = self.args.every((arg) =>
  13904. !(arg instanceof AST_Expansion)
  13905. );
  13906. if (compressor.option("reduce_vars")
  13907. && fn instanceof AST_SymbolRef
  13908. && !has_annotation(self, _NOINLINE)
  13909. ) {
  13910. const fixed = fn.fixed_value();
  13911. if (!retain_top_func(fixed, compressor)) {
  13912. fn = fixed;
  13913. }
  13914. }
  13915. if (self.optional && is_nullish(fn)) {
  13916. return make_node(AST_Undefined, self);
  13917. }
  13918. var is_func = fn instanceof AST_Lambda;
  13919. if (is_func && fn.pinned()) return self;
  13920. if (compressor.option("unused")
  13921. && simple_args
  13922. && is_func
  13923. && !fn.uses_arguments) {
  13924. var pos = 0, last = 0;
  13925. for (var i = 0, len = self.args.length; i < len; i++) {
  13926. if (fn.argnames[i] instanceof AST_Expansion) {
  13927. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  13928. var node = self.args[i++].drop_side_effect_free(compressor);
  13929. if (node) {
  13930. self.args[pos++] = node;
  13931. }
  13932. } else while (i < len) {
  13933. self.args[pos++] = self.args[i++];
  13934. }
  13935. last = pos;
  13936. break;
  13937. }
  13938. var trim = i >= fn.argnames.length;
  13939. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  13940. var node = self.args[i].drop_side_effect_free(compressor);
  13941. if (node) {
  13942. self.args[pos++] = node;
  13943. } else if (!trim) {
  13944. self.args[pos++] = make_node(AST_Number, self.args[i], {
  13945. value: 0
  13946. });
  13947. continue;
  13948. }
  13949. } else {
  13950. self.args[pos++] = self.args[i];
  13951. }
  13952. last = pos;
  13953. }
  13954. self.args.length = last;
  13955. }
  13956. if (compressor.option("unsafe")) {
  13957. if (is_undeclared_ref(exp)) switch (exp.name) {
  13958. case "Array":
  13959. if (self.args.length != 1) {
  13960. return make_node(AST_Array, self, {
  13961. elements: self.args
  13962. }).optimize(compressor);
  13963. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  13964. const elements = [];
  13965. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  13966. return new AST_Array({ elements });
  13967. }
  13968. break;
  13969. case "Object":
  13970. if (self.args.length == 0) {
  13971. return make_node(AST_Object, self, {
  13972. properties: []
  13973. });
  13974. }
  13975. break;
  13976. case "String":
  13977. if (self.args.length == 0) return make_node(AST_String, self, {
  13978. value: ""
  13979. });
  13980. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  13981. left: self.args[0],
  13982. operator: "+",
  13983. right: make_node(AST_String, self, { value: "" })
  13984. }).optimize(compressor);
  13985. break;
  13986. case "Number":
  13987. if (self.args.length == 0) return make_node(AST_Number, self, {
  13988. value: 0
  13989. });
  13990. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  13991. return make_node(AST_UnaryPrefix, self, {
  13992. expression: self.args[0],
  13993. operator: "+"
  13994. }).optimize(compressor);
  13995. }
  13996. break;
  13997. case "Symbol":
  13998. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  13999. self.args.length = 0;
  14000. break;
  14001. case "Boolean":
  14002. if (self.args.length == 0) return make_node(AST_False, self);
  14003. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  14004. expression: make_node(AST_UnaryPrefix, self, {
  14005. expression: self.args[0],
  14006. operator: "!"
  14007. }),
  14008. operator: "!"
  14009. }).optimize(compressor);
  14010. break;
  14011. case "RegExp":
  14012. var params = [];
  14013. if (self.args.length >= 1
  14014. && self.args.length <= 2
  14015. && self.args.every((arg) => {
  14016. var value = arg.evaluate(compressor);
  14017. params.push(value);
  14018. return arg !== value;
  14019. })
  14020. ) {
  14021. let [ source, flags ] = params;
  14022. source = regexp_source_fix(new RegExp(source).source);
  14023. const rx = make_node(AST_RegExp, self, {
  14024. value: { source, flags }
  14025. });
  14026. if (rx._eval(compressor) !== rx) {
  14027. return rx;
  14028. }
  14029. }
  14030. break;
  14031. } else if (exp instanceof AST_Dot) switch(exp.property) {
  14032. case "toString":
  14033. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  14034. return make_node(AST_Binary, self, {
  14035. left: make_node(AST_String, self, { value: "" }),
  14036. operator: "+",
  14037. right: exp.expression
  14038. }).optimize(compressor);
  14039. }
  14040. break;
  14041. case "join":
  14042. if (exp.expression instanceof AST_Array) EXIT: {
  14043. var separator;
  14044. if (self.args.length > 0) {
  14045. separator = self.args[0].evaluate(compressor);
  14046. if (separator === self.args[0]) break EXIT; // not a constant
  14047. }
  14048. var elements = [];
  14049. var consts = [];
  14050. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  14051. var el = exp.expression.elements[i];
  14052. if (el instanceof AST_Expansion) break EXIT;
  14053. var value = el.evaluate(compressor);
  14054. if (value !== el) {
  14055. consts.push(value);
  14056. } else {
  14057. if (consts.length > 0) {
  14058. elements.push(make_node(AST_String, self, {
  14059. value: consts.join(separator)
  14060. }));
  14061. consts.length = 0;
  14062. }
  14063. elements.push(el);
  14064. }
  14065. }
  14066. if (consts.length > 0) {
  14067. elements.push(make_node(AST_String, self, {
  14068. value: consts.join(separator)
  14069. }));
  14070. }
  14071. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  14072. if (elements.length == 1) {
  14073. if (elements[0].is_string(compressor)) {
  14074. return elements[0];
  14075. }
  14076. return make_node(AST_Binary, elements[0], {
  14077. operator : "+",
  14078. left : make_node(AST_String, self, { value: "" }),
  14079. right : elements[0]
  14080. });
  14081. }
  14082. if (separator == "") {
  14083. var first;
  14084. if (elements[0].is_string(compressor)
  14085. || elements[1].is_string(compressor)) {
  14086. first = elements.shift();
  14087. } else {
  14088. first = make_node(AST_String, self, { value: "" });
  14089. }
  14090. return elements.reduce(function(prev, el) {
  14091. return make_node(AST_Binary, el, {
  14092. operator : "+",
  14093. left : prev,
  14094. right : el
  14095. });
  14096. }, first).optimize(compressor);
  14097. }
  14098. // need this awkward cloning to not affect original element
  14099. // best_of will decide which one to get through.
  14100. var node = self.clone();
  14101. node.expression = node.expression.clone();
  14102. node.expression.expression = node.expression.expression.clone();
  14103. node.expression.expression.elements = elements;
  14104. return best_of(compressor, self, node);
  14105. }
  14106. break;
  14107. case "charAt":
  14108. if (exp.expression.is_string(compressor)) {
  14109. var arg = self.args[0];
  14110. var index = arg ? arg.evaluate(compressor) : 0;
  14111. if (index !== arg) {
  14112. return make_node(AST_Sub, exp, {
  14113. expression: exp.expression,
  14114. property: make_node_from_constant(index | 0, arg || exp)
  14115. }).optimize(compressor);
  14116. }
  14117. }
  14118. break;
  14119. case "apply":
  14120. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  14121. var args = self.args[1].elements.slice();
  14122. args.unshift(self.args[0]);
  14123. return make_node(AST_Call, self, {
  14124. expression: make_node(AST_Dot, exp, {
  14125. expression: exp.expression,
  14126. optional: false,
  14127. property: "call"
  14128. }),
  14129. args: args
  14130. }).optimize(compressor);
  14131. }
  14132. break;
  14133. case "call":
  14134. var func = exp.expression;
  14135. if (func instanceof AST_SymbolRef) {
  14136. func = func.fixed_value();
  14137. }
  14138. if (func instanceof AST_Lambda && !func.contains_this()) {
  14139. return (self.args.length ? make_sequence(this, [
  14140. self.args[0],
  14141. make_node(AST_Call, self, {
  14142. expression: exp.expression,
  14143. args: self.args.slice(1)
  14144. })
  14145. ]) : make_node(AST_Call, self, {
  14146. expression: exp.expression,
  14147. args: []
  14148. })).optimize(compressor);
  14149. }
  14150. break;
  14151. }
  14152. }
  14153. if (compressor.option("unsafe_Function")
  14154. && is_undeclared_ref(exp)
  14155. && exp.name == "Function") {
  14156. // new Function() => function(){}
  14157. if (self.args.length == 0) return make_node(AST_Function, self, {
  14158. argnames: [],
  14159. body: []
  14160. }).optimize(compressor);
  14161. if (self.args.every((x) => x instanceof AST_String)) {
  14162. // quite a corner-case, but we can handle it:
  14163. // https://github.com/mishoo/UglifyJS2/issues/203
  14164. // if the code argument is a constant, then we can minify it.
  14165. try {
  14166. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  14167. return arg.value;
  14168. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  14169. var ast = parse(code);
  14170. var mangle = { ie8: compressor.option("ie8") };
  14171. ast.figure_out_scope(mangle);
  14172. var comp = new Compressor(compressor.options, {
  14173. mangle_options: compressor.mangle_options
  14174. });
  14175. ast = ast.transform(comp);
  14176. ast.figure_out_scope(mangle);
  14177. base54.reset();
  14178. ast.compute_char_frequency(mangle);
  14179. ast.mangle_names(mangle);
  14180. var fun;
  14181. walk(ast, node => {
  14182. if (is_func_expr(node)) {
  14183. fun = node;
  14184. return walk_abort;
  14185. }
  14186. });
  14187. var code = OutputStream();
  14188. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  14189. self.args = [
  14190. make_node(AST_String, self, {
  14191. value: fun.argnames.map(function(arg) {
  14192. return arg.print_to_string();
  14193. }).join(",")
  14194. }),
  14195. make_node(AST_String, self.args[self.args.length - 1], {
  14196. value: code.get().replace(/^{|}$/g, "")
  14197. })
  14198. ];
  14199. return self;
  14200. } catch (ex) {
  14201. if (!(ex instanceof JS_Parse_Error)) {
  14202. throw ex;
  14203. }
  14204. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  14205. }
  14206. }
  14207. }
  14208. var stat = is_func && fn.body[0];
  14209. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  14210. var can_inline = is_regular_func && compressor.option("inline") && !self.is_expr_pure(compressor);
  14211. if (can_inline && stat instanceof AST_Return) {
  14212. let returned = stat.value;
  14213. if (!returned || returned.is_constant_expression()) {
  14214. if (returned) {
  14215. returned = returned.clone(true);
  14216. } else {
  14217. returned = make_node(AST_Undefined, self);
  14218. }
  14219. const args = self.args.concat(returned);
  14220. return make_sequence(self, args).optimize(compressor);
  14221. }
  14222. // optimize identity function
  14223. if (
  14224. fn.argnames.length === 1
  14225. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  14226. && self.args.length < 2
  14227. && returned instanceof AST_SymbolRef
  14228. && returned.name === fn.argnames[0].name
  14229. ) {
  14230. const replacement =
  14231. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  14232. let parent;
  14233. if (
  14234. replacement instanceof AST_PropAccess
  14235. && (parent = compressor.parent()) instanceof AST_Call
  14236. && parent.expression === self
  14237. ) {
  14238. // identity function was being used to remove `this`, like in
  14239. //
  14240. // id(bag.no_this)(...)
  14241. //
  14242. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  14243. return make_sequence(self, [
  14244. make_node(AST_Number, self, { value: 0 }),
  14245. replacement
  14246. ]);
  14247. }
  14248. // replace call with first argument or undefined if none passed
  14249. return replacement;
  14250. }
  14251. }
  14252. if (can_inline) {
  14253. var scope, in_loop, level = -1;
  14254. let def;
  14255. let returned_value;
  14256. let nearest_scope;
  14257. if (simple_args
  14258. && !fn.uses_arguments
  14259. && !(compressor.parent() instanceof AST_Class)
  14260. && !(fn.name && fn instanceof AST_Function)
  14261. && (returned_value = can_flatten_body(stat))
  14262. && (exp === fn
  14263. || has_annotation(self, _INLINE)
  14264. || compressor.option("unused")
  14265. && (def = exp.definition()).references.length == 1
  14266. && !recursive_ref(compressor, def)
  14267. && fn.is_constant_expression(exp.scope))
  14268. && !has_annotation(self, _PURE | _NOINLINE)
  14269. && !fn.contains_this()
  14270. && can_inject_symbols()
  14271. && (nearest_scope = find_scope(compressor))
  14272. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  14273. && !(function in_default_assign() {
  14274. // Due to the fact function parameters have their own scope
  14275. // which can't use `var something` in the function body within,
  14276. // we simply don't inline into DefaultAssign.
  14277. let i = 0;
  14278. let p;
  14279. while ((p = compressor.parent(i++))) {
  14280. if (p instanceof AST_DefaultAssign) return true;
  14281. if (p instanceof AST_Block) break;
  14282. }
  14283. return false;
  14284. })()
  14285. && !(scope instanceof AST_Class)
  14286. ) {
  14287. set_flag(fn, SQUEEZED);
  14288. nearest_scope.add_child_scope(fn);
  14289. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  14290. }
  14291. }
  14292. if (can_inline && has_annotation(self, _INLINE)) {
  14293. set_flag(fn, SQUEEZED);
  14294. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  14295. fn.figure_out_scope({}, {
  14296. parent_scope: find_scope(compressor),
  14297. toplevel: compressor.get_toplevel()
  14298. });
  14299. return make_node(AST_Call, self, {
  14300. expression: fn,
  14301. args: self.args,
  14302. }).optimize(compressor);
  14303. }
  14304. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  14305. if (can_drop_this_call) {
  14306. var args = self.args.concat(make_node(AST_Undefined, self));
  14307. return make_sequence(self, args).optimize(compressor);
  14308. }
  14309. if (compressor.option("negate_iife")
  14310. && compressor.parent() instanceof AST_SimpleStatement
  14311. && is_iife_call(self)) {
  14312. return self.negate(compressor, true);
  14313. }
  14314. var ev = self.evaluate(compressor);
  14315. if (ev !== self) {
  14316. ev = make_node_from_constant(ev, self).optimize(compressor);
  14317. return best_of(compressor, ev, self);
  14318. }
  14319. return self;
  14320. function return_value(stat) {
  14321. if (!stat) return make_node(AST_Undefined, self);
  14322. if (stat instanceof AST_Return) {
  14323. if (!stat.value) return make_node(AST_Undefined, self);
  14324. return stat.value.clone(true);
  14325. }
  14326. if (stat instanceof AST_SimpleStatement) {
  14327. return make_node(AST_UnaryPrefix, stat, {
  14328. operator: "void",
  14329. expression: stat.body.clone(true)
  14330. });
  14331. }
  14332. }
  14333. function can_flatten_body(stat) {
  14334. var body = fn.body;
  14335. var len = body.length;
  14336. if (compressor.option("inline") < 3) {
  14337. return len == 1 && return_value(stat);
  14338. }
  14339. stat = null;
  14340. for (var i = 0; i < len; i++) {
  14341. var line = body[i];
  14342. if (line instanceof AST_Var) {
  14343. if (stat && !line.definitions.every((var_def) =>
  14344. !var_def.value
  14345. )) {
  14346. return false;
  14347. }
  14348. } else if (stat) {
  14349. return false;
  14350. } else if (!(line instanceof AST_EmptyStatement)) {
  14351. stat = line;
  14352. }
  14353. }
  14354. return return_value(stat);
  14355. }
  14356. function can_inject_args(block_scoped, safe_to_inject) {
  14357. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  14358. var arg = fn.argnames[i];
  14359. if (arg instanceof AST_DefaultAssign) {
  14360. if (has_flag(arg.left, UNUSED)) continue;
  14361. return false;
  14362. }
  14363. if (arg instanceof AST_Destructuring) return false;
  14364. if (arg instanceof AST_Expansion) {
  14365. if (has_flag(arg.expression, UNUSED)) continue;
  14366. return false;
  14367. }
  14368. if (has_flag(arg, UNUSED)) continue;
  14369. if (!safe_to_inject
  14370. || block_scoped.has(arg.name)
  14371. || identifier_atom.has(arg.name)
  14372. || scope.conflicting_def(arg.name)) {
  14373. return false;
  14374. }
  14375. if (in_loop) in_loop.push(arg.definition());
  14376. }
  14377. return true;
  14378. }
  14379. function can_inject_vars(block_scoped, safe_to_inject) {
  14380. var len = fn.body.length;
  14381. for (var i = 0; i < len; i++) {
  14382. var stat = fn.body[i];
  14383. if (!(stat instanceof AST_Var)) continue;
  14384. if (!safe_to_inject) return false;
  14385. for (var j = stat.definitions.length; --j >= 0;) {
  14386. var name = stat.definitions[j].name;
  14387. if (name instanceof AST_Destructuring
  14388. || block_scoped.has(name.name)
  14389. || identifier_atom.has(name.name)
  14390. || scope.conflicting_def(name.name)) {
  14391. return false;
  14392. }
  14393. if (in_loop) in_loop.push(name.definition());
  14394. }
  14395. }
  14396. return true;
  14397. }
  14398. function can_inject_symbols() {
  14399. var block_scoped = new Set();
  14400. do {
  14401. scope = compressor.parent(++level);
  14402. if (scope.is_block_scope() && scope.block_scope) {
  14403. // TODO this is sometimes undefined during compression.
  14404. // But it should always have a value!
  14405. scope.block_scope.variables.forEach(function (variable) {
  14406. block_scoped.add(variable.name);
  14407. });
  14408. }
  14409. if (scope instanceof AST_Catch) {
  14410. // TODO can we delete? AST_Catch is a block scope.
  14411. if (scope.argname) {
  14412. block_scoped.add(scope.argname.name);
  14413. }
  14414. } else if (scope instanceof AST_IterationStatement) {
  14415. in_loop = [];
  14416. } else if (scope instanceof AST_SymbolRef) {
  14417. if (scope.fixed_value() instanceof AST_Scope) return false;
  14418. }
  14419. } while (!(scope instanceof AST_Scope));
  14420. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  14421. var inline = compressor.option("inline");
  14422. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  14423. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  14424. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  14425. }
  14426. function append_var(decls, expressions, name, value) {
  14427. var def = name.definition();
  14428. // Name already exists, only when a function argument had the same name
  14429. const already_appended = scope.variables.has(name.name);
  14430. if (!already_appended) {
  14431. scope.variables.set(name.name, def);
  14432. scope.enclosed.push(def);
  14433. decls.push(make_node(AST_VarDef, name, {
  14434. name: name,
  14435. value: null
  14436. }));
  14437. }
  14438. var sym = make_node(AST_SymbolRef, name, name);
  14439. def.references.push(sym);
  14440. if (value) expressions.push(make_node(AST_Assign, self, {
  14441. operator: "=",
  14442. left: sym,
  14443. right: value.clone()
  14444. }));
  14445. }
  14446. function flatten_args(decls, expressions) {
  14447. var len = fn.argnames.length;
  14448. for (var i = self.args.length; --i >= len;) {
  14449. expressions.push(self.args[i]);
  14450. }
  14451. for (i = len; --i >= 0;) {
  14452. var name = fn.argnames[i];
  14453. var value = self.args[i];
  14454. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  14455. if (value) expressions.push(value);
  14456. } else {
  14457. var symbol = make_node(AST_SymbolVar, name, name);
  14458. name.definition().orig.push(symbol);
  14459. if (!value && in_loop) value = make_node(AST_Undefined, self);
  14460. append_var(decls, expressions, symbol, value);
  14461. }
  14462. }
  14463. decls.reverse();
  14464. expressions.reverse();
  14465. }
  14466. function flatten_vars(decls, expressions) {
  14467. var pos = expressions.length;
  14468. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  14469. var stat = fn.body[i];
  14470. if (!(stat instanceof AST_Var)) continue;
  14471. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  14472. var var_def = stat.definitions[j];
  14473. var name = var_def.name;
  14474. append_var(decls, expressions, name, var_def.value);
  14475. if (in_loop && fn.argnames.every((argname) =>
  14476. argname.name != name.name
  14477. )) {
  14478. var def = fn.variables.get(name.name);
  14479. var sym = make_node(AST_SymbolRef, name, name);
  14480. def.references.push(sym);
  14481. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  14482. operator: "=",
  14483. left: sym,
  14484. right: make_node(AST_Undefined, name)
  14485. }));
  14486. }
  14487. }
  14488. }
  14489. }
  14490. function flatten_fn(returned_value) {
  14491. var decls = [];
  14492. var expressions = [];
  14493. flatten_args(decls, expressions);
  14494. flatten_vars(decls, expressions);
  14495. expressions.push(returned_value);
  14496. if (decls.length) {
  14497. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  14498. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  14499. definitions: decls
  14500. }));
  14501. }
  14502. return expressions.map(exp => exp.clone(true));
  14503. }
  14504. });
  14505. def_optimize(AST_New, function(self, compressor) {
  14506. if (
  14507. compressor.option("unsafe") &&
  14508. is_undeclared_ref(self.expression) &&
  14509. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  14510. ) return make_node(AST_Call, self, self).transform(compressor);
  14511. return self;
  14512. });
  14513. def_optimize(AST_Sequence, function(self, compressor) {
  14514. if (!compressor.option("side_effects")) return self;
  14515. var expressions = [];
  14516. filter_for_side_effects();
  14517. var end = expressions.length - 1;
  14518. trim_right_for_undefined();
  14519. if (end == 0) {
  14520. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  14521. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  14522. return self;
  14523. }
  14524. self.expressions = expressions;
  14525. return self;
  14526. function filter_for_side_effects() {
  14527. var first = first_in_statement(compressor);
  14528. var last = self.expressions.length - 1;
  14529. self.expressions.forEach(function(expr, index) {
  14530. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  14531. if (expr) {
  14532. merge_sequence(expressions, expr);
  14533. first = false;
  14534. }
  14535. });
  14536. }
  14537. function trim_right_for_undefined() {
  14538. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  14539. if (end < expressions.length - 1) {
  14540. expressions[end] = make_node(AST_UnaryPrefix, self, {
  14541. operator : "void",
  14542. expression : expressions[end]
  14543. });
  14544. expressions.length = end + 1;
  14545. }
  14546. }
  14547. });
  14548. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  14549. if (compressor.option("sequences")) {
  14550. if (this.expression instanceof AST_Sequence) {
  14551. var x = this.expression.expressions.slice();
  14552. var e = this.clone();
  14553. e.expression = x.pop();
  14554. x.push(e);
  14555. return make_sequence(this, x).optimize(compressor);
  14556. }
  14557. }
  14558. return this;
  14559. });
  14560. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  14561. return self.lift_sequences(compressor);
  14562. });
  14563. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  14564. var e = self.expression;
  14565. if (self.operator == "delete"
  14566. && !(e instanceof AST_SymbolRef
  14567. || e instanceof AST_PropAccess
  14568. || is_identifier_atom(e))) {
  14569. if (e instanceof AST_Sequence) {
  14570. const exprs = e.expressions.slice();
  14571. exprs.push(make_node(AST_True, self));
  14572. return make_sequence(self, exprs).optimize(compressor);
  14573. }
  14574. return make_sequence(self, [ e, make_node(AST_True, self) ]).optimize(compressor);
  14575. }
  14576. var seq = self.lift_sequences(compressor);
  14577. if (seq !== self) {
  14578. return seq;
  14579. }
  14580. if (compressor.option("side_effects") && self.operator == "void") {
  14581. e = e.drop_side_effect_free(compressor);
  14582. if (e) {
  14583. self.expression = e;
  14584. return self;
  14585. } else {
  14586. return make_node(AST_Undefined, self).optimize(compressor);
  14587. }
  14588. }
  14589. if (compressor.in_boolean_context()) {
  14590. switch (self.operator) {
  14591. case "!":
  14592. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  14593. // !!foo ==> foo, if we're in boolean context
  14594. return e.expression;
  14595. }
  14596. if (e instanceof AST_Binary) {
  14597. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  14598. }
  14599. break;
  14600. case "typeof":
  14601. // typeof always returns a non-empty string, thus it's
  14602. // always true in booleans
  14603. // And we don't need to check if it's undeclared, because in typeof, that's OK
  14604. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  14605. e,
  14606. make_node(AST_True, self)
  14607. ])).optimize(compressor);
  14608. }
  14609. }
  14610. if (self.operator == "-" && e instanceof AST_Infinity) {
  14611. e = e.transform(compressor);
  14612. }
  14613. if (e instanceof AST_Binary
  14614. && (self.operator == "+" || self.operator == "-")
  14615. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  14616. return make_node(AST_Binary, self, {
  14617. operator: e.operator,
  14618. left: make_node(AST_UnaryPrefix, e.left, {
  14619. operator: self.operator,
  14620. expression: e.left
  14621. }),
  14622. right: e.right
  14623. });
  14624. }
  14625. // avoids infinite recursion of numerals
  14626. if (self.operator != "-"
  14627. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)) {
  14628. var ev = self.evaluate(compressor);
  14629. if (ev !== self) {
  14630. ev = make_node_from_constant(ev, self).optimize(compressor);
  14631. return best_of(compressor, ev, self);
  14632. }
  14633. }
  14634. return self;
  14635. });
  14636. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  14637. if (compressor.option("sequences")) {
  14638. if (this.left instanceof AST_Sequence) {
  14639. var x = this.left.expressions.slice();
  14640. var e = this.clone();
  14641. e.left = x.pop();
  14642. x.push(e);
  14643. return make_sequence(this, x).optimize(compressor);
  14644. }
  14645. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  14646. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  14647. var x = this.right.expressions;
  14648. var last = x.length - 1;
  14649. for (var i = 0; i < last; i++) {
  14650. if (!assign && x[i].has_side_effects(compressor)) break;
  14651. }
  14652. if (i == last) {
  14653. x = x.slice();
  14654. var e = this.clone();
  14655. e.right = x.pop();
  14656. x.push(e);
  14657. return make_sequence(this, x).optimize(compressor);
  14658. } else if (i > 0) {
  14659. var e = this.clone();
  14660. e.right = make_sequence(this.right, x.slice(i));
  14661. x = x.slice(0, i);
  14662. x.push(e);
  14663. return make_sequence(this, x).optimize(compressor);
  14664. }
  14665. }
  14666. }
  14667. return this;
  14668. });
  14669. var commutativeOperators = makePredicate("== === != !== * & | ^");
  14670. function is_object(node) {
  14671. return node instanceof AST_Array
  14672. || node instanceof AST_Lambda
  14673. || node instanceof AST_Object
  14674. || node instanceof AST_Class;
  14675. }
  14676. def_optimize(AST_Binary, function(self, compressor) {
  14677. function reversible() {
  14678. return self.left.is_constant()
  14679. || self.right.is_constant()
  14680. || !self.left.has_side_effects(compressor)
  14681. && !self.right.has_side_effects(compressor);
  14682. }
  14683. function reverse(op) {
  14684. if (reversible()) {
  14685. if (op) self.operator = op;
  14686. var tmp = self.left;
  14687. self.left = self.right;
  14688. self.right = tmp;
  14689. }
  14690. }
  14691. if (commutativeOperators.has(self.operator)) {
  14692. if (self.right.is_constant()
  14693. && !self.left.is_constant()) {
  14694. // if right is a constant, whatever side effects the
  14695. // left side might have could not influence the
  14696. // result. hence, force switch.
  14697. if (!(self.left instanceof AST_Binary
  14698. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  14699. reverse();
  14700. }
  14701. }
  14702. }
  14703. self = self.lift_sequences(compressor);
  14704. if (compressor.option("comparisons")) switch (self.operator) {
  14705. case "===":
  14706. case "!==":
  14707. var is_strict_comparison = true;
  14708. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  14709. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  14710. (self.left.is_boolean() && self.right.is_boolean()) ||
  14711. self.left.equivalent_to(self.right)) {
  14712. self.operator = self.operator.substr(0, 2);
  14713. }
  14714. // XXX: intentionally falling down to the next case
  14715. case "==":
  14716. case "!=":
  14717. // void 0 == x => null == x
  14718. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  14719. self.left = make_node(AST_Null, self.left);
  14720. } else if (compressor.option("typeofs")
  14721. // "undefined" == typeof x => undefined === x
  14722. && self.left instanceof AST_String
  14723. && self.left.value == "undefined"
  14724. && self.right instanceof AST_UnaryPrefix
  14725. && self.right.operator == "typeof") {
  14726. var expr = self.right.expression;
  14727. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  14728. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  14729. self.right = expr;
  14730. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  14731. if (self.operator.length == 2) self.operator += "=";
  14732. }
  14733. } else if (self.left instanceof AST_SymbolRef
  14734. // obj !== obj => false
  14735. && self.right instanceof AST_SymbolRef
  14736. && self.left.definition() === self.right.definition()
  14737. && is_object(self.left.fixed_value())) {
  14738. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  14739. }
  14740. break;
  14741. case "&&":
  14742. case "||":
  14743. var lhs = self.left;
  14744. if (lhs.operator == self.operator) {
  14745. lhs = lhs.right;
  14746. }
  14747. if (lhs instanceof AST_Binary
  14748. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  14749. && self.right instanceof AST_Binary
  14750. && lhs.operator == self.right.operator
  14751. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  14752. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  14753. && !lhs.right.has_side_effects(compressor)
  14754. && lhs.right.equivalent_to(self.right.right)) {
  14755. var combined = make_node(AST_Binary, self, {
  14756. operator: lhs.operator.slice(0, -1),
  14757. left: make_node(AST_Null, self),
  14758. right: lhs.right
  14759. });
  14760. if (lhs !== self.left) {
  14761. combined = make_node(AST_Binary, self, {
  14762. operator: self.operator,
  14763. left: self.left.left,
  14764. right: combined
  14765. });
  14766. }
  14767. return combined;
  14768. }
  14769. break;
  14770. }
  14771. if (self.operator == "+" && compressor.in_boolean_context()) {
  14772. var ll = self.left.evaluate(compressor);
  14773. var rr = self.right.evaluate(compressor);
  14774. if (ll && typeof ll == "string") {
  14775. return make_sequence(self, [
  14776. self.right,
  14777. make_node(AST_True, self)
  14778. ]).optimize(compressor);
  14779. }
  14780. if (rr && typeof rr == "string") {
  14781. return make_sequence(self, [
  14782. self.left,
  14783. make_node(AST_True, self)
  14784. ]).optimize(compressor);
  14785. }
  14786. }
  14787. if (compressor.option("comparisons") && self.is_boolean()) {
  14788. if (!(compressor.parent() instanceof AST_Binary)
  14789. || compressor.parent() instanceof AST_Assign) {
  14790. var negated = make_node(AST_UnaryPrefix, self, {
  14791. operator: "!",
  14792. expression: self.negate(compressor, first_in_statement(compressor))
  14793. });
  14794. self = best_of(compressor, self, negated);
  14795. }
  14796. if (compressor.option("unsafe_comps")) {
  14797. switch (self.operator) {
  14798. case "<": reverse(">"); break;
  14799. case "<=": reverse(">="); break;
  14800. }
  14801. }
  14802. }
  14803. if (self.operator == "+") {
  14804. if (self.right instanceof AST_String
  14805. && self.right.getValue() == ""
  14806. && self.left.is_string(compressor)) {
  14807. return self.left;
  14808. }
  14809. if (self.left instanceof AST_String
  14810. && self.left.getValue() == ""
  14811. && self.right.is_string(compressor)) {
  14812. return self.right;
  14813. }
  14814. if (self.left instanceof AST_Binary
  14815. && self.left.operator == "+"
  14816. && self.left.left instanceof AST_String
  14817. && self.left.left.getValue() == ""
  14818. && self.right.is_string(compressor)) {
  14819. self.left = self.left.right;
  14820. return self;
  14821. }
  14822. }
  14823. if (compressor.option("evaluate")) {
  14824. switch (self.operator) {
  14825. case "&&":
  14826. var ll = has_flag(self.left, TRUTHY)
  14827. ? true
  14828. : has_flag(self.left, FALSY)
  14829. ? false
  14830. : self.left.evaluate(compressor);
  14831. if (!ll) {
  14832. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  14833. } else if (!(ll instanceof AST_Node)) {
  14834. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  14835. }
  14836. var rr = self.right.evaluate(compressor);
  14837. if (!rr) {
  14838. if (compressor.in_boolean_context()) {
  14839. return make_sequence(self, [
  14840. self.left,
  14841. make_node(AST_False, self)
  14842. ]).optimize(compressor);
  14843. } else {
  14844. set_flag(self, FALSY);
  14845. }
  14846. } else if (!(rr instanceof AST_Node)) {
  14847. var parent = compressor.parent();
  14848. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  14849. return self.left.optimize(compressor);
  14850. }
  14851. }
  14852. // x || false && y ---> x ? y : false
  14853. if (self.left.operator == "||") {
  14854. var lr = self.left.right.evaluate(compressor);
  14855. if (!lr) return make_node(AST_Conditional, self, {
  14856. condition: self.left.left,
  14857. consequent: self.right,
  14858. alternative: self.left.right
  14859. }).optimize(compressor);
  14860. }
  14861. break;
  14862. case "||":
  14863. var ll = has_flag(self.left, TRUTHY)
  14864. ? true
  14865. : has_flag(self.left, FALSY)
  14866. ? false
  14867. : self.left.evaluate(compressor);
  14868. if (!ll) {
  14869. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  14870. } else if (!(ll instanceof AST_Node)) {
  14871. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  14872. }
  14873. var rr = self.right.evaluate(compressor);
  14874. if (!rr) {
  14875. var parent = compressor.parent();
  14876. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  14877. return self.left.optimize(compressor);
  14878. }
  14879. } else if (!(rr instanceof AST_Node)) {
  14880. if (compressor.in_boolean_context()) {
  14881. return make_sequence(self, [
  14882. self.left,
  14883. make_node(AST_True, self)
  14884. ]).optimize(compressor);
  14885. } else {
  14886. set_flag(self, TRUTHY);
  14887. }
  14888. }
  14889. if (self.left.operator == "&&") {
  14890. var lr = self.left.right.evaluate(compressor);
  14891. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  14892. condition: self.left.left,
  14893. consequent: self.left.right,
  14894. alternative: self.right
  14895. }).optimize(compressor);
  14896. }
  14897. break;
  14898. case "??":
  14899. if (is_nullish(self.left)) {
  14900. return self.right;
  14901. }
  14902. var ll = self.left.evaluate(compressor);
  14903. if (!(ll instanceof AST_Node)) {
  14904. // if we know the value for sure we can simply compute right away.
  14905. return ll == null ? self.right : self.left;
  14906. }
  14907. if (compressor.in_boolean_context()) {
  14908. const rr = self.right.evaluate(compressor);
  14909. if (!(rr instanceof AST_Node) && !rr) {
  14910. return self.left;
  14911. }
  14912. }
  14913. }
  14914. var associative = true;
  14915. switch (self.operator) {
  14916. case "+":
  14917. // (x + "foo") + "bar" => x + "foobar"
  14918. if (self.right instanceof AST_Constant
  14919. && self.left instanceof AST_Binary
  14920. && self.left.operator == "+"
  14921. && self.left.is_string(compressor)) {
  14922. var binary = make_node(AST_Binary, self, {
  14923. operator: "+",
  14924. left: self.left.right,
  14925. right: self.right,
  14926. });
  14927. var r = binary.optimize(compressor);
  14928. if (binary !== r) {
  14929. self = make_node(AST_Binary, self, {
  14930. operator: "+",
  14931. left: self.left.left,
  14932. right: r
  14933. });
  14934. }
  14935. }
  14936. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  14937. if (self.left instanceof AST_Binary
  14938. && self.left.operator == "+"
  14939. && self.left.is_string(compressor)
  14940. && self.right instanceof AST_Binary
  14941. && self.right.operator == "+"
  14942. && self.right.is_string(compressor)) {
  14943. var binary = make_node(AST_Binary, self, {
  14944. operator: "+",
  14945. left: self.left.right,
  14946. right: self.right.left,
  14947. });
  14948. var m = binary.optimize(compressor);
  14949. if (binary !== m) {
  14950. self = make_node(AST_Binary, self, {
  14951. operator: "+",
  14952. left: make_node(AST_Binary, self.left, {
  14953. operator: "+",
  14954. left: self.left.left,
  14955. right: m
  14956. }),
  14957. right: self.right.right
  14958. });
  14959. }
  14960. }
  14961. // a + -b => a - b
  14962. if (self.right instanceof AST_UnaryPrefix
  14963. && self.right.operator == "-"
  14964. && self.left.is_number(compressor)) {
  14965. self = make_node(AST_Binary, self, {
  14966. operator: "-",
  14967. left: self.left,
  14968. right: self.right.expression
  14969. });
  14970. break;
  14971. }
  14972. // -a + b => b - a
  14973. if (self.left instanceof AST_UnaryPrefix
  14974. && self.left.operator == "-"
  14975. && reversible()
  14976. && self.right.is_number(compressor)) {
  14977. self = make_node(AST_Binary, self, {
  14978. operator: "-",
  14979. left: self.right,
  14980. right: self.left.expression
  14981. });
  14982. break;
  14983. }
  14984. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  14985. if (self.left instanceof AST_TemplateString) {
  14986. var l = self.left;
  14987. var r = self.right.evaluate(compressor);
  14988. if (r != self.right) {
  14989. l.segments[l.segments.length - 1].value += r.toString();
  14990. return l;
  14991. }
  14992. }
  14993. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  14994. if (self.right instanceof AST_TemplateString) {
  14995. var r = self.right;
  14996. var l = self.left.evaluate(compressor);
  14997. if (l != self.left) {
  14998. r.segments[0].value = l.toString() + r.segments[0].value ;
  14999. return r;
  15000. }
  15001. }
  15002. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  15003. if (self.left instanceof AST_TemplateString
  15004. && self.right instanceof AST_TemplateString) {
  15005. var l = self.left;
  15006. var segments = l.segments;
  15007. var r = self.right;
  15008. segments[segments.length - 1].value += r.segments[0].value;
  15009. for (var i = 1; i < r.segments.length; i++) {
  15010. segments.push(r.segments[i]);
  15011. }
  15012. return l;
  15013. }
  15014. case "*":
  15015. associative = compressor.option("unsafe_math");
  15016. case "&":
  15017. case "|":
  15018. case "^":
  15019. // a + +b => +b + a
  15020. if (self.left.is_number(compressor)
  15021. && self.right.is_number(compressor)
  15022. && reversible()
  15023. && !(self.left instanceof AST_Binary
  15024. && self.left.operator != self.operator
  15025. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  15026. var reversed = make_node(AST_Binary, self, {
  15027. operator: self.operator,
  15028. left: self.right,
  15029. right: self.left
  15030. });
  15031. if (self.right instanceof AST_Constant
  15032. && !(self.left instanceof AST_Constant)) {
  15033. self = best_of(compressor, reversed, self);
  15034. } else {
  15035. self = best_of(compressor, self, reversed);
  15036. }
  15037. }
  15038. if (associative && self.is_number(compressor)) {
  15039. // a + (b + c) => (a + b) + c
  15040. if (self.right instanceof AST_Binary
  15041. && self.right.operator == self.operator) {
  15042. self = make_node(AST_Binary, self, {
  15043. operator: self.operator,
  15044. left: make_node(AST_Binary, self.left, {
  15045. operator: self.operator,
  15046. left: self.left,
  15047. right: self.right.left,
  15048. start: self.left.start,
  15049. end: self.right.left.end
  15050. }),
  15051. right: self.right.right
  15052. });
  15053. }
  15054. // (n + 2) + 3 => 5 + n
  15055. // (2 * n) * 3 => 6 + n
  15056. if (self.right instanceof AST_Constant
  15057. && self.left instanceof AST_Binary
  15058. && self.left.operator == self.operator) {
  15059. if (self.left.left instanceof AST_Constant) {
  15060. self = make_node(AST_Binary, self, {
  15061. operator: self.operator,
  15062. left: make_node(AST_Binary, self.left, {
  15063. operator: self.operator,
  15064. left: self.left.left,
  15065. right: self.right,
  15066. start: self.left.left.start,
  15067. end: self.right.end
  15068. }),
  15069. right: self.left.right
  15070. });
  15071. } else if (self.left.right instanceof AST_Constant) {
  15072. self = make_node(AST_Binary, self, {
  15073. operator: self.operator,
  15074. left: make_node(AST_Binary, self.left, {
  15075. operator: self.operator,
  15076. left: self.left.right,
  15077. right: self.right,
  15078. start: self.left.right.start,
  15079. end: self.right.end
  15080. }),
  15081. right: self.left.left
  15082. });
  15083. }
  15084. }
  15085. // (a | 1) | (2 | d) => (3 | a) | b
  15086. if (self.left instanceof AST_Binary
  15087. && self.left.operator == self.operator
  15088. && self.left.right instanceof AST_Constant
  15089. && self.right instanceof AST_Binary
  15090. && self.right.operator == self.operator
  15091. && self.right.left instanceof AST_Constant) {
  15092. self = make_node(AST_Binary, self, {
  15093. operator: self.operator,
  15094. left: make_node(AST_Binary, self.left, {
  15095. operator: self.operator,
  15096. left: make_node(AST_Binary, self.left.left, {
  15097. operator: self.operator,
  15098. left: self.left.right,
  15099. right: self.right.left,
  15100. start: self.left.right.start,
  15101. end: self.right.left.end
  15102. }),
  15103. right: self.left.left
  15104. }),
  15105. right: self.right.right
  15106. });
  15107. }
  15108. }
  15109. }
  15110. }
  15111. // x && (y && z) ==> x && y && z
  15112. // x || (y || z) ==> x || y || z
  15113. // x + ("y" + z) ==> x + "y" + z
  15114. // "x" + (y + "z")==> "x" + y + "z"
  15115. if (self.right instanceof AST_Binary
  15116. && self.right.operator == self.operator
  15117. && (lazy_op.has(self.operator)
  15118. || (self.operator == "+"
  15119. && (self.right.left.is_string(compressor)
  15120. || (self.left.is_string(compressor)
  15121. && self.right.right.is_string(compressor)))))
  15122. ) {
  15123. self.left = make_node(AST_Binary, self.left, {
  15124. operator : self.operator,
  15125. left : self.left.transform(compressor),
  15126. right : self.right.left.transform(compressor)
  15127. });
  15128. self.right = self.right.right.transform(compressor);
  15129. return self.transform(compressor);
  15130. }
  15131. var ev = self.evaluate(compressor);
  15132. if (ev !== self) {
  15133. ev = make_node_from_constant(ev, self).optimize(compressor);
  15134. return best_of(compressor, ev, self);
  15135. }
  15136. return self;
  15137. });
  15138. def_optimize(AST_SymbolExport, function(self) {
  15139. return self;
  15140. });
  15141. function recursive_ref(compressor, def) {
  15142. var node;
  15143. for (var i = 0; node = compressor.parent(i); i++) {
  15144. if (
  15145. node instanceof AST_Lambda
  15146. || node instanceof AST_Class
  15147. ) {
  15148. var name = node.name;
  15149. if (name && name.definition() === def) break;
  15150. }
  15151. }
  15152. return node;
  15153. }
  15154. function within_array_or_object_literal(compressor) {
  15155. var node, level = 0;
  15156. while (node = compressor.parent(level++)) {
  15157. if (node instanceof AST_Statement) return false;
  15158. if (node instanceof AST_Array
  15159. || node instanceof AST_ObjectKeyVal
  15160. || node instanceof AST_Object) {
  15161. return true;
  15162. }
  15163. }
  15164. return false;
  15165. }
  15166. def_optimize(AST_SymbolRef, function(self, compressor) {
  15167. if (
  15168. !compressor.option("ie8")
  15169. && is_undeclared_ref(self)
  15170. && !compressor.find_parent(AST_With)
  15171. ) {
  15172. switch (self.name) {
  15173. case "undefined":
  15174. return make_node(AST_Undefined, self).optimize(compressor);
  15175. case "NaN":
  15176. return make_node(AST_NaN, self).optimize(compressor);
  15177. case "Infinity":
  15178. return make_node(AST_Infinity, self).optimize(compressor);
  15179. }
  15180. }
  15181. const parent = compressor.parent();
  15182. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  15183. const def = self.definition();
  15184. const nearest_scope = find_scope(compressor);
  15185. if (compressor.top_retain && def.global && compressor.top_retain(def)) {
  15186. def.fixed = false;
  15187. def.single_use = false;
  15188. return self;
  15189. }
  15190. let fixed = self.fixed_value();
  15191. let single_use = def.single_use
  15192. && !(parent instanceof AST_Call
  15193. && (parent.is_expr_pure(compressor))
  15194. || has_annotation(parent, _NOINLINE))
  15195. && !(parent instanceof AST_Export
  15196. && fixed instanceof AST_Lambda
  15197. && fixed.name);
  15198. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  15199. if (retain_top_func(fixed, compressor)) {
  15200. single_use = false;
  15201. } else if (def.scope !== self.scope
  15202. && (def.escaped == 1
  15203. || has_flag(fixed, INLINED)
  15204. || within_array_or_object_literal(compressor))) {
  15205. single_use = false;
  15206. } else if (recursive_ref(compressor, def)) {
  15207. single_use = false;
  15208. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  15209. single_use = fixed.is_constant_expression(self.scope);
  15210. if (single_use == "f") {
  15211. var scope = self.scope;
  15212. do {
  15213. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  15214. set_flag(scope, INLINED);
  15215. }
  15216. } while (scope = scope.parent_scope);
  15217. }
  15218. }
  15219. }
  15220. if (single_use && fixed instanceof AST_Lambda) {
  15221. single_use =
  15222. def.scope === self.scope
  15223. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  15224. || parent instanceof AST_Call
  15225. && parent.expression === self
  15226. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  15227. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  15228. }
  15229. if (single_use && fixed instanceof AST_Class) {
  15230. const extends_inert = !fixed.extends
  15231. || !fixed.extends.may_throw(compressor)
  15232. && !fixed.extends.has_side_effects(compressor);
  15233. single_use = extends_inert
  15234. && !fixed.properties.some(prop =>
  15235. prop.may_throw(compressor) || prop.has_side_effects(compressor)
  15236. );
  15237. }
  15238. if (single_use && fixed) {
  15239. if (fixed instanceof AST_DefClass) {
  15240. set_flag(fixed, SQUEEZED);
  15241. fixed = make_node(AST_ClassExpression, fixed, fixed);
  15242. }
  15243. if (fixed instanceof AST_Defun) {
  15244. set_flag(fixed, SQUEEZED);
  15245. fixed = make_node(AST_Function, fixed, fixed);
  15246. }
  15247. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  15248. const defun_def = fixed.name.definition();
  15249. let lambda_def = fixed.variables.get(fixed.name.name);
  15250. let name = lambda_def && lambda_def.orig[0];
  15251. if (!(name instanceof AST_SymbolLambda)) {
  15252. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  15253. name.scope = fixed;
  15254. fixed.name = name;
  15255. lambda_def = fixed.def_function(name);
  15256. }
  15257. walk(fixed, node => {
  15258. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  15259. node.thedef = lambda_def;
  15260. lambda_def.references.push(node);
  15261. }
  15262. });
  15263. }
  15264. if (
  15265. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  15266. && fixed.parent_scope !== nearest_scope
  15267. ) {
  15268. fixed = fixed.clone(true, compressor.get_toplevel());
  15269. nearest_scope.add_child_scope(fixed);
  15270. }
  15271. return fixed.optimize(compressor);
  15272. }
  15273. // multiple uses
  15274. if (fixed) {
  15275. let replace;
  15276. if (fixed instanceof AST_This) {
  15277. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  15278. && def.references.every((ref) =>
  15279. def.scope === ref.scope
  15280. )) {
  15281. replace = fixed;
  15282. }
  15283. } else {
  15284. var ev = fixed.evaluate(compressor);
  15285. if (
  15286. ev !== fixed
  15287. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  15288. ) {
  15289. replace = make_node_from_constant(ev, fixed);
  15290. }
  15291. }
  15292. if (replace) {
  15293. const name_length = self.size(compressor);
  15294. const replace_size = replace.size(compressor);
  15295. let overhead = 0;
  15296. if (compressor.option("unused") && !compressor.exposed(def)) {
  15297. overhead =
  15298. (name_length + 2 + replace_size) /
  15299. (def.references.length - def.assignments);
  15300. }
  15301. if (replace_size <= name_length + overhead) {
  15302. return replace;
  15303. }
  15304. }
  15305. }
  15306. }
  15307. return self;
  15308. });
  15309. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  15310. for (const enclosed of pulled_scope.enclosed) {
  15311. if (pulled_scope.variables.has(enclosed.name)) {
  15312. continue;
  15313. }
  15314. const looked_up = scope.find_variable(enclosed.name);
  15315. if (looked_up) {
  15316. if (looked_up === enclosed) continue;
  15317. return true;
  15318. }
  15319. }
  15320. return false;
  15321. }
  15322. function is_atomic(lhs, self) {
  15323. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  15324. }
  15325. def_optimize(AST_Undefined, function(self, compressor) {
  15326. if (compressor.option("unsafe_undefined")) {
  15327. var undef = find_variable(compressor, "undefined");
  15328. if (undef) {
  15329. var ref = make_node(AST_SymbolRef, self, {
  15330. name : "undefined",
  15331. scope : undef.scope,
  15332. thedef : undef
  15333. });
  15334. set_flag(ref, UNDEFINED);
  15335. return ref;
  15336. }
  15337. }
  15338. var lhs = is_lhs(compressor.self(), compressor.parent());
  15339. if (lhs && is_atomic(lhs, self)) return self;
  15340. return make_node(AST_UnaryPrefix, self, {
  15341. operator: "void",
  15342. expression: make_node(AST_Number, self, {
  15343. value: 0
  15344. })
  15345. });
  15346. });
  15347. def_optimize(AST_Infinity, function(self, compressor) {
  15348. var lhs = is_lhs(compressor.self(), compressor.parent());
  15349. if (lhs && is_atomic(lhs, self)) return self;
  15350. if (
  15351. compressor.option("keep_infinity")
  15352. && !(lhs && !is_atomic(lhs, self))
  15353. && !find_variable(compressor, "Infinity")
  15354. ) {
  15355. return self;
  15356. }
  15357. return make_node(AST_Binary, self, {
  15358. operator: "/",
  15359. left: make_node(AST_Number, self, {
  15360. value: 1
  15361. }),
  15362. right: make_node(AST_Number, self, {
  15363. value: 0
  15364. })
  15365. });
  15366. });
  15367. def_optimize(AST_NaN, function(self, compressor) {
  15368. var lhs = is_lhs(compressor.self(), compressor.parent());
  15369. if (lhs && !is_atomic(lhs, self)
  15370. || find_variable(compressor, "NaN")) {
  15371. return make_node(AST_Binary, self, {
  15372. operator: "/",
  15373. left: make_node(AST_Number, self, {
  15374. value: 0
  15375. }),
  15376. right: make_node(AST_Number, self, {
  15377. value: 0
  15378. })
  15379. });
  15380. }
  15381. return self;
  15382. });
  15383. function is_reachable(self, defs) {
  15384. const find_ref = node => {
  15385. if (node instanceof AST_SymbolRef && member(node.definition(), defs)) {
  15386. return walk_abort;
  15387. }
  15388. };
  15389. return walk_parent(self, (node, info) => {
  15390. if (node instanceof AST_Scope && node !== self) {
  15391. var parent = info.parent();
  15392. if (parent instanceof AST_Call && parent.expression === node) return;
  15393. if (walk(node, find_ref)) return walk_abort;
  15394. return true;
  15395. }
  15396. });
  15397. }
  15398. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  15399. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  15400. def_optimize(AST_Assign, function(self, compressor) {
  15401. var def;
  15402. if (compressor.option("dead_code")
  15403. && self.left instanceof AST_SymbolRef
  15404. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  15405. var level = 0, node, parent = self;
  15406. do {
  15407. node = parent;
  15408. parent = compressor.parent(level++);
  15409. if (parent instanceof AST_Exit) {
  15410. if (in_try(level, parent)) break;
  15411. if (is_reachable(def.scope, [ def ])) break;
  15412. if (self.operator == "=") return self.right;
  15413. def.fixed = false;
  15414. return make_node(AST_Binary, self, {
  15415. operator: self.operator.slice(0, -1),
  15416. left: self.left,
  15417. right: self.right
  15418. }).optimize(compressor);
  15419. }
  15420. } while (parent instanceof AST_Binary && parent.right === node
  15421. || parent instanceof AST_Sequence && parent.tail_node() === node);
  15422. }
  15423. self = self.lift_sequences(compressor);
  15424. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  15425. // x = expr1 OP expr2
  15426. if (self.right.left instanceof AST_SymbolRef
  15427. && self.right.left.name == self.left.name
  15428. && ASSIGN_OPS.has(self.right.operator)) {
  15429. // x = x - 2 ---> x -= 2
  15430. self.operator = self.right.operator + "=";
  15431. self.right = self.right.right;
  15432. } else if (self.right.right instanceof AST_SymbolRef
  15433. && self.right.right.name == self.left.name
  15434. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  15435. && !self.right.left.has_side_effects(compressor)) {
  15436. // x = 2 & x ---> x &= 2
  15437. self.operator = self.right.operator + "=";
  15438. self.right = self.right.left;
  15439. }
  15440. }
  15441. return self;
  15442. function in_try(level, node) {
  15443. var right = self.right;
  15444. self.right = make_node(AST_Null, right);
  15445. var may_throw = node.may_throw(compressor);
  15446. self.right = right;
  15447. var scope = self.left.definition().scope;
  15448. var parent;
  15449. while ((parent = compressor.parent(level++)) !== scope) {
  15450. if (parent instanceof AST_Try) {
  15451. if (parent.bfinally) return true;
  15452. if (may_throw && parent.bcatch) return true;
  15453. }
  15454. }
  15455. }
  15456. });
  15457. def_optimize(AST_DefaultAssign, function(self, compressor) {
  15458. if (!compressor.option("evaluate")) {
  15459. return self;
  15460. }
  15461. var evaluateRight = self.right.evaluate(compressor);
  15462. // `[x = undefined] = foo` ---> `[x] = foo`
  15463. if (evaluateRight === undefined) {
  15464. self = self.left;
  15465. } else if (evaluateRight !== self.right) {
  15466. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  15467. self.right = best_of_expression(evaluateRight, self.right);
  15468. }
  15469. return self;
  15470. });
  15471. function is_nullish(node) {
  15472. let fixed;
  15473. return (
  15474. node instanceof AST_Null
  15475. || is_undefined(node)
  15476. || (
  15477. node instanceof AST_SymbolRef
  15478. && (fixed = node.definition().fixed) instanceof AST_Node
  15479. && is_nullish(fixed)
  15480. )
  15481. // Recurse into those optional chains!
  15482. || node instanceof AST_PropAccess && node.optional && is_nullish(node.expression)
  15483. || node instanceof AST_Call && node.optional && is_nullish(node.expression)
  15484. || node instanceof AST_Chain && is_nullish(node.expression)
  15485. );
  15486. }
  15487. function is_nullish_check(check, check_subject, compressor) {
  15488. if (check_subject.may_throw(compressor)) return false;
  15489. let nullish_side;
  15490. // foo == null
  15491. if (
  15492. check instanceof AST_Binary
  15493. && check.operator === "=="
  15494. // which side is nullish?
  15495. && (
  15496. (nullish_side = is_nullish(check.left) && check.left)
  15497. || (nullish_side = is_nullish(check.right) && check.right)
  15498. )
  15499. // is the other side the same as the check_subject
  15500. && (
  15501. nullish_side === check.left
  15502. ? check.right
  15503. : check.left
  15504. ).equivalent_to(check_subject)
  15505. ) {
  15506. return true;
  15507. }
  15508. // foo === null || foo === undefined
  15509. if (check instanceof AST_Binary && check.operator === "||") {
  15510. let null_cmp;
  15511. let undefined_cmp;
  15512. const find_comparison = cmp => {
  15513. if (!(
  15514. cmp instanceof AST_Binary
  15515. && (cmp.operator === "===" || cmp.operator === "==")
  15516. )) {
  15517. return false;
  15518. }
  15519. let found = 0;
  15520. let defined_side;
  15521. if (cmp.left instanceof AST_Null) {
  15522. found++;
  15523. null_cmp = cmp;
  15524. defined_side = cmp.right;
  15525. }
  15526. if (cmp.right instanceof AST_Null) {
  15527. found++;
  15528. null_cmp = cmp;
  15529. defined_side = cmp.left;
  15530. }
  15531. if (is_undefined(cmp.left)) {
  15532. found++;
  15533. undefined_cmp = cmp;
  15534. defined_side = cmp.right;
  15535. }
  15536. if (is_undefined(cmp.right)) {
  15537. found++;
  15538. undefined_cmp = cmp;
  15539. defined_side = cmp.left;
  15540. }
  15541. if (found !== 1) {
  15542. return false;
  15543. }
  15544. if (!defined_side.equivalent_to(check_subject)) {
  15545. return false;
  15546. }
  15547. return true;
  15548. };
  15549. if (!find_comparison(check.left)) return false;
  15550. if (!find_comparison(check.right)) return false;
  15551. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  15552. return true;
  15553. }
  15554. }
  15555. return false;
  15556. }
  15557. def_optimize(AST_Conditional, function(self, compressor) {
  15558. if (!compressor.option("conditionals")) return self;
  15559. // This looks like lift_sequences(), should probably be under "sequences"
  15560. if (self.condition instanceof AST_Sequence) {
  15561. var expressions = self.condition.expressions.slice();
  15562. self.condition = expressions.pop();
  15563. expressions.push(self);
  15564. return make_sequence(self, expressions);
  15565. }
  15566. var cond = self.condition.evaluate(compressor);
  15567. if (cond !== self.condition) {
  15568. if (cond) {
  15569. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  15570. } else {
  15571. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  15572. }
  15573. }
  15574. var negated = cond.negate(compressor, first_in_statement(compressor));
  15575. if (best_of(compressor, cond, negated) === negated) {
  15576. self = make_node(AST_Conditional, self, {
  15577. condition: negated,
  15578. consequent: self.alternative,
  15579. alternative: self.consequent
  15580. });
  15581. }
  15582. var condition = self.condition;
  15583. var consequent = self.consequent;
  15584. var alternative = self.alternative;
  15585. // x?x:y --> x||y
  15586. if (condition instanceof AST_SymbolRef
  15587. && consequent instanceof AST_SymbolRef
  15588. && condition.definition() === consequent.definition()) {
  15589. return make_node(AST_Binary, self, {
  15590. operator: "||",
  15591. left: condition,
  15592. right: alternative
  15593. });
  15594. }
  15595. // if (foo) exp = something; else exp = something_else;
  15596. // |
  15597. // v
  15598. // exp = foo ? something : something_else;
  15599. if (consequent instanceof AST_Assign
  15600. && alternative instanceof AST_Assign
  15601. && consequent.operator == alternative.operator
  15602. && consequent.left.equivalent_to(alternative.left)
  15603. && (!self.condition.has_side_effects(compressor)
  15604. || consequent.operator == "="
  15605. && !consequent.left.has_side_effects(compressor))) {
  15606. return make_node(AST_Assign, self, {
  15607. operator: consequent.operator,
  15608. left: consequent.left,
  15609. right: make_node(AST_Conditional, self, {
  15610. condition: self.condition,
  15611. consequent: consequent.right,
  15612. alternative: alternative.right
  15613. })
  15614. });
  15615. }
  15616. // x ? y(a) : y(b) --> y(x ? a : b)
  15617. var arg_index;
  15618. if (consequent instanceof AST_Call
  15619. && alternative.TYPE === consequent.TYPE
  15620. && consequent.args.length > 0
  15621. && consequent.args.length == alternative.args.length
  15622. && consequent.expression.equivalent_to(alternative.expression)
  15623. && !self.condition.has_side_effects(compressor)
  15624. && !consequent.expression.has_side_effects(compressor)
  15625. && typeof (arg_index = single_arg_diff()) == "number") {
  15626. var node = consequent.clone();
  15627. node.args[arg_index] = make_node(AST_Conditional, self, {
  15628. condition: self.condition,
  15629. consequent: consequent.args[arg_index],
  15630. alternative: alternative.args[arg_index]
  15631. });
  15632. return node;
  15633. }
  15634. // a ? b : c ? b : d --> (a || c) ? b : d
  15635. if (alternative instanceof AST_Conditional
  15636. && consequent.equivalent_to(alternative.consequent)) {
  15637. return make_node(AST_Conditional, self, {
  15638. condition: make_node(AST_Binary, self, {
  15639. operator: "||",
  15640. left: condition,
  15641. right: alternative.condition
  15642. }),
  15643. consequent: consequent,
  15644. alternative: alternative.alternative
  15645. }).optimize(compressor);
  15646. }
  15647. // a == null ? b : a -> a ?? b
  15648. if (
  15649. compressor.option("ecma") >= 2020 &&
  15650. is_nullish_check(condition, alternative, compressor)
  15651. ) {
  15652. return make_node(AST_Binary, self, {
  15653. operator: "??",
  15654. left: alternative,
  15655. right: consequent
  15656. }).optimize(compressor);
  15657. }
  15658. // a ? b : (c, b) --> (a || c), b
  15659. if (alternative instanceof AST_Sequence
  15660. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  15661. return make_sequence(self, [
  15662. make_node(AST_Binary, self, {
  15663. operator: "||",
  15664. left: condition,
  15665. right: make_sequence(self, alternative.expressions.slice(0, -1))
  15666. }),
  15667. consequent
  15668. ]).optimize(compressor);
  15669. }
  15670. // a ? b : (c && b) --> (a || c) && b
  15671. if (alternative instanceof AST_Binary
  15672. && alternative.operator == "&&"
  15673. && consequent.equivalent_to(alternative.right)) {
  15674. return make_node(AST_Binary, self, {
  15675. operator: "&&",
  15676. left: make_node(AST_Binary, self, {
  15677. operator: "||",
  15678. left: condition,
  15679. right: alternative.left
  15680. }),
  15681. right: consequent
  15682. }).optimize(compressor);
  15683. }
  15684. // x?y?z:a:a --> x&&y?z:a
  15685. if (consequent instanceof AST_Conditional
  15686. && consequent.alternative.equivalent_to(alternative)) {
  15687. return make_node(AST_Conditional, self, {
  15688. condition: make_node(AST_Binary, self, {
  15689. left: self.condition,
  15690. operator: "&&",
  15691. right: consequent.condition
  15692. }),
  15693. consequent: consequent.consequent,
  15694. alternative: alternative
  15695. });
  15696. }
  15697. // x ? y : y --> x, y
  15698. if (consequent.equivalent_to(alternative)) {
  15699. return make_sequence(self, [
  15700. self.condition,
  15701. consequent
  15702. ]).optimize(compressor);
  15703. }
  15704. // x ? y || z : z --> x && y || z
  15705. if (consequent instanceof AST_Binary
  15706. && consequent.operator == "||"
  15707. && consequent.right.equivalent_to(alternative)) {
  15708. return make_node(AST_Binary, self, {
  15709. operator: "||",
  15710. left: make_node(AST_Binary, self, {
  15711. operator: "&&",
  15712. left: self.condition,
  15713. right: consequent.left
  15714. }),
  15715. right: alternative
  15716. }).optimize(compressor);
  15717. }
  15718. var in_bool = compressor.in_boolean_context();
  15719. if (is_true(self.consequent)) {
  15720. if (is_false(self.alternative)) {
  15721. // c ? true : false ---> !!c
  15722. return booleanize(self.condition);
  15723. }
  15724. // c ? true : x ---> !!c || x
  15725. return make_node(AST_Binary, self, {
  15726. operator: "||",
  15727. left: booleanize(self.condition),
  15728. right: self.alternative
  15729. });
  15730. }
  15731. if (is_false(self.consequent)) {
  15732. if (is_true(self.alternative)) {
  15733. // c ? false : true ---> !c
  15734. return booleanize(self.condition.negate(compressor));
  15735. }
  15736. // c ? false : x ---> !c && x
  15737. return make_node(AST_Binary, self, {
  15738. operator: "&&",
  15739. left: booleanize(self.condition.negate(compressor)),
  15740. right: self.alternative
  15741. });
  15742. }
  15743. if (is_true(self.alternative)) {
  15744. // c ? x : true ---> !c || x
  15745. return make_node(AST_Binary, self, {
  15746. operator: "||",
  15747. left: booleanize(self.condition.negate(compressor)),
  15748. right: self.consequent
  15749. });
  15750. }
  15751. if (is_false(self.alternative)) {
  15752. // c ? x : false ---> !!c && x
  15753. return make_node(AST_Binary, self, {
  15754. operator: "&&",
  15755. left: booleanize(self.condition),
  15756. right: self.consequent
  15757. });
  15758. }
  15759. return self;
  15760. function booleanize(node) {
  15761. if (node.is_boolean()) return node;
  15762. // !!expression
  15763. return make_node(AST_UnaryPrefix, node, {
  15764. operator: "!",
  15765. expression: node.negate(compressor)
  15766. });
  15767. }
  15768. // AST_True or !0
  15769. function is_true(node) {
  15770. return node instanceof AST_True
  15771. || in_bool
  15772. && node instanceof AST_Constant
  15773. && node.getValue()
  15774. || (node instanceof AST_UnaryPrefix
  15775. && node.operator == "!"
  15776. && node.expression instanceof AST_Constant
  15777. && !node.expression.getValue());
  15778. }
  15779. // AST_False or !1
  15780. function is_false(node) {
  15781. return node instanceof AST_False
  15782. || in_bool
  15783. && node instanceof AST_Constant
  15784. && !node.getValue()
  15785. || (node instanceof AST_UnaryPrefix
  15786. && node.operator == "!"
  15787. && node.expression instanceof AST_Constant
  15788. && node.expression.getValue());
  15789. }
  15790. function single_arg_diff() {
  15791. var a = consequent.args;
  15792. var b = alternative.args;
  15793. for (var i = 0, len = a.length; i < len; i++) {
  15794. if (a[i] instanceof AST_Expansion) return;
  15795. if (!a[i].equivalent_to(b[i])) {
  15796. if (b[i] instanceof AST_Expansion) return;
  15797. for (var j = i + 1; j < len; j++) {
  15798. if (a[j] instanceof AST_Expansion) return;
  15799. if (!a[j].equivalent_to(b[j])) return;
  15800. }
  15801. return i;
  15802. }
  15803. }
  15804. }
  15805. });
  15806. def_optimize(AST_Boolean, function(self, compressor) {
  15807. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  15808. value: +self.value
  15809. });
  15810. var p = compressor.parent();
  15811. if (compressor.option("booleans_as_integers")) {
  15812. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  15813. p.operator = p.operator.replace(/=$/, "");
  15814. }
  15815. return make_node(AST_Number, self, {
  15816. value: +self.value
  15817. });
  15818. }
  15819. if (compressor.option("booleans")) {
  15820. if (p instanceof AST_Binary && (p.operator == "=="
  15821. || p.operator == "!=")) {
  15822. return make_node(AST_Number, self, {
  15823. value: +self.value
  15824. });
  15825. }
  15826. return make_node(AST_UnaryPrefix, self, {
  15827. operator: "!",
  15828. expression: make_node(AST_Number, self, {
  15829. value: 1 - self.value
  15830. })
  15831. });
  15832. }
  15833. return self;
  15834. });
  15835. function safe_to_flatten(value, compressor) {
  15836. if (value instanceof AST_SymbolRef) {
  15837. value = value.fixed_value();
  15838. }
  15839. if (!value) return false;
  15840. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  15841. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  15842. return compressor.parent() instanceof AST_New;
  15843. }
  15844. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  15845. if (!compressor.option("properties")) return;
  15846. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  15847. var expr = this.expression;
  15848. if (expr instanceof AST_Object) {
  15849. var props = expr.properties;
  15850. for (var i = props.length; --i >= 0;) {
  15851. var prop = props[i];
  15852. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  15853. if (!props.every((prop) => {
  15854. return prop instanceof AST_ObjectKeyVal
  15855. || arrows && prop instanceof AST_ConciseMethod && !prop.is_generator;
  15856. })) break;
  15857. if (!safe_to_flatten(prop.value, compressor)) break;
  15858. return make_node(AST_Sub, this, {
  15859. expression: make_node(AST_Array, expr, {
  15860. elements: props.map(function(prop) {
  15861. var v = prop.value;
  15862. if (v instanceof AST_Accessor) v = make_node(AST_Function, v, v);
  15863. var k = prop.key;
  15864. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  15865. return make_sequence(prop, [ k, v ]);
  15866. }
  15867. return v;
  15868. })
  15869. }),
  15870. property: make_node(AST_Number, this, {
  15871. value: i
  15872. })
  15873. });
  15874. }
  15875. }
  15876. }
  15877. });
  15878. def_optimize(AST_Sub, function(self, compressor) {
  15879. var expr = self.expression;
  15880. var prop = self.property;
  15881. if (compressor.option("properties")) {
  15882. var key = prop.evaluate(compressor);
  15883. if (key !== prop) {
  15884. if (typeof key == "string") {
  15885. if (key == "undefined") {
  15886. key = undefined;
  15887. } else {
  15888. var value = parseFloat(key);
  15889. if (value.toString() == key) {
  15890. key = value;
  15891. }
  15892. }
  15893. }
  15894. prop = self.property = best_of_expression(prop, make_node_from_constant(key, prop).transform(compressor));
  15895. var property = "" + key;
  15896. if (is_basic_identifier_string(property)
  15897. && property.length <= prop.size() + 1) {
  15898. return make_node(AST_Dot, self, {
  15899. expression: expr,
  15900. optional: self.optional,
  15901. property: property,
  15902. quote: prop.quote,
  15903. }).optimize(compressor);
  15904. }
  15905. }
  15906. }
  15907. var fn;
  15908. OPT_ARGUMENTS: if (compressor.option("arguments")
  15909. && expr instanceof AST_SymbolRef
  15910. && expr.name == "arguments"
  15911. && expr.definition().orig.length == 1
  15912. && (fn = expr.scope) instanceof AST_Lambda
  15913. && fn.uses_arguments
  15914. && !(fn instanceof AST_Arrow)
  15915. && prop instanceof AST_Number) {
  15916. var index = prop.getValue();
  15917. var params = new Set();
  15918. var argnames = fn.argnames;
  15919. for (var n = 0; n < argnames.length; n++) {
  15920. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  15921. break OPT_ARGUMENTS; // destructuring parameter - bail
  15922. }
  15923. var param = argnames[n].name;
  15924. if (params.has(param)) {
  15925. break OPT_ARGUMENTS; // duplicate parameter - bail
  15926. }
  15927. params.add(param);
  15928. }
  15929. var argname = fn.argnames[index];
  15930. if (argname && compressor.has_directive("use strict")) {
  15931. var def = argname.definition();
  15932. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  15933. argname = null;
  15934. }
  15935. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  15936. while (index >= fn.argnames.length) {
  15937. argname = fn.create_symbol(AST_SymbolFunarg, {
  15938. source: fn,
  15939. scope: fn,
  15940. tentative_name: "argument_" + fn.argnames.length,
  15941. });
  15942. fn.argnames.push(argname);
  15943. }
  15944. }
  15945. if (argname) {
  15946. var sym = make_node(AST_SymbolRef, self, argname);
  15947. sym.reference({});
  15948. clear_flag(argname, UNUSED);
  15949. return sym;
  15950. }
  15951. }
  15952. if (is_lhs(self, compressor.parent())) return self;
  15953. if (key !== prop) {
  15954. var sub = self.flatten_object(property, compressor);
  15955. if (sub) {
  15956. expr = self.expression = sub.expression;
  15957. prop = self.property = sub.property;
  15958. }
  15959. }
  15960. if (compressor.option("properties") && compressor.option("side_effects")
  15961. && prop instanceof AST_Number && expr instanceof AST_Array) {
  15962. var index = prop.getValue();
  15963. var elements = expr.elements;
  15964. var retValue = elements[index];
  15965. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  15966. var flatten = true;
  15967. var values = [];
  15968. for (var i = elements.length; --i > index;) {
  15969. var value = elements[i].drop_side_effect_free(compressor);
  15970. if (value) {
  15971. values.unshift(value);
  15972. if (flatten && value.has_side_effects(compressor)) flatten = false;
  15973. }
  15974. }
  15975. if (retValue instanceof AST_Expansion) break FLATTEN;
  15976. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  15977. if (!flatten) values.unshift(retValue);
  15978. while (--i >= 0) {
  15979. var value = elements[i];
  15980. if (value instanceof AST_Expansion) break FLATTEN;
  15981. value = value.drop_side_effect_free(compressor);
  15982. if (value) values.unshift(value);
  15983. else index--;
  15984. }
  15985. if (flatten) {
  15986. values.push(retValue);
  15987. return make_sequence(self, values).optimize(compressor);
  15988. } else return make_node(AST_Sub, self, {
  15989. expression: make_node(AST_Array, expr, {
  15990. elements: values
  15991. }),
  15992. property: make_node(AST_Number, prop, {
  15993. value: index
  15994. })
  15995. });
  15996. }
  15997. }
  15998. var ev = self.evaluate(compressor);
  15999. if (ev !== self) {
  16000. ev = make_node_from_constant(ev, self).optimize(compressor);
  16001. return best_of(compressor, ev, self);
  16002. }
  16003. if (self.optional && is_nullish(self.expression)) {
  16004. return make_node(AST_Undefined, self);
  16005. }
  16006. return self;
  16007. });
  16008. def_optimize(AST_Chain, function (self, compressor) {
  16009. self.expression = self.expression.optimize(compressor);
  16010. return self;
  16011. });
  16012. AST_Lambda.DEFMETHOD("contains_this", function() {
  16013. return walk(this, node => {
  16014. if (node instanceof AST_This) return walk_abort;
  16015. if (
  16016. node !== this
  16017. && node instanceof AST_Scope
  16018. && !(node instanceof AST_Arrow)
  16019. ) {
  16020. return true;
  16021. }
  16022. });
  16023. });
  16024. def_optimize(AST_Dot, function(self, compressor) {
  16025. const parent = compressor.parent();
  16026. if (is_lhs(self, parent)) return self;
  16027. if (compressor.option("unsafe_proto")
  16028. && self.expression instanceof AST_Dot
  16029. && self.expression.property == "prototype") {
  16030. var exp = self.expression.expression;
  16031. if (is_undeclared_ref(exp)) switch (exp.name) {
  16032. case "Array":
  16033. self.expression = make_node(AST_Array, self.expression, {
  16034. elements: []
  16035. });
  16036. break;
  16037. case "Function":
  16038. self.expression = make_node(AST_Function, self.expression, {
  16039. argnames: [],
  16040. body: []
  16041. });
  16042. break;
  16043. case "Number":
  16044. self.expression = make_node(AST_Number, self.expression, {
  16045. value: 0
  16046. });
  16047. break;
  16048. case "Object":
  16049. self.expression = make_node(AST_Object, self.expression, {
  16050. properties: []
  16051. });
  16052. break;
  16053. case "RegExp":
  16054. self.expression = make_node(AST_RegExp, self.expression, {
  16055. value: { source: "t", flags: "" }
  16056. });
  16057. break;
  16058. case "String":
  16059. self.expression = make_node(AST_String, self.expression, {
  16060. value: ""
  16061. });
  16062. break;
  16063. }
  16064. }
  16065. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  16066. const sub = self.flatten_object(self.property, compressor);
  16067. if (sub) return sub.optimize(compressor);
  16068. }
  16069. let ev = self.evaluate(compressor);
  16070. if (ev !== self) {
  16071. ev = make_node_from_constant(ev, self).optimize(compressor);
  16072. return best_of(compressor, ev, self);
  16073. }
  16074. if (self.optional && is_nullish(self.expression)) {
  16075. return make_node(AST_Undefined, self);
  16076. }
  16077. return self;
  16078. });
  16079. function literals_in_boolean_context(self, compressor) {
  16080. if (compressor.in_boolean_context()) {
  16081. return best_of(compressor, self, make_sequence(self, [
  16082. self,
  16083. make_node(AST_True, self)
  16084. ]).optimize(compressor));
  16085. }
  16086. return self;
  16087. }
  16088. function inline_array_like_spread(elements) {
  16089. for (var i = 0; i < elements.length; i++) {
  16090. var el = elements[i];
  16091. if (el instanceof AST_Expansion) {
  16092. var expr = el.expression;
  16093. if (
  16094. expr instanceof AST_Array
  16095. && !expr.elements.some(elm => elm instanceof AST_Hole)
  16096. ) {
  16097. elements.splice(i, 1, ...expr.elements);
  16098. // Step back one, as the element at i is now new.
  16099. i--;
  16100. }
  16101. // In array-like spread, spreading a non-iterable value is TypeError.
  16102. // We therefore can’t optimize anything else, unlike with object spread.
  16103. }
  16104. }
  16105. }
  16106. def_optimize(AST_Array, function(self, compressor) {
  16107. var optimized = literals_in_boolean_context(self, compressor);
  16108. if (optimized !== self) {
  16109. return optimized;
  16110. }
  16111. inline_array_like_spread(self.elements);
  16112. return self;
  16113. });
  16114. function inline_object_prop_spread(props) {
  16115. for (var i = 0; i < props.length; i++) {
  16116. var prop = props[i];
  16117. if (prop instanceof AST_Expansion) {
  16118. const expr = prop.expression;
  16119. if (
  16120. expr instanceof AST_Object
  16121. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  16122. ) {
  16123. props.splice(i, 1, ...expr.properties);
  16124. // Step back one, as the property at i is now new.
  16125. i--;
  16126. } else if (expr instanceof AST_Constant
  16127. && !(expr instanceof AST_String)) {
  16128. // Unlike array-like spread, in object spread, spreading a
  16129. // non-iterable value silently does nothing; it is thus safe
  16130. // to remove. AST_String is the only iterable AST_Constant.
  16131. props.splice(i, 1);
  16132. }
  16133. }
  16134. }
  16135. }
  16136. def_optimize(AST_Object, function(self, compressor) {
  16137. var optimized = literals_in_boolean_context(self, compressor);
  16138. if (optimized !== self) {
  16139. return optimized;
  16140. }
  16141. inline_object_prop_spread(self.properties);
  16142. return self;
  16143. });
  16144. def_optimize(AST_RegExp, literals_in_boolean_context);
  16145. def_optimize(AST_Return, function(self, compressor) {
  16146. if (self.value && is_undefined(self.value, compressor)) {
  16147. self.value = null;
  16148. }
  16149. return self;
  16150. });
  16151. def_optimize(AST_Arrow, opt_AST_Lambda);
  16152. def_optimize(AST_Function, function(self, compressor) {
  16153. self = opt_AST_Lambda(self, compressor);
  16154. if (compressor.option("unsafe_arrows")
  16155. && compressor.option("ecma") >= 2015
  16156. && !self.name
  16157. && !self.is_generator
  16158. && !self.uses_arguments
  16159. && !self.pinned()) {
  16160. const uses_this = walk(self, node => {
  16161. if (node instanceof AST_This) return walk_abort;
  16162. });
  16163. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  16164. }
  16165. return self;
  16166. });
  16167. def_optimize(AST_Class, function(self) {
  16168. // HACK to avoid compress failure.
  16169. // AST_Class is not really an AST_Scope/AST_Block as it lacks a body.
  16170. return self;
  16171. });
  16172. def_optimize(AST_Yield, function(self, compressor) {
  16173. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  16174. self.expression = null;
  16175. }
  16176. return self;
  16177. });
  16178. def_optimize(AST_TemplateString, function(self, compressor) {
  16179. if (!compressor.option("evaluate")
  16180. || compressor.parent() instanceof AST_PrefixedTemplateString)
  16181. return self;
  16182. var segments = [];
  16183. for (var i = 0; i < self.segments.length; i++) {
  16184. var segment = self.segments[i];
  16185. if (segment instanceof AST_Node) {
  16186. var result = segment.evaluate(compressor);
  16187. // Evaluate to constant value
  16188. // Constant value shorter than ${segment}
  16189. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  16190. // There should always be a previous and next segment if segment is a node
  16191. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  16192. continue;
  16193. }
  16194. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  16195. // TODO:
  16196. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  16197. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  16198. if (segment instanceof AST_TemplateString) {
  16199. var inners = segment.segments;
  16200. segments[segments.length - 1].value += inners[0].value;
  16201. for (var j = 1; j < inners.length; j++) {
  16202. segment = inners[j];
  16203. segments.push(segment);
  16204. }
  16205. continue;
  16206. }
  16207. }
  16208. segments.push(segment);
  16209. }
  16210. self.segments = segments;
  16211. // `foo` => "foo"
  16212. if (segments.length == 1) {
  16213. return make_node(AST_String, self, segments[0]);
  16214. }
  16215. if (segments.length === 3 && segments[1] instanceof AST_Node) {
  16216. // `foo${bar}` => "foo" + bar
  16217. if (segments[2].value === "") {
  16218. return make_node(AST_Binary, self, {
  16219. operator: "+",
  16220. left: make_node(AST_String, self, {
  16221. value: segments[0].value,
  16222. }),
  16223. right: segments[1],
  16224. });
  16225. }
  16226. // `{bar}baz` => bar + "baz"
  16227. if (segments[0].value === "") {
  16228. return make_node(AST_Binary, self, {
  16229. operator: "+",
  16230. left: segments[1],
  16231. right: make_node(AST_String, self, {
  16232. value: segments[2].value,
  16233. }),
  16234. });
  16235. }
  16236. }
  16237. return self;
  16238. });
  16239. def_optimize(AST_PrefixedTemplateString, function(self) {
  16240. return self;
  16241. });
  16242. // ["p"]:1 ---> p:1
  16243. // [42]:1 ---> 42:1
  16244. function lift_key(self, compressor) {
  16245. if (!compressor.option("computed_props")) return self;
  16246. // save a comparison in the typical case
  16247. if (!(self.key instanceof AST_Constant)) return self;
  16248. // allow certain acceptable props as not all AST_Constants are true constants
  16249. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  16250. if (self.key.value === "__proto__") return self;
  16251. if (self.key.value == "constructor"
  16252. && compressor.parent() instanceof AST_Class) return self;
  16253. if (self instanceof AST_ObjectKeyVal) {
  16254. self.key = self.key.value;
  16255. } else if (self instanceof AST_ClassProperty) {
  16256. self.key = make_node(AST_SymbolClassProperty, self.key, {
  16257. name: self.key.value
  16258. });
  16259. } else {
  16260. self.key = make_node(AST_SymbolMethod, self.key, {
  16261. name: self.key.value
  16262. });
  16263. }
  16264. }
  16265. return self;
  16266. }
  16267. def_optimize(AST_ObjectProperty, lift_key);
  16268. def_optimize(AST_ConciseMethod, function(self, compressor) {
  16269. lift_key(self, compressor);
  16270. // p(){return x;} ---> p:()=>x
  16271. if (compressor.option("arrows")
  16272. && compressor.parent() instanceof AST_Object
  16273. && !self.is_generator
  16274. && !self.value.uses_arguments
  16275. && !self.value.pinned()
  16276. && self.value.body.length == 1
  16277. && self.value.body[0] instanceof AST_Return
  16278. && self.value.body[0].value
  16279. && !self.value.contains_this()) {
  16280. var arrow = make_node(AST_Arrow, self.value, self.value);
  16281. arrow.async = self.async;
  16282. arrow.is_generator = self.is_generator;
  16283. return make_node(AST_ObjectKeyVal, self, {
  16284. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  16285. value: arrow,
  16286. quote: self.quote,
  16287. });
  16288. }
  16289. return self;
  16290. });
  16291. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  16292. lift_key(self, compressor);
  16293. // p:function(){} ---> p(){}
  16294. // p:function*(){} ---> *p(){}
  16295. // p:async function(){} ---> async p(){}
  16296. // p:()=>{} ---> p(){}
  16297. // p:async()=>{} ---> async p(){}
  16298. var unsafe_methods = compressor.option("unsafe_methods");
  16299. if (unsafe_methods
  16300. && compressor.option("ecma") >= 2015
  16301. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  16302. var key = self.key;
  16303. var value = self.value;
  16304. var is_arrow_with_block = value instanceof AST_Arrow
  16305. && Array.isArray(value.body)
  16306. && !value.contains_this();
  16307. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  16308. return make_node(AST_ConciseMethod, self, {
  16309. async: value.async,
  16310. is_generator: value.is_generator,
  16311. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  16312. name: key,
  16313. }),
  16314. value: make_node(AST_Accessor, value, value),
  16315. quote: self.quote,
  16316. });
  16317. }
  16318. }
  16319. return self;
  16320. });
  16321. def_optimize(AST_Destructuring, function(self, compressor) {
  16322. if (compressor.option("pure_getters") == true
  16323. && compressor.option("unused")
  16324. && !self.is_array
  16325. && Array.isArray(self.names)
  16326. && !is_destructuring_export_decl(compressor)
  16327. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  16328. var keep = [];
  16329. for (var i = 0; i < self.names.length; i++) {
  16330. var elem = self.names[i];
  16331. if (!(elem instanceof AST_ObjectKeyVal
  16332. && typeof elem.key == "string"
  16333. && elem.value instanceof AST_SymbolDeclaration
  16334. && !should_retain(compressor, elem.value.definition()))) {
  16335. keep.push(elem);
  16336. }
  16337. }
  16338. if (keep.length != self.names.length) {
  16339. self.names = keep;
  16340. }
  16341. }
  16342. return self;
  16343. function is_destructuring_export_decl(compressor) {
  16344. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  16345. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  16346. var parent = compressor.parent(p);
  16347. if (!parent) return false;
  16348. if (a === 0 && parent.TYPE == "Destructuring") continue;
  16349. if (!ancestors[a].test(parent.TYPE)) {
  16350. return false;
  16351. }
  16352. a++;
  16353. }
  16354. return true;
  16355. }
  16356. function should_retain(compressor, def) {
  16357. if (def.references.length) return true;
  16358. if (!def.global) return false;
  16359. if (compressor.toplevel.vars) {
  16360. if (compressor.top_retain) {
  16361. return compressor.top_retain(def);
  16362. }
  16363. return false;
  16364. }
  16365. return true;
  16366. }
  16367. });
  16368. /***********************************************************************
  16369. A JavaScript tokenizer / parser / beautifier / compressor.
  16370. https://github.com/mishoo/UglifyJS2
  16371. -------------------------------- (C) ---------------------------------
  16372. Author: Mihai Bazon
  16373. <mihai.bazon@gmail.com>
  16374. http://mihai.bazon.net/blog
  16375. Distributed under the BSD license:
  16376. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16377. Redistribution and use in source and binary forms, with or without
  16378. modification, are permitted provided that the following conditions
  16379. are met:
  16380. * Redistributions of source code must retain the above
  16381. copyright notice, this list of conditions and the following
  16382. disclaimer.
  16383. * Redistributions in binary form must reproduce the above
  16384. copyright notice, this list of conditions and the following
  16385. disclaimer in the documentation and/or other materials
  16386. provided with the distribution.
  16387. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16388. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16389. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16390. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16391. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16392. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16393. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16394. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16395. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16396. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16397. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16398. SUCH DAMAGE.
  16399. ***********************************************************************/
  16400. // a small wrapper around fitzgen's source-map library
  16401. async function SourceMap(options) {
  16402. options = defaults(options, {
  16403. file : null,
  16404. root : null,
  16405. orig : null,
  16406. orig_line_diff : 0,
  16407. dest_line_diff : 0,
  16408. });
  16409. var orig_map;
  16410. var generator = new MOZ_SourceMap.SourceMapGenerator({
  16411. file : options.file,
  16412. sourceRoot : options.root
  16413. });
  16414. if (options.orig) {
  16415. orig_map = await new MOZ_SourceMap.SourceMapConsumer(options.orig);
  16416. orig_map.sources.forEach(function(source) {
  16417. var sourceContent = orig_map.sourceContentFor(source, true);
  16418. if (sourceContent) {
  16419. generator.setSourceContent(source, sourceContent);
  16420. }
  16421. });
  16422. }
  16423. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  16424. if (orig_map) {
  16425. var info = orig_map.originalPositionFor({
  16426. line: orig_line,
  16427. column: orig_col
  16428. });
  16429. if (info.source === null) {
  16430. return;
  16431. }
  16432. source = info.source;
  16433. orig_line = info.line;
  16434. orig_col = info.column;
  16435. name = info.name || name;
  16436. }
  16437. generator.addMapping({
  16438. generated : { line: gen_line + options.dest_line_diff, column: gen_col },
  16439. original : { line: orig_line + options.orig_line_diff, column: orig_col },
  16440. source : source,
  16441. name : name
  16442. });
  16443. }
  16444. return {
  16445. add : add,
  16446. get : function() { return generator; },
  16447. toString : function() { return generator.toString(); },
  16448. destroy : function () {
  16449. if (orig_map && orig_map.destroy) {
  16450. orig_map.destroy();
  16451. }
  16452. }
  16453. };
  16454. }
  16455. var domprops = [
  16456. "$&",
  16457. "$'",
  16458. "$*",
  16459. "$+",
  16460. "$1",
  16461. "$2",
  16462. "$3",
  16463. "$4",
  16464. "$5",
  16465. "$6",
  16466. "$7",
  16467. "$8",
  16468. "$9",
  16469. "$_",
  16470. "$`",
  16471. "$input",
  16472. "-moz-animation",
  16473. "-moz-animation-delay",
  16474. "-moz-animation-direction",
  16475. "-moz-animation-duration",
  16476. "-moz-animation-fill-mode",
  16477. "-moz-animation-iteration-count",
  16478. "-moz-animation-name",
  16479. "-moz-animation-play-state",
  16480. "-moz-animation-timing-function",
  16481. "-moz-appearance",
  16482. "-moz-backface-visibility",
  16483. "-moz-border-end",
  16484. "-moz-border-end-color",
  16485. "-moz-border-end-style",
  16486. "-moz-border-end-width",
  16487. "-moz-border-image",
  16488. "-moz-border-start",
  16489. "-moz-border-start-color",
  16490. "-moz-border-start-style",
  16491. "-moz-border-start-width",
  16492. "-moz-box-align",
  16493. "-moz-box-direction",
  16494. "-moz-box-flex",
  16495. "-moz-box-ordinal-group",
  16496. "-moz-box-orient",
  16497. "-moz-box-pack",
  16498. "-moz-box-sizing",
  16499. "-moz-float-edge",
  16500. "-moz-font-feature-settings",
  16501. "-moz-font-language-override",
  16502. "-moz-force-broken-image-icon",
  16503. "-moz-hyphens",
  16504. "-moz-image-region",
  16505. "-moz-margin-end",
  16506. "-moz-margin-start",
  16507. "-moz-orient",
  16508. "-moz-osx-font-smoothing",
  16509. "-moz-outline-radius",
  16510. "-moz-outline-radius-bottomleft",
  16511. "-moz-outline-radius-bottomright",
  16512. "-moz-outline-radius-topleft",
  16513. "-moz-outline-radius-topright",
  16514. "-moz-padding-end",
  16515. "-moz-padding-start",
  16516. "-moz-perspective",
  16517. "-moz-perspective-origin",
  16518. "-moz-tab-size",
  16519. "-moz-text-size-adjust",
  16520. "-moz-transform",
  16521. "-moz-transform-origin",
  16522. "-moz-transform-style",
  16523. "-moz-transition",
  16524. "-moz-transition-delay",
  16525. "-moz-transition-duration",
  16526. "-moz-transition-property",
  16527. "-moz-transition-timing-function",
  16528. "-moz-user-focus",
  16529. "-moz-user-input",
  16530. "-moz-user-modify",
  16531. "-moz-user-select",
  16532. "-moz-window-dragging",
  16533. "-webkit-align-content",
  16534. "-webkit-align-items",
  16535. "-webkit-align-self",
  16536. "-webkit-animation",
  16537. "-webkit-animation-delay",
  16538. "-webkit-animation-direction",
  16539. "-webkit-animation-duration",
  16540. "-webkit-animation-fill-mode",
  16541. "-webkit-animation-iteration-count",
  16542. "-webkit-animation-name",
  16543. "-webkit-animation-play-state",
  16544. "-webkit-animation-timing-function",
  16545. "-webkit-appearance",
  16546. "-webkit-backface-visibility",
  16547. "-webkit-background-clip",
  16548. "-webkit-background-origin",
  16549. "-webkit-background-size",
  16550. "-webkit-border-bottom-left-radius",
  16551. "-webkit-border-bottom-right-radius",
  16552. "-webkit-border-image",
  16553. "-webkit-border-radius",
  16554. "-webkit-border-top-left-radius",
  16555. "-webkit-border-top-right-radius",
  16556. "-webkit-box-align",
  16557. "-webkit-box-direction",
  16558. "-webkit-box-flex",
  16559. "-webkit-box-ordinal-group",
  16560. "-webkit-box-orient",
  16561. "-webkit-box-pack",
  16562. "-webkit-box-shadow",
  16563. "-webkit-box-sizing",
  16564. "-webkit-filter",
  16565. "-webkit-flex",
  16566. "-webkit-flex-basis",
  16567. "-webkit-flex-direction",
  16568. "-webkit-flex-flow",
  16569. "-webkit-flex-grow",
  16570. "-webkit-flex-shrink",
  16571. "-webkit-flex-wrap",
  16572. "-webkit-justify-content",
  16573. "-webkit-line-clamp",
  16574. "-webkit-mask",
  16575. "-webkit-mask-clip",
  16576. "-webkit-mask-composite",
  16577. "-webkit-mask-image",
  16578. "-webkit-mask-origin",
  16579. "-webkit-mask-position",
  16580. "-webkit-mask-position-x",
  16581. "-webkit-mask-position-y",
  16582. "-webkit-mask-repeat",
  16583. "-webkit-mask-size",
  16584. "-webkit-order",
  16585. "-webkit-perspective",
  16586. "-webkit-perspective-origin",
  16587. "-webkit-text-fill-color",
  16588. "-webkit-text-size-adjust",
  16589. "-webkit-text-stroke",
  16590. "-webkit-text-stroke-color",
  16591. "-webkit-text-stroke-width",
  16592. "-webkit-transform",
  16593. "-webkit-transform-origin",
  16594. "-webkit-transform-style",
  16595. "-webkit-transition",
  16596. "-webkit-transition-delay",
  16597. "-webkit-transition-duration",
  16598. "-webkit-transition-property",
  16599. "-webkit-transition-timing-function",
  16600. "-webkit-user-select",
  16601. "0",
  16602. "1",
  16603. "10",
  16604. "11",
  16605. "12",
  16606. "13",
  16607. "14",
  16608. "15",
  16609. "16",
  16610. "17",
  16611. "18",
  16612. "19",
  16613. "2",
  16614. "20",
  16615. "3",
  16616. "4",
  16617. "5",
  16618. "6",
  16619. "7",
  16620. "8",
  16621. "9",
  16622. "@@iterator",
  16623. "ABORT_ERR",
  16624. "ACTIVE",
  16625. "ACTIVE_ATTRIBUTES",
  16626. "ACTIVE_TEXTURE",
  16627. "ACTIVE_UNIFORMS",
  16628. "ACTIVE_UNIFORM_BLOCKS",
  16629. "ADDITION",
  16630. "ALIASED_LINE_WIDTH_RANGE",
  16631. "ALIASED_POINT_SIZE_RANGE",
  16632. "ALLOW_KEYBOARD_INPUT",
  16633. "ALLPASS",
  16634. "ALPHA",
  16635. "ALPHA_BITS",
  16636. "ALREADY_SIGNALED",
  16637. "ALT_MASK",
  16638. "ALWAYS",
  16639. "ANY_SAMPLES_PASSED",
  16640. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  16641. "ANY_TYPE",
  16642. "ANY_UNORDERED_NODE_TYPE",
  16643. "ARRAY_BUFFER",
  16644. "ARRAY_BUFFER_BINDING",
  16645. "ATTACHED_SHADERS",
  16646. "ATTRIBUTE_NODE",
  16647. "AT_TARGET",
  16648. "AbortController",
  16649. "AbortSignal",
  16650. "AbsoluteOrientationSensor",
  16651. "AbstractRange",
  16652. "Accelerometer",
  16653. "AddSearchProvider",
  16654. "AggregateError",
  16655. "AnalyserNode",
  16656. "Animation",
  16657. "AnimationEffect",
  16658. "AnimationEvent",
  16659. "AnimationPlaybackEvent",
  16660. "AnimationTimeline",
  16661. "AnonXMLHttpRequest",
  16662. "Any",
  16663. "ApplicationCache",
  16664. "ApplicationCacheErrorEvent",
  16665. "Array",
  16666. "ArrayBuffer",
  16667. "ArrayType",
  16668. "Atomics",
  16669. "Attr",
  16670. "Audio",
  16671. "AudioBuffer",
  16672. "AudioBufferSourceNode",
  16673. "AudioContext",
  16674. "AudioDestinationNode",
  16675. "AudioListener",
  16676. "AudioNode",
  16677. "AudioParam",
  16678. "AudioParamMap",
  16679. "AudioProcessingEvent",
  16680. "AudioScheduledSourceNode",
  16681. "AudioStreamTrack",
  16682. "AudioWorklet",
  16683. "AudioWorkletNode",
  16684. "AuthenticatorAssertionResponse",
  16685. "AuthenticatorAttestationResponse",
  16686. "AuthenticatorResponse",
  16687. "AutocompleteErrorEvent",
  16688. "BACK",
  16689. "BAD_BOUNDARYPOINTS_ERR",
  16690. "BAD_REQUEST",
  16691. "BANDPASS",
  16692. "BLEND",
  16693. "BLEND_COLOR",
  16694. "BLEND_DST_ALPHA",
  16695. "BLEND_DST_RGB",
  16696. "BLEND_EQUATION",
  16697. "BLEND_EQUATION_ALPHA",
  16698. "BLEND_EQUATION_RGB",
  16699. "BLEND_SRC_ALPHA",
  16700. "BLEND_SRC_RGB",
  16701. "BLUE_BITS",
  16702. "BLUR",
  16703. "BOOL",
  16704. "BOOLEAN_TYPE",
  16705. "BOOL_VEC2",
  16706. "BOOL_VEC3",
  16707. "BOOL_VEC4",
  16708. "BOTH",
  16709. "BROWSER_DEFAULT_WEBGL",
  16710. "BUBBLING_PHASE",
  16711. "BUFFER_SIZE",
  16712. "BUFFER_USAGE",
  16713. "BYTE",
  16714. "BYTES_PER_ELEMENT",
  16715. "BackgroundFetchManager",
  16716. "BackgroundFetchRecord",
  16717. "BackgroundFetchRegistration",
  16718. "BarProp",
  16719. "BarcodeDetector",
  16720. "BaseAudioContext",
  16721. "BaseHref",
  16722. "BatteryManager",
  16723. "BeforeInstallPromptEvent",
  16724. "BeforeLoadEvent",
  16725. "BeforeUnloadEvent",
  16726. "BigInt",
  16727. "BigInt64Array",
  16728. "BigUint64Array",
  16729. "BiquadFilterNode",
  16730. "Blob",
  16731. "BlobEvent",
  16732. "Bluetooth",
  16733. "BluetoothCharacteristicProperties",
  16734. "BluetoothDevice",
  16735. "BluetoothRemoteGATTCharacteristic",
  16736. "BluetoothRemoteGATTDescriptor",
  16737. "BluetoothRemoteGATTServer",
  16738. "BluetoothRemoteGATTService",
  16739. "BluetoothUUID",
  16740. "Boolean",
  16741. "BroadcastChannel",
  16742. "ByteLengthQueuingStrategy",
  16743. "CAPTURING_PHASE",
  16744. "CCW",
  16745. "CDATASection",
  16746. "CDATA_SECTION_NODE",
  16747. "CHANGE",
  16748. "CHARSET_RULE",
  16749. "CHECKING",
  16750. "CLAMP_TO_EDGE",
  16751. "CLICK",
  16752. "CLOSED",
  16753. "CLOSING",
  16754. "COLOR",
  16755. "COLOR_ATTACHMENT0",
  16756. "COLOR_ATTACHMENT1",
  16757. "COLOR_ATTACHMENT10",
  16758. "COLOR_ATTACHMENT11",
  16759. "COLOR_ATTACHMENT12",
  16760. "COLOR_ATTACHMENT13",
  16761. "COLOR_ATTACHMENT14",
  16762. "COLOR_ATTACHMENT15",
  16763. "COLOR_ATTACHMENT2",
  16764. "COLOR_ATTACHMENT3",
  16765. "COLOR_ATTACHMENT4",
  16766. "COLOR_ATTACHMENT5",
  16767. "COLOR_ATTACHMENT6",
  16768. "COLOR_ATTACHMENT7",
  16769. "COLOR_ATTACHMENT8",
  16770. "COLOR_ATTACHMENT9",
  16771. "COLOR_BUFFER_BIT",
  16772. "COLOR_CLEAR_VALUE",
  16773. "COLOR_WRITEMASK",
  16774. "COMMENT_NODE",
  16775. "COMPARE_REF_TO_TEXTURE",
  16776. "COMPILE_STATUS",
  16777. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  16778. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  16779. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  16780. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  16781. "COMPRESSED_TEXTURE_FORMATS",
  16782. "CONDITION_SATISFIED",
  16783. "CONFIGURATION_UNSUPPORTED",
  16784. "CONNECTING",
  16785. "CONSTANT_ALPHA",
  16786. "CONSTANT_COLOR",
  16787. "CONSTRAINT_ERR",
  16788. "CONTEXT_LOST_WEBGL",
  16789. "CONTROL_MASK",
  16790. "COPY_READ_BUFFER",
  16791. "COPY_READ_BUFFER_BINDING",
  16792. "COPY_WRITE_BUFFER",
  16793. "COPY_WRITE_BUFFER_BINDING",
  16794. "COUNTER_STYLE_RULE",
  16795. "CSS",
  16796. "CSS2Properties",
  16797. "CSSAnimation",
  16798. "CSSCharsetRule",
  16799. "CSSConditionRule",
  16800. "CSSCounterStyleRule",
  16801. "CSSFontFaceRule",
  16802. "CSSFontFeatureValuesRule",
  16803. "CSSGroupingRule",
  16804. "CSSImageValue",
  16805. "CSSImportRule",
  16806. "CSSKeyframeRule",
  16807. "CSSKeyframesRule",
  16808. "CSSKeywordValue",
  16809. "CSSMathInvert",
  16810. "CSSMathMax",
  16811. "CSSMathMin",
  16812. "CSSMathNegate",
  16813. "CSSMathProduct",
  16814. "CSSMathSum",
  16815. "CSSMathValue",
  16816. "CSSMatrixComponent",
  16817. "CSSMediaRule",
  16818. "CSSMozDocumentRule",
  16819. "CSSNameSpaceRule",
  16820. "CSSNamespaceRule",
  16821. "CSSNumericArray",
  16822. "CSSNumericValue",
  16823. "CSSPageRule",
  16824. "CSSPerspective",
  16825. "CSSPositionValue",
  16826. "CSSPrimitiveValue",
  16827. "CSSRotate",
  16828. "CSSRule",
  16829. "CSSRuleList",
  16830. "CSSScale",
  16831. "CSSSkew",
  16832. "CSSSkewX",
  16833. "CSSSkewY",
  16834. "CSSStyleDeclaration",
  16835. "CSSStyleRule",
  16836. "CSSStyleSheet",
  16837. "CSSStyleValue",
  16838. "CSSSupportsRule",
  16839. "CSSTransformComponent",
  16840. "CSSTransformValue",
  16841. "CSSTransition",
  16842. "CSSTranslate",
  16843. "CSSUnitValue",
  16844. "CSSUnknownRule",
  16845. "CSSUnparsedValue",
  16846. "CSSValue",
  16847. "CSSValueList",
  16848. "CSSVariableReferenceValue",
  16849. "CSSVariablesDeclaration",
  16850. "CSSVariablesRule",
  16851. "CSSViewportRule",
  16852. "CSS_ATTR",
  16853. "CSS_CM",
  16854. "CSS_COUNTER",
  16855. "CSS_CUSTOM",
  16856. "CSS_DEG",
  16857. "CSS_DIMENSION",
  16858. "CSS_EMS",
  16859. "CSS_EXS",
  16860. "CSS_FILTER_BLUR",
  16861. "CSS_FILTER_BRIGHTNESS",
  16862. "CSS_FILTER_CONTRAST",
  16863. "CSS_FILTER_CUSTOM",
  16864. "CSS_FILTER_DROP_SHADOW",
  16865. "CSS_FILTER_GRAYSCALE",
  16866. "CSS_FILTER_HUE_ROTATE",
  16867. "CSS_FILTER_INVERT",
  16868. "CSS_FILTER_OPACITY",
  16869. "CSS_FILTER_REFERENCE",
  16870. "CSS_FILTER_SATURATE",
  16871. "CSS_FILTER_SEPIA",
  16872. "CSS_GRAD",
  16873. "CSS_HZ",
  16874. "CSS_IDENT",
  16875. "CSS_IN",
  16876. "CSS_INHERIT",
  16877. "CSS_KHZ",
  16878. "CSS_MATRIX",
  16879. "CSS_MATRIX3D",
  16880. "CSS_MM",
  16881. "CSS_MS",
  16882. "CSS_NUMBER",
  16883. "CSS_PC",
  16884. "CSS_PERCENTAGE",
  16885. "CSS_PERSPECTIVE",
  16886. "CSS_PRIMITIVE_VALUE",
  16887. "CSS_PT",
  16888. "CSS_PX",
  16889. "CSS_RAD",
  16890. "CSS_RECT",
  16891. "CSS_RGBCOLOR",
  16892. "CSS_ROTATE",
  16893. "CSS_ROTATE3D",
  16894. "CSS_ROTATEX",
  16895. "CSS_ROTATEY",
  16896. "CSS_ROTATEZ",
  16897. "CSS_S",
  16898. "CSS_SCALE",
  16899. "CSS_SCALE3D",
  16900. "CSS_SCALEX",
  16901. "CSS_SCALEY",
  16902. "CSS_SCALEZ",
  16903. "CSS_SKEW",
  16904. "CSS_SKEWX",
  16905. "CSS_SKEWY",
  16906. "CSS_STRING",
  16907. "CSS_TRANSLATE",
  16908. "CSS_TRANSLATE3D",
  16909. "CSS_TRANSLATEX",
  16910. "CSS_TRANSLATEY",
  16911. "CSS_TRANSLATEZ",
  16912. "CSS_UNKNOWN",
  16913. "CSS_URI",
  16914. "CSS_VALUE_LIST",
  16915. "CSS_VH",
  16916. "CSS_VMAX",
  16917. "CSS_VMIN",
  16918. "CSS_VW",
  16919. "CULL_FACE",
  16920. "CULL_FACE_MODE",
  16921. "CURRENT_PROGRAM",
  16922. "CURRENT_QUERY",
  16923. "CURRENT_VERTEX_ATTRIB",
  16924. "CUSTOM",
  16925. "CW",
  16926. "Cache",
  16927. "CacheStorage",
  16928. "CanvasCaptureMediaStream",
  16929. "CanvasCaptureMediaStreamTrack",
  16930. "CanvasGradient",
  16931. "CanvasPattern",
  16932. "CanvasRenderingContext2D",
  16933. "CaretPosition",
  16934. "ChannelMergerNode",
  16935. "ChannelSplitterNode",
  16936. "CharacterData",
  16937. "ClientRect",
  16938. "ClientRectList",
  16939. "Clipboard",
  16940. "ClipboardEvent",
  16941. "ClipboardItem",
  16942. "CloseEvent",
  16943. "Collator",
  16944. "CommandEvent",
  16945. "Comment",
  16946. "CompileError",
  16947. "CompositionEvent",
  16948. "CompressionStream",
  16949. "Console",
  16950. "ConstantSourceNode",
  16951. "Controllers",
  16952. "ConvolverNode",
  16953. "CountQueuingStrategy",
  16954. "Counter",
  16955. "Credential",
  16956. "CredentialsContainer",
  16957. "Crypto",
  16958. "CryptoKey",
  16959. "CustomElementRegistry",
  16960. "CustomEvent",
  16961. "DATABASE_ERR",
  16962. "DATA_CLONE_ERR",
  16963. "DATA_ERR",
  16964. "DBLCLICK",
  16965. "DECR",
  16966. "DECR_WRAP",
  16967. "DELETE_STATUS",
  16968. "DEPTH",
  16969. "DEPTH24_STENCIL8",
  16970. "DEPTH32F_STENCIL8",
  16971. "DEPTH_ATTACHMENT",
  16972. "DEPTH_BITS",
  16973. "DEPTH_BUFFER_BIT",
  16974. "DEPTH_CLEAR_VALUE",
  16975. "DEPTH_COMPONENT",
  16976. "DEPTH_COMPONENT16",
  16977. "DEPTH_COMPONENT24",
  16978. "DEPTH_COMPONENT32F",
  16979. "DEPTH_FUNC",
  16980. "DEPTH_RANGE",
  16981. "DEPTH_STENCIL",
  16982. "DEPTH_STENCIL_ATTACHMENT",
  16983. "DEPTH_TEST",
  16984. "DEPTH_WRITEMASK",
  16985. "DEVICE_INELIGIBLE",
  16986. "DIRECTION_DOWN",
  16987. "DIRECTION_LEFT",
  16988. "DIRECTION_RIGHT",
  16989. "DIRECTION_UP",
  16990. "DISABLED",
  16991. "DISPATCH_REQUEST_ERR",
  16992. "DITHER",
  16993. "DOCUMENT_FRAGMENT_NODE",
  16994. "DOCUMENT_NODE",
  16995. "DOCUMENT_POSITION_CONTAINED_BY",
  16996. "DOCUMENT_POSITION_CONTAINS",
  16997. "DOCUMENT_POSITION_DISCONNECTED",
  16998. "DOCUMENT_POSITION_FOLLOWING",
  16999. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  17000. "DOCUMENT_POSITION_PRECEDING",
  17001. "DOCUMENT_TYPE_NODE",
  17002. "DOMCursor",
  17003. "DOMError",
  17004. "DOMException",
  17005. "DOMImplementation",
  17006. "DOMImplementationLS",
  17007. "DOMMatrix",
  17008. "DOMMatrixReadOnly",
  17009. "DOMParser",
  17010. "DOMPoint",
  17011. "DOMPointReadOnly",
  17012. "DOMQuad",
  17013. "DOMRect",
  17014. "DOMRectList",
  17015. "DOMRectReadOnly",
  17016. "DOMRequest",
  17017. "DOMSTRING_SIZE_ERR",
  17018. "DOMSettableTokenList",
  17019. "DOMStringList",
  17020. "DOMStringMap",
  17021. "DOMTokenList",
  17022. "DOMTransactionEvent",
  17023. "DOM_DELTA_LINE",
  17024. "DOM_DELTA_PAGE",
  17025. "DOM_DELTA_PIXEL",
  17026. "DOM_INPUT_METHOD_DROP",
  17027. "DOM_INPUT_METHOD_HANDWRITING",
  17028. "DOM_INPUT_METHOD_IME",
  17029. "DOM_INPUT_METHOD_KEYBOARD",
  17030. "DOM_INPUT_METHOD_MULTIMODAL",
  17031. "DOM_INPUT_METHOD_OPTION",
  17032. "DOM_INPUT_METHOD_PASTE",
  17033. "DOM_INPUT_METHOD_SCRIPT",
  17034. "DOM_INPUT_METHOD_UNKNOWN",
  17035. "DOM_INPUT_METHOD_VOICE",
  17036. "DOM_KEY_LOCATION_JOYSTICK",
  17037. "DOM_KEY_LOCATION_LEFT",
  17038. "DOM_KEY_LOCATION_MOBILE",
  17039. "DOM_KEY_LOCATION_NUMPAD",
  17040. "DOM_KEY_LOCATION_RIGHT",
  17041. "DOM_KEY_LOCATION_STANDARD",
  17042. "DOM_VK_0",
  17043. "DOM_VK_1",
  17044. "DOM_VK_2",
  17045. "DOM_VK_3",
  17046. "DOM_VK_4",
  17047. "DOM_VK_5",
  17048. "DOM_VK_6",
  17049. "DOM_VK_7",
  17050. "DOM_VK_8",
  17051. "DOM_VK_9",
  17052. "DOM_VK_A",
  17053. "DOM_VK_ACCEPT",
  17054. "DOM_VK_ADD",
  17055. "DOM_VK_ALT",
  17056. "DOM_VK_ALTGR",
  17057. "DOM_VK_AMPERSAND",
  17058. "DOM_VK_ASTERISK",
  17059. "DOM_VK_AT",
  17060. "DOM_VK_ATTN",
  17061. "DOM_VK_B",
  17062. "DOM_VK_BACKSPACE",
  17063. "DOM_VK_BACK_QUOTE",
  17064. "DOM_VK_BACK_SLASH",
  17065. "DOM_VK_BACK_SPACE",
  17066. "DOM_VK_C",
  17067. "DOM_VK_CANCEL",
  17068. "DOM_VK_CAPS_LOCK",
  17069. "DOM_VK_CIRCUMFLEX",
  17070. "DOM_VK_CLEAR",
  17071. "DOM_VK_CLOSE_BRACKET",
  17072. "DOM_VK_CLOSE_CURLY_BRACKET",
  17073. "DOM_VK_CLOSE_PAREN",
  17074. "DOM_VK_COLON",
  17075. "DOM_VK_COMMA",
  17076. "DOM_VK_CONTEXT_MENU",
  17077. "DOM_VK_CONTROL",
  17078. "DOM_VK_CONVERT",
  17079. "DOM_VK_CRSEL",
  17080. "DOM_VK_CTRL",
  17081. "DOM_VK_D",
  17082. "DOM_VK_DECIMAL",
  17083. "DOM_VK_DELETE",
  17084. "DOM_VK_DIVIDE",
  17085. "DOM_VK_DOLLAR",
  17086. "DOM_VK_DOUBLE_QUOTE",
  17087. "DOM_VK_DOWN",
  17088. "DOM_VK_E",
  17089. "DOM_VK_EISU",
  17090. "DOM_VK_END",
  17091. "DOM_VK_ENTER",
  17092. "DOM_VK_EQUALS",
  17093. "DOM_VK_EREOF",
  17094. "DOM_VK_ESCAPE",
  17095. "DOM_VK_EXCLAMATION",
  17096. "DOM_VK_EXECUTE",
  17097. "DOM_VK_EXSEL",
  17098. "DOM_VK_F",
  17099. "DOM_VK_F1",
  17100. "DOM_VK_F10",
  17101. "DOM_VK_F11",
  17102. "DOM_VK_F12",
  17103. "DOM_VK_F13",
  17104. "DOM_VK_F14",
  17105. "DOM_VK_F15",
  17106. "DOM_VK_F16",
  17107. "DOM_VK_F17",
  17108. "DOM_VK_F18",
  17109. "DOM_VK_F19",
  17110. "DOM_VK_F2",
  17111. "DOM_VK_F20",
  17112. "DOM_VK_F21",
  17113. "DOM_VK_F22",
  17114. "DOM_VK_F23",
  17115. "DOM_VK_F24",
  17116. "DOM_VK_F25",
  17117. "DOM_VK_F26",
  17118. "DOM_VK_F27",
  17119. "DOM_VK_F28",
  17120. "DOM_VK_F29",
  17121. "DOM_VK_F3",
  17122. "DOM_VK_F30",
  17123. "DOM_VK_F31",
  17124. "DOM_VK_F32",
  17125. "DOM_VK_F33",
  17126. "DOM_VK_F34",
  17127. "DOM_VK_F35",
  17128. "DOM_VK_F36",
  17129. "DOM_VK_F4",
  17130. "DOM_VK_F5",
  17131. "DOM_VK_F6",
  17132. "DOM_VK_F7",
  17133. "DOM_VK_F8",
  17134. "DOM_VK_F9",
  17135. "DOM_VK_FINAL",
  17136. "DOM_VK_FRONT",
  17137. "DOM_VK_G",
  17138. "DOM_VK_GREATER_THAN",
  17139. "DOM_VK_H",
  17140. "DOM_VK_HANGUL",
  17141. "DOM_VK_HANJA",
  17142. "DOM_VK_HASH",
  17143. "DOM_VK_HELP",
  17144. "DOM_VK_HK_TOGGLE",
  17145. "DOM_VK_HOME",
  17146. "DOM_VK_HYPHEN_MINUS",
  17147. "DOM_VK_I",
  17148. "DOM_VK_INSERT",
  17149. "DOM_VK_J",
  17150. "DOM_VK_JUNJA",
  17151. "DOM_VK_K",
  17152. "DOM_VK_KANA",
  17153. "DOM_VK_KANJI",
  17154. "DOM_VK_L",
  17155. "DOM_VK_LEFT",
  17156. "DOM_VK_LEFT_TAB",
  17157. "DOM_VK_LESS_THAN",
  17158. "DOM_VK_M",
  17159. "DOM_VK_META",
  17160. "DOM_VK_MODECHANGE",
  17161. "DOM_VK_MULTIPLY",
  17162. "DOM_VK_N",
  17163. "DOM_VK_NONCONVERT",
  17164. "DOM_VK_NUMPAD0",
  17165. "DOM_VK_NUMPAD1",
  17166. "DOM_VK_NUMPAD2",
  17167. "DOM_VK_NUMPAD3",
  17168. "DOM_VK_NUMPAD4",
  17169. "DOM_VK_NUMPAD5",
  17170. "DOM_VK_NUMPAD6",
  17171. "DOM_VK_NUMPAD7",
  17172. "DOM_VK_NUMPAD8",
  17173. "DOM_VK_NUMPAD9",
  17174. "DOM_VK_NUM_LOCK",
  17175. "DOM_VK_O",
  17176. "DOM_VK_OEM_1",
  17177. "DOM_VK_OEM_102",
  17178. "DOM_VK_OEM_2",
  17179. "DOM_VK_OEM_3",
  17180. "DOM_VK_OEM_4",
  17181. "DOM_VK_OEM_5",
  17182. "DOM_VK_OEM_6",
  17183. "DOM_VK_OEM_7",
  17184. "DOM_VK_OEM_8",
  17185. "DOM_VK_OEM_COMMA",
  17186. "DOM_VK_OEM_MINUS",
  17187. "DOM_VK_OEM_PERIOD",
  17188. "DOM_VK_OEM_PLUS",
  17189. "DOM_VK_OPEN_BRACKET",
  17190. "DOM_VK_OPEN_CURLY_BRACKET",
  17191. "DOM_VK_OPEN_PAREN",
  17192. "DOM_VK_P",
  17193. "DOM_VK_PA1",
  17194. "DOM_VK_PAGEDOWN",
  17195. "DOM_VK_PAGEUP",
  17196. "DOM_VK_PAGE_DOWN",
  17197. "DOM_VK_PAGE_UP",
  17198. "DOM_VK_PAUSE",
  17199. "DOM_VK_PERCENT",
  17200. "DOM_VK_PERIOD",
  17201. "DOM_VK_PIPE",
  17202. "DOM_VK_PLAY",
  17203. "DOM_VK_PLUS",
  17204. "DOM_VK_PRINT",
  17205. "DOM_VK_PRINTSCREEN",
  17206. "DOM_VK_PROCESSKEY",
  17207. "DOM_VK_PROPERITES",
  17208. "DOM_VK_Q",
  17209. "DOM_VK_QUESTION_MARK",
  17210. "DOM_VK_QUOTE",
  17211. "DOM_VK_R",
  17212. "DOM_VK_REDO",
  17213. "DOM_VK_RETURN",
  17214. "DOM_VK_RIGHT",
  17215. "DOM_VK_S",
  17216. "DOM_VK_SCROLL_LOCK",
  17217. "DOM_VK_SELECT",
  17218. "DOM_VK_SEMICOLON",
  17219. "DOM_VK_SEPARATOR",
  17220. "DOM_VK_SHIFT",
  17221. "DOM_VK_SLASH",
  17222. "DOM_VK_SLEEP",
  17223. "DOM_VK_SPACE",
  17224. "DOM_VK_SUBTRACT",
  17225. "DOM_VK_T",
  17226. "DOM_VK_TAB",
  17227. "DOM_VK_TILDE",
  17228. "DOM_VK_U",
  17229. "DOM_VK_UNDERSCORE",
  17230. "DOM_VK_UNDO",
  17231. "DOM_VK_UNICODE",
  17232. "DOM_VK_UP",
  17233. "DOM_VK_V",
  17234. "DOM_VK_VOLUME_DOWN",
  17235. "DOM_VK_VOLUME_MUTE",
  17236. "DOM_VK_VOLUME_UP",
  17237. "DOM_VK_W",
  17238. "DOM_VK_WIN",
  17239. "DOM_VK_WINDOW",
  17240. "DOM_VK_WIN_ICO_00",
  17241. "DOM_VK_WIN_ICO_CLEAR",
  17242. "DOM_VK_WIN_ICO_HELP",
  17243. "DOM_VK_WIN_OEM_ATTN",
  17244. "DOM_VK_WIN_OEM_AUTO",
  17245. "DOM_VK_WIN_OEM_BACKTAB",
  17246. "DOM_VK_WIN_OEM_CLEAR",
  17247. "DOM_VK_WIN_OEM_COPY",
  17248. "DOM_VK_WIN_OEM_CUSEL",
  17249. "DOM_VK_WIN_OEM_ENLW",
  17250. "DOM_VK_WIN_OEM_FINISH",
  17251. "DOM_VK_WIN_OEM_FJ_JISHO",
  17252. "DOM_VK_WIN_OEM_FJ_LOYA",
  17253. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  17254. "DOM_VK_WIN_OEM_FJ_ROYA",
  17255. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  17256. "DOM_VK_WIN_OEM_JUMP",
  17257. "DOM_VK_WIN_OEM_PA1",
  17258. "DOM_VK_WIN_OEM_PA2",
  17259. "DOM_VK_WIN_OEM_PA3",
  17260. "DOM_VK_WIN_OEM_RESET",
  17261. "DOM_VK_WIN_OEM_WSCTRL",
  17262. "DOM_VK_X",
  17263. "DOM_VK_XF86XK_ADD_FAVORITE",
  17264. "DOM_VK_XF86XK_APPLICATION_LEFT",
  17265. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  17266. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  17267. "DOM_VK_XF86XK_AUDIO_FORWARD",
  17268. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  17269. "DOM_VK_XF86XK_AUDIO_MEDIA",
  17270. "DOM_VK_XF86XK_AUDIO_MUTE",
  17271. "DOM_VK_XF86XK_AUDIO_NEXT",
  17272. "DOM_VK_XF86XK_AUDIO_PAUSE",
  17273. "DOM_VK_XF86XK_AUDIO_PLAY",
  17274. "DOM_VK_XF86XK_AUDIO_PREV",
  17275. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  17276. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  17277. "DOM_VK_XF86XK_AUDIO_RECORD",
  17278. "DOM_VK_XF86XK_AUDIO_REPEAT",
  17279. "DOM_VK_XF86XK_AUDIO_REWIND",
  17280. "DOM_VK_XF86XK_AUDIO_STOP",
  17281. "DOM_VK_XF86XK_AWAY",
  17282. "DOM_VK_XF86XK_BACK",
  17283. "DOM_VK_XF86XK_BACK_FORWARD",
  17284. "DOM_VK_XF86XK_BATTERY",
  17285. "DOM_VK_XF86XK_BLUE",
  17286. "DOM_VK_XF86XK_BLUETOOTH",
  17287. "DOM_VK_XF86XK_BOOK",
  17288. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  17289. "DOM_VK_XF86XK_CALCULATOR",
  17290. "DOM_VK_XF86XK_CALENDAR",
  17291. "DOM_VK_XF86XK_CD",
  17292. "DOM_VK_XF86XK_CLOSE",
  17293. "DOM_VK_XF86XK_COMMUNITY",
  17294. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  17295. "DOM_VK_XF86XK_COPY",
  17296. "DOM_VK_XF86XK_CUT",
  17297. "DOM_VK_XF86XK_CYCLE_ANGLE",
  17298. "DOM_VK_XF86XK_DISPLAY",
  17299. "DOM_VK_XF86XK_DOCUMENTS",
  17300. "DOM_VK_XF86XK_DOS",
  17301. "DOM_VK_XF86XK_EJECT",
  17302. "DOM_VK_XF86XK_EXCEL",
  17303. "DOM_VK_XF86XK_EXPLORER",
  17304. "DOM_VK_XF86XK_FAVORITES",
  17305. "DOM_VK_XF86XK_FINANCE",
  17306. "DOM_VK_XF86XK_FORWARD",
  17307. "DOM_VK_XF86XK_FRAME_BACK",
  17308. "DOM_VK_XF86XK_FRAME_FORWARD",
  17309. "DOM_VK_XF86XK_GAME",
  17310. "DOM_VK_XF86XK_GO",
  17311. "DOM_VK_XF86XK_GREEN",
  17312. "DOM_VK_XF86XK_HIBERNATE",
  17313. "DOM_VK_XF86XK_HISTORY",
  17314. "DOM_VK_XF86XK_HOME_PAGE",
  17315. "DOM_VK_XF86XK_HOT_LINKS",
  17316. "DOM_VK_XF86XK_I_TOUCH",
  17317. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  17318. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  17319. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  17320. "DOM_VK_XF86XK_LAUNCH0",
  17321. "DOM_VK_XF86XK_LAUNCH1",
  17322. "DOM_VK_XF86XK_LAUNCH2",
  17323. "DOM_VK_XF86XK_LAUNCH3",
  17324. "DOM_VK_XF86XK_LAUNCH4",
  17325. "DOM_VK_XF86XK_LAUNCH5",
  17326. "DOM_VK_XF86XK_LAUNCH6",
  17327. "DOM_VK_XF86XK_LAUNCH7",
  17328. "DOM_VK_XF86XK_LAUNCH8",
  17329. "DOM_VK_XF86XK_LAUNCH9",
  17330. "DOM_VK_XF86XK_LAUNCH_A",
  17331. "DOM_VK_XF86XK_LAUNCH_B",
  17332. "DOM_VK_XF86XK_LAUNCH_C",
  17333. "DOM_VK_XF86XK_LAUNCH_D",
  17334. "DOM_VK_XF86XK_LAUNCH_E",
  17335. "DOM_VK_XF86XK_LAUNCH_F",
  17336. "DOM_VK_XF86XK_LIGHT_BULB",
  17337. "DOM_VK_XF86XK_LOG_OFF",
  17338. "DOM_VK_XF86XK_MAIL",
  17339. "DOM_VK_XF86XK_MAIL_FORWARD",
  17340. "DOM_VK_XF86XK_MARKET",
  17341. "DOM_VK_XF86XK_MEETING",
  17342. "DOM_VK_XF86XK_MEMO",
  17343. "DOM_VK_XF86XK_MENU_KB",
  17344. "DOM_VK_XF86XK_MENU_PB",
  17345. "DOM_VK_XF86XK_MESSENGER",
  17346. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  17347. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  17348. "DOM_VK_XF86XK_MUSIC",
  17349. "DOM_VK_XF86XK_MY_COMPUTER",
  17350. "DOM_VK_XF86XK_MY_SITES",
  17351. "DOM_VK_XF86XK_NEW",
  17352. "DOM_VK_XF86XK_NEWS",
  17353. "DOM_VK_XF86XK_OFFICE_HOME",
  17354. "DOM_VK_XF86XK_OPEN",
  17355. "DOM_VK_XF86XK_OPEN_URL",
  17356. "DOM_VK_XF86XK_OPTION",
  17357. "DOM_VK_XF86XK_PASTE",
  17358. "DOM_VK_XF86XK_PHONE",
  17359. "DOM_VK_XF86XK_PICTURES",
  17360. "DOM_VK_XF86XK_POWER_DOWN",
  17361. "DOM_VK_XF86XK_POWER_OFF",
  17362. "DOM_VK_XF86XK_RED",
  17363. "DOM_VK_XF86XK_REFRESH",
  17364. "DOM_VK_XF86XK_RELOAD",
  17365. "DOM_VK_XF86XK_REPLY",
  17366. "DOM_VK_XF86XK_ROCKER_DOWN",
  17367. "DOM_VK_XF86XK_ROCKER_ENTER",
  17368. "DOM_VK_XF86XK_ROCKER_UP",
  17369. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  17370. "DOM_VK_XF86XK_ROTATION_KB",
  17371. "DOM_VK_XF86XK_ROTATION_PB",
  17372. "DOM_VK_XF86XK_SAVE",
  17373. "DOM_VK_XF86XK_SCREEN_SAVER",
  17374. "DOM_VK_XF86XK_SCROLL_CLICK",
  17375. "DOM_VK_XF86XK_SCROLL_DOWN",
  17376. "DOM_VK_XF86XK_SCROLL_UP",
  17377. "DOM_VK_XF86XK_SEARCH",
  17378. "DOM_VK_XF86XK_SEND",
  17379. "DOM_VK_XF86XK_SHOP",
  17380. "DOM_VK_XF86XK_SPELL",
  17381. "DOM_VK_XF86XK_SPLIT_SCREEN",
  17382. "DOM_VK_XF86XK_STANDBY",
  17383. "DOM_VK_XF86XK_START",
  17384. "DOM_VK_XF86XK_STOP",
  17385. "DOM_VK_XF86XK_SUBTITLE",
  17386. "DOM_VK_XF86XK_SUPPORT",
  17387. "DOM_VK_XF86XK_SUSPEND",
  17388. "DOM_VK_XF86XK_TASK_PANE",
  17389. "DOM_VK_XF86XK_TERMINAL",
  17390. "DOM_VK_XF86XK_TIME",
  17391. "DOM_VK_XF86XK_TOOLS",
  17392. "DOM_VK_XF86XK_TOP_MENU",
  17393. "DOM_VK_XF86XK_TO_DO_LIST",
  17394. "DOM_VK_XF86XK_TRAVEL",
  17395. "DOM_VK_XF86XK_USER1KB",
  17396. "DOM_VK_XF86XK_USER2KB",
  17397. "DOM_VK_XF86XK_USER_PB",
  17398. "DOM_VK_XF86XK_UWB",
  17399. "DOM_VK_XF86XK_VENDOR_HOME",
  17400. "DOM_VK_XF86XK_VIDEO",
  17401. "DOM_VK_XF86XK_VIEW",
  17402. "DOM_VK_XF86XK_WAKE_UP",
  17403. "DOM_VK_XF86XK_WEB_CAM",
  17404. "DOM_VK_XF86XK_WHEEL_BUTTON",
  17405. "DOM_VK_XF86XK_WLAN",
  17406. "DOM_VK_XF86XK_WORD",
  17407. "DOM_VK_XF86XK_WWW",
  17408. "DOM_VK_XF86XK_XFER",
  17409. "DOM_VK_XF86XK_YELLOW",
  17410. "DOM_VK_XF86XK_ZOOM_IN",
  17411. "DOM_VK_XF86XK_ZOOM_OUT",
  17412. "DOM_VK_Y",
  17413. "DOM_VK_Z",
  17414. "DOM_VK_ZOOM",
  17415. "DONE",
  17416. "DONT_CARE",
  17417. "DOWNLOADING",
  17418. "DRAGDROP",
  17419. "DRAW_BUFFER0",
  17420. "DRAW_BUFFER1",
  17421. "DRAW_BUFFER10",
  17422. "DRAW_BUFFER11",
  17423. "DRAW_BUFFER12",
  17424. "DRAW_BUFFER13",
  17425. "DRAW_BUFFER14",
  17426. "DRAW_BUFFER15",
  17427. "DRAW_BUFFER2",
  17428. "DRAW_BUFFER3",
  17429. "DRAW_BUFFER4",
  17430. "DRAW_BUFFER5",
  17431. "DRAW_BUFFER6",
  17432. "DRAW_BUFFER7",
  17433. "DRAW_BUFFER8",
  17434. "DRAW_BUFFER9",
  17435. "DRAW_FRAMEBUFFER",
  17436. "DRAW_FRAMEBUFFER_BINDING",
  17437. "DST_ALPHA",
  17438. "DST_COLOR",
  17439. "DYNAMIC_COPY",
  17440. "DYNAMIC_DRAW",
  17441. "DYNAMIC_READ",
  17442. "DataChannel",
  17443. "DataTransfer",
  17444. "DataTransferItem",
  17445. "DataTransferItemList",
  17446. "DataView",
  17447. "Date",
  17448. "DateTimeFormat",
  17449. "DecompressionStream",
  17450. "DelayNode",
  17451. "DeprecationReportBody",
  17452. "DesktopNotification",
  17453. "DesktopNotificationCenter",
  17454. "DeviceLightEvent",
  17455. "DeviceMotionEvent",
  17456. "DeviceMotionEventAcceleration",
  17457. "DeviceMotionEventRotationRate",
  17458. "DeviceOrientationEvent",
  17459. "DeviceProximityEvent",
  17460. "DeviceStorage",
  17461. "DeviceStorageChangeEvent",
  17462. "Directory",
  17463. "DisplayNames",
  17464. "Document",
  17465. "DocumentFragment",
  17466. "DocumentTimeline",
  17467. "DocumentType",
  17468. "DragEvent",
  17469. "DynamicsCompressorNode",
  17470. "E",
  17471. "ELEMENT_ARRAY_BUFFER",
  17472. "ELEMENT_ARRAY_BUFFER_BINDING",
  17473. "ELEMENT_NODE",
  17474. "EMPTY",
  17475. "ENCODING_ERR",
  17476. "ENDED",
  17477. "END_TO_END",
  17478. "END_TO_START",
  17479. "ENTITY_NODE",
  17480. "ENTITY_REFERENCE_NODE",
  17481. "EPSILON",
  17482. "EQUAL",
  17483. "EQUALPOWER",
  17484. "ERROR",
  17485. "EXPONENTIAL_DISTANCE",
  17486. "Element",
  17487. "ElementInternals",
  17488. "ElementQuery",
  17489. "EnterPictureInPictureEvent",
  17490. "Entity",
  17491. "EntityReference",
  17492. "Error",
  17493. "ErrorEvent",
  17494. "EvalError",
  17495. "Event",
  17496. "EventException",
  17497. "EventSource",
  17498. "EventTarget",
  17499. "External",
  17500. "FASTEST",
  17501. "FIDOSDK",
  17502. "FILTER_ACCEPT",
  17503. "FILTER_INTERRUPT",
  17504. "FILTER_REJECT",
  17505. "FILTER_SKIP",
  17506. "FINISHED_STATE",
  17507. "FIRST_ORDERED_NODE_TYPE",
  17508. "FLOAT",
  17509. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  17510. "FLOAT_MAT2",
  17511. "FLOAT_MAT2x3",
  17512. "FLOAT_MAT2x4",
  17513. "FLOAT_MAT3",
  17514. "FLOAT_MAT3x2",
  17515. "FLOAT_MAT3x4",
  17516. "FLOAT_MAT4",
  17517. "FLOAT_MAT4x2",
  17518. "FLOAT_MAT4x3",
  17519. "FLOAT_VEC2",
  17520. "FLOAT_VEC3",
  17521. "FLOAT_VEC4",
  17522. "FOCUS",
  17523. "FONT_FACE_RULE",
  17524. "FONT_FEATURE_VALUES_RULE",
  17525. "FRAGMENT_SHADER",
  17526. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  17527. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  17528. "FRAMEBUFFER",
  17529. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  17530. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  17531. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  17532. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  17533. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  17534. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  17535. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  17536. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  17537. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  17538. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  17539. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  17540. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  17541. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  17542. "FRAMEBUFFER_BINDING",
  17543. "FRAMEBUFFER_COMPLETE",
  17544. "FRAMEBUFFER_DEFAULT",
  17545. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  17546. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  17547. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  17548. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  17549. "FRAMEBUFFER_UNSUPPORTED",
  17550. "FRONT",
  17551. "FRONT_AND_BACK",
  17552. "FRONT_FACE",
  17553. "FUNC_ADD",
  17554. "FUNC_REVERSE_SUBTRACT",
  17555. "FUNC_SUBTRACT",
  17556. "FeaturePolicy",
  17557. "FeaturePolicyViolationReportBody",
  17558. "FederatedCredential",
  17559. "Feed",
  17560. "FeedEntry",
  17561. "File",
  17562. "FileError",
  17563. "FileList",
  17564. "FileReader",
  17565. "FileSystem",
  17566. "FileSystemDirectoryEntry",
  17567. "FileSystemDirectoryReader",
  17568. "FileSystemEntry",
  17569. "FileSystemFileEntry",
  17570. "FinalizationRegistry",
  17571. "FindInPage",
  17572. "Float32Array",
  17573. "Float64Array",
  17574. "FocusEvent",
  17575. "FontFace",
  17576. "FontFaceSet",
  17577. "FontFaceSetLoadEvent",
  17578. "FormData",
  17579. "FormDataEvent",
  17580. "FragmentDirective",
  17581. "Function",
  17582. "GENERATE_MIPMAP_HINT",
  17583. "GEQUAL",
  17584. "GREATER",
  17585. "GREEN_BITS",
  17586. "GainNode",
  17587. "Gamepad",
  17588. "GamepadAxisMoveEvent",
  17589. "GamepadButton",
  17590. "GamepadButtonEvent",
  17591. "GamepadEvent",
  17592. "GamepadHapticActuator",
  17593. "GamepadPose",
  17594. "Geolocation",
  17595. "GeolocationCoordinates",
  17596. "GeolocationPosition",
  17597. "GeolocationPositionError",
  17598. "GestureEvent",
  17599. "Global",
  17600. "Gyroscope",
  17601. "HALF_FLOAT",
  17602. "HAVE_CURRENT_DATA",
  17603. "HAVE_ENOUGH_DATA",
  17604. "HAVE_FUTURE_DATA",
  17605. "HAVE_METADATA",
  17606. "HAVE_NOTHING",
  17607. "HEADERS_RECEIVED",
  17608. "HIDDEN",
  17609. "HIERARCHY_REQUEST_ERR",
  17610. "HIGHPASS",
  17611. "HIGHSHELF",
  17612. "HIGH_FLOAT",
  17613. "HIGH_INT",
  17614. "HORIZONTAL",
  17615. "HORIZONTAL_AXIS",
  17616. "HRTF",
  17617. "HTMLAllCollection",
  17618. "HTMLAnchorElement",
  17619. "HTMLAppletElement",
  17620. "HTMLAreaElement",
  17621. "HTMLAudioElement",
  17622. "HTMLBRElement",
  17623. "HTMLBaseElement",
  17624. "HTMLBaseFontElement",
  17625. "HTMLBlockquoteElement",
  17626. "HTMLBodyElement",
  17627. "HTMLButtonElement",
  17628. "HTMLCanvasElement",
  17629. "HTMLCollection",
  17630. "HTMLCommandElement",
  17631. "HTMLContentElement",
  17632. "HTMLDListElement",
  17633. "HTMLDataElement",
  17634. "HTMLDataListElement",
  17635. "HTMLDetailsElement",
  17636. "HTMLDialogElement",
  17637. "HTMLDirectoryElement",
  17638. "HTMLDivElement",
  17639. "HTMLDocument",
  17640. "HTMLElement",
  17641. "HTMLEmbedElement",
  17642. "HTMLFieldSetElement",
  17643. "HTMLFontElement",
  17644. "HTMLFormControlsCollection",
  17645. "HTMLFormElement",
  17646. "HTMLFrameElement",
  17647. "HTMLFrameSetElement",
  17648. "HTMLHRElement",
  17649. "HTMLHeadElement",
  17650. "HTMLHeadingElement",
  17651. "HTMLHtmlElement",
  17652. "HTMLIFrameElement",
  17653. "HTMLImageElement",
  17654. "HTMLInputElement",
  17655. "HTMLIsIndexElement",
  17656. "HTMLKeygenElement",
  17657. "HTMLLIElement",
  17658. "HTMLLabelElement",
  17659. "HTMLLegendElement",
  17660. "HTMLLinkElement",
  17661. "HTMLMapElement",
  17662. "HTMLMarqueeElement",
  17663. "HTMLMediaElement",
  17664. "HTMLMenuElement",
  17665. "HTMLMenuItemElement",
  17666. "HTMLMetaElement",
  17667. "HTMLMeterElement",
  17668. "HTMLModElement",
  17669. "HTMLOListElement",
  17670. "HTMLObjectElement",
  17671. "HTMLOptGroupElement",
  17672. "HTMLOptionElement",
  17673. "HTMLOptionsCollection",
  17674. "HTMLOutputElement",
  17675. "HTMLParagraphElement",
  17676. "HTMLParamElement",
  17677. "HTMLPictureElement",
  17678. "HTMLPreElement",
  17679. "HTMLProgressElement",
  17680. "HTMLPropertiesCollection",
  17681. "HTMLQuoteElement",
  17682. "HTMLScriptElement",
  17683. "HTMLSelectElement",
  17684. "HTMLShadowElement",
  17685. "HTMLSlotElement",
  17686. "HTMLSourceElement",
  17687. "HTMLSpanElement",
  17688. "HTMLStyleElement",
  17689. "HTMLTableCaptionElement",
  17690. "HTMLTableCellElement",
  17691. "HTMLTableColElement",
  17692. "HTMLTableElement",
  17693. "HTMLTableRowElement",
  17694. "HTMLTableSectionElement",
  17695. "HTMLTemplateElement",
  17696. "HTMLTextAreaElement",
  17697. "HTMLTimeElement",
  17698. "HTMLTitleElement",
  17699. "HTMLTrackElement",
  17700. "HTMLUListElement",
  17701. "HTMLUnknownElement",
  17702. "HTMLVideoElement",
  17703. "HashChangeEvent",
  17704. "Headers",
  17705. "History",
  17706. "Hz",
  17707. "ICE_CHECKING",
  17708. "ICE_CLOSED",
  17709. "ICE_COMPLETED",
  17710. "ICE_CONNECTED",
  17711. "ICE_FAILED",
  17712. "ICE_GATHERING",
  17713. "ICE_WAITING",
  17714. "IDBCursor",
  17715. "IDBCursorWithValue",
  17716. "IDBDatabase",
  17717. "IDBDatabaseException",
  17718. "IDBFactory",
  17719. "IDBFileHandle",
  17720. "IDBFileRequest",
  17721. "IDBIndex",
  17722. "IDBKeyRange",
  17723. "IDBMutableFile",
  17724. "IDBObjectStore",
  17725. "IDBOpenDBRequest",
  17726. "IDBRequest",
  17727. "IDBTransaction",
  17728. "IDBVersionChangeEvent",
  17729. "IDLE",
  17730. "IIRFilterNode",
  17731. "IMPLEMENTATION_COLOR_READ_FORMAT",
  17732. "IMPLEMENTATION_COLOR_READ_TYPE",
  17733. "IMPORT_RULE",
  17734. "INCR",
  17735. "INCR_WRAP",
  17736. "INDEX_SIZE_ERR",
  17737. "INT",
  17738. "INTERLEAVED_ATTRIBS",
  17739. "INT_2_10_10_10_REV",
  17740. "INT_SAMPLER_2D",
  17741. "INT_SAMPLER_2D_ARRAY",
  17742. "INT_SAMPLER_3D",
  17743. "INT_SAMPLER_CUBE",
  17744. "INT_VEC2",
  17745. "INT_VEC3",
  17746. "INT_VEC4",
  17747. "INUSE_ATTRIBUTE_ERR",
  17748. "INVALID_ACCESS_ERR",
  17749. "INVALID_CHARACTER_ERR",
  17750. "INVALID_ENUM",
  17751. "INVALID_EXPRESSION_ERR",
  17752. "INVALID_FRAMEBUFFER_OPERATION",
  17753. "INVALID_INDEX",
  17754. "INVALID_MODIFICATION_ERR",
  17755. "INVALID_NODE_TYPE_ERR",
  17756. "INVALID_OPERATION",
  17757. "INVALID_STATE_ERR",
  17758. "INVALID_VALUE",
  17759. "INVERSE_DISTANCE",
  17760. "INVERT",
  17761. "IceCandidate",
  17762. "IdleDeadline",
  17763. "Image",
  17764. "ImageBitmap",
  17765. "ImageBitmapRenderingContext",
  17766. "ImageCapture",
  17767. "ImageData",
  17768. "Infinity",
  17769. "InputDeviceCapabilities",
  17770. "InputDeviceInfo",
  17771. "InputEvent",
  17772. "InputMethodContext",
  17773. "InstallTrigger",
  17774. "InstallTriggerImpl",
  17775. "Instance",
  17776. "Int16Array",
  17777. "Int32Array",
  17778. "Int8Array",
  17779. "Intent",
  17780. "InternalError",
  17781. "IntersectionObserver",
  17782. "IntersectionObserverEntry",
  17783. "Intl",
  17784. "IsSearchProviderInstalled",
  17785. "Iterator",
  17786. "JSON",
  17787. "KEEP",
  17788. "KEYDOWN",
  17789. "KEYFRAMES_RULE",
  17790. "KEYFRAME_RULE",
  17791. "KEYPRESS",
  17792. "KEYUP",
  17793. "KeyEvent",
  17794. "Keyboard",
  17795. "KeyboardEvent",
  17796. "KeyboardLayoutMap",
  17797. "KeyframeEffect",
  17798. "LENGTHADJUST_SPACING",
  17799. "LENGTHADJUST_SPACINGANDGLYPHS",
  17800. "LENGTHADJUST_UNKNOWN",
  17801. "LEQUAL",
  17802. "LESS",
  17803. "LINEAR",
  17804. "LINEAR_DISTANCE",
  17805. "LINEAR_MIPMAP_LINEAR",
  17806. "LINEAR_MIPMAP_NEAREST",
  17807. "LINES",
  17808. "LINE_LOOP",
  17809. "LINE_STRIP",
  17810. "LINE_WIDTH",
  17811. "LINK_STATUS",
  17812. "LIVE",
  17813. "LN10",
  17814. "LN2",
  17815. "LOADED",
  17816. "LOADING",
  17817. "LOG10E",
  17818. "LOG2E",
  17819. "LOWPASS",
  17820. "LOWSHELF",
  17821. "LOW_FLOAT",
  17822. "LOW_INT",
  17823. "LSException",
  17824. "LSParserFilter",
  17825. "LUMINANCE",
  17826. "LUMINANCE_ALPHA",
  17827. "LargestContentfulPaint",
  17828. "LayoutShift",
  17829. "LayoutShiftAttribution",
  17830. "LinearAccelerationSensor",
  17831. "LinkError",
  17832. "ListFormat",
  17833. "LocalMediaStream",
  17834. "Locale",
  17835. "Location",
  17836. "Lock",
  17837. "LockManager",
  17838. "MAX",
  17839. "MAX_3D_TEXTURE_SIZE",
  17840. "MAX_ARRAY_TEXTURE_LAYERS",
  17841. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  17842. "MAX_COLOR_ATTACHMENTS",
  17843. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  17844. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  17845. "MAX_COMBINED_UNIFORM_BLOCKS",
  17846. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  17847. "MAX_CUBE_MAP_TEXTURE_SIZE",
  17848. "MAX_DRAW_BUFFERS",
  17849. "MAX_ELEMENTS_INDICES",
  17850. "MAX_ELEMENTS_VERTICES",
  17851. "MAX_ELEMENT_INDEX",
  17852. "MAX_FRAGMENT_INPUT_COMPONENTS",
  17853. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  17854. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  17855. "MAX_FRAGMENT_UNIFORM_VECTORS",
  17856. "MAX_PROGRAM_TEXEL_OFFSET",
  17857. "MAX_RENDERBUFFER_SIZE",
  17858. "MAX_SAFE_INTEGER",
  17859. "MAX_SAMPLES",
  17860. "MAX_SERVER_WAIT_TIMEOUT",
  17861. "MAX_TEXTURE_IMAGE_UNITS",
  17862. "MAX_TEXTURE_LOD_BIAS",
  17863. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  17864. "MAX_TEXTURE_SIZE",
  17865. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  17866. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  17867. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  17868. "MAX_UNIFORM_BLOCK_SIZE",
  17869. "MAX_UNIFORM_BUFFER_BINDINGS",
  17870. "MAX_VALUE",
  17871. "MAX_VARYING_COMPONENTS",
  17872. "MAX_VARYING_VECTORS",
  17873. "MAX_VERTEX_ATTRIBS",
  17874. "MAX_VERTEX_OUTPUT_COMPONENTS",
  17875. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  17876. "MAX_VERTEX_UNIFORM_BLOCKS",
  17877. "MAX_VERTEX_UNIFORM_COMPONENTS",
  17878. "MAX_VERTEX_UNIFORM_VECTORS",
  17879. "MAX_VIEWPORT_DIMS",
  17880. "MEDIA_ERR_ABORTED",
  17881. "MEDIA_ERR_DECODE",
  17882. "MEDIA_ERR_ENCRYPTED",
  17883. "MEDIA_ERR_NETWORK",
  17884. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  17885. "MEDIA_KEYERR_CLIENT",
  17886. "MEDIA_KEYERR_DOMAIN",
  17887. "MEDIA_KEYERR_HARDWARECHANGE",
  17888. "MEDIA_KEYERR_OUTPUT",
  17889. "MEDIA_KEYERR_SERVICE",
  17890. "MEDIA_KEYERR_UNKNOWN",
  17891. "MEDIA_RULE",
  17892. "MEDIUM_FLOAT",
  17893. "MEDIUM_INT",
  17894. "META_MASK",
  17895. "MIDIAccess",
  17896. "MIDIConnectionEvent",
  17897. "MIDIInput",
  17898. "MIDIInputMap",
  17899. "MIDIMessageEvent",
  17900. "MIDIOutput",
  17901. "MIDIOutputMap",
  17902. "MIDIPort",
  17903. "MIN",
  17904. "MIN_PROGRAM_TEXEL_OFFSET",
  17905. "MIN_SAFE_INTEGER",
  17906. "MIN_VALUE",
  17907. "MIRRORED_REPEAT",
  17908. "MODE_ASYNCHRONOUS",
  17909. "MODE_SYNCHRONOUS",
  17910. "MODIFICATION",
  17911. "MOUSEDOWN",
  17912. "MOUSEDRAG",
  17913. "MOUSEMOVE",
  17914. "MOUSEOUT",
  17915. "MOUSEOVER",
  17916. "MOUSEUP",
  17917. "MOZ_KEYFRAMES_RULE",
  17918. "MOZ_KEYFRAME_RULE",
  17919. "MOZ_SOURCE_CURSOR",
  17920. "MOZ_SOURCE_ERASER",
  17921. "MOZ_SOURCE_KEYBOARD",
  17922. "MOZ_SOURCE_MOUSE",
  17923. "MOZ_SOURCE_PEN",
  17924. "MOZ_SOURCE_TOUCH",
  17925. "MOZ_SOURCE_UNKNOWN",
  17926. "MSGESTURE_FLAG_BEGIN",
  17927. "MSGESTURE_FLAG_CANCEL",
  17928. "MSGESTURE_FLAG_END",
  17929. "MSGESTURE_FLAG_INERTIA",
  17930. "MSGESTURE_FLAG_NONE",
  17931. "MSPOINTER_TYPE_MOUSE",
  17932. "MSPOINTER_TYPE_PEN",
  17933. "MSPOINTER_TYPE_TOUCH",
  17934. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  17935. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  17936. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  17937. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  17938. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  17939. "MS_ASYNC_OP_STATUS_CANCELED",
  17940. "MS_ASYNC_OP_STATUS_ERROR",
  17941. "MS_ASYNC_OP_STATUS_SUCCESS",
  17942. "MS_MANIPULATION_STATE_ACTIVE",
  17943. "MS_MANIPULATION_STATE_CANCELLED",
  17944. "MS_MANIPULATION_STATE_COMMITTED",
  17945. "MS_MANIPULATION_STATE_DRAGGING",
  17946. "MS_MANIPULATION_STATE_INERTIA",
  17947. "MS_MANIPULATION_STATE_PRESELECT",
  17948. "MS_MANIPULATION_STATE_SELECTING",
  17949. "MS_MANIPULATION_STATE_STOPPED",
  17950. "MS_MEDIA_ERR_ENCRYPTED",
  17951. "MS_MEDIA_KEYERR_CLIENT",
  17952. "MS_MEDIA_KEYERR_DOMAIN",
  17953. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  17954. "MS_MEDIA_KEYERR_OUTPUT",
  17955. "MS_MEDIA_KEYERR_SERVICE",
  17956. "MS_MEDIA_KEYERR_UNKNOWN",
  17957. "Map",
  17958. "Math",
  17959. "MathMLElement",
  17960. "MediaCapabilities",
  17961. "MediaCapabilitiesInfo",
  17962. "MediaController",
  17963. "MediaDeviceInfo",
  17964. "MediaDevices",
  17965. "MediaElementAudioSourceNode",
  17966. "MediaEncryptedEvent",
  17967. "MediaError",
  17968. "MediaKeyError",
  17969. "MediaKeyEvent",
  17970. "MediaKeyMessageEvent",
  17971. "MediaKeyNeededEvent",
  17972. "MediaKeySession",
  17973. "MediaKeyStatusMap",
  17974. "MediaKeySystemAccess",
  17975. "MediaKeys",
  17976. "MediaList",
  17977. "MediaMetadata",
  17978. "MediaQueryList",
  17979. "MediaQueryListEvent",
  17980. "MediaRecorder",
  17981. "MediaRecorderErrorEvent",
  17982. "MediaSession",
  17983. "MediaSettingsRange",
  17984. "MediaSource",
  17985. "MediaStream",
  17986. "MediaStreamAudioDestinationNode",
  17987. "MediaStreamAudioSourceNode",
  17988. "MediaStreamEvent",
  17989. "MediaStreamTrack",
  17990. "MediaStreamTrackAudioSourceNode",
  17991. "MediaStreamTrackEvent",
  17992. "Memory",
  17993. "MessageChannel",
  17994. "MessageEvent",
  17995. "MessagePort",
  17996. "Methods",
  17997. "MimeType",
  17998. "MimeTypeArray",
  17999. "Module",
  18000. "MouseEvent",
  18001. "MouseScrollEvent",
  18002. "MozAnimation",
  18003. "MozAnimationDelay",
  18004. "MozAnimationDirection",
  18005. "MozAnimationDuration",
  18006. "MozAnimationFillMode",
  18007. "MozAnimationIterationCount",
  18008. "MozAnimationName",
  18009. "MozAnimationPlayState",
  18010. "MozAnimationTimingFunction",
  18011. "MozAppearance",
  18012. "MozBackfaceVisibility",
  18013. "MozBinding",
  18014. "MozBorderBottomColors",
  18015. "MozBorderEnd",
  18016. "MozBorderEndColor",
  18017. "MozBorderEndStyle",
  18018. "MozBorderEndWidth",
  18019. "MozBorderImage",
  18020. "MozBorderLeftColors",
  18021. "MozBorderRightColors",
  18022. "MozBorderStart",
  18023. "MozBorderStartColor",
  18024. "MozBorderStartStyle",
  18025. "MozBorderStartWidth",
  18026. "MozBorderTopColors",
  18027. "MozBoxAlign",
  18028. "MozBoxDirection",
  18029. "MozBoxFlex",
  18030. "MozBoxOrdinalGroup",
  18031. "MozBoxOrient",
  18032. "MozBoxPack",
  18033. "MozBoxSizing",
  18034. "MozCSSKeyframeRule",
  18035. "MozCSSKeyframesRule",
  18036. "MozColumnCount",
  18037. "MozColumnFill",
  18038. "MozColumnGap",
  18039. "MozColumnRule",
  18040. "MozColumnRuleColor",
  18041. "MozColumnRuleStyle",
  18042. "MozColumnRuleWidth",
  18043. "MozColumnWidth",
  18044. "MozColumns",
  18045. "MozContactChangeEvent",
  18046. "MozFloatEdge",
  18047. "MozFontFeatureSettings",
  18048. "MozFontLanguageOverride",
  18049. "MozForceBrokenImageIcon",
  18050. "MozHyphens",
  18051. "MozImageRegion",
  18052. "MozMarginEnd",
  18053. "MozMarginStart",
  18054. "MozMmsEvent",
  18055. "MozMmsMessage",
  18056. "MozMobileMessageThread",
  18057. "MozOSXFontSmoothing",
  18058. "MozOrient",
  18059. "MozOsxFontSmoothing",
  18060. "MozOutlineRadius",
  18061. "MozOutlineRadiusBottomleft",
  18062. "MozOutlineRadiusBottomright",
  18063. "MozOutlineRadiusTopleft",
  18064. "MozOutlineRadiusTopright",
  18065. "MozPaddingEnd",
  18066. "MozPaddingStart",
  18067. "MozPerspective",
  18068. "MozPerspectiveOrigin",
  18069. "MozPowerManager",
  18070. "MozSettingsEvent",
  18071. "MozSmsEvent",
  18072. "MozSmsMessage",
  18073. "MozStackSizing",
  18074. "MozTabSize",
  18075. "MozTextAlignLast",
  18076. "MozTextDecorationColor",
  18077. "MozTextDecorationLine",
  18078. "MozTextDecorationStyle",
  18079. "MozTextSizeAdjust",
  18080. "MozTransform",
  18081. "MozTransformOrigin",
  18082. "MozTransformStyle",
  18083. "MozTransition",
  18084. "MozTransitionDelay",
  18085. "MozTransitionDuration",
  18086. "MozTransitionProperty",
  18087. "MozTransitionTimingFunction",
  18088. "MozUserFocus",
  18089. "MozUserInput",
  18090. "MozUserModify",
  18091. "MozUserSelect",
  18092. "MozWindowDragging",
  18093. "MozWindowShadow",
  18094. "MutationEvent",
  18095. "MutationObserver",
  18096. "MutationRecord",
  18097. "NAMESPACE_ERR",
  18098. "NAMESPACE_RULE",
  18099. "NEAREST",
  18100. "NEAREST_MIPMAP_LINEAR",
  18101. "NEAREST_MIPMAP_NEAREST",
  18102. "NEGATIVE_INFINITY",
  18103. "NETWORK_EMPTY",
  18104. "NETWORK_ERR",
  18105. "NETWORK_IDLE",
  18106. "NETWORK_LOADED",
  18107. "NETWORK_LOADING",
  18108. "NETWORK_NO_SOURCE",
  18109. "NEVER",
  18110. "NEW",
  18111. "NEXT",
  18112. "NEXT_NO_DUPLICATE",
  18113. "NICEST",
  18114. "NODE_AFTER",
  18115. "NODE_BEFORE",
  18116. "NODE_BEFORE_AND_AFTER",
  18117. "NODE_INSIDE",
  18118. "NONE",
  18119. "NON_TRANSIENT_ERR",
  18120. "NOTATION_NODE",
  18121. "NOTCH",
  18122. "NOTEQUAL",
  18123. "NOT_ALLOWED_ERR",
  18124. "NOT_FOUND_ERR",
  18125. "NOT_READABLE_ERR",
  18126. "NOT_SUPPORTED_ERR",
  18127. "NO_DATA_ALLOWED_ERR",
  18128. "NO_ERR",
  18129. "NO_ERROR",
  18130. "NO_MODIFICATION_ALLOWED_ERR",
  18131. "NUMBER_TYPE",
  18132. "NUM_COMPRESSED_TEXTURE_FORMATS",
  18133. "NaN",
  18134. "NamedNodeMap",
  18135. "NavigationPreloadManager",
  18136. "Navigator",
  18137. "NearbyLinks",
  18138. "NetworkInformation",
  18139. "Node",
  18140. "NodeFilter",
  18141. "NodeIterator",
  18142. "NodeList",
  18143. "Notation",
  18144. "Notification",
  18145. "NotifyPaintEvent",
  18146. "Number",
  18147. "NumberFormat",
  18148. "OBJECT_TYPE",
  18149. "OBSOLETE",
  18150. "OK",
  18151. "ONE",
  18152. "ONE_MINUS_CONSTANT_ALPHA",
  18153. "ONE_MINUS_CONSTANT_COLOR",
  18154. "ONE_MINUS_DST_ALPHA",
  18155. "ONE_MINUS_DST_COLOR",
  18156. "ONE_MINUS_SRC_ALPHA",
  18157. "ONE_MINUS_SRC_COLOR",
  18158. "OPEN",
  18159. "OPENED",
  18160. "OPENING",
  18161. "ORDERED_NODE_ITERATOR_TYPE",
  18162. "ORDERED_NODE_SNAPSHOT_TYPE",
  18163. "OTHER_ERROR",
  18164. "OUT_OF_MEMORY",
  18165. "Object",
  18166. "OfflineAudioCompletionEvent",
  18167. "OfflineAudioContext",
  18168. "OfflineResourceList",
  18169. "OffscreenCanvas",
  18170. "OffscreenCanvasRenderingContext2D",
  18171. "Option",
  18172. "OrientationSensor",
  18173. "OscillatorNode",
  18174. "OverconstrainedError",
  18175. "OverflowEvent",
  18176. "PACK_ALIGNMENT",
  18177. "PACK_ROW_LENGTH",
  18178. "PACK_SKIP_PIXELS",
  18179. "PACK_SKIP_ROWS",
  18180. "PAGE_RULE",
  18181. "PARSE_ERR",
  18182. "PATHSEG_ARC_ABS",
  18183. "PATHSEG_ARC_REL",
  18184. "PATHSEG_CLOSEPATH",
  18185. "PATHSEG_CURVETO_CUBIC_ABS",
  18186. "PATHSEG_CURVETO_CUBIC_REL",
  18187. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  18188. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  18189. "PATHSEG_CURVETO_QUADRATIC_ABS",
  18190. "PATHSEG_CURVETO_QUADRATIC_REL",
  18191. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  18192. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  18193. "PATHSEG_LINETO_ABS",
  18194. "PATHSEG_LINETO_HORIZONTAL_ABS",
  18195. "PATHSEG_LINETO_HORIZONTAL_REL",
  18196. "PATHSEG_LINETO_REL",
  18197. "PATHSEG_LINETO_VERTICAL_ABS",
  18198. "PATHSEG_LINETO_VERTICAL_REL",
  18199. "PATHSEG_MOVETO_ABS",
  18200. "PATHSEG_MOVETO_REL",
  18201. "PATHSEG_UNKNOWN",
  18202. "PATH_EXISTS_ERR",
  18203. "PEAKING",
  18204. "PERMISSION_DENIED",
  18205. "PERSISTENT",
  18206. "PI",
  18207. "PIXEL_PACK_BUFFER",
  18208. "PIXEL_PACK_BUFFER_BINDING",
  18209. "PIXEL_UNPACK_BUFFER",
  18210. "PIXEL_UNPACK_BUFFER_BINDING",
  18211. "PLAYING_STATE",
  18212. "POINTS",
  18213. "POLYGON_OFFSET_FACTOR",
  18214. "POLYGON_OFFSET_FILL",
  18215. "POLYGON_OFFSET_UNITS",
  18216. "POSITION_UNAVAILABLE",
  18217. "POSITIVE_INFINITY",
  18218. "PREV",
  18219. "PREV_NO_DUPLICATE",
  18220. "PROCESSING_INSTRUCTION_NODE",
  18221. "PageChangeEvent",
  18222. "PageTransitionEvent",
  18223. "PaintRequest",
  18224. "PaintRequestList",
  18225. "PannerNode",
  18226. "PasswordCredential",
  18227. "Path2D",
  18228. "PaymentAddress",
  18229. "PaymentInstruments",
  18230. "PaymentManager",
  18231. "PaymentMethodChangeEvent",
  18232. "PaymentRequest",
  18233. "PaymentRequestUpdateEvent",
  18234. "PaymentResponse",
  18235. "Performance",
  18236. "PerformanceElementTiming",
  18237. "PerformanceEntry",
  18238. "PerformanceEventTiming",
  18239. "PerformanceLongTaskTiming",
  18240. "PerformanceMark",
  18241. "PerformanceMeasure",
  18242. "PerformanceNavigation",
  18243. "PerformanceNavigationTiming",
  18244. "PerformanceObserver",
  18245. "PerformanceObserverEntryList",
  18246. "PerformancePaintTiming",
  18247. "PerformanceResourceTiming",
  18248. "PerformanceServerTiming",
  18249. "PerformanceTiming",
  18250. "PeriodicSyncManager",
  18251. "PeriodicWave",
  18252. "PermissionStatus",
  18253. "Permissions",
  18254. "PhotoCapabilities",
  18255. "PictureInPictureWindow",
  18256. "Plugin",
  18257. "PluginArray",
  18258. "PluralRules",
  18259. "PointerEvent",
  18260. "PopStateEvent",
  18261. "PopupBlockedEvent",
  18262. "Presentation",
  18263. "PresentationAvailability",
  18264. "PresentationConnection",
  18265. "PresentationConnectionAvailableEvent",
  18266. "PresentationConnectionCloseEvent",
  18267. "PresentationConnectionList",
  18268. "PresentationReceiver",
  18269. "PresentationRequest",
  18270. "ProcessingInstruction",
  18271. "ProgressEvent",
  18272. "Promise",
  18273. "PromiseRejectionEvent",
  18274. "PropertyNodeList",
  18275. "Proxy",
  18276. "PublicKeyCredential",
  18277. "PushManager",
  18278. "PushSubscription",
  18279. "PushSubscriptionOptions",
  18280. "Q",
  18281. "QUERY_RESULT",
  18282. "QUERY_RESULT_AVAILABLE",
  18283. "QUOTA_ERR",
  18284. "QUOTA_EXCEEDED_ERR",
  18285. "QueryInterface",
  18286. "R11F_G11F_B10F",
  18287. "R16F",
  18288. "R16I",
  18289. "R16UI",
  18290. "R32F",
  18291. "R32I",
  18292. "R32UI",
  18293. "R8",
  18294. "R8I",
  18295. "R8UI",
  18296. "R8_SNORM",
  18297. "RASTERIZER_DISCARD",
  18298. "READ_BUFFER",
  18299. "READ_FRAMEBUFFER",
  18300. "READ_FRAMEBUFFER_BINDING",
  18301. "READ_ONLY",
  18302. "READ_ONLY_ERR",
  18303. "READ_WRITE",
  18304. "RED",
  18305. "RED_BITS",
  18306. "RED_INTEGER",
  18307. "REMOVAL",
  18308. "RENDERBUFFER",
  18309. "RENDERBUFFER_ALPHA_SIZE",
  18310. "RENDERBUFFER_BINDING",
  18311. "RENDERBUFFER_BLUE_SIZE",
  18312. "RENDERBUFFER_DEPTH_SIZE",
  18313. "RENDERBUFFER_GREEN_SIZE",
  18314. "RENDERBUFFER_HEIGHT",
  18315. "RENDERBUFFER_INTERNAL_FORMAT",
  18316. "RENDERBUFFER_RED_SIZE",
  18317. "RENDERBUFFER_SAMPLES",
  18318. "RENDERBUFFER_STENCIL_SIZE",
  18319. "RENDERBUFFER_WIDTH",
  18320. "RENDERER",
  18321. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  18322. "RENDERING_INTENT_AUTO",
  18323. "RENDERING_INTENT_PERCEPTUAL",
  18324. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  18325. "RENDERING_INTENT_SATURATION",
  18326. "RENDERING_INTENT_UNKNOWN",
  18327. "REPEAT",
  18328. "REPLACE",
  18329. "RG",
  18330. "RG16F",
  18331. "RG16I",
  18332. "RG16UI",
  18333. "RG32F",
  18334. "RG32I",
  18335. "RG32UI",
  18336. "RG8",
  18337. "RG8I",
  18338. "RG8UI",
  18339. "RG8_SNORM",
  18340. "RGB",
  18341. "RGB10_A2",
  18342. "RGB10_A2UI",
  18343. "RGB16F",
  18344. "RGB16I",
  18345. "RGB16UI",
  18346. "RGB32F",
  18347. "RGB32I",
  18348. "RGB32UI",
  18349. "RGB565",
  18350. "RGB5_A1",
  18351. "RGB8",
  18352. "RGB8I",
  18353. "RGB8UI",
  18354. "RGB8_SNORM",
  18355. "RGB9_E5",
  18356. "RGBA",
  18357. "RGBA16F",
  18358. "RGBA16I",
  18359. "RGBA16UI",
  18360. "RGBA32F",
  18361. "RGBA32I",
  18362. "RGBA32UI",
  18363. "RGBA4",
  18364. "RGBA8",
  18365. "RGBA8I",
  18366. "RGBA8UI",
  18367. "RGBA8_SNORM",
  18368. "RGBA_INTEGER",
  18369. "RGBColor",
  18370. "RGB_INTEGER",
  18371. "RG_INTEGER",
  18372. "ROTATION_CLOCKWISE",
  18373. "ROTATION_COUNTERCLOCKWISE",
  18374. "RTCCertificate",
  18375. "RTCDTMFSender",
  18376. "RTCDTMFToneChangeEvent",
  18377. "RTCDataChannel",
  18378. "RTCDataChannelEvent",
  18379. "RTCDtlsTransport",
  18380. "RTCError",
  18381. "RTCErrorEvent",
  18382. "RTCIceCandidate",
  18383. "RTCIceTransport",
  18384. "RTCPeerConnection",
  18385. "RTCPeerConnectionIceErrorEvent",
  18386. "RTCPeerConnectionIceEvent",
  18387. "RTCRtpReceiver",
  18388. "RTCRtpSender",
  18389. "RTCRtpTransceiver",
  18390. "RTCSctpTransport",
  18391. "RTCSessionDescription",
  18392. "RTCStatsReport",
  18393. "RTCTrackEvent",
  18394. "RadioNodeList",
  18395. "Range",
  18396. "RangeError",
  18397. "RangeException",
  18398. "ReadableStream",
  18399. "ReadableStreamDefaultReader",
  18400. "RecordErrorEvent",
  18401. "Rect",
  18402. "ReferenceError",
  18403. "Reflect",
  18404. "RegExp",
  18405. "RelativeOrientationSensor",
  18406. "RelativeTimeFormat",
  18407. "RemotePlayback",
  18408. "Report",
  18409. "ReportBody",
  18410. "ReportingObserver",
  18411. "Request",
  18412. "ResizeObserver",
  18413. "ResizeObserverEntry",
  18414. "ResizeObserverSize",
  18415. "Response",
  18416. "RuntimeError",
  18417. "SAMPLER_2D",
  18418. "SAMPLER_2D_ARRAY",
  18419. "SAMPLER_2D_ARRAY_SHADOW",
  18420. "SAMPLER_2D_SHADOW",
  18421. "SAMPLER_3D",
  18422. "SAMPLER_BINDING",
  18423. "SAMPLER_CUBE",
  18424. "SAMPLER_CUBE_SHADOW",
  18425. "SAMPLES",
  18426. "SAMPLE_ALPHA_TO_COVERAGE",
  18427. "SAMPLE_BUFFERS",
  18428. "SAMPLE_COVERAGE",
  18429. "SAMPLE_COVERAGE_INVERT",
  18430. "SAMPLE_COVERAGE_VALUE",
  18431. "SAWTOOTH",
  18432. "SCHEDULED_STATE",
  18433. "SCISSOR_BOX",
  18434. "SCISSOR_TEST",
  18435. "SCROLL_PAGE_DOWN",
  18436. "SCROLL_PAGE_UP",
  18437. "SDP_ANSWER",
  18438. "SDP_OFFER",
  18439. "SDP_PRANSWER",
  18440. "SECURITY_ERR",
  18441. "SELECT",
  18442. "SEPARATE_ATTRIBS",
  18443. "SERIALIZE_ERR",
  18444. "SEVERITY_ERROR",
  18445. "SEVERITY_FATAL_ERROR",
  18446. "SEVERITY_WARNING",
  18447. "SHADER_COMPILER",
  18448. "SHADER_TYPE",
  18449. "SHADING_LANGUAGE_VERSION",
  18450. "SHIFT_MASK",
  18451. "SHORT",
  18452. "SHOWING",
  18453. "SHOW_ALL",
  18454. "SHOW_ATTRIBUTE",
  18455. "SHOW_CDATA_SECTION",
  18456. "SHOW_COMMENT",
  18457. "SHOW_DOCUMENT",
  18458. "SHOW_DOCUMENT_FRAGMENT",
  18459. "SHOW_DOCUMENT_TYPE",
  18460. "SHOW_ELEMENT",
  18461. "SHOW_ENTITY",
  18462. "SHOW_ENTITY_REFERENCE",
  18463. "SHOW_NOTATION",
  18464. "SHOW_PROCESSING_INSTRUCTION",
  18465. "SHOW_TEXT",
  18466. "SIGNALED",
  18467. "SIGNED_NORMALIZED",
  18468. "SINE",
  18469. "SOUNDFIELD",
  18470. "SQLException",
  18471. "SQRT1_2",
  18472. "SQRT2",
  18473. "SQUARE",
  18474. "SRC_ALPHA",
  18475. "SRC_ALPHA_SATURATE",
  18476. "SRC_COLOR",
  18477. "SRGB",
  18478. "SRGB8",
  18479. "SRGB8_ALPHA8",
  18480. "START_TO_END",
  18481. "START_TO_START",
  18482. "STATIC_COPY",
  18483. "STATIC_DRAW",
  18484. "STATIC_READ",
  18485. "STENCIL",
  18486. "STENCIL_ATTACHMENT",
  18487. "STENCIL_BACK_FAIL",
  18488. "STENCIL_BACK_FUNC",
  18489. "STENCIL_BACK_PASS_DEPTH_FAIL",
  18490. "STENCIL_BACK_PASS_DEPTH_PASS",
  18491. "STENCIL_BACK_REF",
  18492. "STENCIL_BACK_VALUE_MASK",
  18493. "STENCIL_BACK_WRITEMASK",
  18494. "STENCIL_BITS",
  18495. "STENCIL_BUFFER_BIT",
  18496. "STENCIL_CLEAR_VALUE",
  18497. "STENCIL_FAIL",
  18498. "STENCIL_FUNC",
  18499. "STENCIL_INDEX",
  18500. "STENCIL_INDEX8",
  18501. "STENCIL_PASS_DEPTH_FAIL",
  18502. "STENCIL_PASS_DEPTH_PASS",
  18503. "STENCIL_REF",
  18504. "STENCIL_TEST",
  18505. "STENCIL_VALUE_MASK",
  18506. "STENCIL_WRITEMASK",
  18507. "STREAM_COPY",
  18508. "STREAM_DRAW",
  18509. "STREAM_READ",
  18510. "STRING_TYPE",
  18511. "STYLE_RULE",
  18512. "SUBPIXEL_BITS",
  18513. "SUPPORTS_RULE",
  18514. "SVGAElement",
  18515. "SVGAltGlyphDefElement",
  18516. "SVGAltGlyphElement",
  18517. "SVGAltGlyphItemElement",
  18518. "SVGAngle",
  18519. "SVGAnimateColorElement",
  18520. "SVGAnimateElement",
  18521. "SVGAnimateMotionElement",
  18522. "SVGAnimateTransformElement",
  18523. "SVGAnimatedAngle",
  18524. "SVGAnimatedBoolean",
  18525. "SVGAnimatedEnumeration",
  18526. "SVGAnimatedInteger",
  18527. "SVGAnimatedLength",
  18528. "SVGAnimatedLengthList",
  18529. "SVGAnimatedNumber",
  18530. "SVGAnimatedNumberList",
  18531. "SVGAnimatedPreserveAspectRatio",
  18532. "SVGAnimatedRect",
  18533. "SVGAnimatedString",
  18534. "SVGAnimatedTransformList",
  18535. "SVGAnimationElement",
  18536. "SVGCircleElement",
  18537. "SVGClipPathElement",
  18538. "SVGColor",
  18539. "SVGComponentTransferFunctionElement",
  18540. "SVGCursorElement",
  18541. "SVGDefsElement",
  18542. "SVGDescElement",
  18543. "SVGDiscardElement",
  18544. "SVGDocument",
  18545. "SVGElement",
  18546. "SVGElementInstance",
  18547. "SVGElementInstanceList",
  18548. "SVGEllipseElement",
  18549. "SVGException",
  18550. "SVGFEBlendElement",
  18551. "SVGFEColorMatrixElement",
  18552. "SVGFEComponentTransferElement",
  18553. "SVGFECompositeElement",
  18554. "SVGFEConvolveMatrixElement",
  18555. "SVGFEDiffuseLightingElement",
  18556. "SVGFEDisplacementMapElement",
  18557. "SVGFEDistantLightElement",
  18558. "SVGFEDropShadowElement",
  18559. "SVGFEFloodElement",
  18560. "SVGFEFuncAElement",
  18561. "SVGFEFuncBElement",
  18562. "SVGFEFuncGElement",
  18563. "SVGFEFuncRElement",
  18564. "SVGFEGaussianBlurElement",
  18565. "SVGFEImageElement",
  18566. "SVGFEMergeElement",
  18567. "SVGFEMergeNodeElement",
  18568. "SVGFEMorphologyElement",
  18569. "SVGFEOffsetElement",
  18570. "SVGFEPointLightElement",
  18571. "SVGFESpecularLightingElement",
  18572. "SVGFESpotLightElement",
  18573. "SVGFETileElement",
  18574. "SVGFETurbulenceElement",
  18575. "SVGFilterElement",
  18576. "SVGFontElement",
  18577. "SVGFontFaceElement",
  18578. "SVGFontFaceFormatElement",
  18579. "SVGFontFaceNameElement",
  18580. "SVGFontFaceSrcElement",
  18581. "SVGFontFaceUriElement",
  18582. "SVGForeignObjectElement",
  18583. "SVGGElement",
  18584. "SVGGeometryElement",
  18585. "SVGGlyphElement",
  18586. "SVGGlyphRefElement",
  18587. "SVGGradientElement",
  18588. "SVGGraphicsElement",
  18589. "SVGHKernElement",
  18590. "SVGImageElement",
  18591. "SVGLength",
  18592. "SVGLengthList",
  18593. "SVGLineElement",
  18594. "SVGLinearGradientElement",
  18595. "SVGMPathElement",
  18596. "SVGMarkerElement",
  18597. "SVGMaskElement",
  18598. "SVGMatrix",
  18599. "SVGMetadataElement",
  18600. "SVGMissingGlyphElement",
  18601. "SVGNumber",
  18602. "SVGNumberList",
  18603. "SVGPaint",
  18604. "SVGPathElement",
  18605. "SVGPathSeg",
  18606. "SVGPathSegArcAbs",
  18607. "SVGPathSegArcRel",
  18608. "SVGPathSegClosePath",
  18609. "SVGPathSegCurvetoCubicAbs",
  18610. "SVGPathSegCurvetoCubicRel",
  18611. "SVGPathSegCurvetoCubicSmoothAbs",
  18612. "SVGPathSegCurvetoCubicSmoothRel",
  18613. "SVGPathSegCurvetoQuadraticAbs",
  18614. "SVGPathSegCurvetoQuadraticRel",
  18615. "SVGPathSegCurvetoQuadraticSmoothAbs",
  18616. "SVGPathSegCurvetoQuadraticSmoothRel",
  18617. "SVGPathSegLinetoAbs",
  18618. "SVGPathSegLinetoHorizontalAbs",
  18619. "SVGPathSegLinetoHorizontalRel",
  18620. "SVGPathSegLinetoRel",
  18621. "SVGPathSegLinetoVerticalAbs",
  18622. "SVGPathSegLinetoVerticalRel",
  18623. "SVGPathSegList",
  18624. "SVGPathSegMovetoAbs",
  18625. "SVGPathSegMovetoRel",
  18626. "SVGPatternElement",
  18627. "SVGPoint",
  18628. "SVGPointList",
  18629. "SVGPolygonElement",
  18630. "SVGPolylineElement",
  18631. "SVGPreserveAspectRatio",
  18632. "SVGRadialGradientElement",
  18633. "SVGRect",
  18634. "SVGRectElement",
  18635. "SVGRenderingIntent",
  18636. "SVGSVGElement",
  18637. "SVGScriptElement",
  18638. "SVGSetElement",
  18639. "SVGStopElement",
  18640. "SVGStringList",
  18641. "SVGStyleElement",
  18642. "SVGSwitchElement",
  18643. "SVGSymbolElement",
  18644. "SVGTRefElement",
  18645. "SVGTSpanElement",
  18646. "SVGTextContentElement",
  18647. "SVGTextElement",
  18648. "SVGTextPathElement",
  18649. "SVGTextPositioningElement",
  18650. "SVGTitleElement",
  18651. "SVGTransform",
  18652. "SVGTransformList",
  18653. "SVGUnitTypes",
  18654. "SVGUseElement",
  18655. "SVGVKernElement",
  18656. "SVGViewElement",
  18657. "SVGViewSpec",
  18658. "SVGZoomAndPan",
  18659. "SVGZoomEvent",
  18660. "SVG_ANGLETYPE_DEG",
  18661. "SVG_ANGLETYPE_GRAD",
  18662. "SVG_ANGLETYPE_RAD",
  18663. "SVG_ANGLETYPE_UNKNOWN",
  18664. "SVG_ANGLETYPE_UNSPECIFIED",
  18665. "SVG_CHANNEL_A",
  18666. "SVG_CHANNEL_B",
  18667. "SVG_CHANNEL_G",
  18668. "SVG_CHANNEL_R",
  18669. "SVG_CHANNEL_UNKNOWN",
  18670. "SVG_COLORTYPE_CURRENTCOLOR",
  18671. "SVG_COLORTYPE_RGBCOLOR",
  18672. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  18673. "SVG_COLORTYPE_UNKNOWN",
  18674. "SVG_EDGEMODE_DUPLICATE",
  18675. "SVG_EDGEMODE_NONE",
  18676. "SVG_EDGEMODE_UNKNOWN",
  18677. "SVG_EDGEMODE_WRAP",
  18678. "SVG_FEBLEND_MODE_COLOR",
  18679. "SVG_FEBLEND_MODE_COLOR_BURN",
  18680. "SVG_FEBLEND_MODE_COLOR_DODGE",
  18681. "SVG_FEBLEND_MODE_DARKEN",
  18682. "SVG_FEBLEND_MODE_DIFFERENCE",
  18683. "SVG_FEBLEND_MODE_EXCLUSION",
  18684. "SVG_FEBLEND_MODE_HARD_LIGHT",
  18685. "SVG_FEBLEND_MODE_HUE",
  18686. "SVG_FEBLEND_MODE_LIGHTEN",
  18687. "SVG_FEBLEND_MODE_LUMINOSITY",
  18688. "SVG_FEBLEND_MODE_MULTIPLY",
  18689. "SVG_FEBLEND_MODE_NORMAL",
  18690. "SVG_FEBLEND_MODE_OVERLAY",
  18691. "SVG_FEBLEND_MODE_SATURATION",
  18692. "SVG_FEBLEND_MODE_SCREEN",
  18693. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  18694. "SVG_FEBLEND_MODE_UNKNOWN",
  18695. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  18696. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  18697. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  18698. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  18699. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  18700. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  18701. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  18702. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  18703. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  18704. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  18705. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  18706. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  18707. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  18708. "SVG_FECOMPOSITE_OPERATOR_IN",
  18709. "SVG_FECOMPOSITE_OPERATOR_OUT",
  18710. "SVG_FECOMPOSITE_OPERATOR_OVER",
  18711. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  18712. "SVG_FECOMPOSITE_OPERATOR_XOR",
  18713. "SVG_INVALID_VALUE_ERR",
  18714. "SVG_LENGTHTYPE_CM",
  18715. "SVG_LENGTHTYPE_EMS",
  18716. "SVG_LENGTHTYPE_EXS",
  18717. "SVG_LENGTHTYPE_IN",
  18718. "SVG_LENGTHTYPE_MM",
  18719. "SVG_LENGTHTYPE_NUMBER",
  18720. "SVG_LENGTHTYPE_PC",
  18721. "SVG_LENGTHTYPE_PERCENTAGE",
  18722. "SVG_LENGTHTYPE_PT",
  18723. "SVG_LENGTHTYPE_PX",
  18724. "SVG_LENGTHTYPE_UNKNOWN",
  18725. "SVG_MARKERUNITS_STROKEWIDTH",
  18726. "SVG_MARKERUNITS_UNKNOWN",
  18727. "SVG_MARKERUNITS_USERSPACEONUSE",
  18728. "SVG_MARKER_ORIENT_ANGLE",
  18729. "SVG_MARKER_ORIENT_AUTO",
  18730. "SVG_MARKER_ORIENT_UNKNOWN",
  18731. "SVG_MASKTYPE_ALPHA",
  18732. "SVG_MASKTYPE_LUMINANCE",
  18733. "SVG_MATRIX_NOT_INVERTABLE",
  18734. "SVG_MEETORSLICE_MEET",
  18735. "SVG_MEETORSLICE_SLICE",
  18736. "SVG_MEETORSLICE_UNKNOWN",
  18737. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  18738. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  18739. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  18740. "SVG_PAINTTYPE_CURRENTCOLOR",
  18741. "SVG_PAINTTYPE_NONE",
  18742. "SVG_PAINTTYPE_RGBCOLOR",
  18743. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  18744. "SVG_PAINTTYPE_UNKNOWN",
  18745. "SVG_PAINTTYPE_URI",
  18746. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  18747. "SVG_PAINTTYPE_URI_NONE",
  18748. "SVG_PAINTTYPE_URI_RGBCOLOR",
  18749. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  18750. "SVG_PRESERVEASPECTRATIO_NONE",
  18751. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  18752. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  18753. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  18754. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  18755. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  18756. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  18757. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  18758. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  18759. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  18760. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  18761. "SVG_SPREADMETHOD_PAD",
  18762. "SVG_SPREADMETHOD_REFLECT",
  18763. "SVG_SPREADMETHOD_REPEAT",
  18764. "SVG_SPREADMETHOD_UNKNOWN",
  18765. "SVG_STITCHTYPE_NOSTITCH",
  18766. "SVG_STITCHTYPE_STITCH",
  18767. "SVG_STITCHTYPE_UNKNOWN",
  18768. "SVG_TRANSFORM_MATRIX",
  18769. "SVG_TRANSFORM_ROTATE",
  18770. "SVG_TRANSFORM_SCALE",
  18771. "SVG_TRANSFORM_SKEWX",
  18772. "SVG_TRANSFORM_SKEWY",
  18773. "SVG_TRANSFORM_TRANSLATE",
  18774. "SVG_TRANSFORM_UNKNOWN",
  18775. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  18776. "SVG_TURBULENCE_TYPE_TURBULENCE",
  18777. "SVG_TURBULENCE_TYPE_UNKNOWN",
  18778. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  18779. "SVG_UNIT_TYPE_UNKNOWN",
  18780. "SVG_UNIT_TYPE_USERSPACEONUSE",
  18781. "SVG_WRONG_TYPE_ERR",
  18782. "SVG_ZOOMANDPAN_DISABLE",
  18783. "SVG_ZOOMANDPAN_MAGNIFY",
  18784. "SVG_ZOOMANDPAN_UNKNOWN",
  18785. "SYNC_CONDITION",
  18786. "SYNC_FENCE",
  18787. "SYNC_FLAGS",
  18788. "SYNC_FLUSH_COMMANDS_BIT",
  18789. "SYNC_GPU_COMMANDS_COMPLETE",
  18790. "SYNC_STATUS",
  18791. "SYNTAX_ERR",
  18792. "SavedPages",
  18793. "Screen",
  18794. "ScreenOrientation",
  18795. "Script",
  18796. "ScriptProcessorNode",
  18797. "ScrollAreaEvent",
  18798. "SecurityPolicyViolationEvent",
  18799. "Selection",
  18800. "Sensor",
  18801. "SensorErrorEvent",
  18802. "ServiceWorker",
  18803. "ServiceWorkerContainer",
  18804. "ServiceWorkerRegistration",
  18805. "SessionDescription",
  18806. "Set",
  18807. "ShadowRoot",
  18808. "SharedArrayBuffer",
  18809. "SharedWorker",
  18810. "SimpleGestureEvent",
  18811. "SourceBuffer",
  18812. "SourceBufferList",
  18813. "SpeechSynthesis",
  18814. "SpeechSynthesisErrorEvent",
  18815. "SpeechSynthesisEvent",
  18816. "SpeechSynthesisUtterance",
  18817. "SpeechSynthesisVoice",
  18818. "StaticRange",
  18819. "StereoPannerNode",
  18820. "StopIteration",
  18821. "Storage",
  18822. "StorageEvent",
  18823. "StorageManager",
  18824. "String",
  18825. "StructType",
  18826. "StylePropertyMap",
  18827. "StylePropertyMapReadOnly",
  18828. "StyleSheet",
  18829. "StyleSheetList",
  18830. "SubmitEvent",
  18831. "SubtleCrypto",
  18832. "Symbol",
  18833. "SyncManager",
  18834. "SyntaxError",
  18835. "TEMPORARY",
  18836. "TEXTPATH_METHODTYPE_ALIGN",
  18837. "TEXTPATH_METHODTYPE_STRETCH",
  18838. "TEXTPATH_METHODTYPE_UNKNOWN",
  18839. "TEXTPATH_SPACINGTYPE_AUTO",
  18840. "TEXTPATH_SPACINGTYPE_EXACT",
  18841. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  18842. "TEXTURE",
  18843. "TEXTURE0",
  18844. "TEXTURE1",
  18845. "TEXTURE10",
  18846. "TEXTURE11",
  18847. "TEXTURE12",
  18848. "TEXTURE13",
  18849. "TEXTURE14",
  18850. "TEXTURE15",
  18851. "TEXTURE16",
  18852. "TEXTURE17",
  18853. "TEXTURE18",
  18854. "TEXTURE19",
  18855. "TEXTURE2",
  18856. "TEXTURE20",
  18857. "TEXTURE21",
  18858. "TEXTURE22",
  18859. "TEXTURE23",
  18860. "TEXTURE24",
  18861. "TEXTURE25",
  18862. "TEXTURE26",
  18863. "TEXTURE27",
  18864. "TEXTURE28",
  18865. "TEXTURE29",
  18866. "TEXTURE3",
  18867. "TEXTURE30",
  18868. "TEXTURE31",
  18869. "TEXTURE4",
  18870. "TEXTURE5",
  18871. "TEXTURE6",
  18872. "TEXTURE7",
  18873. "TEXTURE8",
  18874. "TEXTURE9",
  18875. "TEXTURE_2D",
  18876. "TEXTURE_2D_ARRAY",
  18877. "TEXTURE_3D",
  18878. "TEXTURE_BASE_LEVEL",
  18879. "TEXTURE_BINDING_2D",
  18880. "TEXTURE_BINDING_2D_ARRAY",
  18881. "TEXTURE_BINDING_3D",
  18882. "TEXTURE_BINDING_CUBE_MAP",
  18883. "TEXTURE_COMPARE_FUNC",
  18884. "TEXTURE_COMPARE_MODE",
  18885. "TEXTURE_CUBE_MAP",
  18886. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  18887. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  18888. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  18889. "TEXTURE_CUBE_MAP_POSITIVE_X",
  18890. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  18891. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  18892. "TEXTURE_IMMUTABLE_FORMAT",
  18893. "TEXTURE_IMMUTABLE_LEVELS",
  18894. "TEXTURE_MAG_FILTER",
  18895. "TEXTURE_MAX_ANISOTROPY_EXT",
  18896. "TEXTURE_MAX_LEVEL",
  18897. "TEXTURE_MAX_LOD",
  18898. "TEXTURE_MIN_FILTER",
  18899. "TEXTURE_MIN_LOD",
  18900. "TEXTURE_WRAP_R",
  18901. "TEXTURE_WRAP_S",
  18902. "TEXTURE_WRAP_T",
  18903. "TEXT_NODE",
  18904. "TIMEOUT",
  18905. "TIMEOUT_ERR",
  18906. "TIMEOUT_EXPIRED",
  18907. "TIMEOUT_IGNORED",
  18908. "TOO_LARGE_ERR",
  18909. "TRANSACTION_INACTIVE_ERR",
  18910. "TRANSFORM_FEEDBACK",
  18911. "TRANSFORM_FEEDBACK_ACTIVE",
  18912. "TRANSFORM_FEEDBACK_BINDING",
  18913. "TRANSFORM_FEEDBACK_BUFFER",
  18914. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  18915. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  18916. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  18917. "TRANSFORM_FEEDBACK_BUFFER_START",
  18918. "TRANSFORM_FEEDBACK_PAUSED",
  18919. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  18920. "TRANSFORM_FEEDBACK_VARYINGS",
  18921. "TRIANGLE",
  18922. "TRIANGLES",
  18923. "TRIANGLE_FAN",
  18924. "TRIANGLE_STRIP",
  18925. "TYPE_BACK_FORWARD",
  18926. "TYPE_ERR",
  18927. "TYPE_MISMATCH_ERR",
  18928. "TYPE_NAVIGATE",
  18929. "TYPE_RELOAD",
  18930. "TYPE_RESERVED",
  18931. "Table",
  18932. "TaskAttributionTiming",
  18933. "Text",
  18934. "TextDecoder",
  18935. "TextDecoderStream",
  18936. "TextEncoder",
  18937. "TextEncoderStream",
  18938. "TextEvent",
  18939. "TextMetrics",
  18940. "TextTrack",
  18941. "TextTrackCue",
  18942. "TextTrackCueList",
  18943. "TextTrackList",
  18944. "TimeEvent",
  18945. "TimeRanges",
  18946. "Touch",
  18947. "TouchEvent",
  18948. "TouchList",
  18949. "TrackEvent",
  18950. "TransformStream",
  18951. "TransitionEvent",
  18952. "TreeWalker",
  18953. "TrustedHTML",
  18954. "TrustedScript",
  18955. "TrustedScriptURL",
  18956. "TrustedTypePolicy",
  18957. "TrustedTypePolicyFactory",
  18958. "TypeError",
  18959. "TypedObject",
  18960. "U2F",
  18961. "UIEvent",
  18962. "UNCACHED",
  18963. "UNIFORM_ARRAY_STRIDE",
  18964. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  18965. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  18966. "UNIFORM_BLOCK_BINDING",
  18967. "UNIFORM_BLOCK_DATA_SIZE",
  18968. "UNIFORM_BLOCK_INDEX",
  18969. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  18970. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  18971. "UNIFORM_BUFFER",
  18972. "UNIFORM_BUFFER_BINDING",
  18973. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  18974. "UNIFORM_BUFFER_SIZE",
  18975. "UNIFORM_BUFFER_START",
  18976. "UNIFORM_IS_ROW_MAJOR",
  18977. "UNIFORM_MATRIX_STRIDE",
  18978. "UNIFORM_OFFSET",
  18979. "UNIFORM_SIZE",
  18980. "UNIFORM_TYPE",
  18981. "UNKNOWN_ERR",
  18982. "UNKNOWN_RULE",
  18983. "UNMASKED_RENDERER_WEBGL",
  18984. "UNMASKED_VENDOR_WEBGL",
  18985. "UNORDERED_NODE_ITERATOR_TYPE",
  18986. "UNORDERED_NODE_SNAPSHOT_TYPE",
  18987. "UNPACK_ALIGNMENT",
  18988. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  18989. "UNPACK_FLIP_Y_WEBGL",
  18990. "UNPACK_IMAGE_HEIGHT",
  18991. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  18992. "UNPACK_ROW_LENGTH",
  18993. "UNPACK_SKIP_IMAGES",
  18994. "UNPACK_SKIP_PIXELS",
  18995. "UNPACK_SKIP_ROWS",
  18996. "UNSCHEDULED_STATE",
  18997. "UNSENT",
  18998. "UNSIGNALED",
  18999. "UNSIGNED_BYTE",
  19000. "UNSIGNED_INT",
  19001. "UNSIGNED_INT_10F_11F_11F_REV",
  19002. "UNSIGNED_INT_24_8",
  19003. "UNSIGNED_INT_2_10_10_10_REV",
  19004. "UNSIGNED_INT_5_9_9_9_REV",
  19005. "UNSIGNED_INT_SAMPLER_2D",
  19006. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  19007. "UNSIGNED_INT_SAMPLER_3D",
  19008. "UNSIGNED_INT_SAMPLER_CUBE",
  19009. "UNSIGNED_INT_VEC2",
  19010. "UNSIGNED_INT_VEC3",
  19011. "UNSIGNED_INT_VEC4",
  19012. "UNSIGNED_NORMALIZED",
  19013. "UNSIGNED_SHORT",
  19014. "UNSIGNED_SHORT_4_4_4_4",
  19015. "UNSIGNED_SHORT_5_5_5_1",
  19016. "UNSIGNED_SHORT_5_6_5",
  19017. "UNSPECIFIED_EVENT_TYPE_ERR",
  19018. "UPDATEREADY",
  19019. "URIError",
  19020. "URL",
  19021. "URLSearchParams",
  19022. "URLUnencoded",
  19023. "URL_MISMATCH_ERR",
  19024. "USB",
  19025. "USBAlternateInterface",
  19026. "USBConfiguration",
  19027. "USBConnectionEvent",
  19028. "USBDevice",
  19029. "USBEndpoint",
  19030. "USBInTransferResult",
  19031. "USBInterface",
  19032. "USBIsochronousInTransferPacket",
  19033. "USBIsochronousInTransferResult",
  19034. "USBIsochronousOutTransferPacket",
  19035. "USBIsochronousOutTransferResult",
  19036. "USBOutTransferResult",
  19037. "UTC",
  19038. "Uint16Array",
  19039. "Uint32Array",
  19040. "Uint8Array",
  19041. "Uint8ClampedArray",
  19042. "UserActivation",
  19043. "UserMessageHandler",
  19044. "UserMessageHandlersNamespace",
  19045. "UserProximityEvent",
  19046. "VALIDATE_STATUS",
  19047. "VALIDATION_ERR",
  19048. "VARIABLES_RULE",
  19049. "VENDOR",
  19050. "VERSION",
  19051. "VERSION_CHANGE",
  19052. "VERSION_ERR",
  19053. "VERTEX_ARRAY_BINDING",
  19054. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  19055. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  19056. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  19057. "VERTEX_ATTRIB_ARRAY_ENABLED",
  19058. "VERTEX_ATTRIB_ARRAY_INTEGER",
  19059. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  19060. "VERTEX_ATTRIB_ARRAY_POINTER",
  19061. "VERTEX_ATTRIB_ARRAY_SIZE",
  19062. "VERTEX_ATTRIB_ARRAY_STRIDE",
  19063. "VERTEX_ATTRIB_ARRAY_TYPE",
  19064. "VERTEX_SHADER",
  19065. "VERTICAL",
  19066. "VERTICAL_AXIS",
  19067. "VER_ERR",
  19068. "VIEWPORT",
  19069. "VIEWPORT_RULE",
  19070. "VRDisplay",
  19071. "VRDisplayCapabilities",
  19072. "VRDisplayEvent",
  19073. "VREyeParameters",
  19074. "VRFieldOfView",
  19075. "VRFrameData",
  19076. "VRPose",
  19077. "VRStageParameters",
  19078. "VTTCue",
  19079. "VTTRegion",
  19080. "ValidityState",
  19081. "VideoPlaybackQuality",
  19082. "VideoStreamTrack",
  19083. "VisualViewport",
  19084. "WAIT_FAILED",
  19085. "WEBKIT_FILTER_RULE",
  19086. "WEBKIT_KEYFRAMES_RULE",
  19087. "WEBKIT_KEYFRAME_RULE",
  19088. "WEBKIT_REGION_RULE",
  19089. "WRONG_DOCUMENT_ERR",
  19090. "WakeLock",
  19091. "WakeLockSentinel",
  19092. "WasmAnyRef",
  19093. "WaveShaperNode",
  19094. "WeakMap",
  19095. "WeakRef",
  19096. "WeakSet",
  19097. "WebAssembly",
  19098. "WebGL2RenderingContext",
  19099. "WebGLActiveInfo",
  19100. "WebGLBuffer",
  19101. "WebGLContextEvent",
  19102. "WebGLFramebuffer",
  19103. "WebGLProgram",
  19104. "WebGLQuery",
  19105. "WebGLRenderbuffer",
  19106. "WebGLRenderingContext",
  19107. "WebGLSampler",
  19108. "WebGLShader",
  19109. "WebGLShaderPrecisionFormat",
  19110. "WebGLSync",
  19111. "WebGLTexture",
  19112. "WebGLTransformFeedback",
  19113. "WebGLUniformLocation",
  19114. "WebGLVertexArray",
  19115. "WebGLVertexArrayObject",
  19116. "WebKitAnimationEvent",
  19117. "WebKitBlobBuilder",
  19118. "WebKitCSSFilterRule",
  19119. "WebKitCSSFilterValue",
  19120. "WebKitCSSKeyframeRule",
  19121. "WebKitCSSKeyframesRule",
  19122. "WebKitCSSMatrix",
  19123. "WebKitCSSRegionRule",
  19124. "WebKitCSSTransformValue",
  19125. "WebKitDataCue",
  19126. "WebKitGamepad",
  19127. "WebKitMediaKeyError",
  19128. "WebKitMediaKeyMessageEvent",
  19129. "WebKitMediaKeySession",
  19130. "WebKitMediaKeys",
  19131. "WebKitMediaSource",
  19132. "WebKitMutationObserver",
  19133. "WebKitNamespace",
  19134. "WebKitPlaybackTargetAvailabilityEvent",
  19135. "WebKitPoint",
  19136. "WebKitShadowRoot",
  19137. "WebKitSourceBuffer",
  19138. "WebKitSourceBufferList",
  19139. "WebKitTransitionEvent",
  19140. "WebSocket",
  19141. "WebkitAlignContent",
  19142. "WebkitAlignItems",
  19143. "WebkitAlignSelf",
  19144. "WebkitAnimation",
  19145. "WebkitAnimationDelay",
  19146. "WebkitAnimationDirection",
  19147. "WebkitAnimationDuration",
  19148. "WebkitAnimationFillMode",
  19149. "WebkitAnimationIterationCount",
  19150. "WebkitAnimationName",
  19151. "WebkitAnimationPlayState",
  19152. "WebkitAnimationTimingFunction",
  19153. "WebkitAppearance",
  19154. "WebkitBackfaceVisibility",
  19155. "WebkitBackgroundClip",
  19156. "WebkitBackgroundOrigin",
  19157. "WebkitBackgroundSize",
  19158. "WebkitBorderBottomLeftRadius",
  19159. "WebkitBorderBottomRightRadius",
  19160. "WebkitBorderImage",
  19161. "WebkitBorderRadius",
  19162. "WebkitBorderTopLeftRadius",
  19163. "WebkitBorderTopRightRadius",
  19164. "WebkitBoxAlign",
  19165. "WebkitBoxDirection",
  19166. "WebkitBoxFlex",
  19167. "WebkitBoxOrdinalGroup",
  19168. "WebkitBoxOrient",
  19169. "WebkitBoxPack",
  19170. "WebkitBoxShadow",
  19171. "WebkitBoxSizing",
  19172. "WebkitFilter",
  19173. "WebkitFlex",
  19174. "WebkitFlexBasis",
  19175. "WebkitFlexDirection",
  19176. "WebkitFlexFlow",
  19177. "WebkitFlexGrow",
  19178. "WebkitFlexShrink",
  19179. "WebkitFlexWrap",
  19180. "WebkitJustifyContent",
  19181. "WebkitLineClamp",
  19182. "WebkitMask",
  19183. "WebkitMaskClip",
  19184. "WebkitMaskComposite",
  19185. "WebkitMaskImage",
  19186. "WebkitMaskOrigin",
  19187. "WebkitMaskPosition",
  19188. "WebkitMaskPositionX",
  19189. "WebkitMaskPositionY",
  19190. "WebkitMaskRepeat",
  19191. "WebkitMaskSize",
  19192. "WebkitOrder",
  19193. "WebkitPerspective",
  19194. "WebkitPerspectiveOrigin",
  19195. "WebkitTextFillColor",
  19196. "WebkitTextSizeAdjust",
  19197. "WebkitTextStroke",
  19198. "WebkitTextStrokeColor",
  19199. "WebkitTextStrokeWidth",
  19200. "WebkitTransform",
  19201. "WebkitTransformOrigin",
  19202. "WebkitTransformStyle",
  19203. "WebkitTransition",
  19204. "WebkitTransitionDelay",
  19205. "WebkitTransitionDuration",
  19206. "WebkitTransitionProperty",
  19207. "WebkitTransitionTimingFunction",
  19208. "WebkitUserSelect",
  19209. "WheelEvent",
  19210. "Window",
  19211. "Worker",
  19212. "Worklet",
  19213. "WritableStream",
  19214. "WritableStreamDefaultWriter",
  19215. "XMLDocument",
  19216. "XMLHttpRequest",
  19217. "XMLHttpRequestEventTarget",
  19218. "XMLHttpRequestException",
  19219. "XMLHttpRequestProgressEvent",
  19220. "XMLHttpRequestUpload",
  19221. "XMLSerializer",
  19222. "XMLStylesheetProcessingInstruction",
  19223. "XPathEvaluator",
  19224. "XPathException",
  19225. "XPathExpression",
  19226. "XPathNSResolver",
  19227. "XPathResult",
  19228. "XRBoundedReferenceSpace",
  19229. "XRDOMOverlayState",
  19230. "XRFrame",
  19231. "XRHitTestResult",
  19232. "XRHitTestSource",
  19233. "XRInputSource",
  19234. "XRInputSourceArray",
  19235. "XRInputSourceEvent",
  19236. "XRInputSourcesChangeEvent",
  19237. "XRLayer",
  19238. "XRPose",
  19239. "XRRay",
  19240. "XRReferenceSpace",
  19241. "XRReferenceSpaceEvent",
  19242. "XRRenderState",
  19243. "XRRigidTransform",
  19244. "XRSession",
  19245. "XRSessionEvent",
  19246. "XRSpace",
  19247. "XRSystem",
  19248. "XRTransientInputHitTestResult",
  19249. "XRTransientInputHitTestSource",
  19250. "XRView",
  19251. "XRViewerPose",
  19252. "XRViewport",
  19253. "XRWebGLLayer",
  19254. "XSLTProcessor",
  19255. "ZERO",
  19256. "_XD0M_",
  19257. "_YD0M_",
  19258. "__defineGetter__",
  19259. "__defineSetter__",
  19260. "__lookupGetter__",
  19261. "__lookupSetter__",
  19262. "__opera",
  19263. "__proto__",
  19264. "_browserjsran",
  19265. "a",
  19266. "aLink",
  19267. "abbr",
  19268. "abort",
  19269. "aborted",
  19270. "abs",
  19271. "absolute",
  19272. "acceleration",
  19273. "accelerationIncludingGravity",
  19274. "accelerator",
  19275. "accept",
  19276. "acceptCharset",
  19277. "acceptNode",
  19278. "accessKey",
  19279. "accessKeyLabel",
  19280. "accuracy",
  19281. "acos",
  19282. "acosh",
  19283. "action",
  19284. "actionURL",
  19285. "actions",
  19286. "activated",
  19287. "active",
  19288. "activeCues",
  19289. "activeElement",
  19290. "activeSourceBuffers",
  19291. "activeSourceCount",
  19292. "activeTexture",
  19293. "activeVRDisplays",
  19294. "actualBoundingBoxAscent",
  19295. "actualBoundingBoxDescent",
  19296. "actualBoundingBoxLeft",
  19297. "actualBoundingBoxRight",
  19298. "add",
  19299. "addAll",
  19300. "addBehavior",
  19301. "addCandidate",
  19302. "addColorStop",
  19303. "addCue",
  19304. "addElement",
  19305. "addEventListener",
  19306. "addFilter",
  19307. "addFromString",
  19308. "addFromUri",
  19309. "addIceCandidate",
  19310. "addImport",
  19311. "addListener",
  19312. "addModule",
  19313. "addNamed",
  19314. "addPageRule",
  19315. "addPath",
  19316. "addPointer",
  19317. "addRange",
  19318. "addRegion",
  19319. "addRule",
  19320. "addSearchEngine",
  19321. "addSourceBuffer",
  19322. "addStream",
  19323. "addTextTrack",
  19324. "addTrack",
  19325. "addTransceiver",
  19326. "addWakeLockListener",
  19327. "added",
  19328. "addedNodes",
  19329. "additionalName",
  19330. "additiveSymbols",
  19331. "addons",
  19332. "address",
  19333. "addressLine",
  19334. "adoptNode",
  19335. "adoptedStyleSheets",
  19336. "adr",
  19337. "advance",
  19338. "after",
  19339. "album",
  19340. "alert",
  19341. "algorithm",
  19342. "align",
  19343. "align-content",
  19344. "align-items",
  19345. "align-self",
  19346. "alignContent",
  19347. "alignItems",
  19348. "alignSelf",
  19349. "alignmentBaseline",
  19350. "alinkColor",
  19351. "all",
  19352. "allSettled",
  19353. "allow",
  19354. "allowFullscreen",
  19355. "allowPaymentRequest",
  19356. "allowedDirections",
  19357. "allowedFeatures",
  19358. "allowedToPlay",
  19359. "allowsFeature",
  19360. "alpha",
  19361. "alt",
  19362. "altGraphKey",
  19363. "altHtml",
  19364. "altKey",
  19365. "altLeft",
  19366. "alternate",
  19367. "alternateSetting",
  19368. "alternates",
  19369. "altitude",
  19370. "altitudeAccuracy",
  19371. "amplitude",
  19372. "ancestorOrigins",
  19373. "anchor",
  19374. "anchorNode",
  19375. "anchorOffset",
  19376. "anchors",
  19377. "and",
  19378. "angle",
  19379. "angularAcceleration",
  19380. "angularVelocity",
  19381. "animVal",
  19382. "animate",
  19383. "animatedInstanceRoot",
  19384. "animatedNormalizedPathSegList",
  19385. "animatedPathSegList",
  19386. "animatedPoints",
  19387. "animation",
  19388. "animation-delay",
  19389. "animation-direction",
  19390. "animation-duration",
  19391. "animation-fill-mode",
  19392. "animation-iteration-count",
  19393. "animation-name",
  19394. "animation-play-state",
  19395. "animation-timing-function",
  19396. "animationDelay",
  19397. "animationDirection",
  19398. "animationDuration",
  19399. "animationFillMode",
  19400. "animationIterationCount",
  19401. "animationName",
  19402. "animationPlayState",
  19403. "animationStartTime",
  19404. "animationTimingFunction",
  19405. "animationsPaused",
  19406. "anniversary",
  19407. "antialias",
  19408. "anticipatedRemoval",
  19409. "any",
  19410. "app",
  19411. "appCodeName",
  19412. "appMinorVersion",
  19413. "appName",
  19414. "appNotifications",
  19415. "appVersion",
  19416. "appearance",
  19417. "append",
  19418. "appendBuffer",
  19419. "appendChild",
  19420. "appendData",
  19421. "appendItem",
  19422. "appendMedium",
  19423. "appendNamed",
  19424. "appendRule",
  19425. "appendStream",
  19426. "appendWindowEnd",
  19427. "appendWindowStart",
  19428. "applets",
  19429. "applicationCache",
  19430. "applicationServerKey",
  19431. "apply",
  19432. "applyConstraints",
  19433. "applyElement",
  19434. "arc",
  19435. "arcTo",
  19436. "archive",
  19437. "areas",
  19438. "arguments",
  19439. "ariaAtomic",
  19440. "ariaAutoComplete",
  19441. "ariaBusy",
  19442. "ariaChecked",
  19443. "ariaColCount",
  19444. "ariaColIndex",
  19445. "ariaColSpan",
  19446. "ariaCurrent",
  19447. "ariaDescription",
  19448. "ariaDisabled",
  19449. "ariaExpanded",
  19450. "ariaHasPopup",
  19451. "ariaHidden",
  19452. "ariaKeyShortcuts",
  19453. "ariaLabel",
  19454. "ariaLevel",
  19455. "ariaLive",
  19456. "ariaModal",
  19457. "ariaMultiLine",
  19458. "ariaMultiSelectable",
  19459. "ariaOrientation",
  19460. "ariaPlaceholder",
  19461. "ariaPosInSet",
  19462. "ariaPressed",
  19463. "ariaReadOnly",
  19464. "ariaRelevant",
  19465. "ariaRequired",
  19466. "ariaRoleDescription",
  19467. "ariaRowCount",
  19468. "ariaRowIndex",
  19469. "ariaRowSpan",
  19470. "ariaSelected",
  19471. "ariaSetSize",
  19472. "ariaSort",
  19473. "ariaValueMax",
  19474. "ariaValueMin",
  19475. "ariaValueNow",
  19476. "ariaValueText",
  19477. "arrayBuffer",
  19478. "artist",
  19479. "artwork",
  19480. "as",
  19481. "asIntN",
  19482. "asUintN",
  19483. "asin",
  19484. "asinh",
  19485. "assert",
  19486. "assign",
  19487. "assignedElements",
  19488. "assignedNodes",
  19489. "assignedSlot",
  19490. "async",
  19491. "asyncIterator",
  19492. "atEnd",
  19493. "atan",
  19494. "atan2",
  19495. "atanh",
  19496. "atob",
  19497. "attachEvent",
  19498. "attachInternals",
  19499. "attachShader",
  19500. "attachShadow",
  19501. "attachments",
  19502. "attack",
  19503. "attestationObject",
  19504. "attrChange",
  19505. "attrName",
  19506. "attributeFilter",
  19507. "attributeName",
  19508. "attributeNamespace",
  19509. "attributeOldValue",
  19510. "attributeStyleMap",
  19511. "attributes",
  19512. "attribution",
  19513. "audioBitsPerSecond",
  19514. "audioTracks",
  19515. "audioWorklet",
  19516. "authenticatedSignedWrites",
  19517. "authenticatorData",
  19518. "autoIncrement",
  19519. "autobuffer",
  19520. "autocapitalize",
  19521. "autocomplete",
  19522. "autocorrect",
  19523. "autofocus",
  19524. "automationRate",
  19525. "autoplay",
  19526. "availHeight",
  19527. "availLeft",
  19528. "availTop",
  19529. "availWidth",
  19530. "availability",
  19531. "available",
  19532. "aversion",
  19533. "ax",
  19534. "axes",
  19535. "axis",
  19536. "ay",
  19537. "azimuth",
  19538. "b",
  19539. "back",
  19540. "backface-visibility",
  19541. "backfaceVisibility",
  19542. "background",
  19543. "background-attachment",
  19544. "background-blend-mode",
  19545. "background-clip",
  19546. "background-color",
  19547. "background-image",
  19548. "background-origin",
  19549. "background-position",
  19550. "background-position-x",
  19551. "background-position-y",
  19552. "background-repeat",
  19553. "background-size",
  19554. "backgroundAttachment",
  19555. "backgroundBlendMode",
  19556. "backgroundClip",
  19557. "backgroundColor",
  19558. "backgroundFetch",
  19559. "backgroundImage",
  19560. "backgroundOrigin",
  19561. "backgroundPosition",
  19562. "backgroundPositionX",
  19563. "backgroundPositionY",
  19564. "backgroundRepeat",
  19565. "backgroundSize",
  19566. "badInput",
  19567. "badge",
  19568. "balance",
  19569. "baseFrequencyX",
  19570. "baseFrequencyY",
  19571. "baseLatency",
  19572. "baseLayer",
  19573. "baseNode",
  19574. "baseOffset",
  19575. "baseURI",
  19576. "baseVal",
  19577. "baselineShift",
  19578. "battery",
  19579. "bday",
  19580. "before",
  19581. "beginElement",
  19582. "beginElementAt",
  19583. "beginPath",
  19584. "beginQuery",
  19585. "beginTransformFeedback",
  19586. "behavior",
  19587. "behaviorCookie",
  19588. "behaviorPart",
  19589. "behaviorUrns",
  19590. "beta",
  19591. "bezierCurveTo",
  19592. "bgColor",
  19593. "bgProperties",
  19594. "bias",
  19595. "big",
  19596. "bigint64",
  19597. "biguint64",
  19598. "binaryType",
  19599. "bind",
  19600. "bindAttribLocation",
  19601. "bindBuffer",
  19602. "bindBufferBase",
  19603. "bindBufferRange",
  19604. "bindFramebuffer",
  19605. "bindRenderbuffer",
  19606. "bindSampler",
  19607. "bindTexture",
  19608. "bindTransformFeedback",
  19609. "bindVertexArray",
  19610. "blendColor",
  19611. "blendEquation",
  19612. "blendEquationSeparate",
  19613. "blendFunc",
  19614. "blendFuncSeparate",
  19615. "blink",
  19616. "blitFramebuffer",
  19617. "blob",
  19618. "block-size",
  19619. "blockDirection",
  19620. "blockSize",
  19621. "blockedURI",
  19622. "blue",
  19623. "bluetooth",
  19624. "blur",
  19625. "body",
  19626. "bodyUsed",
  19627. "bold",
  19628. "bookmarks",
  19629. "booleanValue",
  19630. "border",
  19631. "border-block",
  19632. "border-block-color",
  19633. "border-block-end",
  19634. "border-block-end-color",
  19635. "border-block-end-style",
  19636. "border-block-end-width",
  19637. "border-block-start",
  19638. "border-block-start-color",
  19639. "border-block-start-style",
  19640. "border-block-start-width",
  19641. "border-block-style",
  19642. "border-block-width",
  19643. "border-bottom",
  19644. "border-bottom-color",
  19645. "border-bottom-left-radius",
  19646. "border-bottom-right-radius",
  19647. "border-bottom-style",
  19648. "border-bottom-width",
  19649. "border-collapse",
  19650. "border-color",
  19651. "border-end-end-radius",
  19652. "border-end-start-radius",
  19653. "border-image",
  19654. "border-image-outset",
  19655. "border-image-repeat",
  19656. "border-image-slice",
  19657. "border-image-source",
  19658. "border-image-width",
  19659. "border-inline",
  19660. "border-inline-color",
  19661. "border-inline-end",
  19662. "border-inline-end-color",
  19663. "border-inline-end-style",
  19664. "border-inline-end-width",
  19665. "border-inline-start",
  19666. "border-inline-start-color",
  19667. "border-inline-start-style",
  19668. "border-inline-start-width",
  19669. "border-inline-style",
  19670. "border-inline-width",
  19671. "border-left",
  19672. "border-left-color",
  19673. "border-left-style",
  19674. "border-left-width",
  19675. "border-radius",
  19676. "border-right",
  19677. "border-right-color",
  19678. "border-right-style",
  19679. "border-right-width",
  19680. "border-spacing",
  19681. "border-start-end-radius",
  19682. "border-start-start-radius",
  19683. "border-style",
  19684. "border-top",
  19685. "border-top-color",
  19686. "border-top-left-radius",
  19687. "border-top-right-radius",
  19688. "border-top-style",
  19689. "border-top-width",
  19690. "border-width",
  19691. "borderBlock",
  19692. "borderBlockColor",
  19693. "borderBlockEnd",
  19694. "borderBlockEndColor",
  19695. "borderBlockEndStyle",
  19696. "borderBlockEndWidth",
  19697. "borderBlockStart",
  19698. "borderBlockStartColor",
  19699. "borderBlockStartStyle",
  19700. "borderBlockStartWidth",
  19701. "borderBlockStyle",
  19702. "borderBlockWidth",
  19703. "borderBottom",
  19704. "borderBottomColor",
  19705. "borderBottomLeftRadius",
  19706. "borderBottomRightRadius",
  19707. "borderBottomStyle",
  19708. "borderBottomWidth",
  19709. "borderBoxSize",
  19710. "borderCollapse",
  19711. "borderColor",
  19712. "borderColorDark",
  19713. "borderColorLight",
  19714. "borderEndEndRadius",
  19715. "borderEndStartRadius",
  19716. "borderImage",
  19717. "borderImageOutset",
  19718. "borderImageRepeat",
  19719. "borderImageSlice",
  19720. "borderImageSource",
  19721. "borderImageWidth",
  19722. "borderInline",
  19723. "borderInlineColor",
  19724. "borderInlineEnd",
  19725. "borderInlineEndColor",
  19726. "borderInlineEndStyle",
  19727. "borderInlineEndWidth",
  19728. "borderInlineStart",
  19729. "borderInlineStartColor",
  19730. "borderInlineStartStyle",
  19731. "borderInlineStartWidth",
  19732. "borderInlineStyle",
  19733. "borderInlineWidth",
  19734. "borderLeft",
  19735. "borderLeftColor",
  19736. "borderLeftStyle",
  19737. "borderLeftWidth",
  19738. "borderRadius",
  19739. "borderRight",
  19740. "borderRightColor",
  19741. "borderRightStyle",
  19742. "borderRightWidth",
  19743. "borderSpacing",
  19744. "borderStartEndRadius",
  19745. "borderStartStartRadius",
  19746. "borderStyle",
  19747. "borderTop",
  19748. "borderTopColor",
  19749. "borderTopLeftRadius",
  19750. "borderTopRightRadius",
  19751. "borderTopStyle",
  19752. "borderTopWidth",
  19753. "borderWidth",
  19754. "bottom",
  19755. "bottomMargin",
  19756. "bound",
  19757. "boundElements",
  19758. "boundingClientRect",
  19759. "boundingHeight",
  19760. "boundingLeft",
  19761. "boundingTop",
  19762. "boundingWidth",
  19763. "bounds",
  19764. "boundsGeometry",
  19765. "box-decoration-break",
  19766. "box-shadow",
  19767. "box-sizing",
  19768. "boxDecorationBreak",
  19769. "boxShadow",
  19770. "boxSizing",
  19771. "break-after",
  19772. "break-before",
  19773. "break-inside",
  19774. "breakAfter",
  19775. "breakBefore",
  19776. "breakInside",
  19777. "broadcast",
  19778. "browserLanguage",
  19779. "btoa",
  19780. "bubbles",
  19781. "buffer",
  19782. "bufferData",
  19783. "bufferDepth",
  19784. "bufferSize",
  19785. "bufferSubData",
  19786. "buffered",
  19787. "bufferedAmount",
  19788. "bufferedAmountLowThreshold",
  19789. "buildID",
  19790. "buildNumber",
  19791. "button",
  19792. "buttonID",
  19793. "buttons",
  19794. "byteLength",
  19795. "byteOffset",
  19796. "bytesWritten",
  19797. "c",
  19798. "cache",
  19799. "caches",
  19800. "call",
  19801. "caller",
  19802. "canBeFormatted",
  19803. "canBeMounted",
  19804. "canBeShared",
  19805. "canHaveChildren",
  19806. "canHaveHTML",
  19807. "canInsertDTMF",
  19808. "canMakePayment",
  19809. "canPlayType",
  19810. "canPresent",
  19811. "canTrickleIceCandidates",
  19812. "cancel",
  19813. "cancelAndHoldAtTime",
  19814. "cancelAnimationFrame",
  19815. "cancelBubble",
  19816. "cancelIdleCallback",
  19817. "cancelScheduledValues",
  19818. "cancelVideoFrameCallback",
  19819. "cancelWatchAvailability",
  19820. "cancelable",
  19821. "candidate",
  19822. "canonicalUUID",
  19823. "canvas",
  19824. "capabilities",
  19825. "caption",
  19826. "caption-side",
  19827. "captionSide",
  19828. "capture",
  19829. "captureEvents",
  19830. "captureStackTrace",
  19831. "captureStream",
  19832. "caret-color",
  19833. "caretBidiLevel",
  19834. "caretColor",
  19835. "caretPositionFromPoint",
  19836. "caretRangeFromPoint",
  19837. "cast",
  19838. "catch",
  19839. "category",
  19840. "cbrt",
  19841. "cd",
  19842. "ceil",
  19843. "cellIndex",
  19844. "cellPadding",
  19845. "cellSpacing",
  19846. "cells",
  19847. "ch",
  19848. "chOff",
  19849. "chain",
  19850. "challenge",
  19851. "changeType",
  19852. "changedTouches",
  19853. "channel",
  19854. "channelCount",
  19855. "channelCountMode",
  19856. "channelInterpretation",
  19857. "char",
  19858. "charAt",
  19859. "charCode",
  19860. "charCodeAt",
  19861. "charIndex",
  19862. "charLength",
  19863. "characterData",
  19864. "characterDataOldValue",
  19865. "characterSet",
  19866. "characteristic",
  19867. "charging",
  19868. "chargingTime",
  19869. "charset",
  19870. "check",
  19871. "checkEnclosure",
  19872. "checkFramebufferStatus",
  19873. "checkIntersection",
  19874. "checkValidity",
  19875. "checked",
  19876. "childElementCount",
  19877. "childList",
  19878. "childNodes",
  19879. "children",
  19880. "chrome",
  19881. "ciphertext",
  19882. "cite",
  19883. "city",
  19884. "claimInterface",
  19885. "claimed",
  19886. "classList",
  19887. "className",
  19888. "classid",
  19889. "clear",
  19890. "clearAppBadge",
  19891. "clearAttributes",
  19892. "clearBufferfi",
  19893. "clearBufferfv",
  19894. "clearBufferiv",
  19895. "clearBufferuiv",
  19896. "clearColor",
  19897. "clearData",
  19898. "clearDepth",
  19899. "clearHalt",
  19900. "clearImmediate",
  19901. "clearInterval",
  19902. "clearLiveSeekableRange",
  19903. "clearMarks",
  19904. "clearMaxGCPauseAccumulator",
  19905. "clearMeasures",
  19906. "clearParameters",
  19907. "clearRect",
  19908. "clearResourceTimings",
  19909. "clearShadow",
  19910. "clearStencil",
  19911. "clearTimeout",
  19912. "clearWatch",
  19913. "click",
  19914. "clickCount",
  19915. "clientDataJSON",
  19916. "clientHeight",
  19917. "clientInformation",
  19918. "clientLeft",
  19919. "clientRect",
  19920. "clientRects",
  19921. "clientTop",
  19922. "clientWaitSync",
  19923. "clientWidth",
  19924. "clientX",
  19925. "clientY",
  19926. "clip",
  19927. "clip-path",
  19928. "clip-rule",
  19929. "clipBottom",
  19930. "clipLeft",
  19931. "clipPath",
  19932. "clipPathUnits",
  19933. "clipRight",
  19934. "clipRule",
  19935. "clipTop",
  19936. "clipboard",
  19937. "clipboardData",
  19938. "clone",
  19939. "cloneContents",
  19940. "cloneNode",
  19941. "cloneRange",
  19942. "close",
  19943. "closePath",
  19944. "closed",
  19945. "closest",
  19946. "clz",
  19947. "clz32",
  19948. "cm",
  19949. "cmp",
  19950. "code",
  19951. "codeBase",
  19952. "codePointAt",
  19953. "codeType",
  19954. "colSpan",
  19955. "collapse",
  19956. "collapseToEnd",
  19957. "collapseToStart",
  19958. "collapsed",
  19959. "collect",
  19960. "colno",
  19961. "color",
  19962. "color-adjust",
  19963. "color-interpolation",
  19964. "color-interpolation-filters",
  19965. "colorAdjust",
  19966. "colorDepth",
  19967. "colorInterpolation",
  19968. "colorInterpolationFilters",
  19969. "colorMask",
  19970. "colorType",
  19971. "cols",
  19972. "column-count",
  19973. "column-fill",
  19974. "column-gap",
  19975. "column-rule",
  19976. "column-rule-color",
  19977. "column-rule-style",
  19978. "column-rule-width",
  19979. "column-span",
  19980. "column-width",
  19981. "columnCount",
  19982. "columnFill",
  19983. "columnGap",
  19984. "columnNumber",
  19985. "columnRule",
  19986. "columnRuleColor",
  19987. "columnRuleStyle",
  19988. "columnRuleWidth",
  19989. "columnSpan",
  19990. "columnWidth",
  19991. "columns",
  19992. "command",
  19993. "commit",
  19994. "commitPreferences",
  19995. "commitStyles",
  19996. "commonAncestorContainer",
  19997. "compact",
  19998. "compareBoundaryPoints",
  19999. "compareDocumentPosition",
  20000. "compareEndPoints",
  20001. "compareExchange",
  20002. "compareNode",
  20003. "comparePoint",
  20004. "compatMode",
  20005. "compatible",
  20006. "compile",
  20007. "compileShader",
  20008. "compileStreaming",
  20009. "complete",
  20010. "component",
  20011. "componentFromPoint",
  20012. "composed",
  20013. "composedPath",
  20014. "composite",
  20015. "compositionEndOffset",
  20016. "compositionStartOffset",
  20017. "compressedTexImage2D",
  20018. "compressedTexImage3D",
  20019. "compressedTexSubImage2D",
  20020. "compressedTexSubImage3D",
  20021. "computedStyleMap",
  20022. "concat",
  20023. "conditionText",
  20024. "coneInnerAngle",
  20025. "coneOuterAngle",
  20026. "coneOuterGain",
  20027. "configuration",
  20028. "configurationName",
  20029. "configurationValue",
  20030. "configurations",
  20031. "confirm",
  20032. "confirmComposition",
  20033. "confirmSiteSpecificTrackingException",
  20034. "confirmWebWideTrackingException",
  20035. "connect",
  20036. "connectEnd",
  20037. "connectShark",
  20038. "connectStart",
  20039. "connected",
  20040. "connection",
  20041. "connectionList",
  20042. "connectionSpeed",
  20043. "connectionState",
  20044. "connections",
  20045. "console",
  20046. "consolidate",
  20047. "constraint",
  20048. "constrictionActive",
  20049. "construct",
  20050. "constructor",
  20051. "contactID",
  20052. "contain",
  20053. "containerId",
  20054. "containerName",
  20055. "containerSrc",
  20056. "containerType",
  20057. "contains",
  20058. "containsNode",
  20059. "content",
  20060. "contentBoxSize",
  20061. "contentDocument",
  20062. "contentEditable",
  20063. "contentHint",
  20064. "contentOverflow",
  20065. "contentRect",
  20066. "contentScriptType",
  20067. "contentStyleType",
  20068. "contentType",
  20069. "contentWindow",
  20070. "context",
  20071. "contextMenu",
  20072. "contextmenu",
  20073. "continue",
  20074. "continuePrimaryKey",
  20075. "continuous",
  20076. "control",
  20077. "controlTransferIn",
  20078. "controlTransferOut",
  20079. "controller",
  20080. "controls",
  20081. "controlsList",
  20082. "convertPointFromNode",
  20083. "convertQuadFromNode",
  20084. "convertRectFromNode",
  20085. "convertToBlob",
  20086. "convertToSpecifiedUnits",
  20087. "cookie",
  20088. "cookieEnabled",
  20089. "coords",
  20090. "copyBufferSubData",
  20091. "copyFromChannel",
  20092. "copyTexImage2D",
  20093. "copyTexSubImage2D",
  20094. "copyTexSubImage3D",
  20095. "copyToChannel",
  20096. "copyWithin",
  20097. "correspondingElement",
  20098. "correspondingUseElement",
  20099. "corruptedVideoFrames",
  20100. "cos",
  20101. "cosh",
  20102. "count",
  20103. "countReset",
  20104. "counter-increment",
  20105. "counter-reset",
  20106. "counter-set",
  20107. "counterIncrement",
  20108. "counterReset",
  20109. "counterSet",
  20110. "country",
  20111. "cpuClass",
  20112. "cpuSleepAllowed",
  20113. "create",
  20114. "createAnalyser",
  20115. "createAnswer",
  20116. "createAttribute",
  20117. "createAttributeNS",
  20118. "createBiquadFilter",
  20119. "createBuffer",
  20120. "createBufferSource",
  20121. "createCDATASection",
  20122. "createCSSStyleSheet",
  20123. "createCaption",
  20124. "createChannelMerger",
  20125. "createChannelSplitter",
  20126. "createComment",
  20127. "createConstantSource",
  20128. "createContextualFragment",
  20129. "createControlRange",
  20130. "createConvolver",
  20131. "createDTMFSender",
  20132. "createDataChannel",
  20133. "createDelay",
  20134. "createDelayNode",
  20135. "createDocument",
  20136. "createDocumentFragment",
  20137. "createDocumentType",
  20138. "createDynamicsCompressor",
  20139. "createElement",
  20140. "createElementNS",
  20141. "createEntityReference",
  20142. "createEvent",
  20143. "createEventObject",
  20144. "createExpression",
  20145. "createFramebuffer",
  20146. "createFunction",
  20147. "createGain",
  20148. "createGainNode",
  20149. "createHTML",
  20150. "createHTMLDocument",
  20151. "createIIRFilter",
  20152. "createImageBitmap",
  20153. "createImageData",
  20154. "createIndex",
  20155. "createJavaScriptNode",
  20156. "createLinearGradient",
  20157. "createMediaElementSource",
  20158. "createMediaKeys",
  20159. "createMediaStreamDestination",
  20160. "createMediaStreamSource",
  20161. "createMediaStreamTrackSource",
  20162. "createMutableFile",
  20163. "createNSResolver",
  20164. "createNodeIterator",
  20165. "createNotification",
  20166. "createObjectStore",
  20167. "createObjectURL",
  20168. "createOffer",
  20169. "createOscillator",
  20170. "createPanner",
  20171. "createPattern",
  20172. "createPeriodicWave",
  20173. "createPolicy",
  20174. "createPopup",
  20175. "createProcessingInstruction",
  20176. "createProgram",
  20177. "createQuery",
  20178. "createRadialGradient",
  20179. "createRange",
  20180. "createRangeCollection",
  20181. "createReader",
  20182. "createRenderbuffer",
  20183. "createSVGAngle",
  20184. "createSVGLength",
  20185. "createSVGMatrix",
  20186. "createSVGNumber",
  20187. "createSVGPathSegArcAbs",
  20188. "createSVGPathSegArcRel",
  20189. "createSVGPathSegClosePath",
  20190. "createSVGPathSegCurvetoCubicAbs",
  20191. "createSVGPathSegCurvetoCubicRel",
  20192. "createSVGPathSegCurvetoCubicSmoothAbs",
  20193. "createSVGPathSegCurvetoCubicSmoothRel",
  20194. "createSVGPathSegCurvetoQuadraticAbs",
  20195. "createSVGPathSegCurvetoQuadraticRel",
  20196. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  20197. "createSVGPathSegCurvetoQuadraticSmoothRel",
  20198. "createSVGPathSegLinetoAbs",
  20199. "createSVGPathSegLinetoHorizontalAbs",
  20200. "createSVGPathSegLinetoHorizontalRel",
  20201. "createSVGPathSegLinetoRel",
  20202. "createSVGPathSegLinetoVerticalAbs",
  20203. "createSVGPathSegLinetoVerticalRel",
  20204. "createSVGPathSegMovetoAbs",
  20205. "createSVGPathSegMovetoRel",
  20206. "createSVGPoint",
  20207. "createSVGRect",
  20208. "createSVGTransform",
  20209. "createSVGTransformFromMatrix",
  20210. "createSampler",
  20211. "createScript",
  20212. "createScriptProcessor",
  20213. "createScriptURL",
  20214. "createSession",
  20215. "createShader",
  20216. "createShadowRoot",
  20217. "createStereoPanner",
  20218. "createStyleSheet",
  20219. "createTBody",
  20220. "createTFoot",
  20221. "createTHead",
  20222. "createTextNode",
  20223. "createTextRange",
  20224. "createTexture",
  20225. "createTouch",
  20226. "createTouchList",
  20227. "createTransformFeedback",
  20228. "createTreeWalker",
  20229. "createVertexArray",
  20230. "createWaveShaper",
  20231. "creationTime",
  20232. "credentials",
  20233. "crossOrigin",
  20234. "crossOriginIsolated",
  20235. "crypto",
  20236. "csi",
  20237. "csp",
  20238. "cssFloat",
  20239. "cssRules",
  20240. "cssText",
  20241. "cssValueType",
  20242. "ctrlKey",
  20243. "ctrlLeft",
  20244. "cues",
  20245. "cullFace",
  20246. "currentDirection",
  20247. "currentLocalDescription",
  20248. "currentNode",
  20249. "currentPage",
  20250. "currentRect",
  20251. "currentRemoteDescription",
  20252. "currentScale",
  20253. "currentScript",
  20254. "currentSrc",
  20255. "currentState",
  20256. "currentStyle",
  20257. "currentTarget",
  20258. "currentTime",
  20259. "currentTranslate",
  20260. "currentView",
  20261. "cursor",
  20262. "curve",
  20263. "customElements",
  20264. "customError",
  20265. "cx",
  20266. "cy",
  20267. "d",
  20268. "data",
  20269. "dataFld",
  20270. "dataFormatAs",
  20271. "dataLoss",
  20272. "dataLossMessage",
  20273. "dataPageSize",
  20274. "dataSrc",
  20275. "dataTransfer",
  20276. "database",
  20277. "databases",
  20278. "dataset",
  20279. "dateTime",
  20280. "db",
  20281. "debug",
  20282. "debuggerEnabled",
  20283. "declare",
  20284. "decode",
  20285. "decodeAudioData",
  20286. "decodeURI",
  20287. "decodeURIComponent",
  20288. "decodedBodySize",
  20289. "decoding",
  20290. "decodingInfo",
  20291. "decrypt",
  20292. "default",
  20293. "defaultCharset",
  20294. "defaultChecked",
  20295. "defaultMuted",
  20296. "defaultPlaybackRate",
  20297. "defaultPolicy",
  20298. "defaultPrevented",
  20299. "defaultRequest",
  20300. "defaultSelected",
  20301. "defaultStatus",
  20302. "defaultURL",
  20303. "defaultValue",
  20304. "defaultView",
  20305. "defaultstatus",
  20306. "defer",
  20307. "define",
  20308. "defineMagicFunction",
  20309. "defineMagicVariable",
  20310. "defineProperties",
  20311. "defineProperty",
  20312. "deg",
  20313. "delay",
  20314. "delayTime",
  20315. "delegatesFocus",
  20316. "delete",
  20317. "deleteBuffer",
  20318. "deleteCaption",
  20319. "deleteCell",
  20320. "deleteContents",
  20321. "deleteData",
  20322. "deleteDatabase",
  20323. "deleteFramebuffer",
  20324. "deleteFromDocument",
  20325. "deleteIndex",
  20326. "deleteMedium",
  20327. "deleteObjectStore",
  20328. "deleteProgram",
  20329. "deleteProperty",
  20330. "deleteQuery",
  20331. "deleteRenderbuffer",
  20332. "deleteRow",
  20333. "deleteRule",
  20334. "deleteSampler",
  20335. "deleteShader",
  20336. "deleteSync",
  20337. "deleteTFoot",
  20338. "deleteTHead",
  20339. "deleteTexture",
  20340. "deleteTransformFeedback",
  20341. "deleteVertexArray",
  20342. "deliverChangeRecords",
  20343. "delivery",
  20344. "deliveryInfo",
  20345. "deliveryStatus",
  20346. "deliveryTimestamp",
  20347. "delta",
  20348. "deltaMode",
  20349. "deltaX",
  20350. "deltaY",
  20351. "deltaZ",
  20352. "dependentLocality",
  20353. "depthFar",
  20354. "depthFunc",
  20355. "depthMask",
  20356. "depthNear",
  20357. "depthRange",
  20358. "deref",
  20359. "deriveBits",
  20360. "deriveKey",
  20361. "description",
  20362. "deselectAll",
  20363. "designMode",
  20364. "desiredSize",
  20365. "destination",
  20366. "destinationURL",
  20367. "detach",
  20368. "detachEvent",
  20369. "detachShader",
  20370. "detail",
  20371. "details",
  20372. "detect",
  20373. "detune",
  20374. "device",
  20375. "deviceClass",
  20376. "deviceId",
  20377. "deviceMemory",
  20378. "devicePixelContentBoxSize",
  20379. "devicePixelRatio",
  20380. "deviceProtocol",
  20381. "deviceSubclass",
  20382. "deviceVersionMajor",
  20383. "deviceVersionMinor",
  20384. "deviceVersionSubminor",
  20385. "deviceXDPI",
  20386. "deviceYDPI",
  20387. "didTimeout",
  20388. "diffuseConstant",
  20389. "digest",
  20390. "dimensions",
  20391. "dir",
  20392. "dirName",
  20393. "direction",
  20394. "dirxml",
  20395. "disable",
  20396. "disablePictureInPicture",
  20397. "disableRemotePlayback",
  20398. "disableVertexAttribArray",
  20399. "disabled",
  20400. "dischargingTime",
  20401. "disconnect",
  20402. "disconnectShark",
  20403. "dispatchEvent",
  20404. "display",
  20405. "displayId",
  20406. "displayName",
  20407. "disposition",
  20408. "distanceModel",
  20409. "div",
  20410. "divisor",
  20411. "djsapi",
  20412. "djsproxy",
  20413. "doImport",
  20414. "doNotTrack",
  20415. "doScroll",
  20416. "doctype",
  20417. "document",
  20418. "documentElement",
  20419. "documentMode",
  20420. "documentURI",
  20421. "dolphin",
  20422. "dolphinGameCenter",
  20423. "dolphininfo",
  20424. "dolphinmeta",
  20425. "domComplete",
  20426. "domContentLoadedEventEnd",
  20427. "domContentLoadedEventStart",
  20428. "domInteractive",
  20429. "domLoading",
  20430. "domOverlayState",
  20431. "domain",
  20432. "domainLookupEnd",
  20433. "domainLookupStart",
  20434. "dominant-baseline",
  20435. "dominantBaseline",
  20436. "done",
  20437. "dopplerFactor",
  20438. "dotAll",
  20439. "downDegrees",
  20440. "downlink",
  20441. "download",
  20442. "downloadTotal",
  20443. "downloaded",
  20444. "dpcm",
  20445. "dpi",
  20446. "dppx",
  20447. "dragDrop",
  20448. "draggable",
  20449. "drawArrays",
  20450. "drawArraysInstanced",
  20451. "drawArraysInstancedANGLE",
  20452. "drawBuffers",
  20453. "drawCustomFocusRing",
  20454. "drawElements",
  20455. "drawElementsInstanced",
  20456. "drawElementsInstancedANGLE",
  20457. "drawFocusIfNeeded",
  20458. "drawImage",
  20459. "drawImageFromRect",
  20460. "drawRangeElements",
  20461. "drawSystemFocusRing",
  20462. "drawingBufferHeight",
  20463. "drawingBufferWidth",
  20464. "dropEffect",
  20465. "droppedVideoFrames",
  20466. "dropzone",
  20467. "dtmf",
  20468. "dump",
  20469. "dumpProfile",
  20470. "duplicate",
  20471. "durability",
  20472. "duration",
  20473. "dvname",
  20474. "dvnum",
  20475. "dx",
  20476. "dy",
  20477. "dynsrc",
  20478. "e",
  20479. "edgeMode",
  20480. "effect",
  20481. "effectAllowed",
  20482. "effectiveDirective",
  20483. "effectiveType",
  20484. "elapsedTime",
  20485. "element",
  20486. "elementFromPoint",
  20487. "elementTiming",
  20488. "elements",
  20489. "elementsFromPoint",
  20490. "elevation",
  20491. "ellipse",
  20492. "em",
  20493. "email",
  20494. "embeds",
  20495. "emma",
  20496. "empty",
  20497. "empty-cells",
  20498. "emptyCells",
  20499. "emptyHTML",
  20500. "emptyScript",
  20501. "emulatedPosition",
  20502. "enable",
  20503. "enableBackground",
  20504. "enableDelegations",
  20505. "enableStyleSheetsForSet",
  20506. "enableVertexAttribArray",
  20507. "enabled",
  20508. "enabledPlugin",
  20509. "encode",
  20510. "encodeInto",
  20511. "encodeURI",
  20512. "encodeURIComponent",
  20513. "encodedBodySize",
  20514. "encoding",
  20515. "encodingInfo",
  20516. "encrypt",
  20517. "enctype",
  20518. "end",
  20519. "endContainer",
  20520. "endElement",
  20521. "endElementAt",
  20522. "endOfStream",
  20523. "endOffset",
  20524. "endQuery",
  20525. "endTime",
  20526. "endTransformFeedback",
  20527. "ended",
  20528. "endpoint",
  20529. "endpointNumber",
  20530. "endpoints",
  20531. "endsWith",
  20532. "enterKeyHint",
  20533. "entities",
  20534. "entries",
  20535. "entryType",
  20536. "enumerate",
  20537. "enumerateDevices",
  20538. "enumerateEditable",
  20539. "environmentBlendMode",
  20540. "equals",
  20541. "error",
  20542. "errorCode",
  20543. "errorDetail",
  20544. "errorText",
  20545. "escape",
  20546. "estimate",
  20547. "eval",
  20548. "evaluate",
  20549. "event",
  20550. "eventPhase",
  20551. "every",
  20552. "ex",
  20553. "exception",
  20554. "exchange",
  20555. "exec",
  20556. "execCommand",
  20557. "execCommandShowHelp",
  20558. "execScript",
  20559. "exitFullscreen",
  20560. "exitPictureInPicture",
  20561. "exitPointerLock",
  20562. "exitPresent",
  20563. "exp",
  20564. "expand",
  20565. "expandEntityReferences",
  20566. "expando",
  20567. "expansion",
  20568. "expiration",
  20569. "expirationTime",
  20570. "expires",
  20571. "expiryDate",
  20572. "explicitOriginalTarget",
  20573. "expm1",
  20574. "exponent",
  20575. "exponentialRampToValueAtTime",
  20576. "exportKey",
  20577. "extend",
  20578. "extensions",
  20579. "extentNode",
  20580. "extentOffset",
  20581. "external",
  20582. "externalResourcesRequired",
  20583. "extractContents",
  20584. "extractable",
  20585. "eye",
  20586. "f",
  20587. "face",
  20588. "factoryReset",
  20589. "failureReason",
  20590. "fallback",
  20591. "family",
  20592. "familyName",
  20593. "farthestViewportElement",
  20594. "fastSeek",
  20595. "fatal",
  20596. "featureId",
  20597. "featurePolicy",
  20598. "featureSettings",
  20599. "features",
  20600. "fenceSync",
  20601. "fetch",
  20602. "fetchStart",
  20603. "fftSize",
  20604. "fgColor",
  20605. "fieldOfView",
  20606. "file",
  20607. "fileCreatedDate",
  20608. "fileHandle",
  20609. "fileModifiedDate",
  20610. "fileName",
  20611. "fileSize",
  20612. "fileUpdatedDate",
  20613. "filename",
  20614. "files",
  20615. "filesystem",
  20616. "fill",
  20617. "fill-opacity",
  20618. "fill-rule",
  20619. "fillLightMode",
  20620. "fillOpacity",
  20621. "fillRect",
  20622. "fillRule",
  20623. "fillStyle",
  20624. "fillText",
  20625. "filter",
  20626. "filterResX",
  20627. "filterResY",
  20628. "filterUnits",
  20629. "filters",
  20630. "finally",
  20631. "find",
  20632. "findIndex",
  20633. "findRule",
  20634. "findText",
  20635. "finish",
  20636. "finished",
  20637. "fireEvent",
  20638. "firesTouchEvents",
  20639. "firstChild",
  20640. "firstElementChild",
  20641. "firstPage",
  20642. "fixed",
  20643. "flags",
  20644. "flat",
  20645. "flatMap",
  20646. "flex",
  20647. "flex-basis",
  20648. "flex-direction",
  20649. "flex-flow",
  20650. "flex-grow",
  20651. "flex-shrink",
  20652. "flex-wrap",
  20653. "flexBasis",
  20654. "flexDirection",
  20655. "flexFlow",
  20656. "flexGrow",
  20657. "flexShrink",
  20658. "flexWrap",
  20659. "flipX",
  20660. "flipY",
  20661. "float",
  20662. "float32",
  20663. "float64",
  20664. "flood-color",
  20665. "flood-opacity",
  20666. "floodColor",
  20667. "floodOpacity",
  20668. "floor",
  20669. "flush",
  20670. "focus",
  20671. "focusNode",
  20672. "focusOffset",
  20673. "font",
  20674. "font-family",
  20675. "font-feature-settings",
  20676. "font-kerning",
  20677. "font-language-override",
  20678. "font-optical-sizing",
  20679. "font-size",
  20680. "font-size-adjust",
  20681. "font-stretch",
  20682. "font-style",
  20683. "font-synthesis",
  20684. "font-variant",
  20685. "font-variant-alternates",
  20686. "font-variant-caps",
  20687. "font-variant-east-asian",
  20688. "font-variant-ligatures",
  20689. "font-variant-numeric",
  20690. "font-variant-position",
  20691. "font-variation-settings",
  20692. "font-weight",
  20693. "fontFamily",
  20694. "fontFeatureSettings",
  20695. "fontKerning",
  20696. "fontLanguageOverride",
  20697. "fontOpticalSizing",
  20698. "fontSize",
  20699. "fontSizeAdjust",
  20700. "fontSmoothingEnabled",
  20701. "fontStretch",
  20702. "fontStyle",
  20703. "fontSynthesis",
  20704. "fontVariant",
  20705. "fontVariantAlternates",
  20706. "fontVariantCaps",
  20707. "fontVariantEastAsian",
  20708. "fontVariantLigatures",
  20709. "fontVariantNumeric",
  20710. "fontVariantPosition",
  20711. "fontVariationSettings",
  20712. "fontWeight",
  20713. "fontcolor",
  20714. "fontfaces",
  20715. "fonts",
  20716. "fontsize",
  20717. "for",
  20718. "forEach",
  20719. "force",
  20720. "forceRedraw",
  20721. "form",
  20722. "formAction",
  20723. "formData",
  20724. "formEnctype",
  20725. "formMethod",
  20726. "formNoValidate",
  20727. "formTarget",
  20728. "format",
  20729. "formatToParts",
  20730. "forms",
  20731. "forward",
  20732. "forwardX",
  20733. "forwardY",
  20734. "forwardZ",
  20735. "foundation",
  20736. "fr",
  20737. "fragmentDirective",
  20738. "frame",
  20739. "frameBorder",
  20740. "frameElement",
  20741. "frameSpacing",
  20742. "framebuffer",
  20743. "framebufferHeight",
  20744. "framebufferRenderbuffer",
  20745. "framebufferTexture2D",
  20746. "framebufferTextureLayer",
  20747. "framebufferWidth",
  20748. "frames",
  20749. "freeSpace",
  20750. "freeze",
  20751. "frequency",
  20752. "frequencyBinCount",
  20753. "from",
  20754. "fromCharCode",
  20755. "fromCodePoint",
  20756. "fromElement",
  20757. "fromEntries",
  20758. "fromFloat32Array",
  20759. "fromFloat64Array",
  20760. "fromMatrix",
  20761. "fromPoint",
  20762. "fromQuad",
  20763. "fromRect",
  20764. "frontFace",
  20765. "fround",
  20766. "fullPath",
  20767. "fullScreen",
  20768. "fullscreen",
  20769. "fullscreenElement",
  20770. "fullscreenEnabled",
  20771. "fx",
  20772. "fy",
  20773. "gain",
  20774. "gamepad",
  20775. "gamma",
  20776. "gap",
  20777. "gatheringState",
  20778. "gatt",
  20779. "genderIdentity",
  20780. "generateCertificate",
  20781. "generateKey",
  20782. "generateMipmap",
  20783. "generateRequest",
  20784. "geolocation",
  20785. "gestureObject",
  20786. "get",
  20787. "getActiveAttrib",
  20788. "getActiveUniform",
  20789. "getActiveUniformBlockName",
  20790. "getActiveUniformBlockParameter",
  20791. "getActiveUniforms",
  20792. "getAdjacentText",
  20793. "getAll",
  20794. "getAllKeys",
  20795. "getAllResponseHeaders",
  20796. "getAllowlistForFeature",
  20797. "getAnimations",
  20798. "getAsFile",
  20799. "getAsString",
  20800. "getAttachedShaders",
  20801. "getAttribLocation",
  20802. "getAttribute",
  20803. "getAttributeNS",
  20804. "getAttributeNames",
  20805. "getAttributeNode",
  20806. "getAttributeNodeNS",
  20807. "getAttributeType",
  20808. "getAudioTracks",
  20809. "getAvailability",
  20810. "getBBox",
  20811. "getBattery",
  20812. "getBigInt64",
  20813. "getBigUint64",
  20814. "getBlob",
  20815. "getBookmark",
  20816. "getBoundingClientRect",
  20817. "getBounds",
  20818. "getBoxQuads",
  20819. "getBufferParameter",
  20820. "getBufferSubData",
  20821. "getByteFrequencyData",
  20822. "getByteTimeDomainData",
  20823. "getCSSCanvasContext",
  20824. "getCTM",
  20825. "getCandidateWindowClientRect",
  20826. "getCanonicalLocales",
  20827. "getCapabilities",
  20828. "getChannelData",
  20829. "getCharNumAtPosition",
  20830. "getCharacteristic",
  20831. "getCharacteristics",
  20832. "getClientExtensionResults",
  20833. "getClientRect",
  20834. "getClientRects",
  20835. "getCoalescedEvents",
  20836. "getCompositionAlternatives",
  20837. "getComputedStyle",
  20838. "getComputedTextLength",
  20839. "getComputedTiming",
  20840. "getConfiguration",
  20841. "getConstraints",
  20842. "getContext",
  20843. "getContextAttributes",
  20844. "getContributingSources",
  20845. "getCounterValue",
  20846. "getCueAsHTML",
  20847. "getCueById",
  20848. "getCurrentPosition",
  20849. "getCurrentTime",
  20850. "getData",
  20851. "getDatabaseNames",
  20852. "getDate",
  20853. "getDay",
  20854. "getDefaultComputedStyle",
  20855. "getDescriptor",
  20856. "getDescriptors",
  20857. "getDestinationInsertionPoints",
  20858. "getDevices",
  20859. "getDirectory",
  20860. "getDisplayMedia",
  20861. "getDistributedNodes",
  20862. "getEditable",
  20863. "getElementById",
  20864. "getElementsByClassName",
  20865. "getElementsByName",
  20866. "getElementsByTagName",
  20867. "getElementsByTagNameNS",
  20868. "getEnclosureList",
  20869. "getEndPositionOfChar",
  20870. "getEntries",
  20871. "getEntriesByName",
  20872. "getEntriesByType",
  20873. "getError",
  20874. "getExtension",
  20875. "getExtentOfChar",
  20876. "getEyeParameters",
  20877. "getFeature",
  20878. "getFile",
  20879. "getFiles",
  20880. "getFilesAndDirectories",
  20881. "getFingerprints",
  20882. "getFloat32",
  20883. "getFloat64",
  20884. "getFloatFrequencyData",
  20885. "getFloatTimeDomainData",
  20886. "getFloatValue",
  20887. "getFragDataLocation",
  20888. "getFrameData",
  20889. "getFramebufferAttachmentParameter",
  20890. "getFrequencyResponse",
  20891. "getFullYear",
  20892. "getGamepads",
  20893. "getHitTestResults",
  20894. "getHitTestResultsForTransientInput",
  20895. "getHours",
  20896. "getIdentityAssertion",
  20897. "getIds",
  20898. "getImageData",
  20899. "getIndexedParameter",
  20900. "getInstalledRelatedApps",
  20901. "getInt16",
  20902. "getInt32",
  20903. "getInt8",
  20904. "getInternalformatParameter",
  20905. "getIntersectionList",
  20906. "getItem",
  20907. "getItems",
  20908. "getKey",
  20909. "getKeyframes",
  20910. "getLayers",
  20911. "getLayoutMap",
  20912. "getLineDash",
  20913. "getLocalCandidates",
  20914. "getLocalParameters",
  20915. "getLocalStreams",
  20916. "getMarks",
  20917. "getMatchedCSSRules",
  20918. "getMaxGCPauseSinceClear",
  20919. "getMeasures",
  20920. "getMetadata",
  20921. "getMilliseconds",
  20922. "getMinutes",
  20923. "getModifierState",
  20924. "getMonth",
  20925. "getNamedItem",
  20926. "getNamedItemNS",
  20927. "getNativeFramebufferScaleFactor",
  20928. "getNotifications",
  20929. "getNotifier",
  20930. "getNumberOfChars",
  20931. "getOffsetReferenceSpace",
  20932. "getOutputTimestamp",
  20933. "getOverrideHistoryNavigationMode",
  20934. "getOverrideStyle",
  20935. "getOwnPropertyDescriptor",
  20936. "getOwnPropertyDescriptors",
  20937. "getOwnPropertyNames",
  20938. "getOwnPropertySymbols",
  20939. "getParameter",
  20940. "getParameters",
  20941. "getParent",
  20942. "getPathSegAtLength",
  20943. "getPhotoCapabilities",
  20944. "getPhotoSettings",
  20945. "getPointAtLength",
  20946. "getPose",
  20947. "getPredictedEvents",
  20948. "getPreference",
  20949. "getPreferenceDefault",
  20950. "getPresentationAttribute",
  20951. "getPreventDefault",
  20952. "getPrimaryService",
  20953. "getPrimaryServices",
  20954. "getProgramInfoLog",
  20955. "getProgramParameter",
  20956. "getPropertyCSSValue",
  20957. "getPropertyPriority",
  20958. "getPropertyShorthand",
  20959. "getPropertyType",
  20960. "getPropertyValue",
  20961. "getPrototypeOf",
  20962. "getQuery",
  20963. "getQueryParameter",
  20964. "getRGBColorValue",
  20965. "getRandomValues",
  20966. "getRangeAt",
  20967. "getReader",
  20968. "getReceivers",
  20969. "getRectValue",
  20970. "getRegistration",
  20971. "getRegistrations",
  20972. "getRemoteCandidates",
  20973. "getRemoteCertificates",
  20974. "getRemoteParameters",
  20975. "getRemoteStreams",
  20976. "getRenderbufferParameter",
  20977. "getResponseHeader",
  20978. "getRoot",
  20979. "getRootNode",
  20980. "getRotationOfChar",
  20981. "getSVGDocument",
  20982. "getSamplerParameter",
  20983. "getScreenCTM",
  20984. "getSeconds",
  20985. "getSelectedCandidatePair",
  20986. "getSelection",
  20987. "getSenders",
  20988. "getService",
  20989. "getSettings",
  20990. "getShaderInfoLog",
  20991. "getShaderParameter",
  20992. "getShaderPrecisionFormat",
  20993. "getShaderSource",
  20994. "getSimpleDuration",
  20995. "getSiteIcons",
  20996. "getSources",
  20997. "getSpeculativeParserUrls",
  20998. "getStartPositionOfChar",
  20999. "getStartTime",
  21000. "getState",
  21001. "getStats",
  21002. "getStatusForPolicy",
  21003. "getStorageUpdates",
  21004. "getStreamById",
  21005. "getStringValue",
  21006. "getSubStringLength",
  21007. "getSubscription",
  21008. "getSupportedConstraints",
  21009. "getSupportedExtensions",
  21010. "getSupportedFormats",
  21011. "getSyncParameter",
  21012. "getSynchronizationSources",
  21013. "getTags",
  21014. "getTargetRanges",
  21015. "getTexParameter",
  21016. "getTime",
  21017. "getTimezoneOffset",
  21018. "getTiming",
  21019. "getTotalLength",
  21020. "getTrackById",
  21021. "getTracks",
  21022. "getTransceivers",
  21023. "getTransform",
  21024. "getTransformFeedbackVarying",
  21025. "getTransformToElement",
  21026. "getTransports",
  21027. "getType",
  21028. "getTypeMapping",
  21029. "getUTCDate",
  21030. "getUTCDay",
  21031. "getUTCFullYear",
  21032. "getUTCHours",
  21033. "getUTCMilliseconds",
  21034. "getUTCMinutes",
  21035. "getUTCMonth",
  21036. "getUTCSeconds",
  21037. "getUint16",
  21038. "getUint32",
  21039. "getUint8",
  21040. "getUniform",
  21041. "getUniformBlockIndex",
  21042. "getUniformIndices",
  21043. "getUniformLocation",
  21044. "getUserMedia",
  21045. "getVRDisplays",
  21046. "getValues",
  21047. "getVarDate",
  21048. "getVariableValue",
  21049. "getVertexAttrib",
  21050. "getVertexAttribOffset",
  21051. "getVideoPlaybackQuality",
  21052. "getVideoTracks",
  21053. "getViewerPose",
  21054. "getViewport",
  21055. "getVoices",
  21056. "getWakeLockState",
  21057. "getWriter",
  21058. "getYear",
  21059. "givenName",
  21060. "global",
  21061. "globalAlpha",
  21062. "globalCompositeOperation",
  21063. "globalThis",
  21064. "glyphOrientationHorizontal",
  21065. "glyphOrientationVertical",
  21066. "glyphRef",
  21067. "go",
  21068. "grabFrame",
  21069. "grad",
  21070. "gradientTransform",
  21071. "gradientUnits",
  21072. "grammars",
  21073. "green",
  21074. "grid",
  21075. "grid-area",
  21076. "grid-auto-columns",
  21077. "grid-auto-flow",
  21078. "grid-auto-rows",
  21079. "grid-column",
  21080. "grid-column-end",
  21081. "grid-column-gap",
  21082. "grid-column-start",
  21083. "grid-gap",
  21084. "grid-row",
  21085. "grid-row-end",
  21086. "grid-row-gap",
  21087. "grid-row-start",
  21088. "grid-template",
  21089. "grid-template-areas",
  21090. "grid-template-columns",
  21091. "grid-template-rows",
  21092. "gridArea",
  21093. "gridAutoColumns",
  21094. "gridAutoFlow",
  21095. "gridAutoRows",
  21096. "gridColumn",
  21097. "gridColumnEnd",
  21098. "gridColumnGap",
  21099. "gridColumnStart",
  21100. "gridGap",
  21101. "gridRow",
  21102. "gridRowEnd",
  21103. "gridRowGap",
  21104. "gridRowStart",
  21105. "gridTemplate",
  21106. "gridTemplateAreas",
  21107. "gridTemplateColumns",
  21108. "gridTemplateRows",
  21109. "gripSpace",
  21110. "group",
  21111. "groupCollapsed",
  21112. "groupEnd",
  21113. "groupId",
  21114. "hadRecentInput",
  21115. "hand",
  21116. "handedness",
  21117. "hapticActuators",
  21118. "hardwareConcurrency",
  21119. "has",
  21120. "hasAttribute",
  21121. "hasAttributeNS",
  21122. "hasAttributes",
  21123. "hasBeenActive",
  21124. "hasChildNodes",
  21125. "hasComposition",
  21126. "hasEnrolledInstrument",
  21127. "hasExtension",
  21128. "hasExternalDisplay",
  21129. "hasFeature",
  21130. "hasFocus",
  21131. "hasInstance",
  21132. "hasLayout",
  21133. "hasOrientation",
  21134. "hasOwnProperty",
  21135. "hasPointerCapture",
  21136. "hasPosition",
  21137. "hasReading",
  21138. "hasStorageAccess",
  21139. "hash",
  21140. "head",
  21141. "headers",
  21142. "heading",
  21143. "height",
  21144. "hidden",
  21145. "hide",
  21146. "hideFocus",
  21147. "high",
  21148. "highWaterMark",
  21149. "hint",
  21150. "history",
  21151. "honorificPrefix",
  21152. "honorificSuffix",
  21153. "horizontalOverflow",
  21154. "host",
  21155. "hostCandidate",
  21156. "hostname",
  21157. "href",
  21158. "hrefTranslate",
  21159. "hreflang",
  21160. "hspace",
  21161. "html5TagCheckInerface",
  21162. "htmlFor",
  21163. "htmlText",
  21164. "httpEquiv",
  21165. "httpRequestStatusCode",
  21166. "hwTimestamp",
  21167. "hyphens",
  21168. "hypot",
  21169. "iccId",
  21170. "iceConnectionState",
  21171. "iceGatheringState",
  21172. "iceTransport",
  21173. "icon",
  21174. "iconURL",
  21175. "id",
  21176. "identifier",
  21177. "identity",
  21178. "idpLoginUrl",
  21179. "ignoreBOM",
  21180. "ignoreCase",
  21181. "ignoreDepthValues",
  21182. "image-orientation",
  21183. "image-rendering",
  21184. "imageHeight",
  21185. "imageOrientation",
  21186. "imageRendering",
  21187. "imageSizes",
  21188. "imageSmoothingEnabled",
  21189. "imageSmoothingQuality",
  21190. "imageSrcset",
  21191. "imageWidth",
  21192. "images",
  21193. "ime-mode",
  21194. "imeMode",
  21195. "implementation",
  21196. "importKey",
  21197. "importNode",
  21198. "importStylesheet",
  21199. "imports",
  21200. "impp",
  21201. "imul",
  21202. "in",
  21203. "in1",
  21204. "in2",
  21205. "inBandMetadataTrackDispatchType",
  21206. "inRange",
  21207. "includes",
  21208. "incremental",
  21209. "indeterminate",
  21210. "index",
  21211. "indexNames",
  21212. "indexOf",
  21213. "indexedDB",
  21214. "indicate",
  21215. "inertiaDestinationX",
  21216. "inertiaDestinationY",
  21217. "info",
  21218. "init",
  21219. "initAnimationEvent",
  21220. "initBeforeLoadEvent",
  21221. "initClipboardEvent",
  21222. "initCloseEvent",
  21223. "initCommandEvent",
  21224. "initCompositionEvent",
  21225. "initCustomEvent",
  21226. "initData",
  21227. "initDataType",
  21228. "initDeviceMotionEvent",
  21229. "initDeviceOrientationEvent",
  21230. "initDragEvent",
  21231. "initErrorEvent",
  21232. "initEvent",
  21233. "initFocusEvent",
  21234. "initGestureEvent",
  21235. "initHashChangeEvent",
  21236. "initKeyEvent",
  21237. "initKeyboardEvent",
  21238. "initMSManipulationEvent",
  21239. "initMessageEvent",
  21240. "initMouseEvent",
  21241. "initMouseScrollEvent",
  21242. "initMouseWheelEvent",
  21243. "initMutationEvent",
  21244. "initNSMouseEvent",
  21245. "initOverflowEvent",
  21246. "initPageEvent",
  21247. "initPageTransitionEvent",
  21248. "initPointerEvent",
  21249. "initPopStateEvent",
  21250. "initProgressEvent",
  21251. "initScrollAreaEvent",
  21252. "initSimpleGestureEvent",
  21253. "initStorageEvent",
  21254. "initTextEvent",
  21255. "initTimeEvent",
  21256. "initTouchEvent",
  21257. "initTransitionEvent",
  21258. "initUIEvent",
  21259. "initWebKitAnimationEvent",
  21260. "initWebKitTransitionEvent",
  21261. "initWebKitWheelEvent",
  21262. "initWheelEvent",
  21263. "initialTime",
  21264. "initialize",
  21265. "initiatorType",
  21266. "inline-size",
  21267. "inlineSize",
  21268. "inlineVerticalFieldOfView",
  21269. "inner",
  21270. "innerHTML",
  21271. "innerHeight",
  21272. "innerText",
  21273. "innerWidth",
  21274. "input",
  21275. "inputBuffer",
  21276. "inputEncoding",
  21277. "inputMethod",
  21278. "inputMode",
  21279. "inputSource",
  21280. "inputSources",
  21281. "inputType",
  21282. "inputs",
  21283. "insertAdjacentElement",
  21284. "insertAdjacentHTML",
  21285. "insertAdjacentText",
  21286. "insertBefore",
  21287. "insertCell",
  21288. "insertDTMF",
  21289. "insertData",
  21290. "insertItemBefore",
  21291. "insertNode",
  21292. "insertRow",
  21293. "insertRule",
  21294. "inset",
  21295. "inset-block",
  21296. "inset-block-end",
  21297. "inset-block-start",
  21298. "inset-inline",
  21299. "inset-inline-end",
  21300. "inset-inline-start",
  21301. "insetBlock",
  21302. "insetBlockEnd",
  21303. "insetBlockStart",
  21304. "insetInline",
  21305. "insetInlineEnd",
  21306. "insetInlineStart",
  21307. "installing",
  21308. "instanceRoot",
  21309. "instantiate",
  21310. "instantiateStreaming",
  21311. "instruments",
  21312. "int16",
  21313. "int32",
  21314. "int8",
  21315. "integrity",
  21316. "interactionMode",
  21317. "intercept",
  21318. "interfaceClass",
  21319. "interfaceName",
  21320. "interfaceNumber",
  21321. "interfaceProtocol",
  21322. "interfaceSubclass",
  21323. "interfaces",
  21324. "interimResults",
  21325. "internalSubset",
  21326. "interpretation",
  21327. "intersectionRatio",
  21328. "intersectionRect",
  21329. "intersectsNode",
  21330. "interval",
  21331. "invalidIteratorState",
  21332. "invalidateFramebuffer",
  21333. "invalidateSubFramebuffer",
  21334. "inverse",
  21335. "invertSelf",
  21336. "is",
  21337. "is2D",
  21338. "isActive",
  21339. "isAlternate",
  21340. "isArray",
  21341. "isBingCurrentSearchDefault",
  21342. "isBuffer",
  21343. "isCandidateWindowVisible",
  21344. "isChar",
  21345. "isCollapsed",
  21346. "isComposing",
  21347. "isConcatSpreadable",
  21348. "isConnected",
  21349. "isContentEditable",
  21350. "isContentHandlerRegistered",
  21351. "isContextLost",
  21352. "isDefaultNamespace",
  21353. "isDirectory",
  21354. "isDisabled",
  21355. "isEnabled",
  21356. "isEqual",
  21357. "isEqualNode",
  21358. "isExtensible",
  21359. "isExternalCTAP2SecurityKeySupported",
  21360. "isFile",
  21361. "isFinite",
  21362. "isFramebuffer",
  21363. "isFrozen",
  21364. "isGenerator",
  21365. "isHTML",
  21366. "isHistoryNavigation",
  21367. "isId",
  21368. "isIdentity",
  21369. "isInjected",
  21370. "isInteger",
  21371. "isIntersecting",
  21372. "isLockFree",
  21373. "isMap",
  21374. "isMultiLine",
  21375. "isNaN",
  21376. "isOpen",
  21377. "isPointInFill",
  21378. "isPointInPath",
  21379. "isPointInRange",
  21380. "isPointInStroke",
  21381. "isPrefAlternate",
  21382. "isPresenting",
  21383. "isPrimary",
  21384. "isProgram",
  21385. "isPropertyImplicit",
  21386. "isProtocolHandlerRegistered",
  21387. "isPrototypeOf",
  21388. "isQuery",
  21389. "isRenderbuffer",
  21390. "isSafeInteger",
  21391. "isSameNode",
  21392. "isSampler",
  21393. "isScript",
  21394. "isScriptURL",
  21395. "isSealed",
  21396. "isSecureContext",
  21397. "isSessionSupported",
  21398. "isShader",
  21399. "isSupported",
  21400. "isSync",
  21401. "isTextEdit",
  21402. "isTexture",
  21403. "isTransformFeedback",
  21404. "isTrusted",
  21405. "isTypeSupported",
  21406. "isUserVerifyingPlatformAuthenticatorAvailable",
  21407. "isVertexArray",
  21408. "isView",
  21409. "isVisible",
  21410. "isochronousTransferIn",
  21411. "isochronousTransferOut",
  21412. "isolation",
  21413. "italics",
  21414. "item",
  21415. "itemId",
  21416. "itemProp",
  21417. "itemRef",
  21418. "itemScope",
  21419. "itemType",
  21420. "itemValue",
  21421. "items",
  21422. "iterateNext",
  21423. "iterationComposite",
  21424. "iterator",
  21425. "javaEnabled",
  21426. "jobTitle",
  21427. "join",
  21428. "json",
  21429. "justify-content",
  21430. "justify-items",
  21431. "justify-self",
  21432. "justifyContent",
  21433. "justifyItems",
  21434. "justifySelf",
  21435. "k1",
  21436. "k2",
  21437. "k3",
  21438. "k4",
  21439. "kHz",
  21440. "keepalive",
  21441. "kernelMatrix",
  21442. "kernelUnitLengthX",
  21443. "kernelUnitLengthY",
  21444. "kerning",
  21445. "key",
  21446. "keyCode",
  21447. "keyFor",
  21448. "keyIdentifier",
  21449. "keyLightEnabled",
  21450. "keyLocation",
  21451. "keyPath",
  21452. "keyStatuses",
  21453. "keySystem",
  21454. "keyText",
  21455. "keyUsage",
  21456. "keyboard",
  21457. "keys",
  21458. "keytype",
  21459. "kind",
  21460. "knee",
  21461. "label",
  21462. "labels",
  21463. "lang",
  21464. "language",
  21465. "languages",
  21466. "largeArcFlag",
  21467. "lastChild",
  21468. "lastElementChild",
  21469. "lastEventId",
  21470. "lastIndex",
  21471. "lastIndexOf",
  21472. "lastInputTime",
  21473. "lastMatch",
  21474. "lastMessageSubject",
  21475. "lastMessageType",
  21476. "lastModified",
  21477. "lastModifiedDate",
  21478. "lastPage",
  21479. "lastParen",
  21480. "lastState",
  21481. "lastStyleSheetSet",
  21482. "latitude",
  21483. "layerX",
  21484. "layerY",
  21485. "layoutFlow",
  21486. "layoutGrid",
  21487. "layoutGridChar",
  21488. "layoutGridLine",
  21489. "layoutGridMode",
  21490. "layoutGridType",
  21491. "lbound",
  21492. "left",
  21493. "leftContext",
  21494. "leftDegrees",
  21495. "leftMargin",
  21496. "leftProjectionMatrix",
  21497. "leftViewMatrix",
  21498. "length",
  21499. "lengthAdjust",
  21500. "lengthComputable",
  21501. "letter-spacing",
  21502. "letterSpacing",
  21503. "level",
  21504. "lighting-color",
  21505. "lightingColor",
  21506. "limitingConeAngle",
  21507. "line",
  21508. "line-break",
  21509. "line-height",
  21510. "lineAlign",
  21511. "lineBreak",
  21512. "lineCap",
  21513. "lineDashOffset",
  21514. "lineHeight",
  21515. "lineJoin",
  21516. "lineNumber",
  21517. "lineTo",
  21518. "lineWidth",
  21519. "linearAcceleration",
  21520. "linearRampToValueAtTime",
  21521. "linearVelocity",
  21522. "lineno",
  21523. "lines",
  21524. "link",
  21525. "linkColor",
  21526. "linkProgram",
  21527. "links",
  21528. "list",
  21529. "list-style",
  21530. "list-style-image",
  21531. "list-style-position",
  21532. "list-style-type",
  21533. "listStyle",
  21534. "listStyleImage",
  21535. "listStylePosition",
  21536. "listStyleType",
  21537. "listener",
  21538. "load",
  21539. "loadEventEnd",
  21540. "loadEventStart",
  21541. "loadTime",
  21542. "loadTimes",
  21543. "loaded",
  21544. "loading",
  21545. "localDescription",
  21546. "localName",
  21547. "localService",
  21548. "localStorage",
  21549. "locale",
  21550. "localeCompare",
  21551. "location",
  21552. "locationbar",
  21553. "lock",
  21554. "locked",
  21555. "lockedFile",
  21556. "locks",
  21557. "log",
  21558. "log10",
  21559. "log1p",
  21560. "log2",
  21561. "logicalXDPI",
  21562. "logicalYDPI",
  21563. "longDesc",
  21564. "longitude",
  21565. "lookupNamespaceURI",
  21566. "lookupPrefix",
  21567. "loop",
  21568. "loopEnd",
  21569. "loopStart",
  21570. "looping",
  21571. "low",
  21572. "lower",
  21573. "lowerBound",
  21574. "lowerOpen",
  21575. "lowsrc",
  21576. "m11",
  21577. "m12",
  21578. "m13",
  21579. "m14",
  21580. "m21",
  21581. "m22",
  21582. "m23",
  21583. "m24",
  21584. "m31",
  21585. "m32",
  21586. "m33",
  21587. "m34",
  21588. "m41",
  21589. "m42",
  21590. "m43",
  21591. "m44",
  21592. "makeXRCompatible",
  21593. "manifest",
  21594. "manufacturer",
  21595. "manufacturerName",
  21596. "map",
  21597. "mapping",
  21598. "margin",
  21599. "margin-block",
  21600. "margin-block-end",
  21601. "margin-block-start",
  21602. "margin-bottom",
  21603. "margin-inline",
  21604. "margin-inline-end",
  21605. "margin-inline-start",
  21606. "margin-left",
  21607. "margin-right",
  21608. "margin-top",
  21609. "marginBlock",
  21610. "marginBlockEnd",
  21611. "marginBlockStart",
  21612. "marginBottom",
  21613. "marginHeight",
  21614. "marginInline",
  21615. "marginInlineEnd",
  21616. "marginInlineStart",
  21617. "marginLeft",
  21618. "marginRight",
  21619. "marginTop",
  21620. "marginWidth",
  21621. "mark",
  21622. "marker",
  21623. "marker-end",
  21624. "marker-mid",
  21625. "marker-offset",
  21626. "marker-start",
  21627. "markerEnd",
  21628. "markerHeight",
  21629. "markerMid",
  21630. "markerOffset",
  21631. "markerStart",
  21632. "markerUnits",
  21633. "markerWidth",
  21634. "marks",
  21635. "mask",
  21636. "mask-clip",
  21637. "mask-composite",
  21638. "mask-image",
  21639. "mask-mode",
  21640. "mask-origin",
  21641. "mask-position",
  21642. "mask-position-x",
  21643. "mask-position-y",
  21644. "mask-repeat",
  21645. "mask-size",
  21646. "mask-type",
  21647. "maskClip",
  21648. "maskComposite",
  21649. "maskContentUnits",
  21650. "maskImage",
  21651. "maskMode",
  21652. "maskOrigin",
  21653. "maskPosition",
  21654. "maskPositionX",
  21655. "maskPositionY",
  21656. "maskRepeat",
  21657. "maskSize",
  21658. "maskType",
  21659. "maskUnits",
  21660. "match",
  21661. "matchAll",
  21662. "matchMedia",
  21663. "matchMedium",
  21664. "matches",
  21665. "matrix",
  21666. "matrixTransform",
  21667. "max",
  21668. "max-block-size",
  21669. "max-height",
  21670. "max-inline-size",
  21671. "max-width",
  21672. "maxActions",
  21673. "maxAlternatives",
  21674. "maxBlockSize",
  21675. "maxChannelCount",
  21676. "maxChannels",
  21677. "maxConnectionsPerServer",
  21678. "maxDecibels",
  21679. "maxDistance",
  21680. "maxHeight",
  21681. "maxInlineSize",
  21682. "maxLayers",
  21683. "maxLength",
  21684. "maxMessageSize",
  21685. "maxPacketLifeTime",
  21686. "maxRetransmits",
  21687. "maxTouchPoints",
  21688. "maxValue",
  21689. "maxWidth",
  21690. "measure",
  21691. "measureText",
  21692. "media",
  21693. "mediaCapabilities",
  21694. "mediaDevices",
  21695. "mediaElement",
  21696. "mediaGroup",
  21697. "mediaKeys",
  21698. "mediaSession",
  21699. "mediaStream",
  21700. "mediaText",
  21701. "meetOrSlice",
  21702. "memory",
  21703. "menubar",
  21704. "mergeAttributes",
  21705. "message",
  21706. "messageClass",
  21707. "messageHandlers",
  21708. "messageType",
  21709. "metaKey",
  21710. "metadata",
  21711. "method",
  21712. "methodDetails",
  21713. "methodName",
  21714. "mid",
  21715. "mimeType",
  21716. "mimeTypes",
  21717. "min",
  21718. "min-block-size",
  21719. "min-height",
  21720. "min-inline-size",
  21721. "min-width",
  21722. "minBlockSize",
  21723. "minDecibels",
  21724. "minHeight",
  21725. "minInlineSize",
  21726. "minLength",
  21727. "minValue",
  21728. "minWidth",
  21729. "miterLimit",
  21730. "mix-blend-mode",
  21731. "mixBlendMode",
  21732. "mm",
  21733. "mode",
  21734. "modify",
  21735. "mount",
  21736. "move",
  21737. "moveBy",
  21738. "moveEnd",
  21739. "moveFirst",
  21740. "moveFocusDown",
  21741. "moveFocusLeft",
  21742. "moveFocusRight",
  21743. "moveFocusUp",
  21744. "moveNext",
  21745. "moveRow",
  21746. "moveStart",
  21747. "moveTo",
  21748. "moveToBookmark",
  21749. "moveToElementText",
  21750. "moveToPoint",
  21751. "movementX",
  21752. "movementY",
  21753. "mozAdd",
  21754. "mozAnimationStartTime",
  21755. "mozAnon",
  21756. "mozApps",
  21757. "mozAudioCaptured",
  21758. "mozAudioChannelType",
  21759. "mozAutoplayEnabled",
  21760. "mozCancelAnimationFrame",
  21761. "mozCancelFullScreen",
  21762. "mozCancelRequestAnimationFrame",
  21763. "mozCaptureStream",
  21764. "mozCaptureStreamUntilEnded",
  21765. "mozClearDataAt",
  21766. "mozContact",
  21767. "mozContacts",
  21768. "mozCreateFileHandle",
  21769. "mozCurrentTransform",
  21770. "mozCurrentTransformInverse",
  21771. "mozCursor",
  21772. "mozDash",
  21773. "mozDashOffset",
  21774. "mozDecodedFrames",
  21775. "mozExitPointerLock",
  21776. "mozFillRule",
  21777. "mozFragmentEnd",
  21778. "mozFrameDelay",
  21779. "mozFullScreen",
  21780. "mozFullScreenElement",
  21781. "mozFullScreenEnabled",
  21782. "mozGetAll",
  21783. "mozGetAllKeys",
  21784. "mozGetAsFile",
  21785. "mozGetDataAt",
  21786. "mozGetMetadata",
  21787. "mozGetUserMedia",
  21788. "mozHasAudio",
  21789. "mozHasItem",
  21790. "mozHidden",
  21791. "mozImageSmoothingEnabled",
  21792. "mozIndexedDB",
  21793. "mozInnerScreenX",
  21794. "mozInnerScreenY",
  21795. "mozInputSource",
  21796. "mozIsTextField",
  21797. "mozItem",
  21798. "mozItemCount",
  21799. "mozItems",
  21800. "mozLength",
  21801. "mozLockOrientation",
  21802. "mozMatchesSelector",
  21803. "mozMovementX",
  21804. "mozMovementY",
  21805. "mozOpaque",
  21806. "mozOrientation",
  21807. "mozPaintCount",
  21808. "mozPaintedFrames",
  21809. "mozParsedFrames",
  21810. "mozPay",
  21811. "mozPointerLockElement",
  21812. "mozPresentedFrames",
  21813. "mozPreservesPitch",
  21814. "mozPressure",
  21815. "mozPrintCallback",
  21816. "mozRTCIceCandidate",
  21817. "mozRTCPeerConnection",
  21818. "mozRTCSessionDescription",
  21819. "mozRemove",
  21820. "mozRequestAnimationFrame",
  21821. "mozRequestFullScreen",
  21822. "mozRequestPointerLock",
  21823. "mozSetDataAt",
  21824. "mozSetImageElement",
  21825. "mozSourceNode",
  21826. "mozSrcObject",
  21827. "mozSystem",
  21828. "mozTCPSocket",
  21829. "mozTextStyle",
  21830. "mozTypesAt",
  21831. "mozUnlockOrientation",
  21832. "mozUserCancelled",
  21833. "mozVisibilityState",
  21834. "ms",
  21835. "msAnimation",
  21836. "msAnimationDelay",
  21837. "msAnimationDirection",
  21838. "msAnimationDuration",
  21839. "msAnimationFillMode",
  21840. "msAnimationIterationCount",
  21841. "msAnimationName",
  21842. "msAnimationPlayState",
  21843. "msAnimationStartTime",
  21844. "msAnimationTimingFunction",
  21845. "msBackfaceVisibility",
  21846. "msBlockProgression",
  21847. "msCSSOMElementFloatMetrics",
  21848. "msCaching",
  21849. "msCachingEnabled",
  21850. "msCancelRequestAnimationFrame",
  21851. "msCapsLockWarningOff",
  21852. "msClearImmediate",
  21853. "msClose",
  21854. "msContentZoomChaining",
  21855. "msContentZoomFactor",
  21856. "msContentZoomLimit",
  21857. "msContentZoomLimitMax",
  21858. "msContentZoomLimitMin",
  21859. "msContentZoomSnap",
  21860. "msContentZoomSnapPoints",
  21861. "msContentZoomSnapType",
  21862. "msContentZooming",
  21863. "msConvertURL",
  21864. "msCrypto",
  21865. "msDoNotTrack",
  21866. "msElementsFromPoint",
  21867. "msElementsFromRect",
  21868. "msExitFullscreen",
  21869. "msExtendedCode",
  21870. "msFillRule",
  21871. "msFirstPaint",
  21872. "msFlex",
  21873. "msFlexAlign",
  21874. "msFlexDirection",
  21875. "msFlexFlow",
  21876. "msFlexItemAlign",
  21877. "msFlexLinePack",
  21878. "msFlexNegative",
  21879. "msFlexOrder",
  21880. "msFlexPack",
  21881. "msFlexPositive",
  21882. "msFlexPreferredSize",
  21883. "msFlexWrap",
  21884. "msFlowFrom",
  21885. "msFlowInto",
  21886. "msFontFeatureSettings",
  21887. "msFullscreenElement",
  21888. "msFullscreenEnabled",
  21889. "msGetInputContext",
  21890. "msGetRegionContent",
  21891. "msGetUntransformedBounds",
  21892. "msGraphicsTrustStatus",
  21893. "msGridColumn",
  21894. "msGridColumnAlign",
  21895. "msGridColumnSpan",
  21896. "msGridColumns",
  21897. "msGridRow",
  21898. "msGridRowAlign",
  21899. "msGridRowSpan",
  21900. "msGridRows",
  21901. "msHidden",
  21902. "msHighContrastAdjust",
  21903. "msHyphenateLimitChars",
  21904. "msHyphenateLimitLines",
  21905. "msHyphenateLimitZone",
  21906. "msHyphens",
  21907. "msImageSmoothingEnabled",
  21908. "msImeAlign",
  21909. "msIndexedDB",
  21910. "msInterpolationMode",
  21911. "msIsStaticHTML",
  21912. "msKeySystem",
  21913. "msKeys",
  21914. "msLaunchUri",
  21915. "msLockOrientation",
  21916. "msManipulationViewsEnabled",
  21917. "msMatchMedia",
  21918. "msMatchesSelector",
  21919. "msMaxTouchPoints",
  21920. "msOrientation",
  21921. "msOverflowStyle",
  21922. "msPerspective",
  21923. "msPerspectiveOrigin",
  21924. "msPlayToDisabled",
  21925. "msPlayToPreferredSourceUri",
  21926. "msPlayToPrimary",
  21927. "msPointerEnabled",
  21928. "msRegionOverflow",
  21929. "msReleasePointerCapture",
  21930. "msRequestAnimationFrame",
  21931. "msRequestFullscreen",
  21932. "msSaveBlob",
  21933. "msSaveOrOpenBlob",
  21934. "msScrollChaining",
  21935. "msScrollLimit",
  21936. "msScrollLimitXMax",
  21937. "msScrollLimitXMin",
  21938. "msScrollLimitYMax",
  21939. "msScrollLimitYMin",
  21940. "msScrollRails",
  21941. "msScrollSnapPointsX",
  21942. "msScrollSnapPointsY",
  21943. "msScrollSnapType",
  21944. "msScrollSnapX",
  21945. "msScrollSnapY",
  21946. "msScrollTranslation",
  21947. "msSetImmediate",
  21948. "msSetMediaKeys",
  21949. "msSetPointerCapture",
  21950. "msTextCombineHorizontal",
  21951. "msTextSizeAdjust",
  21952. "msToBlob",
  21953. "msTouchAction",
  21954. "msTouchSelect",
  21955. "msTraceAsyncCallbackCompleted",
  21956. "msTraceAsyncCallbackStarting",
  21957. "msTraceAsyncOperationCompleted",
  21958. "msTraceAsyncOperationStarting",
  21959. "msTransform",
  21960. "msTransformOrigin",
  21961. "msTransformStyle",
  21962. "msTransition",
  21963. "msTransitionDelay",
  21964. "msTransitionDuration",
  21965. "msTransitionProperty",
  21966. "msTransitionTimingFunction",
  21967. "msUnlockOrientation",
  21968. "msUpdateAsyncCallbackRelation",
  21969. "msUserSelect",
  21970. "msVisibilityState",
  21971. "msWrapFlow",
  21972. "msWrapMargin",
  21973. "msWrapThrough",
  21974. "msWriteProfilerMark",
  21975. "msZoom",
  21976. "msZoomTo",
  21977. "mt",
  21978. "mul",
  21979. "multiEntry",
  21980. "multiSelectionObj",
  21981. "multiline",
  21982. "multiple",
  21983. "multiply",
  21984. "multiplySelf",
  21985. "mutableFile",
  21986. "muted",
  21987. "n",
  21988. "name",
  21989. "nameProp",
  21990. "namedItem",
  21991. "namedRecordset",
  21992. "names",
  21993. "namespaceURI",
  21994. "namespaces",
  21995. "naturalHeight",
  21996. "naturalWidth",
  21997. "navigate",
  21998. "navigation",
  21999. "navigationMode",
  22000. "navigationPreload",
  22001. "navigationStart",
  22002. "navigator",
  22003. "near",
  22004. "nearestViewportElement",
  22005. "negative",
  22006. "negotiated",
  22007. "netscape",
  22008. "networkState",
  22009. "newScale",
  22010. "newTranslate",
  22011. "newURL",
  22012. "newValue",
  22013. "newValueSpecifiedUnits",
  22014. "newVersion",
  22015. "newhome",
  22016. "next",
  22017. "nextElementSibling",
  22018. "nextHopProtocol",
  22019. "nextNode",
  22020. "nextPage",
  22021. "nextSibling",
  22022. "nickname",
  22023. "noHref",
  22024. "noModule",
  22025. "noResize",
  22026. "noShade",
  22027. "noValidate",
  22028. "noWrap",
  22029. "node",
  22030. "nodeName",
  22031. "nodeType",
  22032. "nodeValue",
  22033. "nonce",
  22034. "normalize",
  22035. "normalizedPathSegList",
  22036. "notationName",
  22037. "notations",
  22038. "note",
  22039. "noteGrainOn",
  22040. "noteOff",
  22041. "noteOn",
  22042. "notify",
  22043. "now",
  22044. "numOctaves",
  22045. "number",
  22046. "numberOfChannels",
  22047. "numberOfInputs",
  22048. "numberOfItems",
  22049. "numberOfOutputs",
  22050. "numberValue",
  22051. "oMatchesSelector",
  22052. "object",
  22053. "object-fit",
  22054. "object-position",
  22055. "objectFit",
  22056. "objectPosition",
  22057. "objectStore",
  22058. "objectStoreNames",
  22059. "objectType",
  22060. "observe",
  22061. "of",
  22062. "offscreenBuffering",
  22063. "offset",
  22064. "offset-anchor",
  22065. "offset-distance",
  22066. "offset-path",
  22067. "offset-rotate",
  22068. "offsetAnchor",
  22069. "offsetDistance",
  22070. "offsetHeight",
  22071. "offsetLeft",
  22072. "offsetNode",
  22073. "offsetParent",
  22074. "offsetPath",
  22075. "offsetRotate",
  22076. "offsetTop",
  22077. "offsetWidth",
  22078. "offsetX",
  22079. "offsetY",
  22080. "ok",
  22081. "oldURL",
  22082. "oldValue",
  22083. "oldVersion",
  22084. "olderShadowRoot",
  22085. "onLine",
  22086. "onabort",
  22087. "onabsolutedeviceorientation",
  22088. "onactivate",
  22089. "onactive",
  22090. "onaddsourcebuffer",
  22091. "onaddstream",
  22092. "onaddtrack",
  22093. "onafterprint",
  22094. "onafterscriptexecute",
  22095. "onafterupdate",
  22096. "onanimationcancel",
  22097. "onanimationend",
  22098. "onanimationiteration",
  22099. "onanimationstart",
  22100. "onappinstalled",
  22101. "onaudioend",
  22102. "onaudioprocess",
  22103. "onaudiostart",
  22104. "onautocomplete",
  22105. "onautocompleteerror",
  22106. "onauxclick",
  22107. "onbeforeactivate",
  22108. "onbeforecopy",
  22109. "onbeforecut",
  22110. "onbeforedeactivate",
  22111. "onbeforeeditfocus",
  22112. "onbeforeinstallprompt",
  22113. "onbeforepaste",
  22114. "onbeforeprint",
  22115. "onbeforescriptexecute",
  22116. "onbeforeunload",
  22117. "onbeforeupdate",
  22118. "onbeforexrselect",
  22119. "onbegin",
  22120. "onblocked",
  22121. "onblur",
  22122. "onbounce",
  22123. "onboundary",
  22124. "onbufferedamountlow",
  22125. "oncached",
  22126. "oncancel",
  22127. "oncandidatewindowhide",
  22128. "oncandidatewindowshow",
  22129. "oncandidatewindowupdate",
  22130. "oncanplay",
  22131. "oncanplaythrough",
  22132. "once",
  22133. "oncellchange",
  22134. "onchange",
  22135. "oncharacteristicvaluechanged",
  22136. "onchargingchange",
  22137. "onchargingtimechange",
  22138. "onchecking",
  22139. "onclick",
  22140. "onclose",
  22141. "onclosing",
  22142. "oncompassneedscalibration",
  22143. "oncomplete",
  22144. "onconnect",
  22145. "onconnecting",
  22146. "onconnectionavailable",
  22147. "onconnectionstatechange",
  22148. "oncontextmenu",
  22149. "oncontrollerchange",
  22150. "oncontrolselect",
  22151. "oncopy",
  22152. "oncuechange",
  22153. "oncut",
  22154. "ondataavailable",
  22155. "ondatachannel",
  22156. "ondatasetchanged",
  22157. "ondatasetcomplete",
  22158. "ondblclick",
  22159. "ondeactivate",
  22160. "ondevicechange",
  22161. "ondevicelight",
  22162. "ondevicemotion",
  22163. "ondeviceorientation",
  22164. "ondeviceorientationabsolute",
  22165. "ondeviceproximity",
  22166. "ondischargingtimechange",
  22167. "ondisconnect",
  22168. "ondisplay",
  22169. "ondownloading",
  22170. "ondrag",
  22171. "ondragend",
  22172. "ondragenter",
  22173. "ondragexit",
  22174. "ondragleave",
  22175. "ondragover",
  22176. "ondragstart",
  22177. "ondrop",
  22178. "ondurationchange",
  22179. "onemptied",
  22180. "onencrypted",
  22181. "onend",
  22182. "onended",
  22183. "onenter",
  22184. "onenterpictureinpicture",
  22185. "onerror",
  22186. "onerrorupdate",
  22187. "onexit",
  22188. "onfilterchange",
  22189. "onfinish",
  22190. "onfocus",
  22191. "onfocusin",
  22192. "onfocusout",
  22193. "onformdata",
  22194. "onfreeze",
  22195. "onfullscreenchange",
  22196. "onfullscreenerror",
  22197. "ongatheringstatechange",
  22198. "ongattserverdisconnected",
  22199. "ongesturechange",
  22200. "ongestureend",
  22201. "ongesturestart",
  22202. "ongotpointercapture",
  22203. "onhashchange",
  22204. "onhelp",
  22205. "onicecandidate",
  22206. "onicecandidateerror",
  22207. "oniceconnectionstatechange",
  22208. "onicegatheringstatechange",
  22209. "oninactive",
  22210. "oninput",
  22211. "oninputsourceschange",
  22212. "oninvalid",
  22213. "onkeydown",
  22214. "onkeypress",
  22215. "onkeystatuseschange",
  22216. "onkeyup",
  22217. "onlanguagechange",
  22218. "onlayoutcomplete",
  22219. "onleavepictureinpicture",
  22220. "onlevelchange",
  22221. "onload",
  22222. "onloadeddata",
  22223. "onloadedmetadata",
  22224. "onloadend",
  22225. "onloading",
  22226. "onloadingdone",
  22227. "onloadingerror",
  22228. "onloadstart",
  22229. "onlosecapture",
  22230. "onlostpointercapture",
  22231. "only",
  22232. "onmark",
  22233. "onmessage",
  22234. "onmessageerror",
  22235. "onmidimessage",
  22236. "onmousedown",
  22237. "onmouseenter",
  22238. "onmouseleave",
  22239. "onmousemove",
  22240. "onmouseout",
  22241. "onmouseover",
  22242. "onmouseup",
  22243. "onmousewheel",
  22244. "onmove",
  22245. "onmoveend",
  22246. "onmovestart",
  22247. "onmozfullscreenchange",
  22248. "onmozfullscreenerror",
  22249. "onmozorientationchange",
  22250. "onmozpointerlockchange",
  22251. "onmozpointerlockerror",
  22252. "onmscontentzoom",
  22253. "onmsfullscreenchange",
  22254. "onmsfullscreenerror",
  22255. "onmsgesturechange",
  22256. "onmsgesturedoubletap",
  22257. "onmsgestureend",
  22258. "onmsgesturehold",
  22259. "onmsgesturestart",
  22260. "onmsgesturetap",
  22261. "onmsgotpointercapture",
  22262. "onmsinertiastart",
  22263. "onmslostpointercapture",
  22264. "onmsmanipulationstatechanged",
  22265. "onmsneedkey",
  22266. "onmsorientationchange",
  22267. "onmspointercancel",
  22268. "onmspointerdown",
  22269. "onmspointerenter",
  22270. "onmspointerhover",
  22271. "onmspointerleave",
  22272. "onmspointermove",
  22273. "onmspointerout",
  22274. "onmspointerover",
  22275. "onmspointerup",
  22276. "onmssitemodejumplistitemremoved",
  22277. "onmsthumbnailclick",
  22278. "onmute",
  22279. "onnegotiationneeded",
  22280. "onnomatch",
  22281. "onnoupdate",
  22282. "onobsolete",
  22283. "onoffline",
  22284. "ononline",
  22285. "onopen",
  22286. "onorientationchange",
  22287. "onpagechange",
  22288. "onpagehide",
  22289. "onpageshow",
  22290. "onpaste",
  22291. "onpause",
  22292. "onpayerdetailchange",
  22293. "onpaymentmethodchange",
  22294. "onplay",
  22295. "onplaying",
  22296. "onpluginstreamstart",
  22297. "onpointercancel",
  22298. "onpointerdown",
  22299. "onpointerenter",
  22300. "onpointerleave",
  22301. "onpointerlockchange",
  22302. "onpointerlockerror",
  22303. "onpointermove",
  22304. "onpointerout",
  22305. "onpointerover",
  22306. "onpointerrawupdate",
  22307. "onpointerup",
  22308. "onpopstate",
  22309. "onprocessorerror",
  22310. "onprogress",
  22311. "onpropertychange",
  22312. "onratechange",
  22313. "onreading",
  22314. "onreadystatechange",
  22315. "onrejectionhandled",
  22316. "onrelease",
  22317. "onremove",
  22318. "onremovesourcebuffer",
  22319. "onremovestream",
  22320. "onremovetrack",
  22321. "onrepeat",
  22322. "onreset",
  22323. "onresize",
  22324. "onresizeend",
  22325. "onresizestart",
  22326. "onresourcetimingbufferfull",
  22327. "onresult",
  22328. "onresume",
  22329. "onrowenter",
  22330. "onrowexit",
  22331. "onrowsdelete",
  22332. "onrowsinserted",
  22333. "onscroll",
  22334. "onsearch",
  22335. "onsecuritypolicyviolation",
  22336. "onseeked",
  22337. "onseeking",
  22338. "onselect",
  22339. "onselectedcandidatepairchange",
  22340. "onselectend",
  22341. "onselectionchange",
  22342. "onselectstart",
  22343. "onshippingaddresschange",
  22344. "onshippingoptionchange",
  22345. "onshow",
  22346. "onsignalingstatechange",
  22347. "onsoundend",
  22348. "onsoundstart",
  22349. "onsourceclose",
  22350. "onsourceclosed",
  22351. "onsourceended",
  22352. "onsourceopen",
  22353. "onspeechend",
  22354. "onspeechstart",
  22355. "onsqueeze",
  22356. "onsqueezeend",
  22357. "onsqueezestart",
  22358. "onstalled",
  22359. "onstart",
  22360. "onstatechange",
  22361. "onstop",
  22362. "onstorage",
  22363. "onstoragecommit",
  22364. "onsubmit",
  22365. "onsuccess",
  22366. "onsuspend",
  22367. "onterminate",
  22368. "ontextinput",
  22369. "ontimeout",
  22370. "ontimeupdate",
  22371. "ontoggle",
  22372. "ontonechange",
  22373. "ontouchcancel",
  22374. "ontouchend",
  22375. "ontouchmove",
  22376. "ontouchstart",
  22377. "ontrack",
  22378. "ontransitioncancel",
  22379. "ontransitionend",
  22380. "ontransitionrun",
  22381. "ontransitionstart",
  22382. "onunhandledrejection",
  22383. "onunload",
  22384. "onunmute",
  22385. "onupdate",
  22386. "onupdateend",
  22387. "onupdatefound",
  22388. "onupdateready",
  22389. "onupdatestart",
  22390. "onupgradeneeded",
  22391. "onuserproximity",
  22392. "onversionchange",
  22393. "onvisibilitychange",
  22394. "onvoiceschanged",
  22395. "onvolumechange",
  22396. "onvrdisplayactivate",
  22397. "onvrdisplayconnect",
  22398. "onvrdisplaydeactivate",
  22399. "onvrdisplaydisconnect",
  22400. "onvrdisplaypresentchange",
  22401. "onwaiting",
  22402. "onwaitingforkey",
  22403. "onwarning",
  22404. "onwebkitanimationend",
  22405. "onwebkitanimationiteration",
  22406. "onwebkitanimationstart",
  22407. "onwebkitcurrentplaybacktargetiswirelesschanged",
  22408. "onwebkitfullscreenchange",
  22409. "onwebkitfullscreenerror",
  22410. "onwebkitkeyadded",
  22411. "onwebkitkeyerror",
  22412. "onwebkitkeymessage",
  22413. "onwebkitneedkey",
  22414. "onwebkitorientationchange",
  22415. "onwebkitplaybacktargetavailabilitychanged",
  22416. "onwebkitpointerlockchange",
  22417. "onwebkitpointerlockerror",
  22418. "onwebkitresourcetimingbufferfull",
  22419. "onwebkittransitionend",
  22420. "onwheel",
  22421. "onzoom",
  22422. "opacity",
  22423. "open",
  22424. "openCursor",
  22425. "openDatabase",
  22426. "openKeyCursor",
  22427. "opened",
  22428. "opener",
  22429. "opera",
  22430. "operationType",
  22431. "operator",
  22432. "opr",
  22433. "optimum",
  22434. "options",
  22435. "or",
  22436. "order",
  22437. "orderX",
  22438. "orderY",
  22439. "ordered",
  22440. "org",
  22441. "organization",
  22442. "orient",
  22443. "orientAngle",
  22444. "orientType",
  22445. "orientation",
  22446. "orientationX",
  22447. "orientationY",
  22448. "orientationZ",
  22449. "origin",
  22450. "originalPolicy",
  22451. "originalTarget",
  22452. "orphans",
  22453. "oscpu",
  22454. "outerHTML",
  22455. "outerHeight",
  22456. "outerText",
  22457. "outerWidth",
  22458. "outline",
  22459. "outline-color",
  22460. "outline-offset",
  22461. "outline-style",
  22462. "outline-width",
  22463. "outlineColor",
  22464. "outlineOffset",
  22465. "outlineStyle",
  22466. "outlineWidth",
  22467. "outputBuffer",
  22468. "outputLatency",
  22469. "outputs",
  22470. "overflow",
  22471. "overflow-anchor",
  22472. "overflow-block",
  22473. "overflow-inline",
  22474. "overflow-wrap",
  22475. "overflow-x",
  22476. "overflow-y",
  22477. "overflowAnchor",
  22478. "overflowBlock",
  22479. "overflowInline",
  22480. "overflowWrap",
  22481. "overflowX",
  22482. "overflowY",
  22483. "overrideMimeType",
  22484. "oversample",
  22485. "overscroll-behavior",
  22486. "overscroll-behavior-block",
  22487. "overscroll-behavior-inline",
  22488. "overscroll-behavior-x",
  22489. "overscroll-behavior-y",
  22490. "overscrollBehavior",
  22491. "overscrollBehaviorBlock",
  22492. "overscrollBehaviorInline",
  22493. "overscrollBehaviorX",
  22494. "overscrollBehaviorY",
  22495. "ownKeys",
  22496. "ownerDocument",
  22497. "ownerElement",
  22498. "ownerNode",
  22499. "ownerRule",
  22500. "ownerSVGElement",
  22501. "owningElement",
  22502. "p1",
  22503. "p2",
  22504. "p3",
  22505. "p4",
  22506. "packetSize",
  22507. "packets",
  22508. "pad",
  22509. "padEnd",
  22510. "padStart",
  22511. "padding",
  22512. "padding-block",
  22513. "padding-block-end",
  22514. "padding-block-start",
  22515. "padding-bottom",
  22516. "padding-inline",
  22517. "padding-inline-end",
  22518. "padding-inline-start",
  22519. "padding-left",
  22520. "padding-right",
  22521. "padding-top",
  22522. "paddingBlock",
  22523. "paddingBlockEnd",
  22524. "paddingBlockStart",
  22525. "paddingBottom",
  22526. "paddingInline",
  22527. "paddingInlineEnd",
  22528. "paddingInlineStart",
  22529. "paddingLeft",
  22530. "paddingRight",
  22531. "paddingTop",
  22532. "page",
  22533. "page-break-after",
  22534. "page-break-before",
  22535. "page-break-inside",
  22536. "pageBreakAfter",
  22537. "pageBreakBefore",
  22538. "pageBreakInside",
  22539. "pageCount",
  22540. "pageLeft",
  22541. "pageTop",
  22542. "pageX",
  22543. "pageXOffset",
  22544. "pageY",
  22545. "pageYOffset",
  22546. "pages",
  22547. "paint-order",
  22548. "paintOrder",
  22549. "paintRequests",
  22550. "paintType",
  22551. "paintWorklet",
  22552. "palette",
  22553. "pan",
  22554. "panningModel",
  22555. "parameters",
  22556. "parent",
  22557. "parentElement",
  22558. "parentNode",
  22559. "parentRule",
  22560. "parentStyleSheet",
  22561. "parentTextEdit",
  22562. "parentWindow",
  22563. "parse",
  22564. "parseAll",
  22565. "parseFloat",
  22566. "parseFromString",
  22567. "parseInt",
  22568. "part",
  22569. "participants",
  22570. "passive",
  22571. "password",
  22572. "pasteHTML",
  22573. "path",
  22574. "pathLength",
  22575. "pathSegList",
  22576. "pathSegType",
  22577. "pathSegTypeAsLetter",
  22578. "pathname",
  22579. "pattern",
  22580. "patternContentUnits",
  22581. "patternMismatch",
  22582. "patternTransform",
  22583. "patternUnits",
  22584. "pause",
  22585. "pauseAnimations",
  22586. "pauseOnExit",
  22587. "pauseProfilers",
  22588. "pauseTransformFeedback",
  22589. "paused",
  22590. "payerEmail",
  22591. "payerName",
  22592. "payerPhone",
  22593. "paymentManager",
  22594. "pc",
  22595. "peerIdentity",
  22596. "pending",
  22597. "pendingLocalDescription",
  22598. "pendingRemoteDescription",
  22599. "percent",
  22600. "performance",
  22601. "periodicSync",
  22602. "permission",
  22603. "permissionState",
  22604. "permissions",
  22605. "persist",
  22606. "persisted",
  22607. "personalbar",
  22608. "perspective",
  22609. "perspective-origin",
  22610. "perspectiveOrigin",
  22611. "phone",
  22612. "phoneticFamilyName",
  22613. "phoneticGivenName",
  22614. "photo",
  22615. "pictureInPictureElement",
  22616. "pictureInPictureEnabled",
  22617. "pictureInPictureWindow",
  22618. "ping",
  22619. "pipeThrough",
  22620. "pipeTo",
  22621. "pitch",
  22622. "pixelBottom",
  22623. "pixelDepth",
  22624. "pixelHeight",
  22625. "pixelLeft",
  22626. "pixelRight",
  22627. "pixelStorei",
  22628. "pixelTop",
  22629. "pixelUnitToMillimeterX",
  22630. "pixelUnitToMillimeterY",
  22631. "pixelWidth",
  22632. "place-content",
  22633. "place-items",
  22634. "place-self",
  22635. "placeContent",
  22636. "placeItems",
  22637. "placeSelf",
  22638. "placeholder",
  22639. "platform",
  22640. "platforms",
  22641. "play",
  22642. "playEffect",
  22643. "playState",
  22644. "playbackRate",
  22645. "playbackState",
  22646. "playbackTime",
  22647. "played",
  22648. "playoutDelayHint",
  22649. "playsInline",
  22650. "plugins",
  22651. "pluginspage",
  22652. "pname",
  22653. "pointer-events",
  22654. "pointerBeforeReferenceNode",
  22655. "pointerEnabled",
  22656. "pointerEvents",
  22657. "pointerId",
  22658. "pointerLockElement",
  22659. "pointerType",
  22660. "points",
  22661. "pointsAtX",
  22662. "pointsAtY",
  22663. "pointsAtZ",
  22664. "polygonOffset",
  22665. "pop",
  22666. "populateMatrix",
  22667. "popupWindowFeatures",
  22668. "popupWindowName",
  22669. "popupWindowURI",
  22670. "port",
  22671. "port1",
  22672. "port2",
  22673. "ports",
  22674. "posBottom",
  22675. "posHeight",
  22676. "posLeft",
  22677. "posRight",
  22678. "posTop",
  22679. "posWidth",
  22680. "pose",
  22681. "position",
  22682. "positionAlign",
  22683. "positionX",
  22684. "positionY",
  22685. "positionZ",
  22686. "postError",
  22687. "postMessage",
  22688. "postalCode",
  22689. "poster",
  22690. "pow",
  22691. "powerEfficient",
  22692. "powerOff",
  22693. "preMultiplySelf",
  22694. "precision",
  22695. "preferredStyleSheetSet",
  22696. "preferredStylesheetSet",
  22697. "prefix",
  22698. "preload",
  22699. "prepend",
  22700. "presentation",
  22701. "preserveAlpha",
  22702. "preserveAspectRatio",
  22703. "preserveAspectRatioString",
  22704. "pressed",
  22705. "pressure",
  22706. "prevValue",
  22707. "preventDefault",
  22708. "preventExtensions",
  22709. "preventSilentAccess",
  22710. "previousElementSibling",
  22711. "previousNode",
  22712. "previousPage",
  22713. "previousRect",
  22714. "previousScale",
  22715. "previousSibling",
  22716. "previousTranslate",
  22717. "primaryKey",
  22718. "primitiveType",
  22719. "primitiveUnits",
  22720. "principals",
  22721. "print",
  22722. "priority",
  22723. "privateKey",
  22724. "probablySupportsContext",
  22725. "process",
  22726. "processIceMessage",
  22727. "processingEnd",
  22728. "processingStart",
  22729. "product",
  22730. "productId",
  22731. "productName",
  22732. "productSub",
  22733. "profile",
  22734. "profileEnd",
  22735. "profiles",
  22736. "projectionMatrix",
  22737. "promise",
  22738. "prompt",
  22739. "properties",
  22740. "propertyIsEnumerable",
  22741. "propertyName",
  22742. "protocol",
  22743. "protocolLong",
  22744. "prototype",
  22745. "provider",
  22746. "pseudoClass",
  22747. "pseudoElement",
  22748. "pt",
  22749. "publicId",
  22750. "publicKey",
  22751. "published",
  22752. "pulse",
  22753. "push",
  22754. "pushManager",
  22755. "pushNotification",
  22756. "pushState",
  22757. "put",
  22758. "putImageData",
  22759. "px",
  22760. "quadraticCurveTo",
  22761. "qualifier",
  22762. "quaternion",
  22763. "query",
  22764. "queryCommandEnabled",
  22765. "queryCommandIndeterm",
  22766. "queryCommandState",
  22767. "queryCommandSupported",
  22768. "queryCommandText",
  22769. "queryCommandValue",
  22770. "querySelector",
  22771. "querySelectorAll",
  22772. "queueMicrotask",
  22773. "quote",
  22774. "quotes",
  22775. "r",
  22776. "r1",
  22777. "r2",
  22778. "race",
  22779. "rad",
  22780. "radiogroup",
  22781. "radiusX",
  22782. "radiusY",
  22783. "random",
  22784. "range",
  22785. "rangeCount",
  22786. "rangeMax",
  22787. "rangeMin",
  22788. "rangeOffset",
  22789. "rangeOverflow",
  22790. "rangeParent",
  22791. "rangeUnderflow",
  22792. "rate",
  22793. "ratio",
  22794. "raw",
  22795. "rawId",
  22796. "read",
  22797. "readAsArrayBuffer",
  22798. "readAsBinaryString",
  22799. "readAsBlob",
  22800. "readAsDataURL",
  22801. "readAsText",
  22802. "readBuffer",
  22803. "readEntries",
  22804. "readOnly",
  22805. "readPixels",
  22806. "readReportRequested",
  22807. "readText",
  22808. "readValue",
  22809. "readable",
  22810. "ready",
  22811. "readyState",
  22812. "reason",
  22813. "reboot",
  22814. "receivedAlert",
  22815. "receiver",
  22816. "receivers",
  22817. "recipient",
  22818. "reconnect",
  22819. "recordNumber",
  22820. "recordsAvailable",
  22821. "recordset",
  22822. "rect",
  22823. "red",
  22824. "redEyeReduction",
  22825. "redirect",
  22826. "redirectCount",
  22827. "redirectEnd",
  22828. "redirectStart",
  22829. "redirected",
  22830. "reduce",
  22831. "reduceRight",
  22832. "reduction",
  22833. "refDistance",
  22834. "refX",
  22835. "refY",
  22836. "referenceNode",
  22837. "referenceSpace",
  22838. "referrer",
  22839. "referrerPolicy",
  22840. "refresh",
  22841. "region",
  22842. "regionAnchorX",
  22843. "regionAnchorY",
  22844. "regionId",
  22845. "regions",
  22846. "register",
  22847. "registerContentHandler",
  22848. "registerElement",
  22849. "registerProperty",
  22850. "registerProtocolHandler",
  22851. "reject",
  22852. "rel",
  22853. "relList",
  22854. "relatedAddress",
  22855. "relatedNode",
  22856. "relatedPort",
  22857. "relatedTarget",
  22858. "release",
  22859. "releaseCapture",
  22860. "releaseEvents",
  22861. "releaseInterface",
  22862. "releaseLock",
  22863. "releasePointerCapture",
  22864. "releaseShaderCompiler",
  22865. "reliable",
  22866. "reliableWrite",
  22867. "reload",
  22868. "rem",
  22869. "remainingSpace",
  22870. "remote",
  22871. "remoteDescription",
  22872. "remove",
  22873. "removeAllRanges",
  22874. "removeAttribute",
  22875. "removeAttributeNS",
  22876. "removeAttributeNode",
  22877. "removeBehavior",
  22878. "removeChild",
  22879. "removeCue",
  22880. "removeEventListener",
  22881. "removeFilter",
  22882. "removeImport",
  22883. "removeItem",
  22884. "removeListener",
  22885. "removeNamedItem",
  22886. "removeNamedItemNS",
  22887. "removeNode",
  22888. "removeParameter",
  22889. "removeProperty",
  22890. "removeRange",
  22891. "removeRegion",
  22892. "removeRule",
  22893. "removeSiteSpecificTrackingException",
  22894. "removeSourceBuffer",
  22895. "removeStream",
  22896. "removeTrack",
  22897. "removeVariable",
  22898. "removeWakeLockListener",
  22899. "removeWebWideTrackingException",
  22900. "removed",
  22901. "removedNodes",
  22902. "renderHeight",
  22903. "renderState",
  22904. "renderTime",
  22905. "renderWidth",
  22906. "renderbufferStorage",
  22907. "renderbufferStorageMultisample",
  22908. "renderedBuffer",
  22909. "renderingMode",
  22910. "renotify",
  22911. "repeat",
  22912. "replace",
  22913. "replaceAdjacentText",
  22914. "replaceAll",
  22915. "replaceChild",
  22916. "replaceChildren",
  22917. "replaceData",
  22918. "replaceId",
  22919. "replaceItem",
  22920. "replaceNode",
  22921. "replaceState",
  22922. "replaceSync",
  22923. "replaceTrack",
  22924. "replaceWholeText",
  22925. "replaceWith",
  22926. "reportValidity",
  22927. "request",
  22928. "requestAnimationFrame",
  22929. "requestAutocomplete",
  22930. "requestData",
  22931. "requestDevice",
  22932. "requestFrame",
  22933. "requestFullscreen",
  22934. "requestHitTestSource",
  22935. "requestHitTestSourceForTransientInput",
  22936. "requestId",
  22937. "requestIdleCallback",
  22938. "requestMIDIAccess",
  22939. "requestMediaKeySystemAccess",
  22940. "requestPermission",
  22941. "requestPictureInPicture",
  22942. "requestPointerLock",
  22943. "requestPresent",
  22944. "requestReferenceSpace",
  22945. "requestSession",
  22946. "requestStart",
  22947. "requestStorageAccess",
  22948. "requestSubmit",
  22949. "requestVideoFrameCallback",
  22950. "requestingWindow",
  22951. "requireInteraction",
  22952. "required",
  22953. "requiredExtensions",
  22954. "requiredFeatures",
  22955. "reset",
  22956. "resetPose",
  22957. "resetTransform",
  22958. "resize",
  22959. "resizeBy",
  22960. "resizeTo",
  22961. "resolve",
  22962. "response",
  22963. "responseBody",
  22964. "responseEnd",
  22965. "responseReady",
  22966. "responseStart",
  22967. "responseText",
  22968. "responseType",
  22969. "responseURL",
  22970. "responseXML",
  22971. "restartIce",
  22972. "restore",
  22973. "result",
  22974. "resultIndex",
  22975. "resultType",
  22976. "results",
  22977. "resume",
  22978. "resumeProfilers",
  22979. "resumeTransformFeedback",
  22980. "retry",
  22981. "returnValue",
  22982. "rev",
  22983. "reverse",
  22984. "reversed",
  22985. "revocable",
  22986. "revokeObjectURL",
  22987. "rgbColor",
  22988. "right",
  22989. "rightContext",
  22990. "rightDegrees",
  22991. "rightMargin",
  22992. "rightProjectionMatrix",
  22993. "rightViewMatrix",
  22994. "role",
  22995. "rolloffFactor",
  22996. "root",
  22997. "rootBounds",
  22998. "rootElement",
  22999. "rootMargin",
  23000. "rotate",
  23001. "rotateAxisAngle",
  23002. "rotateAxisAngleSelf",
  23003. "rotateFromVector",
  23004. "rotateFromVectorSelf",
  23005. "rotateSelf",
  23006. "rotation",
  23007. "rotationAngle",
  23008. "rotationRate",
  23009. "round",
  23010. "row-gap",
  23011. "rowGap",
  23012. "rowIndex",
  23013. "rowSpan",
  23014. "rows",
  23015. "rtcpTransport",
  23016. "rtt",
  23017. "ruby-align",
  23018. "ruby-position",
  23019. "rubyAlign",
  23020. "rubyOverhang",
  23021. "rubyPosition",
  23022. "rules",
  23023. "runtime",
  23024. "runtimeStyle",
  23025. "rx",
  23026. "ry",
  23027. "s",
  23028. "safari",
  23029. "sample",
  23030. "sampleCoverage",
  23031. "sampleRate",
  23032. "samplerParameterf",
  23033. "samplerParameteri",
  23034. "sandbox",
  23035. "save",
  23036. "saveData",
  23037. "scale",
  23038. "scale3d",
  23039. "scale3dSelf",
  23040. "scaleNonUniform",
  23041. "scaleNonUniformSelf",
  23042. "scaleSelf",
  23043. "scheme",
  23044. "scissor",
  23045. "scope",
  23046. "scopeName",
  23047. "scoped",
  23048. "screen",
  23049. "screenBrightness",
  23050. "screenEnabled",
  23051. "screenLeft",
  23052. "screenPixelToMillimeterX",
  23053. "screenPixelToMillimeterY",
  23054. "screenTop",
  23055. "screenX",
  23056. "screenY",
  23057. "scriptURL",
  23058. "scripts",
  23059. "scroll",
  23060. "scroll-behavior",
  23061. "scroll-margin",
  23062. "scroll-margin-block",
  23063. "scroll-margin-block-end",
  23064. "scroll-margin-block-start",
  23065. "scroll-margin-bottom",
  23066. "scroll-margin-inline",
  23067. "scroll-margin-inline-end",
  23068. "scroll-margin-inline-start",
  23069. "scroll-margin-left",
  23070. "scroll-margin-right",
  23071. "scroll-margin-top",
  23072. "scroll-padding",
  23073. "scroll-padding-block",
  23074. "scroll-padding-block-end",
  23075. "scroll-padding-block-start",
  23076. "scroll-padding-bottom",
  23077. "scroll-padding-inline",
  23078. "scroll-padding-inline-end",
  23079. "scroll-padding-inline-start",
  23080. "scroll-padding-left",
  23081. "scroll-padding-right",
  23082. "scroll-padding-top",
  23083. "scroll-snap-align",
  23084. "scroll-snap-type",
  23085. "scrollAmount",
  23086. "scrollBehavior",
  23087. "scrollBy",
  23088. "scrollByLines",
  23089. "scrollByPages",
  23090. "scrollDelay",
  23091. "scrollHeight",
  23092. "scrollIntoView",
  23093. "scrollIntoViewIfNeeded",
  23094. "scrollLeft",
  23095. "scrollLeftMax",
  23096. "scrollMargin",
  23097. "scrollMarginBlock",
  23098. "scrollMarginBlockEnd",
  23099. "scrollMarginBlockStart",
  23100. "scrollMarginBottom",
  23101. "scrollMarginInline",
  23102. "scrollMarginInlineEnd",
  23103. "scrollMarginInlineStart",
  23104. "scrollMarginLeft",
  23105. "scrollMarginRight",
  23106. "scrollMarginTop",
  23107. "scrollMaxX",
  23108. "scrollMaxY",
  23109. "scrollPadding",
  23110. "scrollPaddingBlock",
  23111. "scrollPaddingBlockEnd",
  23112. "scrollPaddingBlockStart",
  23113. "scrollPaddingBottom",
  23114. "scrollPaddingInline",
  23115. "scrollPaddingInlineEnd",
  23116. "scrollPaddingInlineStart",
  23117. "scrollPaddingLeft",
  23118. "scrollPaddingRight",
  23119. "scrollPaddingTop",
  23120. "scrollRestoration",
  23121. "scrollSnapAlign",
  23122. "scrollSnapType",
  23123. "scrollTo",
  23124. "scrollTop",
  23125. "scrollTopMax",
  23126. "scrollWidth",
  23127. "scrollX",
  23128. "scrollY",
  23129. "scrollbar-color",
  23130. "scrollbar-width",
  23131. "scrollbar3dLightColor",
  23132. "scrollbarArrowColor",
  23133. "scrollbarBaseColor",
  23134. "scrollbarColor",
  23135. "scrollbarDarkShadowColor",
  23136. "scrollbarFaceColor",
  23137. "scrollbarHighlightColor",
  23138. "scrollbarShadowColor",
  23139. "scrollbarTrackColor",
  23140. "scrollbarWidth",
  23141. "scrollbars",
  23142. "scrolling",
  23143. "scrollingElement",
  23144. "sctp",
  23145. "sctpCauseCode",
  23146. "sdp",
  23147. "sdpLineNumber",
  23148. "sdpMLineIndex",
  23149. "sdpMid",
  23150. "seal",
  23151. "search",
  23152. "searchBox",
  23153. "searchBoxJavaBridge_",
  23154. "searchParams",
  23155. "sectionRowIndex",
  23156. "secureConnectionStart",
  23157. "security",
  23158. "seed",
  23159. "seekToNextFrame",
  23160. "seekable",
  23161. "seeking",
  23162. "select",
  23163. "selectAllChildren",
  23164. "selectAlternateInterface",
  23165. "selectConfiguration",
  23166. "selectNode",
  23167. "selectNodeContents",
  23168. "selectNodes",
  23169. "selectSingleNode",
  23170. "selectSubString",
  23171. "selected",
  23172. "selectedIndex",
  23173. "selectedOptions",
  23174. "selectedStyleSheetSet",
  23175. "selectedStylesheetSet",
  23176. "selection",
  23177. "selectionDirection",
  23178. "selectionEnd",
  23179. "selectionStart",
  23180. "selector",
  23181. "selectorText",
  23182. "self",
  23183. "send",
  23184. "sendAsBinary",
  23185. "sendBeacon",
  23186. "sender",
  23187. "sentAlert",
  23188. "sentTimestamp",
  23189. "separator",
  23190. "serialNumber",
  23191. "serializeToString",
  23192. "serverTiming",
  23193. "service",
  23194. "serviceWorker",
  23195. "session",
  23196. "sessionId",
  23197. "sessionStorage",
  23198. "set",
  23199. "setActionHandler",
  23200. "setActive",
  23201. "setAlpha",
  23202. "setAppBadge",
  23203. "setAttribute",
  23204. "setAttributeNS",
  23205. "setAttributeNode",
  23206. "setAttributeNodeNS",
  23207. "setBaseAndExtent",
  23208. "setBigInt64",
  23209. "setBigUint64",
  23210. "setBingCurrentSearchDefault",
  23211. "setCapture",
  23212. "setCodecPreferences",
  23213. "setColor",
  23214. "setCompositeOperation",
  23215. "setConfiguration",
  23216. "setCurrentTime",
  23217. "setCustomValidity",
  23218. "setData",
  23219. "setDate",
  23220. "setDragImage",
  23221. "setEnd",
  23222. "setEndAfter",
  23223. "setEndBefore",
  23224. "setEndPoint",
  23225. "setFillColor",
  23226. "setFilterRes",
  23227. "setFloat32",
  23228. "setFloat64",
  23229. "setFloatValue",
  23230. "setFormValue",
  23231. "setFullYear",
  23232. "setHeaderValue",
  23233. "setHours",
  23234. "setIdentityProvider",
  23235. "setImmediate",
  23236. "setInt16",
  23237. "setInt32",
  23238. "setInt8",
  23239. "setInterval",
  23240. "setItem",
  23241. "setKeyframes",
  23242. "setLineCap",
  23243. "setLineDash",
  23244. "setLineJoin",
  23245. "setLineWidth",
  23246. "setLiveSeekableRange",
  23247. "setLocalDescription",
  23248. "setMatrix",
  23249. "setMatrixValue",
  23250. "setMediaKeys",
  23251. "setMilliseconds",
  23252. "setMinutes",
  23253. "setMiterLimit",
  23254. "setMonth",
  23255. "setNamedItem",
  23256. "setNamedItemNS",
  23257. "setNonUserCodeExceptions",
  23258. "setOrientToAngle",
  23259. "setOrientToAuto",
  23260. "setOrientation",
  23261. "setOverrideHistoryNavigationMode",
  23262. "setPaint",
  23263. "setParameter",
  23264. "setParameters",
  23265. "setPeriodicWave",
  23266. "setPointerCapture",
  23267. "setPosition",
  23268. "setPositionState",
  23269. "setPreference",
  23270. "setProperty",
  23271. "setPrototypeOf",
  23272. "setRGBColor",
  23273. "setRGBColorICCColor",
  23274. "setRadius",
  23275. "setRangeText",
  23276. "setRemoteDescription",
  23277. "setRequestHeader",
  23278. "setResizable",
  23279. "setResourceTimingBufferSize",
  23280. "setRotate",
  23281. "setScale",
  23282. "setSeconds",
  23283. "setSelectionRange",
  23284. "setServerCertificate",
  23285. "setShadow",
  23286. "setSinkId",
  23287. "setSkewX",
  23288. "setSkewY",
  23289. "setStart",
  23290. "setStartAfter",
  23291. "setStartBefore",
  23292. "setStdDeviation",
  23293. "setStreams",
  23294. "setStringValue",
  23295. "setStrokeColor",
  23296. "setSuggestResult",
  23297. "setTargetAtTime",
  23298. "setTargetValueAtTime",
  23299. "setTime",
  23300. "setTimeout",
  23301. "setTransform",
  23302. "setTranslate",
  23303. "setUTCDate",
  23304. "setUTCFullYear",
  23305. "setUTCHours",
  23306. "setUTCMilliseconds",
  23307. "setUTCMinutes",
  23308. "setUTCMonth",
  23309. "setUTCSeconds",
  23310. "setUint16",
  23311. "setUint32",
  23312. "setUint8",
  23313. "setUri",
  23314. "setValidity",
  23315. "setValueAtTime",
  23316. "setValueCurveAtTime",
  23317. "setVariable",
  23318. "setVelocity",
  23319. "setVersion",
  23320. "setYear",
  23321. "settingName",
  23322. "settingValue",
  23323. "sex",
  23324. "shaderSource",
  23325. "shadowBlur",
  23326. "shadowColor",
  23327. "shadowOffsetX",
  23328. "shadowOffsetY",
  23329. "shadowRoot",
  23330. "shape",
  23331. "shape-image-threshold",
  23332. "shape-margin",
  23333. "shape-outside",
  23334. "shape-rendering",
  23335. "shapeImageThreshold",
  23336. "shapeMargin",
  23337. "shapeOutside",
  23338. "shapeRendering",
  23339. "sheet",
  23340. "shift",
  23341. "shiftKey",
  23342. "shiftLeft",
  23343. "shippingAddress",
  23344. "shippingOption",
  23345. "shippingType",
  23346. "show",
  23347. "showHelp",
  23348. "showModal",
  23349. "showModalDialog",
  23350. "showModelessDialog",
  23351. "showNotification",
  23352. "sidebar",
  23353. "sign",
  23354. "signal",
  23355. "signalingState",
  23356. "signature",
  23357. "silent",
  23358. "sin",
  23359. "singleNodeValue",
  23360. "sinh",
  23361. "sinkId",
  23362. "sittingToStandingTransform",
  23363. "size",
  23364. "sizeToContent",
  23365. "sizeX",
  23366. "sizeZ",
  23367. "sizes",
  23368. "skewX",
  23369. "skewXSelf",
  23370. "skewY",
  23371. "skewYSelf",
  23372. "slice",
  23373. "slope",
  23374. "slot",
  23375. "small",
  23376. "smil",
  23377. "smooth",
  23378. "smoothingTimeConstant",
  23379. "snapToLines",
  23380. "snapshotItem",
  23381. "snapshotLength",
  23382. "some",
  23383. "sort",
  23384. "sortingCode",
  23385. "source",
  23386. "sourceBuffer",
  23387. "sourceBuffers",
  23388. "sourceCapabilities",
  23389. "sourceFile",
  23390. "sourceIndex",
  23391. "sources",
  23392. "spacing",
  23393. "span",
  23394. "speak",
  23395. "speakAs",
  23396. "speaking",
  23397. "species",
  23398. "specified",
  23399. "specularConstant",
  23400. "specularExponent",
  23401. "speechSynthesis",
  23402. "speed",
  23403. "speedOfSound",
  23404. "spellcheck",
  23405. "splice",
  23406. "split",
  23407. "splitText",
  23408. "spreadMethod",
  23409. "sqrt",
  23410. "src",
  23411. "srcElement",
  23412. "srcFilter",
  23413. "srcObject",
  23414. "srcUrn",
  23415. "srcdoc",
  23416. "srclang",
  23417. "srcset",
  23418. "stack",
  23419. "stackTraceLimit",
  23420. "stacktrace",
  23421. "stageParameters",
  23422. "standalone",
  23423. "standby",
  23424. "start",
  23425. "startContainer",
  23426. "startIce",
  23427. "startMessages",
  23428. "startNotifications",
  23429. "startOffset",
  23430. "startProfiling",
  23431. "startRendering",
  23432. "startShark",
  23433. "startTime",
  23434. "startsWith",
  23435. "state",
  23436. "status",
  23437. "statusCode",
  23438. "statusMessage",
  23439. "statusText",
  23440. "statusbar",
  23441. "stdDeviationX",
  23442. "stdDeviationY",
  23443. "stencilFunc",
  23444. "stencilFuncSeparate",
  23445. "stencilMask",
  23446. "stencilMaskSeparate",
  23447. "stencilOp",
  23448. "stencilOpSeparate",
  23449. "step",
  23450. "stepDown",
  23451. "stepMismatch",
  23452. "stepUp",
  23453. "sticky",
  23454. "stitchTiles",
  23455. "stop",
  23456. "stop-color",
  23457. "stop-opacity",
  23458. "stopColor",
  23459. "stopImmediatePropagation",
  23460. "stopNotifications",
  23461. "stopOpacity",
  23462. "stopProfiling",
  23463. "stopPropagation",
  23464. "stopShark",
  23465. "stopped",
  23466. "storage",
  23467. "storageArea",
  23468. "storageName",
  23469. "storageStatus",
  23470. "store",
  23471. "storeSiteSpecificTrackingException",
  23472. "storeWebWideTrackingException",
  23473. "stpVersion",
  23474. "stream",
  23475. "streams",
  23476. "stretch",
  23477. "strike",
  23478. "string",
  23479. "stringValue",
  23480. "stringify",
  23481. "stroke",
  23482. "stroke-dasharray",
  23483. "stroke-dashoffset",
  23484. "stroke-linecap",
  23485. "stroke-linejoin",
  23486. "stroke-miterlimit",
  23487. "stroke-opacity",
  23488. "stroke-width",
  23489. "strokeDasharray",
  23490. "strokeDashoffset",
  23491. "strokeLinecap",
  23492. "strokeLinejoin",
  23493. "strokeMiterlimit",
  23494. "strokeOpacity",
  23495. "strokeRect",
  23496. "strokeStyle",
  23497. "strokeText",
  23498. "strokeWidth",
  23499. "style",
  23500. "styleFloat",
  23501. "styleMap",
  23502. "styleMedia",
  23503. "styleSheet",
  23504. "styleSheetSets",
  23505. "styleSheets",
  23506. "sub",
  23507. "subarray",
  23508. "subject",
  23509. "submit",
  23510. "submitFrame",
  23511. "submitter",
  23512. "subscribe",
  23513. "substr",
  23514. "substring",
  23515. "substringData",
  23516. "subtle",
  23517. "subtree",
  23518. "suffix",
  23519. "suffixes",
  23520. "summary",
  23521. "sup",
  23522. "supported",
  23523. "supportedContentEncodings",
  23524. "supportedEntryTypes",
  23525. "supports",
  23526. "supportsSession",
  23527. "surfaceScale",
  23528. "surroundContents",
  23529. "suspend",
  23530. "suspendRedraw",
  23531. "swapCache",
  23532. "swapNode",
  23533. "sweepFlag",
  23534. "symbols",
  23535. "sync",
  23536. "sysexEnabled",
  23537. "system",
  23538. "systemCode",
  23539. "systemId",
  23540. "systemLanguage",
  23541. "systemXDPI",
  23542. "systemYDPI",
  23543. "tBodies",
  23544. "tFoot",
  23545. "tHead",
  23546. "tabIndex",
  23547. "table",
  23548. "table-layout",
  23549. "tableLayout",
  23550. "tableValues",
  23551. "tag",
  23552. "tagName",
  23553. "tagUrn",
  23554. "tags",
  23555. "taintEnabled",
  23556. "takePhoto",
  23557. "takeRecords",
  23558. "tan",
  23559. "tangentialPressure",
  23560. "tanh",
  23561. "target",
  23562. "targetElement",
  23563. "targetRayMode",
  23564. "targetRaySpace",
  23565. "targetTouches",
  23566. "targetX",
  23567. "targetY",
  23568. "tcpType",
  23569. "tee",
  23570. "tel",
  23571. "terminate",
  23572. "test",
  23573. "texImage2D",
  23574. "texImage3D",
  23575. "texParameterf",
  23576. "texParameteri",
  23577. "texStorage2D",
  23578. "texStorage3D",
  23579. "texSubImage2D",
  23580. "texSubImage3D",
  23581. "text",
  23582. "text-align",
  23583. "text-align-last",
  23584. "text-anchor",
  23585. "text-combine-upright",
  23586. "text-decoration",
  23587. "text-decoration-color",
  23588. "text-decoration-line",
  23589. "text-decoration-skip-ink",
  23590. "text-decoration-style",
  23591. "text-decoration-thickness",
  23592. "text-emphasis",
  23593. "text-emphasis-color",
  23594. "text-emphasis-position",
  23595. "text-emphasis-style",
  23596. "text-indent",
  23597. "text-justify",
  23598. "text-orientation",
  23599. "text-overflow",
  23600. "text-rendering",
  23601. "text-shadow",
  23602. "text-transform",
  23603. "text-underline-offset",
  23604. "text-underline-position",
  23605. "textAlign",
  23606. "textAlignLast",
  23607. "textAnchor",
  23608. "textAutospace",
  23609. "textBaseline",
  23610. "textCombineUpright",
  23611. "textContent",
  23612. "textDecoration",
  23613. "textDecorationBlink",
  23614. "textDecorationColor",
  23615. "textDecorationLine",
  23616. "textDecorationLineThrough",
  23617. "textDecorationNone",
  23618. "textDecorationOverline",
  23619. "textDecorationSkipInk",
  23620. "textDecorationStyle",
  23621. "textDecorationThickness",
  23622. "textDecorationUnderline",
  23623. "textEmphasis",
  23624. "textEmphasisColor",
  23625. "textEmphasisPosition",
  23626. "textEmphasisStyle",
  23627. "textIndent",
  23628. "textJustify",
  23629. "textJustifyTrim",
  23630. "textKashida",
  23631. "textKashidaSpace",
  23632. "textLength",
  23633. "textOrientation",
  23634. "textOverflow",
  23635. "textRendering",
  23636. "textShadow",
  23637. "textTracks",
  23638. "textTransform",
  23639. "textUnderlineOffset",
  23640. "textUnderlinePosition",
  23641. "then",
  23642. "threadId",
  23643. "threshold",
  23644. "thresholds",
  23645. "tiltX",
  23646. "tiltY",
  23647. "time",
  23648. "timeEnd",
  23649. "timeLog",
  23650. "timeOrigin",
  23651. "timeRemaining",
  23652. "timeStamp",
  23653. "timecode",
  23654. "timeline",
  23655. "timelineTime",
  23656. "timeout",
  23657. "timestamp",
  23658. "timestampOffset",
  23659. "timing",
  23660. "title",
  23661. "to",
  23662. "toArray",
  23663. "toBlob",
  23664. "toDataURL",
  23665. "toDateString",
  23666. "toElement",
  23667. "toExponential",
  23668. "toFixed",
  23669. "toFloat32Array",
  23670. "toFloat64Array",
  23671. "toGMTString",
  23672. "toISOString",
  23673. "toJSON",
  23674. "toLocaleDateString",
  23675. "toLocaleFormat",
  23676. "toLocaleLowerCase",
  23677. "toLocaleString",
  23678. "toLocaleTimeString",
  23679. "toLocaleUpperCase",
  23680. "toLowerCase",
  23681. "toMatrix",
  23682. "toMethod",
  23683. "toPrecision",
  23684. "toPrimitive",
  23685. "toSdp",
  23686. "toSource",
  23687. "toStaticHTML",
  23688. "toString",
  23689. "toStringTag",
  23690. "toSum",
  23691. "toTimeString",
  23692. "toUTCString",
  23693. "toUpperCase",
  23694. "toggle",
  23695. "toggleAttribute",
  23696. "toggleLongPressEnabled",
  23697. "tone",
  23698. "toneBuffer",
  23699. "tooLong",
  23700. "tooShort",
  23701. "toolbar",
  23702. "top",
  23703. "topMargin",
  23704. "total",
  23705. "totalFrameDelay",
  23706. "totalVideoFrames",
  23707. "touch-action",
  23708. "touchAction",
  23709. "touched",
  23710. "touches",
  23711. "trace",
  23712. "track",
  23713. "trackVisibility",
  23714. "transaction",
  23715. "transactions",
  23716. "transceiver",
  23717. "transferControlToOffscreen",
  23718. "transferFromImageBitmap",
  23719. "transferImageBitmap",
  23720. "transferIn",
  23721. "transferOut",
  23722. "transferSize",
  23723. "transferToImageBitmap",
  23724. "transform",
  23725. "transform-box",
  23726. "transform-origin",
  23727. "transform-style",
  23728. "transformBox",
  23729. "transformFeedbackVaryings",
  23730. "transformOrigin",
  23731. "transformPoint",
  23732. "transformString",
  23733. "transformStyle",
  23734. "transformToDocument",
  23735. "transformToFragment",
  23736. "transition",
  23737. "transition-delay",
  23738. "transition-duration",
  23739. "transition-property",
  23740. "transition-timing-function",
  23741. "transitionDelay",
  23742. "transitionDuration",
  23743. "transitionProperty",
  23744. "transitionTimingFunction",
  23745. "translate",
  23746. "translateSelf",
  23747. "translationX",
  23748. "translationY",
  23749. "transport",
  23750. "trim",
  23751. "trimEnd",
  23752. "trimLeft",
  23753. "trimRight",
  23754. "trimStart",
  23755. "trueSpeed",
  23756. "trunc",
  23757. "truncate",
  23758. "trustedTypes",
  23759. "turn",
  23760. "twist",
  23761. "type",
  23762. "typeDetail",
  23763. "typeMismatch",
  23764. "typeMustMatch",
  23765. "types",
  23766. "u2f",
  23767. "ubound",
  23768. "uint16",
  23769. "uint32",
  23770. "uint8",
  23771. "uint8Clamped",
  23772. "undefined",
  23773. "unescape",
  23774. "uneval",
  23775. "unicode",
  23776. "unicode-bidi",
  23777. "unicodeBidi",
  23778. "unicodeRange",
  23779. "uniform1f",
  23780. "uniform1fv",
  23781. "uniform1i",
  23782. "uniform1iv",
  23783. "uniform1ui",
  23784. "uniform1uiv",
  23785. "uniform2f",
  23786. "uniform2fv",
  23787. "uniform2i",
  23788. "uniform2iv",
  23789. "uniform2ui",
  23790. "uniform2uiv",
  23791. "uniform3f",
  23792. "uniform3fv",
  23793. "uniform3i",
  23794. "uniform3iv",
  23795. "uniform3ui",
  23796. "uniform3uiv",
  23797. "uniform4f",
  23798. "uniform4fv",
  23799. "uniform4i",
  23800. "uniform4iv",
  23801. "uniform4ui",
  23802. "uniform4uiv",
  23803. "uniformBlockBinding",
  23804. "uniformMatrix2fv",
  23805. "uniformMatrix2x3fv",
  23806. "uniformMatrix2x4fv",
  23807. "uniformMatrix3fv",
  23808. "uniformMatrix3x2fv",
  23809. "uniformMatrix3x4fv",
  23810. "uniformMatrix4fv",
  23811. "uniformMatrix4x2fv",
  23812. "uniformMatrix4x3fv",
  23813. "unique",
  23814. "uniqueID",
  23815. "uniqueNumber",
  23816. "unit",
  23817. "unitType",
  23818. "units",
  23819. "unloadEventEnd",
  23820. "unloadEventStart",
  23821. "unlock",
  23822. "unmount",
  23823. "unobserve",
  23824. "unpause",
  23825. "unpauseAnimations",
  23826. "unreadCount",
  23827. "unregister",
  23828. "unregisterContentHandler",
  23829. "unregisterProtocolHandler",
  23830. "unscopables",
  23831. "unselectable",
  23832. "unshift",
  23833. "unsubscribe",
  23834. "unsuspendRedraw",
  23835. "unsuspendRedrawAll",
  23836. "unwatch",
  23837. "unwrapKey",
  23838. "upDegrees",
  23839. "upX",
  23840. "upY",
  23841. "upZ",
  23842. "update",
  23843. "updateCommands",
  23844. "updateIce",
  23845. "updateInterval",
  23846. "updatePlaybackRate",
  23847. "updateRenderState",
  23848. "updateSettings",
  23849. "updateTiming",
  23850. "updateViaCache",
  23851. "updateWith",
  23852. "updated",
  23853. "updating",
  23854. "upgrade",
  23855. "upload",
  23856. "uploadTotal",
  23857. "uploaded",
  23858. "upper",
  23859. "upperBound",
  23860. "upperOpen",
  23861. "uri",
  23862. "url",
  23863. "urn",
  23864. "urns",
  23865. "usages",
  23866. "usb",
  23867. "usbVersionMajor",
  23868. "usbVersionMinor",
  23869. "usbVersionSubminor",
  23870. "useCurrentView",
  23871. "useMap",
  23872. "useProgram",
  23873. "usedSpace",
  23874. "user-select",
  23875. "userActivation",
  23876. "userAgent",
  23877. "userChoice",
  23878. "userHandle",
  23879. "userHint",
  23880. "userLanguage",
  23881. "userSelect",
  23882. "userVisibleOnly",
  23883. "username",
  23884. "usernameFragment",
  23885. "utterance",
  23886. "uuid",
  23887. "v8BreakIterator",
  23888. "vAlign",
  23889. "vLink",
  23890. "valid",
  23891. "validate",
  23892. "validateProgram",
  23893. "validationMessage",
  23894. "validity",
  23895. "value",
  23896. "valueAsDate",
  23897. "valueAsNumber",
  23898. "valueAsString",
  23899. "valueInSpecifiedUnits",
  23900. "valueMissing",
  23901. "valueOf",
  23902. "valueText",
  23903. "valueType",
  23904. "values",
  23905. "variable",
  23906. "variant",
  23907. "variationSettings",
  23908. "vector-effect",
  23909. "vectorEffect",
  23910. "velocityAngular",
  23911. "velocityExpansion",
  23912. "velocityX",
  23913. "velocityY",
  23914. "vendor",
  23915. "vendorId",
  23916. "vendorSub",
  23917. "verify",
  23918. "version",
  23919. "vertexAttrib1f",
  23920. "vertexAttrib1fv",
  23921. "vertexAttrib2f",
  23922. "vertexAttrib2fv",
  23923. "vertexAttrib3f",
  23924. "vertexAttrib3fv",
  23925. "vertexAttrib4f",
  23926. "vertexAttrib4fv",
  23927. "vertexAttribDivisor",
  23928. "vertexAttribDivisorANGLE",
  23929. "vertexAttribI4i",
  23930. "vertexAttribI4iv",
  23931. "vertexAttribI4ui",
  23932. "vertexAttribI4uiv",
  23933. "vertexAttribIPointer",
  23934. "vertexAttribPointer",
  23935. "vertical",
  23936. "vertical-align",
  23937. "verticalAlign",
  23938. "verticalOverflow",
  23939. "vh",
  23940. "vibrate",
  23941. "vibrationActuator",
  23942. "videoBitsPerSecond",
  23943. "videoHeight",
  23944. "videoTracks",
  23945. "videoWidth",
  23946. "view",
  23947. "viewBox",
  23948. "viewBoxString",
  23949. "viewTarget",
  23950. "viewTargetString",
  23951. "viewport",
  23952. "viewportAnchorX",
  23953. "viewportAnchorY",
  23954. "viewportElement",
  23955. "views",
  23956. "violatedDirective",
  23957. "visibility",
  23958. "visibilityState",
  23959. "visible",
  23960. "visualViewport",
  23961. "vlinkColor",
  23962. "vmax",
  23963. "vmin",
  23964. "voice",
  23965. "voiceURI",
  23966. "volume",
  23967. "vrml",
  23968. "vspace",
  23969. "vw",
  23970. "w",
  23971. "wait",
  23972. "waitSync",
  23973. "waiting",
  23974. "wake",
  23975. "wakeLock",
  23976. "wand",
  23977. "warn",
  23978. "wasClean",
  23979. "wasDiscarded",
  23980. "watch",
  23981. "watchAvailability",
  23982. "watchPosition",
  23983. "webdriver",
  23984. "webkitAddKey",
  23985. "webkitAlignContent",
  23986. "webkitAlignItems",
  23987. "webkitAlignSelf",
  23988. "webkitAnimation",
  23989. "webkitAnimationDelay",
  23990. "webkitAnimationDirection",
  23991. "webkitAnimationDuration",
  23992. "webkitAnimationFillMode",
  23993. "webkitAnimationIterationCount",
  23994. "webkitAnimationName",
  23995. "webkitAnimationPlayState",
  23996. "webkitAnimationTimingFunction",
  23997. "webkitAppearance",
  23998. "webkitAudioContext",
  23999. "webkitAudioDecodedByteCount",
  24000. "webkitAudioPannerNode",
  24001. "webkitBackfaceVisibility",
  24002. "webkitBackground",
  24003. "webkitBackgroundAttachment",
  24004. "webkitBackgroundClip",
  24005. "webkitBackgroundColor",
  24006. "webkitBackgroundImage",
  24007. "webkitBackgroundOrigin",
  24008. "webkitBackgroundPosition",
  24009. "webkitBackgroundPositionX",
  24010. "webkitBackgroundPositionY",
  24011. "webkitBackgroundRepeat",
  24012. "webkitBackgroundSize",
  24013. "webkitBackingStorePixelRatio",
  24014. "webkitBorderBottomLeftRadius",
  24015. "webkitBorderBottomRightRadius",
  24016. "webkitBorderImage",
  24017. "webkitBorderImageOutset",
  24018. "webkitBorderImageRepeat",
  24019. "webkitBorderImageSlice",
  24020. "webkitBorderImageSource",
  24021. "webkitBorderImageWidth",
  24022. "webkitBorderRadius",
  24023. "webkitBorderTopLeftRadius",
  24024. "webkitBorderTopRightRadius",
  24025. "webkitBoxAlign",
  24026. "webkitBoxDirection",
  24027. "webkitBoxFlex",
  24028. "webkitBoxOrdinalGroup",
  24029. "webkitBoxOrient",
  24030. "webkitBoxPack",
  24031. "webkitBoxShadow",
  24032. "webkitBoxSizing",
  24033. "webkitCancelAnimationFrame",
  24034. "webkitCancelFullScreen",
  24035. "webkitCancelKeyRequest",
  24036. "webkitCancelRequestAnimationFrame",
  24037. "webkitClearResourceTimings",
  24038. "webkitClosedCaptionsVisible",
  24039. "webkitConvertPointFromNodeToPage",
  24040. "webkitConvertPointFromPageToNode",
  24041. "webkitCreateShadowRoot",
  24042. "webkitCurrentFullScreenElement",
  24043. "webkitCurrentPlaybackTargetIsWireless",
  24044. "webkitDecodedFrameCount",
  24045. "webkitDirectionInvertedFromDevice",
  24046. "webkitDisplayingFullscreen",
  24047. "webkitDroppedFrameCount",
  24048. "webkitEnterFullScreen",
  24049. "webkitEnterFullscreen",
  24050. "webkitEntries",
  24051. "webkitExitFullScreen",
  24052. "webkitExitFullscreen",
  24053. "webkitExitPointerLock",
  24054. "webkitFilter",
  24055. "webkitFlex",
  24056. "webkitFlexBasis",
  24057. "webkitFlexDirection",
  24058. "webkitFlexFlow",
  24059. "webkitFlexGrow",
  24060. "webkitFlexShrink",
  24061. "webkitFlexWrap",
  24062. "webkitFullScreenKeyboardInputAllowed",
  24063. "webkitFullscreenElement",
  24064. "webkitFullscreenEnabled",
  24065. "webkitGenerateKeyRequest",
  24066. "webkitGetAsEntry",
  24067. "webkitGetDatabaseNames",
  24068. "webkitGetEntries",
  24069. "webkitGetEntriesByName",
  24070. "webkitGetEntriesByType",
  24071. "webkitGetFlowByName",
  24072. "webkitGetGamepads",
  24073. "webkitGetImageDataHD",
  24074. "webkitGetNamedFlows",
  24075. "webkitGetRegionFlowRanges",
  24076. "webkitGetUserMedia",
  24077. "webkitHasClosedCaptions",
  24078. "webkitHidden",
  24079. "webkitIDBCursor",
  24080. "webkitIDBDatabase",
  24081. "webkitIDBDatabaseError",
  24082. "webkitIDBDatabaseException",
  24083. "webkitIDBFactory",
  24084. "webkitIDBIndex",
  24085. "webkitIDBKeyRange",
  24086. "webkitIDBObjectStore",
  24087. "webkitIDBRequest",
  24088. "webkitIDBTransaction",
  24089. "webkitImageSmoothingEnabled",
  24090. "webkitIndexedDB",
  24091. "webkitInitMessageEvent",
  24092. "webkitIsFullScreen",
  24093. "webkitJustifyContent",
  24094. "webkitKeys",
  24095. "webkitLineClamp",
  24096. "webkitLineDashOffset",
  24097. "webkitLockOrientation",
  24098. "webkitMask",
  24099. "webkitMaskClip",
  24100. "webkitMaskComposite",
  24101. "webkitMaskImage",
  24102. "webkitMaskOrigin",
  24103. "webkitMaskPosition",
  24104. "webkitMaskPositionX",
  24105. "webkitMaskPositionY",
  24106. "webkitMaskRepeat",
  24107. "webkitMaskSize",
  24108. "webkitMatchesSelector",
  24109. "webkitMediaStream",
  24110. "webkitNotifications",
  24111. "webkitOfflineAudioContext",
  24112. "webkitOrder",
  24113. "webkitOrientation",
  24114. "webkitPeerConnection00",
  24115. "webkitPersistentStorage",
  24116. "webkitPerspective",
  24117. "webkitPerspectiveOrigin",
  24118. "webkitPointerLockElement",
  24119. "webkitPostMessage",
  24120. "webkitPreservesPitch",
  24121. "webkitPutImageDataHD",
  24122. "webkitRTCPeerConnection",
  24123. "webkitRegionOverset",
  24124. "webkitRelativePath",
  24125. "webkitRequestAnimationFrame",
  24126. "webkitRequestFileSystem",
  24127. "webkitRequestFullScreen",
  24128. "webkitRequestFullscreen",
  24129. "webkitRequestPointerLock",
  24130. "webkitResolveLocalFileSystemURL",
  24131. "webkitSetMediaKeys",
  24132. "webkitSetResourceTimingBufferSize",
  24133. "webkitShadowRoot",
  24134. "webkitShowPlaybackTargetPicker",
  24135. "webkitSlice",
  24136. "webkitSpeechGrammar",
  24137. "webkitSpeechGrammarList",
  24138. "webkitSpeechRecognition",
  24139. "webkitSpeechRecognitionError",
  24140. "webkitSpeechRecognitionEvent",
  24141. "webkitStorageInfo",
  24142. "webkitSupportsFullscreen",
  24143. "webkitTemporaryStorage",
  24144. "webkitTextFillColor",
  24145. "webkitTextSizeAdjust",
  24146. "webkitTextStroke",
  24147. "webkitTextStrokeColor",
  24148. "webkitTextStrokeWidth",
  24149. "webkitTransform",
  24150. "webkitTransformOrigin",
  24151. "webkitTransformStyle",
  24152. "webkitTransition",
  24153. "webkitTransitionDelay",
  24154. "webkitTransitionDuration",
  24155. "webkitTransitionProperty",
  24156. "webkitTransitionTimingFunction",
  24157. "webkitURL",
  24158. "webkitUnlockOrientation",
  24159. "webkitUserSelect",
  24160. "webkitVideoDecodedByteCount",
  24161. "webkitVisibilityState",
  24162. "webkitWirelessVideoPlaybackDisabled",
  24163. "webkitdirectory",
  24164. "webkitdropzone",
  24165. "webstore",
  24166. "weight",
  24167. "whatToShow",
  24168. "wheelDelta",
  24169. "wheelDeltaX",
  24170. "wheelDeltaY",
  24171. "whenDefined",
  24172. "which",
  24173. "white-space",
  24174. "whiteSpace",
  24175. "wholeText",
  24176. "widows",
  24177. "width",
  24178. "will-change",
  24179. "willChange",
  24180. "willValidate",
  24181. "window",
  24182. "withCredentials",
  24183. "word-break",
  24184. "word-spacing",
  24185. "word-wrap",
  24186. "wordBreak",
  24187. "wordSpacing",
  24188. "wordWrap",
  24189. "workerStart",
  24190. "wrap",
  24191. "wrapKey",
  24192. "writable",
  24193. "writableAuxiliaries",
  24194. "write",
  24195. "writeText",
  24196. "writeValue",
  24197. "writeWithoutResponse",
  24198. "writeln",
  24199. "writing-mode",
  24200. "writingMode",
  24201. "x",
  24202. "x1",
  24203. "x2",
  24204. "xChannelSelector",
  24205. "xmlEncoding",
  24206. "xmlStandalone",
  24207. "xmlVersion",
  24208. "xmlbase",
  24209. "xmllang",
  24210. "xmlspace",
  24211. "xor",
  24212. "xr",
  24213. "y",
  24214. "y1",
  24215. "y2",
  24216. "yChannelSelector",
  24217. "yandex",
  24218. "z",
  24219. "z-index",
  24220. "zIndex",
  24221. "zoom",
  24222. "zoomAndPan",
  24223. "zoomRectScreen",
  24224. ];
  24225. /***********************************************************************
  24226. A JavaScript tokenizer / parser / beautifier / compressor.
  24227. https://github.com/mishoo/UglifyJS2
  24228. -------------------------------- (C) ---------------------------------
  24229. Author: Mihai Bazon
  24230. <mihai.bazon@gmail.com>
  24231. http://mihai.bazon.net/blog
  24232. Distributed under the BSD license:
  24233. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  24234. Redistribution and use in source and binary forms, with or without
  24235. modification, are permitted provided that the following conditions
  24236. are met:
  24237. * Redistributions of source code must retain the above
  24238. copyright notice, this list of conditions and the following
  24239. disclaimer.
  24240. * Redistributions in binary form must reproduce the above
  24241. copyright notice, this list of conditions and the following
  24242. disclaimer in the documentation and/or other materials
  24243. provided with the distribution.
  24244. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  24245. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24246. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  24247. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  24248. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  24249. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24250. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24251. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24252. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  24253. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  24254. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24255. SUCH DAMAGE.
  24256. ***********************************************************************/
  24257. function find_builtins(reserved) {
  24258. domprops.forEach(add);
  24259. // Compatibility fix for some standard defined globals not defined on every js environment
  24260. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  24261. var objects = {};
  24262. var global_ref = typeof global === "object" ? global : self;
  24263. new_globals.forEach(function (new_global) {
  24264. objects[new_global] = global_ref[new_global] || new Function();
  24265. });
  24266. [
  24267. "null",
  24268. "true",
  24269. "false",
  24270. "NaN",
  24271. "Infinity",
  24272. "-Infinity",
  24273. "undefined",
  24274. ].forEach(add);
  24275. [ Object, Array, Function, Number,
  24276. String, Boolean, Error, Math,
  24277. Date, RegExp, objects.Symbol, ArrayBuffer,
  24278. DataView, decodeURI, decodeURIComponent,
  24279. encodeURI, encodeURIComponent, eval, EvalError,
  24280. Float32Array, Float64Array, Int8Array, Int16Array,
  24281. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  24282. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  24283. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  24284. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  24285. objects.WeakMap, objects.WeakSet
  24286. ].forEach(function(ctor) {
  24287. Object.getOwnPropertyNames(ctor).map(add);
  24288. if (ctor.prototype) {
  24289. Object.getOwnPropertyNames(ctor.prototype).map(add);
  24290. }
  24291. });
  24292. function add(name) {
  24293. reserved.add(name);
  24294. }
  24295. }
  24296. function reserve_quoted_keys(ast, reserved) {
  24297. function add(name) {
  24298. push_uniq(reserved, name);
  24299. }
  24300. ast.walk(new TreeWalker(function(node) {
  24301. if (node instanceof AST_ObjectKeyVal && node.quote) {
  24302. add(node.key);
  24303. } else if (node instanceof AST_ObjectProperty && node.quote) {
  24304. add(node.key.name);
  24305. } else if (node instanceof AST_Sub) {
  24306. addStrings(node.property, add);
  24307. }
  24308. }));
  24309. }
  24310. function addStrings(node, add) {
  24311. node.walk(new TreeWalker(function(node) {
  24312. if (node instanceof AST_Sequence) {
  24313. addStrings(node.tail_node(), add);
  24314. } else if (node instanceof AST_String) {
  24315. add(node.value);
  24316. } else if (node instanceof AST_Conditional) {
  24317. addStrings(node.consequent, add);
  24318. addStrings(node.alternative, add);
  24319. }
  24320. return true;
  24321. }));
  24322. }
  24323. function mangle_properties(ast, options) {
  24324. options = defaults(options, {
  24325. builtins: false,
  24326. cache: null,
  24327. debug: false,
  24328. keep_quoted: false,
  24329. only_cache: false,
  24330. regex: null,
  24331. reserved: null,
  24332. undeclared: false,
  24333. }, true);
  24334. var reserved_option = options.reserved;
  24335. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  24336. var reserved = new Set(reserved_option);
  24337. if (!options.builtins) find_builtins(reserved);
  24338. var cname = -1;
  24339. var cache;
  24340. if (options.cache) {
  24341. cache = options.cache.props;
  24342. cache.forEach(function(mangled_name) {
  24343. reserved.add(mangled_name);
  24344. });
  24345. } else {
  24346. cache = new Map();
  24347. }
  24348. var regex = options.regex && new RegExp(options.regex);
  24349. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  24350. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  24351. // the same as passing an empty string.
  24352. var debug = options.debug !== false;
  24353. var debug_name_suffix;
  24354. if (debug) {
  24355. debug_name_suffix = (options.debug === true ? "" : options.debug);
  24356. }
  24357. var names_to_mangle = new Set();
  24358. var unmangleable = new Set();
  24359. var keep_quoted_strict = options.keep_quoted === "strict";
  24360. // step 1: find candidates to mangle
  24361. ast.walk(new TreeWalker(function(node) {
  24362. if (node instanceof AST_ObjectKeyVal) {
  24363. if (typeof node.key == "string" &&
  24364. (!keep_quoted_strict || !node.quote)) {
  24365. add(node.key);
  24366. }
  24367. } else if (node instanceof AST_ObjectProperty) {
  24368. // setter or getter, since KeyVal is handled above
  24369. if (!keep_quoted_strict || !node.key.end.quote) {
  24370. add(node.key.name);
  24371. }
  24372. } else if (node instanceof AST_Dot) {
  24373. var declared = !!options.undeclared;
  24374. if (!declared) {
  24375. var root = node;
  24376. while (root.expression) {
  24377. root = root.expression;
  24378. }
  24379. declared = !(root.thedef && root.thedef.undeclared);
  24380. }
  24381. if (declared &&
  24382. (!keep_quoted_strict || !node.quote)) {
  24383. add(node.property);
  24384. }
  24385. } else if (node instanceof AST_Sub) {
  24386. if (!keep_quoted_strict) {
  24387. addStrings(node.property, add);
  24388. }
  24389. } else if (node instanceof AST_Call
  24390. && node.expression.print_to_string() == "Object.defineProperty") {
  24391. addStrings(node.args[1], add);
  24392. } else if (node instanceof AST_Binary && node.operator === "in") {
  24393. addStrings(node.left, add);
  24394. }
  24395. }));
  24396. // step 2: transform the tree, renaming properties
  24397. return ast.transform(new TreeTransformer(function(node) {
  24398. if (node instanceof AST_ObjectKeyVal) {
  24399. if (typeof node.key == "string" &&
  24400. (!keep_quoted_strict || !node.quote)) {
  24401. node.key = mangle(node.key);
  24402. }
  24403. } else if (node instanceof AST_ObjectProperty) {
  24404. // setter, getter, method or class field
  24405. if (!keep_quoted_strict || !node.key.end.quote) {
  24406. node.key.name = mangle(node.key.name);
  24407. }
  24408. } else if (node instanceof AST_Dot) {
  24409. if (!keep_quoted_strict || !node.quote) {
  24410. node.property = mangle(node.property);
  24411. }
  24412. } else if (!options.keep_quoted && node instanceof AST_Sub) {
  24413. node.property = mangleStrings(node.property);
  24414. } else if (node instanceof AST_Call
  24415. && node.expression.print_to_string() == "Object.defineProperty") {
  24416. node.args[1] = mangleStrings(node.args[1]);
  24417. } else if (node instanceof AST_Binary && node.operator === "in") {
  24418. node.left = mangleStrings(node.left);
  24419. }
  24420. }));
  24421. // only function declarations after this line
  24422. function can_mangle(name) {
  24423. if (unmangleable.has(name)) return false;
  24424. if (reserved.has(name)) return false;
  24425. if (options.only_cache) {
  24426. return cache.has(name);
  24427. }
  24428. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  24429. return true;
  24430. }
  24431. function should_mangle(name) {
  24432. if (regex && !regex.test(name)) return false;
  24433. if (reserved.has(name)) return false;
  24434. return cache.has(name)
  24435. || names_to_mangle.has(name);
  24436. }
  24437. function add(name) {
  24438. if (can_mangle(name))
  24439. names_to_mangle.add(name);
  24440. if (!should_mangle(name)) {
  24441. unmangleable.add(name);
  24442. }
  24443. }
  24444. function mangle(name) {
  24445. if (!should_mangle(name)) {
  24446. return name;
  24447. }
  24448. var mangled = cache.get(name);
  24449. if (!mangled) {
  24450. if (debug) {
  24451. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  24452. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  24453. if (can_mangle(debug_mangled)) {
  24454. mangled = debug_mangled;
  24455. }
  24456. }
  24457. // either debug mode is off, or it is on and we could not use the mangled name
  24458. if (!mangled) {
  24459. do {
  24460. mangled = base54(++cname);
  24461. } while (!can_mangle(mangled));
  24462. }
  24463. cache.set(name, mangled);
  24464. }
  24465. return mangled;
  24466. }
  24467. function mangleStrings(node) {
  24468. return node.transform(new TreeTransformer(function(node) {
  24469. if (node instanceof AST_Sequence) {
  24470. var last = node.expressions.length - 1;
  24471. node.expressions[last] = mangleStrings(node.expressions[last]);
  24472. } else if (node instanceof AST_String) {
  24473. node.value = mangle(node.value);
  24474. } else if (node instanceof AST_Conditional) {
  24475. node.consequent = mangleStrings(node.consequent);
  24476. node.alternative = mangleStrings(node.alternative);
  24477. }
  24478. return node;
  24479. }));
  24480. }
  24481. }
  24482. var to_ascii = typeof atob == "undefined" ? function(b64) {
  24483. return Buffer.from(b64, "base64").toString();
  24484. } : atob;
  24485. var to_base64 = typeof btoa == "undefined" ? function(str) {
  24486. return Buffer.from(str).toString("base64");
  24487. } : btoa;
  24488. function read_source_map(code) {
  24489. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  24490. if (!match) {
  24491. console.warn("inline source map not found");
  24492. return null;
  24493. }
  24494. return to_ascii(match[2]);
  24495. }
  24496. function set_shorthand(name, options, keys) {
  24497. if (options[name]) {
  24498. keys.forEach(function(key) {
  24499. if (options[key]) {
  24500. if (typeof options[key] != "object") options[key] = {};
  24501. if (!(name in options[key])) options[key][name] = options[name];
  24502. }
  24503. });
  24504. }
  24505. }
  24506. function init_cache(cache) {
  24507. if (!cache) return;
  24508. if (!("props" in cache)) {
  24509. cache.props = new Map();
  24510. } else if (!(cache.props instanceof Map)) {
  24511. cache.props = map_from_object(cache.props);
  24512. }
  24513. }
  24514. function cache_to_json(cache) {
  24515. return {
  24516. props: map_to_object(cache.props)
  24517. };
  24518. }
  24519. async function minify(files, options) {
  24520. options = defaults(options, {
  24521. compress: {},
  24522. ecma: undefined,
  24523. enclose: false,
  24524. ie8: false,
  24525. keep_classnames: undefined,
  24526. keep_fnames: false,
  24527. mangle: {},
  24528. module: false,
  24529. nameCache: null,
  24530. output: null,
  24531. format: null,
  24532. parse: {},
  24533. rename: undefined,
  24534. safari10: false,
  24535. sourceMap: false,
  24536. timings: false,
  24537. toplevel: false,
  24538. warnings: false,
  24539. wrap: false,
  24540. }, true);
  24541. var timings = options.timings && {
  24542. start: Date.now()
  24543. };
  24544. if (options.keep_classnames === undefined) {
  24545. options.keep_classnames = options.keep_fnames;
  24546. }
  24547. if (options.rename === undefined) {
  24548. options.rename = options.compress && options.mangle;
  24549. }
  24550. if (options.output && options.format) {
  24551. throw new Error("Please only specify either output or format option, preferrably format.");
  24552. }
  24553. options.format = options.format || options.output || {};
  24554. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  24555. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  24556. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  24557. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  24558. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  24559. set_shorthand("safari10", options, [ "mangle", "format" ]);
  24560. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  24561. set_shorthand("warnings", options, [ "compress" ]); // legacy
  24562. var quoted_props;
  24563. if (options.mangle) {
  24564. options.mangle = defaults(options.mangle, {
  24565. cache: options.nameCache && (options.nameCache.vars || {}),
  24566. eval: false,
  24567. ie8: false,
  24568. keep_classnames: false,
  24569. keep_fnames: false,
  24570. module: false,
  24571. properties: false,
  24572. reserved: [],
  24573. safari10: false,
  24574. toplevel: false,
  24575. }, true);
  24576. if (options.mangle.properties) {
  24577. if (typeof options.mangle.properties != "object") {
  24578. options.mangle.properties = {};
  24579. }
  24580. if (options.mangle.properties.keep_quoted) {
  24581. quoted_props = options.mangle.properties.reserved;
  24582. if (!Array.isArray(quoted_props)) quoted_props = [];
  24583. options.mangle.properties.reserved = quoted_props;
  24584. }
  24585. if (options.nameCache && !("cache" in options.mangle.properties)) {
  24586. options.mangle.properties.cache = options.nameCache.props || {};
  24587. }
  24588. }
  24589. init_cache(options.mangle.cache);
  24590. init_cache(options.mangle.properties.cache);
  24591. }
  24592. if (options.sourceMap) {
  24593. options.sourceMap = defaults(options.sourceMap, {
  24594. asObject: false,
  24595. content: null,
  24596. filename: null,
  24597. includeSources: false,
  24598. root: null,
  24599. url: null,
  24600. }, true);
  24601. }
  24602. if (timings) timings.parse = Date.now();
  24603. var toplevel;
  24604. if (files instanceof AST_Toplevel) {
  24605. toplevel = files;
  24606. } else {
  24607. if (typeof files == "string") {
  24608. files = [ files ];
  24609. }
  24610. options.parse = options.parse || {};
  24611. options.parse.toplevel = null;
  24612. for (var name in files) if (HOP(files, name)) {
  24613. options.parse.filename = name;
  24614. options.parse.toplevel = parse(files[name], options.parse);
  24615. if (options.sourceMap && options.sourceMap.content == "inline") {
  24616. if (Object.keys(files).length > 1)
  24617. throw new Error("inline source map only works with singular input");
  24618. options.sourceMap.content = read_source_map(files[name]);
  24619. }
  24620. }
  24621. toplevel = options.parse.toplevel;
  24622. }
  24623. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  24624. reserve_quoted_keys(toplevel, quoted_props);
  24625. }
  24626. if (options.wrap) {
  24627. toplevel = toplevel.wrap_commonjs(options.wrap);
  24628. }
  24629. if (options.enclose) {
  24630. toplevel = toplevel.wrap_enclose(options.enclose);
  24631. }
  24632. if (timings) timings.rename = Date.now();
  24633. if (timings) timings.compress = Date.now();
  24634. if (options.compress) {
  24635. toplevel = new Compressor(options.compress, {
  24636. mangle_options: options.mangle
  24637. }).compress(toplevel);
  24638. }
  24639. if (timings) timings.scope = Date.now();
  24640. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  24641. if (timings) timings.mangle = Date.now();
  24642. if (options.mangle) {
  24643. base54.reset();
  24644. toplevel.compute_char_frequency(options.mangle);
  24645. toplevel.mangle_names(options.mangle);
  24646. }
  24647. if (timings) timings.properties = Date.now();
  24648. if (options.mangle && options.mangle.properties) {
  24649. toplevel = mangle_properties(toplevel, options.mangle.properties);
  24650. }
  24651. if (timings) timings.format = Date.now();
  24652. var result = {};
  24653. if (options.format.ast) {
  24654. result.ast = toplevel;
  24655. }
  24656. if (!HOP(options.format, "code") || options.format.code) {
  24657. if (options.sourceMap) {
  24658. options.format.source_map = await SourceMap({
  24659. file: options.sourceMap.filename,
  24660. orig: options.sourceMap.content,
  24661. root: options.sourceMap.root
  24662. });
  24663. if (options.sourceMap.includeSources) {
  24664. if (files instanceof AST_Toplevel) {
  24665. throw new Error("original source content unavailable");
  24666. } else for (var name in files) if (HOP(files, name)) {
  24667. options.format.source_map.get().setSourceContent(name, files[name]);
  24668. }
  24669. }
  24670. }
  24671. delete options.format.ast;
  24672. delete options.format.code;
  24673. var stream = OutputStream(options.format);
  24674. toplevel.print(stream);
  24675. result.code = stream.get();
  24676. if (options.sourceMap) {
  24677. if(options.sourceMap.asObject) {
  24678. result.map = options.format.source_map.get().toJSON();
  24679. } else {
  24680. result.map = options.format.source_map.toString();
  24681. }
  24682. if (options.sourceMap.url == "inline") {
  24683. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  24684. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  24685. } else if (options.sourceMap.url) {
  24686. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  24687. }
  24688. }
  24689. }
  24690. if (options.nameCache && options.mangle) {
  24691. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  24692. if (options.mangle.properties && options.mangle.properties.cache) {
  24693. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  24694. }
  24695. }
  24696. if (options.format && options.format.source_map) {
  24697. options.format.source_map.destroy();
  24698. }
  24699. if (timings) {
  24700. timings.end = Date.now();
  24701. result.timings = {
  24702. parse: 1e-3 * (timings.rename - timings.parse),
  24703. rename: 1e-3 * (timings.compress - timings.rename),
  24704. compress: 1e-3 * (timings.scope - timings.compress),
  24705. scope: 1e-3 * (timings.mangle - timings.scope),
  24706. mangle: 1e-3 * (timings.properties - timings.mangle),
  24707. properties: 1e-3 * (timings.format - timings.properties),
  24708. format: 1e-3 * (timings.end - timings.format),
  24709. total: 1e-3 * (timings.end - timings.start)
  24710. };
  24711. }
  24712. return result;
  24713. }
  24714. async function run_cli({ program, packageJson, fs, path }) {
  24715. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  24716. var files = {};
  24717. var options = {
  24718. compress: false,
  24719. mangle: false
  24720. };
  24721. const default_options = await _default_options();
  24722. program.version(packageJson.name + " " + packageJson.version);
  24723. program.parseArgv = program.parse;
  24724. program.parse = undefined;
  24725. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  24726. else if (process.argv.includes("options")) program.helpInformation = function() {
  24727. var text = [];
  24728. for (var option in default_options) {
  24729. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  24730. text.push(format_object(default_options[option]));
  24731. text.push("");
  24732. }
  24733. return text.join("\n");
  24734. };
  24735. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  24736. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  24737. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  24738. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  24739. program.option("-f, --format [options]", "Format options.", parse_js());
  24740. program.option("-b, --beautify [options]", "Alias for --format beautify=true.", parse_js());
  24741. program.option("-o, --output <file>", "Output file (default STDOUT).");
  24742. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  24743. program.option("--config-file <file>", "Read minify() options from JSON file.");
  24744. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  24745. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  24746. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  24747. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  24748. program.option("--keep-classnames", "Do not mangle/drop class names.");
  24749. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  24750. program.option("--module", "Input is an ES6 module");
  24751. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  24752. program.option("--rename", "Force symbol expansion.");
  24753. program.option("--no-rename", "Disable symbol expansion.");
  24754. program.option("--safari10", "Support non-standard Safari 10.");
  24755. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  24756. program.option("--timings", "Display operations run time on STDERR.");
  24757. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  24758. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  24759. program.arguments("[files...]").parseArgv(process.argv);
  24760. if (program.configFile) {
  24761. options = JSON.parse(read_file(program.configFile));
  24762. }
  24763. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  24764. fatal("ERROR: cannot write source map to STDOUT");
  24765. }
  24766. [
  24767. "compress",
  24768. "enclose",
  24769. "ie8",
  24770. "mangle",
  24771. "module",
  24772. "safari10",
  24773. "sourceMap",
  24774. "toplevel",
  24775. "wrap"
  24776. ].forEach(function(name) {
  24777. if (name in program) {
  24778. options[name] = program[name];
  24779. }
  24780. });
  24781. if ("ecma" in program) {
  24782. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  24783. const ecma = program.ecma | 0;
  24784. if (ecma > 5 && ecma < 2015)
  24785. options.ecma = ecma + 2009;
  24786. else
  24787. options.ecma = ecma;
  24788. }
  24789. if (program.beautify || program.format) {
  24790. if (program.beautify && program.format) {
  24791. fatal("Please only specify one of --beautify or --format");
  24792. }
  24793. if (program.beautify) {
  24794. options.format = typeof program.beautify == "object" ? program.beautify : {};
  24795. if (!("beautify" in options.format)) {
  24796. options.format.beautify = true;
  24797. }
  24798. }
  24799. if (program.format) {
  24800. options.format = typeof program.format == "object" ? program.format : {};
  24801. }
  24802. }
  24803. if (program.comments) {
  24804. if (typeof options.format != "object") options.format = {};
  24805. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  24806. }
  24807. if (program.define) {
  24808. if (typeof options.compress != "object") options.compress = {};
  24809. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  24810. for (var expr in program.define) {
  24811. options.compress.global_defs[expr] = program.define[expr];
  24812. }
  24813. }
  24814. if (program.keepClassnames) {
  24815. options.keep_classnames = true;
  24816. }
  24817. if (program.keepFnames) {
  24818. options.keep_fnames = true;
  24819. }
  24820. if (program.mangleProps) {
  24821. if (program.mangleProps.domprops) {
  24822. delete program.mangleProps.domprops;
  24823. } else {
  24824. if (typeof program.mangleProps != "object") program.mangleProps = {};
  24825. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  24826. }
  24827. if (typeof options.mangle != "object") options.mangle = {};
  24828. options.mangle.properties = program.mangleProps;
  24829. }
  24830. if (program.nameCache) {
  24831. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  24832. }
  24833. if (program.output == "ast") {
  24834. options.format = {
  24835. ast: true,
  24836. code: false
  24837. };
  24838. }
  24839. if (program.parse) {
  24840. if (!program.parse.acorn && !program.parse.spidermonkey) {
  24841. options.parse = program.parse;
  24842. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  24843. fatal("ERROR: inline source map only works with built-in parser");
  24844. }
  24845. }
  24846. if (~program.rawArgs.indexOf("--rename")) {
  24847. options.rename = true;
  24848. } else if (!program.rename) {
  24849. options.rename = false;
  24850. }
  24851. let convert_path = name => name;
  24852. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  24853. convert_path = function() {
  24854. var base = program.sourceMap.base;
  24855. delete options.sourceMap.base;
  24856. return function(name) {
  24857. return path.relative(base, name);
  24858. };
  24859. }();
  24860. }
  24861. let filesList;
  24862. if (options.files && options.files.length) {
  24863. filesList = options.files;
  24864. delete options.files;
  24865. } else if (program.args.length) {
  24866. filesList = program.args;
  24867. }
  24868. if (filesList) {
  24869. simple_glob(filesList).forEach(function(name) {
  24870. files[convert_path(name)] = read_file(name);
  24871. });
  24872. } else {
  24873. await new Promise((resolve) => {
  24874. var chunks = [];
  24875. process.stdin.setEncoding("utf8");
  24876. process.stdin.on("data", function(chunk) {
  24877. chunks.push(chunk);
  24878. }).on("end", function() {
  24879. files = [ chunks.join("") ];
  24880. resolve();
  24881. });
  24882. process.stdin.resume();
  24883. });
  24884. }
  24885. await run_cli();
  24886. function convert_ast(fn) {
  24887. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  24888. }
  24889. async function run_cli() {
  24890. var content = program.sourceMap && program.sourceMap.content;
  24891. if (content && content !== "inline") {
  24892. options.sourceMap.content = read_file(content, content);
  24893. }
  24894. if (program.timings) options.timings = true;
  24895. try {
  24896. if (program.parse) {
  24897. if (program.parse.acorn) {
  24898. files = convert_ast(function(toplevel, name) {
  24899. return require("acorn").parse(files[name], {
  24900. ecmaVersion: 2018,
  24901. locations: true,
  24902. program: toplevel,
  24903. sourceFile: name,
  24904. sourceType: options.module || program.parse.module ? "module" : "script"
  24905. });
  24906. });
  24907. } else if (program.parse.spidermonkey) {
  24908. files = convert_ast(function(toplevel, name) {
  24909. var obj = JSON.parse(files[name]);
  24910. if (!toplevel) return obj;
  24911. toplevel.body = toplevel.body.concat(obj.body);
  24912. return toplevel;
  24913. });
  24914. }
  24915. }
  24916. } catch (ex) {
  24917. fatal(ex);
  24918. }
  24919. let result;
  24920. try {
  24921. result = await minify(files, options);
  24922. } catch (ex) {
  24923. if (ex.name == "SyntaxError") {
  24924. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  24925. var col = ex.col;
  24926. var lines = files[ex.filename].split(/\r?\n/);
  24927. var line = lines[ex.line - 1];
  24928. if (!line && !col) {
  24929. line = lines[ex.line - 2];
  24930. col = line.length;
  24931. }
  24932. if (line) {
  24933. var limit = 70;
  24934. if (col > limit) {
  24935. line = line.slice(col - limit);
  24936. col = limit;
  24937. }
  24938. print_error(line.slice(0, 80));
  24939. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  24940. }
  24941. }
  24942. if (ex.defs) {
  24943. print_error("Supported options:");
  24944. print_error(format_object(ex.defs));
  24945. }
  24946. fatal(ex);
  24947. return;
  24948. }
  24949. if (program.output == "ast") {
  24950. if (!options.compress && !options.mangle) {
  24951. result.ast.figure_out_scope({});
  24952. }
  24953. console.log(JSON.stringify(result.ast, function(key, value) {
  24954. if (value) switch (key) {
  24955. case "thedef":
  24956. return symdef(value);
  24957. case "enclosed":
  24958. return value.length ? value.map(symdef) : undefined;
  24959. case "variables":
  24960. case "functions":
  24961. case "globals":
  24962. return value.size ? collect_from_map(value, symdef) : undefined;
  24963. }
  24964. if (skip_keys.has(key)) return;
  24965. if (value instanceof AST_Token) return;
  24966. if (value instanceof Map) return;
  24967. if (value instanceof AST_Node) {
  24968. var result = {
  24969. _class: "AST_" + value.TYPE
  24970. };
  24971. if (value.block_scope) {
  24972. result.variables = value.block_scope.variables;
  24973. result.functions = value.block_scope.functions;
  24974. result.enclosed = value.block_scope.enclosed;
  24975. }
  24976. value.CTOR.PROPS.forEach(function(prop) {
  24977. result[prop] = value[prop];
  24978. });
  24979. return result;
  24980. }
  24981. return value;
  24982. }, 2));
  24983. } else if (program.output == "spidermonkey") {
  24984. try {
  24985. const minified = await minify(result.code, {
  24986. compress: false,
  24987. mangle: false,
  24988. format: {
  24989. ast: true,
  24990. code: false
  24991. }
  24992. });
  24993. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  24994. } catch (ex) {
  24995. fatal(ex);
  24996. return;
  24997. }
  24998. } else if (program.output) {
  24999. fs.writeFileSync(program.output, result.code);
  25000. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  25001. fs.writeFileSync(program.output + ".map", result.map);
  25002. }
  25003. } else {
  25004. console.log(result.code);
  25005. }
  25006. if (program.nameCache) {
  25007. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  25008. }
  25009. if (result.timings) for (var phase in result.timings) {
  25010. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  25011. }
  25012. }
  25013. function fatal(message) {
  25014. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  25015. print_error(message);
  25016. process.exit(1);
  25017. }
  25018. // A file glob function that only supports "*" and "?" wildcards in the basename.
  25019. // Example: "foo/bar/*baz??.*.js"
  25020. // Argument `glob` may be a string or an array of strings.
  25021. // Returns an array of strings. Garbage in, garbage out.
  25022. function simple_glob(glob) {
  25023. if (Array.isArray(glob)) {
  25024. return [].concat.apply([], glob.map(simple_glob));
  25025. }
  25026. if (glob && glob.match(/[*?]/)) {
  25027. var dir = path.dirname(glob);
  25028. try {
  25029. var entries = fs.readdirSync(dir);
  25030. } catch (ex) {}
  25031. if (entries) {
  25032. var pattern = "^" + path.basename(glob)
  25033. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  25034. .replace(/\*/g, "[^/\\\\]*")
  25035. .replace(/\?/g, "[^/\\\\]") + "$";
  25036. var mod = process.platform === "win32" ? "i" : "";
  25037. var rx = new RegExp(pattern, mod);
  25038. var results = entries.filter(function(name) {
  25039. return rx.test(name);
  25040. }).map(function(name) {
  25041. return path.join(dir, name);
  25042. });
  25043. if (results.length) return results;
  25044. }
  25045. }
  25046. return [ glob ];
  25047. }
  25048. function read_file(path, default_value) {
  25049. try {
  25050. return fs.readFileSync(path, "utf8");
  25051. } catch (ex) {
  25052. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  25053. fatal(ex);
  25054. }
  25055. }
  25056. function parse_js(flag) {
  25057. return function(value, options) {
  25058. options = options || {};
  25059. try {
  25060. walk(parse(value, { expression: true }), node => {
  25061. if (node instanceof AST_Assign) {
  25062. var name = node.left.print_to_string();
  25063. var value = node.right;
  25064. if (flag) {
  25065. options[name] = value;
  25066. } else if (value instanceof AST_Array) {
  25067. options[name] = value.elements.map(to_string);
  25068. } else if (value instanceof AST_RegExp) {
  25069. value = value.value;
  25070. options[name] = new RegExp(value.source, value.flags);
  25071. } else {
  25072. options[name] = to_string(value);
  25073. }
  25074. return true;
  25075. }
  25076. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  25077. var name = node.print_to_string();
  25078. options[name] = true;
  25079. return true;
  25080. }
  25081. if (!(node instanceof AST_Sequence)) throw node;
  25082. function to_string(value) {
  25083. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  25084. quote_keys: true
  25085. });
  25086. }
  25087. });
  25088. } catch(ex) {
  25089. if (flag) {
  25090. fatal("Error parsing arguments for '" + flag + "': " + value);
  25091. } else {
  25092. options[value] = null;
  25093. }
  25094. }
  25095. return options;
  25096. };
  25097. }
  25098. function symdef(def) {
  25099. var ret = (1e6 + def.id) + " " + def.name;
  25100. if (def.mangled_name) ret += " " + def.mangled_name;
  25101. return ret;
  25102. }
  25103. function collect_from_map(map, callback) {
  25104. var result = [];
  25105. map.forEach(function (def) {
  25106. result.push(callback(def));
  25107. });
  25108. return result;
  25109. }
  25110. function format_object(obj) {
  25111. var lines = [];
  25112. var padding = "";
  25113. Object.keys(obj).map(function(name) {
  25114. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  25115. return [ name, JSON.stringify(obj[name]) ];
  25116. }).forEach(function(tokens) {
  25117. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  25118. });
  25119. return lines.join("\n");
  25120. }
  25121. function print_error(msg) {
  25122. process.stderr.write(msg);
  25123. process.stderr.write("\n");
  25124. }
  25125. function describe_ast() {
  25126. var out = OutputStream({ beautify: true });
  25127. function doitem(ctor) {
  25128. out.print("AST_" + ctor.TYPE);
  25129. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  25130. if (props.length > 0) {
  25131. out.space();
  25132. out.with_parens(function() {
  25133. props.forEach(function(prop, i) {
  25134. if (i) out.space();
  25135. out.print(prop);
  25136. });
  25137. });
  25138. }
  25139. if (ctor.documentation) {
  25140. out.space();
  25141. out.print_string(ctor.documentation);
  25142. }
  25143. if (ctor.SUBCLASSES.length > 0) {
  25144. out.space();
  25145. out.with_block(function() {
  25146. ctor.SUBCLASSES.forEach(function(ctor) {
  25147. out.indent();
  25148. doitem(ctor);
  25149. out.newline();
  25150. });
  25151. });
  25152. }
  25153. }
  25154. doitem(AST_Node);
  25155. return out + "\n";
  25156. }
  25157. }
  25158. async function _default_options() {
  25159. const defs = {};
  25160. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  25161. const options = infer_options({
  25162. [component]: {0: 0}
  25163. });
  25164. if (options) defs[component] = options;
  25165. });
  25166. return defs;
  25167. }
  25168. async function infer_options(options) {
  25169. try {
  25170. await minify("", options);
  25171. } catch (error) {
  25172. return error.defs;
  25173. }
  25174. }
  25175. exports._default_options = _default_options;
  25176. exports._run_cli = run_cli;
  25177. exports.minify = minify;
  25178. })));
  25179. //# sourceMappingURL=bundle.min.js.map