bundle.min.js 962 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jridgewell/source-map')) :
  3. typeof define === 'function' && define.amd ? define(['exports', '@jridgewell/source-map'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
  5. })(this, (function (exports, sourceMap) { 'use strict';
  6. /***********************************************************************
  7. A JavaScript tokenizer / parser / beautifier / compressor.
  8. https://github.com/mishoo/UglifyJS2
  9. -------------------------------- (C) ---------------------------------
  10. Author: Mihai Bazon
  11. <mihai.bazon@gmail.com>
  12. http://mihai.bazon.net/blog
  13. Distributed under the BSD license:
  14. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15. Redistribution and use in source and binary forms, with or without
  16. modification, are permitted provided that the following conditions
  17. are met:
  18. * Redistributions of source code must retain the above
  19. copyright notice, this list of conditions and the following
  20. disclaimer.
  21. * Redistributions in binary form must reproduce the above
  22. copyright notice, this list of conditions and the following
  23. disclaimer in the documentation and/or other materials
  24. provided with the distribution.
  25. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  26. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  28. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  29. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  30. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  31. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  32. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  35. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. SUCH DAMAGE.
  37. ***********************************************************************/
  38. function characters(str) {
  39. return str.split("");
  40. }
  41. function member(name, array) {
  42. return array.includes(name);
  43. }
  44. class DefaultsError extends Error {
  45. constructor(msg, defs) {
  46. super();
  47. this.name = "DefaultsError";
  48. this.message = msg;
  49. this.defs = defs;
  50. }
  51. }
  52. function defaults(args, defs, croak) {
  53. if (args === true) {
  54. args = {};
  55. } else if (args != null && typeof args === "object") {
  56. args = {...args};
  57. }
  58. const ret = args || {};
  59. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  60. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  61. }
  62. for (const i in defs) if (HOP(defs, i)) {
  63. if (!args || !HOP(args, i)) {
  64. ret[i] = defs[i];
  65. } else if (i === "ecma") {
  66. let ecma = args[i] | 0;
  67. if (ecma > 5 && ecma < 2015) ecma += 2009;
  68. ret[i] = ecma;
  69. } else {
  70. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  71. }
  72. }
  73. return ret;
  74. }
  75. function noop() {}
  76. function return_false() { return false; }
  77. function return_true() { return true; }
  78. function return_this() { return this; }
  79. function return_null() { return null; }
  80. var MAP = (function() {
  81. function MAP(a, tw, allow_splicing = true) {
  82. const new_a = [];
  83. for (let i = 0; i < a.length; ++i) {
  84. let item = a[i];
  85. let ret = item.transform(tw, allow_splicing);
  86. if (ret instanceof AST_Node) {
  87. new_a.push(ret);
  88. } else if (ret instanceof Splice) {
  89. new_a.push(...ret.v);
  90. }
  91. }
  92. return new_a;
  93. }
  94. MAP.splice = function(val) { return new Splice(val); };
  95. MAP.skip = {};
  96. function Splice(val) { this.v = val; }
  97. return MAP;
  98. })();
  99. function make_node(ctor, orig, props) {
  100. if (!props) props = {};
  101. if (orig) {
  102. if (!props.start) props.start = orig.start;
  103. if (!props.end) props.end = orig.end;
  104. }
  105. return new ctor(props);
  106. }
  107. function push_uniq(array, el) {
  108. if (!array.includes(el))
  109. array.push(el);
  110. }
  111. function string_template(text, props) {
  112. return text.replace(/{(.+?)}/g, function(str, p) {
  113. return props && props[p];
  114. });
  115. }
  116. function remove(array, el) {
  117. for (var i = array.length; --i >= 0;) {
  118. if (array[i] === el) array.splice(i, 1);
  119. }
  120. }
  121. function mergeSort(array, cmp) {
  122. if (array.length < 2) return array.slice();
  123. function merge(a, b) {
  124. var r = [], ai = 0, bi = 0, i = 0;
  125. while (ai < a.length && bi < b.length) {
  126. cmp(a[ai], b[bi]) <= 0
  127. ? r[i++] = a[ai++]
  128. : r[i++] = b[bi++];
  129. }
  130. if (ai < a.length) r.push.apply(r, a.slice(ai));
  131. if (bi < b.length) r.push.apply(r, b.slice(bi));
  132. return r;
  133. }
  134. function _ms(a) {
  135. if (a.length <= 1)
  136. return a;
  137. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  138. left = _ms(left);
  139. right = _ms(right);
  140. return merge(left, right);
  141. }
  142. return _ms(array);
  143. }
  144. function makePredicate(words) {
  145. if (!Array.isArray(words)) words = words.split(" ");
  146. return new Set(words.sort());
  147. }
  148. function map_add(map, key, value) {
  149. if (map.has(key)) {
  150. map.get(key).push(value);
  151. } else {
  152. map.set(key, [ value ]);
  153. }
  154. }
  155. function map_from_object(obj) {
  156. var map = new Map();
  157. for (var key in obj) {
  158. if (HOP(obj, key) && key.charAt(0) === "$") {
  159. map.set(key.substr(1), obj[key]);
  160. }
  161. }
  162. return map;
  163. }
  164. function map_to_object(map) {
  165. var obj = Object.create(null);
  166. map.forEach(function (value, key) {
  167. obj["$" + key] = value;
  168. });
  169. return obj;
  170. }
  171. function HOP(obj, prop) {
  172. return Object.prototype.hasOwnProperty.call(obj, prop);
  173. }
  174. function keep_name(keep_setting, name) {
  175. return keep_setting === true
  176. || (keep_setting instanceof RegExp && keep_setting.test(name));
  177. }
  178. var lineTerminatorEscape = {
  179. "\0": "0",
  180. "\n": "n",
  181. "\r": "r",
  182. "\u2028": "u2028",
  183. "\u2029": "u2029",
  184. };
  185. function regexp_source_fix(source) {
  186. // V8 does not escape line terminators in regexp patterns in node 12
  187. // We'll also remove literal \0
  188. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  189. var escaped = source[offset - 1] == "\\"
  190. && (source[offset - 2] != "\\"
  191. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  192. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  193. });
  194. }
  195. // Subset of regexps that is not going to cause regexp based DDOS
  196. // https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
  197. const re_safe_regexp = /^[\\/|\0\s\w^$.[\]()]*$/;
  198. /** Check if the regexp is safe for Terser to create without risking a RegExp DOS */
  199. const regexp_is_safe = (source) => re_safe_regexp.test(source);
  200. const all_flags = "dgimsuyv";
  201. function sort_regexp_flags(flags) {
  202. const existing_flags = new Set(flags.split(""));
  203. let out = "";
  204. for (const flag of all_flags) {
  205. if (existing_flags.has(flag)) {
  206. out += flag;
  207. existing_flags.delete(flag);
  208. }
  209. }
  210. if (existing_flags.size) {
  211. // Flags Terser doesn't know about
  212. existing_flags.forEach(flag => { out += flag; });
  213. }
  214. return out;
  215. }
  216. function has_annotation(node, annotation) {
  217. return node._annotations & annotation;
  218. }
  219. function set_annotation(node, annotation) {
  220. node._annotations |= annotation;
  221. }
  222. function clear_annotation(node, annotation) {
  223. node._annotations &= ~annotation;
  224. }
  225. /***********************************************************************
  226. A JavaScript tokenizer / parser / beautifier / compressor.
  227. https://github.com/mishoo/UglifyJS2
  228. -------------------------------- (C) ---------------------------------
  229. Author: Mihai Bazon
  230. <mihai.bazon@gmail.com>
  231. http://mihai.bazon.net/blog
  232. Distributed under the BSD license:
  233. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  234. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  235. Redistribution and use in source and binary forms, with or without
  236. modification, are permitted provided that the following conditions
  237. are met:
  238. * Redistributions of source code must retain the above
  239. copyright notice, this list of conditions and the following
  240. disclaimer.
  241. * Redistributions in binary form must reproduce the above
  242. copyright notice, this list of conditions and the following
  243. disclaimer in the documentation and/or other materials
  244. provided with the distribution.
  245. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  246. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  247. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  248. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  249. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  250. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  251. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  252. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  253. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  254. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  255. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  256. SUCH DAMAGE.
  257. ***********************************************************************/
  258. var LATEST_RAW = ""; // Only used for numbers and template strings
  259. var TEMPLATE_RAWS = new Map(); // Raw template strings
  260. 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";
  261. var KEYWORDS_ATOM = "false null true";
  262. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  263. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  264. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  265. KEYWORDS = makePredicate(KEYWORDS);
  266. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  267. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  268. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  269. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  270. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  271. var RE_NUM_LITERAL = /[0-9a-f]/i;
  272. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  273. var RE_OCT_NUMBER = /^0[0-7]+$/;
  274. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  275. var RE_BIN_NUMBER = /^0b[01]+$/i;
  276. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  277. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  278. var OPERATORS = makePredicate([
  279. "in",
  280. "instanceof",
  281. "typeof",
  282. "new",
  283. "void",
  284. "delete",
  285. "++",
  286. "--",
  287. "+",
  288. "-",
  289. "!",
  290. "~",
  291. "&",
  292. "|",
  293. "^",
  294. "*",
  295. "**",
  296. "/",
  297. "%",
  298. ">>",
  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. 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"));
  331. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  332. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  333. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  334. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  335. /* -----[ Tokenizer ]----- */
  336. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  337. var UNICODE = {
  338. 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]/,
  339. 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])+/,
  340. };
  341. try {
  342. UNICODE = {
  343. // https://262.ecma-international.org/13.0/#prod-IdentifierStartChar
  344. // $, _, ID_Start
  345. ID_Start: new RegExp("[_$\\p{ID_Start}]", "u"),
  346. // https://262.ecma-international.org/13.0/#prod-IdentifierPartChar
  347. // $, zero-width-joiner, zero-width-non-joiner, ID_Continue
  348. ID_Continue: new RegExp("[$\\u200C\\u200D\\p{ID_Continue}]+", "u"),
  349. };
  350. } catch(e) {
  351. // Could not use modern JS \p{...}. UNICODE is already defined above so let's continue
  352. }
  353. function get_full_char(str, pos) {
  354. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  355. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  356. return str.charAt(pos) + str.charAt(pos + 1);
  357. }
  358. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  359. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  360. return str.charAt(pos - 1) + str.charAt(pos);
  361. }
  362. }
  363. return str.charAt(pos);
  364. }
  365. function get_full_char_code(str, pos) {
  366. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  367. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  368. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  369. }
  370. return str.charCodeAt(pos);
  371. }
  372. function get_full_char_length(str) {
  373. var surrogates = 0;
  374. for (var i = 0; i < str.length; i++) {
  375. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  376. surrogates++;
  377. i++;
  378. }
  379. }
  380. return str.length - surrogates;
  381. }
  382. function from_char_code(code) {
  383. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  384. if (code > 0xFFFF) {
  385. code -= 0x10000;
  386. return (String.fromCharCode((code >> 10) + 0xD800) +
  387. String.fromCharCode((code % 0x400) + 0xDC00));
  388. }
  389. return String.fromCharCode(code);
  390. }
  391. function is_surrogate_pair_head(code) {
  392. return code >= 0xd800 && code <= 0xdbff;
  393. }
  394. function is_surrogate_pair_tail(code) {
  395. return code >= 0xdc00 && code <= 0xdfff;
  396. }
  397. function is_digit(code) {
  398. return code >= 48 && code <= 57;
  399. }
  400. function is_identifier_start(ch) {
  401. return UNICODE.ID_Start.test(ch);
  402. }
  403. function is_identifier_char(ch) {
  404. return UNICODE.ID_Continue.test(ch);
  405. }
  406. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  407. function is_basic_identifier_string(str) {
  408. return BASIC_IDENT.test(str);
  409. }
  410. function is_identifier_string(str, allow_surrogates) {
  411. if (BASIC_IDENT.test(str)) {
  412. return true;
  413. }
  414. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  415. return false;
  416. }
  417. var match = UNICODE.ID_Start.exec(str);
  418. if (!match || match.index !== 0) {
  419. return false;
  420. }
  421. str = str.slice(match[0].length);
  422. if (!str) {
  423. return true;
  424. }
  425. match = UNICODE.ID_Continue.exec(str);
  426. return !!match && match[0].length === str.length;
  427. }
  428. function parse_js_number(num, allow_e = true) {
  429. if (!allow_e && num.includes("e")) {
  430. return NaN;
  431. }
  432. if (RE_HEX_NUMBER.test(num)) {
  433. return parseInt(num.substr(2), 16);
  434. } else if (RE_OCT_NUMBER.test(num)) {
  435. return parseInt(num.substr(1), 8);
  436. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  437. return parseInt(num.substr(2), 8);
  438. } else if (RE_BIN_NUMBER.test(num)) {
  439. return parseInt(num.substr(2), 2);
  440. } else if (RE_DEC_NUMBER.test(num)) {
  441. return parseFloat(num);
  442. } else {
  443. var val = parseFloat(num);
  444. if (val == num) return val;
  445. }
  446. }
  447. class JS_Parse_Error extends Error {
  448. constructor(message, filename, line, col, pos) {
  449. super();
  450. this.name = "SyntaxError";
  451. this.message = message;
  452. this.filename = filename;
  453. this.line = line;
  454. this.col = col;
  455. this.pos = pos;
  456. }
  457. }
  458. function js_error(message, filename, line, col, pos) {
  459. throw new JS_Parse_Error(message, filename, line, col, pos);
  460. }
  461. function is_token(token, type, val) {
  462. return token.type == type && (val == null || token.value == val);
  463. }
  464. var EX_EOF = {};
  465. function tokenizer($TEXT, filename, html5_comments, shebang) {
  466. var S = {
  467. text : $TEXT,
  468. filename : filename,
  469. pos : 0,
  470. tokpos : 0,
  471. line : 1,
  472. tokline : 0,
  473. col : 0,
  474. tokcol : 0,
  475. newline_before : false,
  476. regex_allowed : false,
  477. brace_counter : 0,
  478. template_braces : [],
  479. comments_before : [],
  480. directives : {},
  481. directive_stack : []
  482. };
  483. function peek() { return get_full_char(S.text, S.pos); }
  484. // Used because parsing ?. involves a lookahead for a digit
  485. function is_option_chain_op() {
  486. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  487. if (!must_be_dot) return false;
  488. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  489. return cannot_be_digit < 48 || cannot_be_digit > 57;
  490. }
  491. function next(signal_eof, in_string) {
  492. var ch = get_full_char(S.text, S.pos++);
  493. if (signal_eof && !ch)
  494. throw EX_EOF;
  495. if (NEWLINE_CHARS.has(ch)) {
  496. S.newline_before = S.newline_before || !in_string;
  497. ++S.line;
  498. S.col = 0;
  499. if (ch == "\r" && peek() == "\n") {
  500. // treat a \r\n sequence as a single \n
  501. ++S.pos;
  502. ch = "\n";
  503. }
  504. } else {
  505. if (ch.length > 1) {
  506. ++S.pos;
  507. ++S.col;
  508. }
  509. ++S.col;
  510. }
  511. return ch;
  512. }
  513. function forward(i) {
  514. while (i--) next();
  515. }
  516. function looking_at(str) {
  517. return S.text.substr(S.pos, str.length) == str;
  518. }
  519. function find_eol() {
  520. var text = S.text;
  521. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  522. var ch = text[i];
  523. if (NEWLINE_CHARS.has(ch))
  524. return i;
  525. }
  526. return -1;
  527. }
  528. function find(what, signal_eof) {
  529. var pos = S.text.indexOf(what, S.pos);
  530. if (signal_eof && pos == -1) throw EX_EOF;
  531. return pos;
  532. }
  533. function start_token() {
  534. S.tokline = S.line;
  535. S.tokcol = S.col;
  536. S.tokpos = S.pos;
  537. }
  538. var prev_was_dot = false;
  539. var previous_token = null;
  540. function token(type, value, is_comment) {
  541. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  542. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  543. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  544. (type == "arrow");
  545. if (type == "punc" && (value == "." || value == "?.")) {
  546. prev_was_dot = true;
  547. } else if (!is_comment) {
  548. prev_was_dot = false;
  549. }
  550. const line = S.tokline;
  551. const col = S.tokcol;
  552. const pos = S.tokpos;
  553. const nlb = S.newline_before;
  554. const file = filename;
  555. let comments_before = [];
  556. let comments_after = [];
  557. if (!is_comment) {
  558. comments_before = S.comments_before;
  559. comments_after = S.comments_before = [];
  560. }
  561. S.newline_before = false;
  562. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  563. if (!is_comment) previous_token = tok;
  564. return tok;
  565. }
  566. function skip_whitespace() {
  567. while (WHITESPACE_CHARS.has(peek()))
  568. next();
  569. }
  570. function read_while(pred) {
  571. var ret = "", ch, i = 0;
  572. while ((ch = peek()) && pred(ch, i++))
  573. ret += next();
  574. return ret;
  575. }
  576. function parse_error(err) {
  577. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  578. }
  579. function read_num(prefix) {
  580. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  581. var num = read_while(function(ch, i) {
  582. if (is_big_int) return false;
  583. var code = ch.charCodeAt(0);
  584. switch (code) {
  585. case 95: // _
  586. return (numeric_separator = true);
  587. case 98: case 66: // bB
  588. return (has_x = true); // Can occur in hex sequence, don't return false yet
  589. case 111: case 79: // oO
  590. case 120: case 88: // xX
  591. return has_x ? false : (has_x = true);
  592. case 101: case 69: // eE
  593. return has_x ? true : has_e ? false : (has_e = after_e = true);
  594. case 45: // -
  595. return after_e || (i == 0 && !prefix);
  596. case 43: // +
  597. return after_e;
  598. case (after_e = false, 46): // .
  599. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  600. }
  601. if (ch === "n") {
  602. is_big_int = true;
  603. return true;
  604. }
  605. return RE_NUM_LITERAL.test(ch);
  606. });
  607. if (prefix) num = prefix + num;
  608. LATEST_RAW = num;
  609. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  610. parse_error("Legacy octal literals are not allowed in strict mode");
  611. }
  612. if (numeric_separator) {
  613. if (num.endsWith("_")) {
  614. parse_error("Numeric separators are not allowed at the end of numeric literals");
  615. } else if (num.includes("__")) {
  616. parse_error("Only one underscore is allowed as numeric separator");
  617. }
  618. num = num.replace(/_/g, "");
  619. }
  620. if (num.endsWith("n")) {
  621. const without_n = num.slice(0, -1);
  622. const allow_e = RE_HEX_NUMBER.test(without_n);
  623. const valid = parse_js_number(without_n, allow_e);
  624. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  625. return token("big_int", without_n);
  626. parse_error("Invalid or unexpected token");
  627. }
  628. var valid = parse_js_number(num);
  629. if (!isNaN(valid)) {
  630. return token("num", valid);
  631. } else {
  632. parse_error("Invalid syntax: " + num);
  633. }
  634. }
  635. function is_octal(ch) {
  636. return ch >= "0" && ch <= "7";
  637. }
  638. function read_escaped_char(in_string, strict_hex, template_string) {
  639. var ch = next(true, in_string);
  640. switch (ch.charCodeAt(0)) {
  641. case 110 : return "\n";
  642. case 114 : return "\r";
  643. case 116 : return "\t";
  644. case 98 : return "\b";
  645. case 118 : return "\u000b"; // \v
  646. case 102 : return "\f";
  647. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  648. case 117 : // \u
  649. if (peek() == "{") {
  650. next(true);
  651. if (peek() === "}")
  652. parse_error("Expecting hex-character between {}");
  653. while (peek() == "0") next(true); // No significance
  654. var result, length = find("}", true) - S.pos;
  655. // Avoid 32 bit integer overflow (1 << 32 === 1)
  656. // We know first character isn't 0 and thus out of range anyway
  657. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  658. parse_error("Unicode reference out of bounds");
  659. }
  660. next(true);
  661. return from_char_code(result);
  662. }
  663. return String.fromCharCode(hex_bytes(4, strict_hex));
  664. case 10 : return ""; // newline
  665. case 13 : // \r
  666. if (peek() == "\n") { // DOS newline
  667. next(true, in_string);
  668. return "";
  669. }
  670. }
  671. if (is_octal(ch)) {
  672. if (template_string && strict_hex) {
  673. const represents_null_character = ch === "0" && !is_octal(peek());
  674. if (!represents_null_character) {
  675. parse_error("Octal escape sequences are not allowed in template strings");
  676. }
  677. }
  678. return read_octal_escape_sequence(ch, strict_hex);
  679. }
  680. return ch;
  681. }
  682. function read_octal_escape_sequence(ch, strict_octal) {
  683. // Read
  684. var p = peek();
  685. if (p >= "0" && p <= "7") {
  686. ch += next(true);
  687. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  688. ch += next(true);
  689. }
  690. // Parse
  691. if (ch === "0") return "\0";
  692. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  693. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  694. return String.fromCharCode(parseInt(ch, 8));
  695. }
  696. function hex_bytes(n, strict_hex) {
  697. var num = 0;
  698. for (; n > 0; --n) {
  699. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  700. return parseInt(num, 16) || "";
  701. }
  702. var digit = next(true);
  703. if (isNaN(parseInt(digit, 16)))
  704. parse_error("Invalid hex-character pattern in string");
  705. num += digit;
  706. }
  707. return parseInt(num, 16);
  708. }
  709. var read_string = with_eof_error("Unterminated string constant", function() {
  710. const start_pos = S.pos;
  711. var quote = next(), ret = [];
  712. for (;;) {
  713. var ch = next(true, true);
  714. if (ch == "\\") ch = read_escaped_char(true, true);
  715. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  716. else if (ch == quote) break;
  717. ret.push(ch);
  718. }
  719. var tok = token("string", ret.join(""));
  720. LATEST_RAW = S.text.slice(start_pos, S.pos);
  721. tok.quote = quote;
  722. return tok;
  723. });
  724. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  725. if (begin) {
  726. S.template_braces.push(S.brace_counter);
  727. }
  728. var content = "", raw = "", ch, tok;
  729. next(true, true);
  730. while ((ch = next(true, true)) != "`") {
  731. if (ch == "\r") {
  732. if (peek() == "\n") ++S.pos;
  733. ch = "\n";
  734. } else if (ch == "$" && peek() == "{") {
  735. next(true, true);
  736. S.brace_counter++;
  737. tok = token(begin ? "template_head" : "template_substitution", content);
  738. TEMPLATE_RAWS.set(tok, raw);
  739. tok.template_end = false;
  740. return tok;
  741. }
  742. raw += ch;
  743. if (ch == "\\") {
  744. var tmp = S.pos;
  745. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  746. ch = read_escaped_char(true, !prev_is_tag, true);
  747. raw += S.text.substr(tmp, S.pos - tmp);
  748. }
  749. content += ch;
  750. }
  751. S.template_braces.pop();
  752. tok = token(begin ? "template_head" : "template_substitution", content);
  753. TEMPLATE_RAWS.set(tok, raw);
  754. tok.template_end = true;
  755. return tok;
  756. });
  757. function skip_line_comment(type) {
  758. var regex_allowed = S.regex_allowed;
  759. var i = find_eol(), ret;
  760. if (i == -1) {
  761. ret = S.text.substr(S.pos);
  762. S.pos = S.text.length;
  763. } else {
  764. ret = S.text.substring(S.pos, i);
  765. S.pos = i;
  766. }
  767. S.col = S.tokcol + (S.pos - S.tokpos);
  768. S.comments_before.push(token(type, ret, true));
  769. S.regex_allowed = regex_allowed;
  770. return next_token;
  771. }
  772. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  773. var regex_allowed = S.regex_allowed;
  774. var i = find("*/", true);
  775. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  776. // update stream position
  777. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  778. S.comments_before.push(token("comment2", text, true));
  779. S.newline_before = S.newline_before || text.includes("\n");
  780. S.regex_allowed = regex_allowed;
  781. return next_token;
  782. });
  783. var read_name = with_eof_error("Unterminated identifier name", function() {
  784. var name = [], ch, escaped = false;
  785. var read_escaped_identifier_char = function() {
  786. escaped = true;
  787. next();
  788. if (peek() !== "u") {
  789. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  790. }
  791. return read_escaped_char(false, true);
  792. };
  793. // Read first character (ID_Start)
  794. if ((ch = peek()) === "\\") {
  795. ch = read_escaped_identifier_char();
  796. if (!is_identifier_start(ch)) {
  797. parse_error("First identifier char is an invalid identifier char");
  798. }
  799. } else if (is_identifier_start(ch)) {
  800. next();
  801. } else {
  802. return "";
  803. }
  804. name.push(ch);
  805. // Read ID_Continue
  806. while ((ch = peek()) != null) {
  807. if ((ch = peek()) === "\\") {
  808. ch = read_escaped_identifier_char();
  809. if (!is_identifier_char(ch)) {
  810. parse_error("Invalid escaped identifier char");
  811. }
  812. } else {
  813. if (!is_identifier_char(ch)) {
  814. break;
  815. }
  816. next();
  817. }
  818. name.push(ch);
  819. }
  820. const name_str = name.join("");
  821. if (RESERVED_WORDS.has(name_str) && escaped) {
  822. parse_error("Escaped characters are not allowed in keywords");
  823. }
  824. return name_str;
  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 read_private_word() {
  904. next();
  905. return token("privatename", read_name());
  906. }
  907. function with_eof_error(eof_error, cont) {
  908. return function(x) {
  909. try {
  910. return cont(x);
  911. } catch(ex) {
  912. if (ex === EX_EOF) parse_error(eof_error);
  913. else throw ex;
  914. }
  915. };
  916. }
  917. function next_token(force_regexp) {
  918. if (force_regexp != null)
  919. return read_regexp(force_regexp);
  920. if (shebang && S.pos == 0 && looking_at("#!")) {
  921. start_token();
  922. forward(2);
  923. skip_line_comment("comment5");
  924. }
  925. for (;;) {
  926. skip_whitespace();
  927. start_token();
  928. if (html5_comments) {
  929. if (looking_at("<!--")) {
  930. forward(4);
  931. skip_line_comment("comment3");
  932. continue;
  933. }
  934. if (looking_at("-->") && S.newline_before) {
  935. forward(3);
  936. skip_line_comment("comment4");
  937. continue;
  938. }
  939. }
  940. var ch = peek();
  941. if (!ch) return token("eof");
  942. var code = ch.charCodeAt(0);
  943. switch (code) {
  944. case 34: case 39: return read_string();
  945. case 46: return handle_dot();
  946. case 47: {
  947. var tok = handle_slash();
  948. if (tok === next_token) continue;
  949. return tok;
  950. }
  951. case 61: return handle_eq_sign();
  952. case 63: {
  953. if (!is_option_chain_op()) break; // Handled below
  954. next(); // ?
  955. next(); // .
  956. return token("punc", "?.");
  957. }
  958. case 96: return read_template_characters(true);
  959. case 123:
  960. S.brace_counter++;
  961. break;
  962. case 125:
  963. S.brace_counter--;
  964. if (S.template_braces.length > 0
  965. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  966. return read_template_characters(false);
  967. break;
  968. }
  969. if (is_digit(code)) return read_num();
  970. if (PUNC_CHARS.has(ch)) return token("punc", next());
  971. if (OPERATOR_CHARS.has(ch)) return read_operator();
  972. if (code == 92 || is_identifier_start(ch)) return read_word();
  973. if (code == 35) return read_private_word();
  974. break;
  975. }
  976. parse_error("Unexpected character '" + ch + "'");
  977. }
  978. next_token.next = next;
  979. next_token.peek = peek;
  980. next_token.context = function(nc) {
  981. if (nc) S = nc;
  982. return S;
  983. };
  984. next_token.add_directive = function(directive) {
  985. S.directive_stack[S.directive_stack.length - 1].push(directive);
  986. if (S.directives[directive] === undefined) {
  987. S.directives[directive] = 1;
  988. } else {
  989. S.directives[directive]++;
  990. }
  991. };
  992. next_token.push_directives_stack = function() {
  993. S.directive_stack.push([]);
  994. };
  995. next_token.pop_directives_stack = function() {
  996. var directives = S.directive_stack[S.directive_stack.length - 1];
  997. for (var i = 0; i < directives.length; i++) {
  998. S.directives[directives[i]]--;
  999. }
  1000. S.directive_stack.pop();
  1001. };
  1002. next_token.has_directive = function(directive) {
  1003. return S.directives[directive] > 0;
  1004. };
  1005. return next_token;
  1006. }
  1007. /* -----[ Parser (constants) ]----- */
  1008. var UNARY_PREFIX = makePredicate([
  1009. "typeof",
  1010. "void",
  1011. "delete",
  1012. "--",
  1013. "++",
  1014. "!",
  1015. "~",
  1016. "-",
  1017. "+"
  1018. ]);
  1019. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  1020. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  1021. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  1022. var PRECEDENCE = (function(a, ret) {
  1023. for (var i = 0; i < a.length; ++i) {
  1024. var b = a[i];
  1025. for (var j = 0; j < b.length; ++j) {
  1026. ret[b[j]] = i + 1;
  1027. }
  1028. }
  1029. return ret;
  1030. })(
  1031. [
  1032. ["||"],
  1033. ["??"],
  1034. ["&&"],
  1035. ["|"],
  1036. ["^"],
  1037. ["&"],
  1038. ["==", "===", "!=", "!=="],
  1039. ["<", ">", "<=", ">=", "in", "instanceof"],
  1040. [">>", "<<", ">>>"],
  1041. ["+", "-"],
  1042. ["*", "/", "%"],
  1043. ["**"]
  1044. ],
  1045. {}
  1046. );
  1047. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name"]);
  1048. /* -----[ Parser ]----- */
  1049. function parse($TEXT, options) {
  1050. // maps start tokens to count of comments found outside of their parens
  1051. // Example: /* I count */ ( /* I don't */ foo() )
  1052. // Useful because comments_before property of call with parens outside
  1053. // contains both comments inside and outside these parens. Used to find the
  1054. const outer_comments_before_counts = new WeakMap();
  1055. options = defaults(options, {
  1056. bare_returns : false,
  1057. ecma : null, // Legacy
  1058. expression : false,
  1059. filename : null,
  1060. html5_comments : true,
  1061. module : false,
  1062. shebang : true,
  1063. strict : false,
  1064. toplevel : null,
  1065. }, true);
  1066. var S = {
  1067. input : (typeof $TEXT == "string"
  1068. ? tokenizer($TEXT, options.filename,
  1069. options.html5_comments, options.shebang)
  1070. : $TEXT),
  1071. token : null,
  1072. prev : null,
  1073. peeked : null,
  1074. in_function : 0,
  1075. in_async : -1,
  1076. in_generator : -1,
  1077. in_directives : true,
  1078. in_loop : 0,
  1079. labels : []
  1080. };
  1081. S.token = next();
  1082. function is(type, value) {
  1083. return is_token(S.token, type, value);
  1084. }
  1085. function peek() { return S.peeked || (S.peeked = S.input()); }
  1086. function next() {
  1087. S.prev = S.token;
  1088. if (!S.peeked) peek();
  1089. S.token = S.peeked;
  1090. S.peeked = null;
  1091. S.in_directives = S.in_directives && (
  1092. S.token.type == "string" || is("punc", ";")
  1093. );
  1094. return S.token;
  1095. }
  1096. function prev() {
  1097. return S.prev;
  1098. }
  1099. function croak(msg, line, col, pos) {
  1100. var ctx = S.input.context();
  1101. js_error(msg,
  1102. ctx.filename,
  1103. line != null ? line : ctx.tokline,
  1104. col != null ? col : ctx.tokcol,
  1105. pos != null ? pos : ctx.tokpos);
  1106. }
  1107. function token_error(token, msg) {
  1108. croak(msg, token.line, token.col);
  1109. }
  1110. function unexpected(token) {
  1111. if (token == null)
  1112. token = S.token;
  1113. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  1114. }
  1115. function expect_token(type, val) {
  1116. if (is(type, val)) {
  1117. return next();
  1118. }
  1119. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  1120. }
  1121. function expect(punc) { return expect_token("punc", punc); }
  1122. function has_newline_before(token) {
  1123. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  1124. }
  1125. function can_insert_semicolon() {
  1126. return !options.strict
  1127. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  1128. }
  1129. function is_in_generator() {
  1130. return S.in_generator === S.in_function;
  1131. }
  1132. function is_in_async() {
  1133. return S.in_async === S.in_function;
  1134. }
  1135. function can_await() {
  1136. return (
  1137. S.in_async === S.in_function
  1138. || S.in_function === 0 && S.input.has_directive("use strict")
  1139. );
  1140. }
  1141. function semicolon(optional) {
  1142. if (is("punc", ";")) next();
  1143. else if (!optional && !can_insert_semicolon()) unexpected();
  1144. }
  1145. function parenthesised() {
  1146. expect("(");
  1147. var exp = expression(true);
  1148. expect(")");
  1149. return exp;
  1150. }
  1151. function embed_tokens(parser) {
  1152. return function _embed_tokens_wrapper(...args) {
  1153. const start = S.token;
  1154. const expr = parser(...args);
  1155. expr.start = start;
  1156. expr.end = prev();
  1157. return expr;
  1158. };
  1159. }
  1160. function handle_regexp() {
  1161. if (is("operator", "/") || is("operator", "/=")) {
  1162. S.peeked = null;
  1163. S.token = S.input(S.token.value.substr(1)); // force regexp
  1164. }
  1165. }
  1166. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  1167. handle_regexp();
  1168. switch (S.token.type) {
  1169. case "string":
  1170. if (S.in_directives) {
  1171. var token = peek();
  1172. if (!LATEST_RAW.includes("\\")
  1173. && (is_token(token, "punc", ";")
  1174. || is_token(token, "punc", "}")
  1175. || has_newline_before(token)
  1176. || is_token(token, "eof"))) {
  1177. S.input.add_directive(S.token.value);
  1178. } else {
  1179. S.in_directives = false;
  1180. }
  1181. }
  1182. var dir = S.in_directives, stat = simple_statement();
  1183. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  1184. case "template_head":
  1185. case "num":
  1186. case "big_int":
  1187. case "regexp":
  1188. case "operator":
  1189. case "atom":
  1190. return simple_statement();
  1191. case "name":
  1192. case "privatename":
  1193. if(is("privatename") && !S.in_class)
  1194. croak("Private field must be used in an enclosing class");
  1195. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  1196. next();
  1197. next();
  1198. if (is_for_body) {
  1199. croak("functions are not allowed as the body of a loop");
  1200. }
  1201. return function_(AST_Defun, false, true, is_export_default);
  1202. }
  1203. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  1204. next();
  1205. var node = import_statement();
  1206. semicolon();
  1207. return node;
  1208. }
  1209. return is_token(peek(), "punc", ":")
  1210. ? labeled_statement()
  1211. : simple_statement();
  1212. case "punc":
  1213. switch (S.token.value) {
  1214. case "{":
  1215. return new AST_BlockStatement({
  1216. start : S.token,
  1217. body : block_(),
  1218. end : prev()
  1219. });
  1220. case "[":
  1221. case "(":
  1222. return simple_statement();
  1223. case ";":
  1224. S.in_directives = false;
  1225. next();
  1226. return new AST_EmptyStatement();
  1227. default:
  1228. unexpected();
  1229. }
  1230. case "keyword":
  1231. switch (S.token.value) {
  1232. case "break":
  1233. next();
  1234. return break_cont(AST_Break);
  1235. case "continue":
  1236. next();
  1237. return break_cont(AST_Continue);
  1238. case "debugger":
  1239. next();
  1240. semicolon();
  1241. return new AST_Debugger();
  1242. case "do":
  1243. next();
  1244. var body = in_loop(statement);
  1245. expect_token("keyword", "while");
  1246. var condition = parenthesised();
  1247. semicolon(true);
  1248. return new AST_Do({
  1249. body : body,
  1250. condition : condition
  1251. });
  1252. case "while":
  1253. next();
  1254. return new AST_While({
  1255. condition : parenthesised(),
  1256. body : in_loop(function() { return statement(false, true); })
  1257. });
  1258. case "for":
  1259. next();
  1260. return for_();
  1261. case "class":
  1262. next();
  1263. if (is_for_body) {
  1264. croak("classes are not allowed as the body of a loop");
  1265. }
  1266. if (is_if_body) {
  1267. croak("classes are not allowed as the body of an if");
  1268. }
  1269. return class_(AST_DefClass, is_export_default);
  1270. case "function":
  1271. next();
  1272. if (is_for_body) {
  1273. croak("functions are not allowed as the body of a loop");
  1274. }
  1275. return function_(AST_Defun, false, false, is_export_default);
  1276. case "if":
  1277. next();
  1278. return if_();
  1279. case "return":
  1280. if (S.in_function == 0 && !options.bare_returns)
  1281. croak("'return' outside of function");
  1282. next();
  1283. var value = null;
  1284. if (is("punc", ";")) {
  1285. next();
  1286. } else if (!can_insert_semicolon()) {
  1287. value = expression(true);
  1288. semicolon();
  1289. }
  1290. return new AST_Return({
  1291. value: value
  1292. });
  1293. case "switch":
  1294. next();
  1295. return new AST_Switch({
  1296. expression : parenthesised(),
  1297. body : in_loop(switch_body_)
  1298. });
  1299. case "throw":
  1300. next();
  1301. if (has_newline_before(S.token))
  1302. croak("Illegal newline after 'throw'");
  1303. var value = expression(true);
  1304. semicolon();
  1305. return new AST_Throw({
  1306. value: value
  1307. });
  1308. case "try":
  1309. next();
  1310. return try_();
  1311. case "var":
  1312. next();
  1313. var node = var_();
  1314. semicolon();
  1315. return node;
  1316. case "let":
  1317. next();
  1318. var node = let_();
  1319. semicolon();
  1320. return node;
  1321. case "const":
  1322. next();
  1323. var node = const_();
  1324. semicolon();
  1325. return node;
  1326. case "with":
  1327. if (S.input.has_directive("use strict")) {
  1328. croak("Strict mode may not include a with statement");
  1329. }
  1330. next();
  1331. return new AST_With({
  1332. expression : parenthesised(),
  1333. body : statement()
  1334. });
  1335. case "export":
  1336. if (!is_token(peek(), "punc", "(")) {
  1337. next();
  1338. var node = export_statement();
  1339. if (is("punc", ";")) semicolon();
  1340. return node;
  1341. }
  1342. }
  1343. }
  1344. unexpected();
  1345. });
  1346. function labeled_statement() {
  1347. var label = as_symbol(AST_Label);
  1348. if (label.name === "await" && is_in_async()) {
  1349. token_error(S.prev, "await cannot be used as label inside async function");
  1350. }
  1351. if (S.labels.some((l) => l.name === label.name)) {
  1352. // ECMA-262, 12.12: An ECMAScript program is considered
  1353. // syntactically incorrect if it contains a
  1354. // LabelledStatement that is enclosed by a
  1355. // LabelledStatement with the same Identifier as label.
  1356. croak("Label " + label.name + " defined twice");
  1357. }
  1358. expect(":");
  1359. S.labels.push(label);
  1360. var stat = statement();
  1361. S.labels.pop();
  1362. if (!(stat instanceof AST_IterationStatement)) {
  1363. // check for `continue` that refers to this label.
  1364. // those should be reported as syntax errors.
  1365. // https://github.com/mishoo/UglifyJS2/issues/287
  1366. label.references.forEach(function(ref) {
  1367. if (ref instanceof AST_Continue) {
  1368. ref = ref.label.start;
  1369. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  1370. ref.line, ref.col, ref.pos);
  1371. }
  1372. });
  1373. }
  1374. return new AST_LabeledStatement({ body: stat, label: label });
  1375. }
  1376. function simple_statement(tmp) {
  1377. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  1378. }
  1379. function break_cont(type) {
  1380. var label = null, ldef;
  1381. if (!can_insert_semicolon()) {
  1382. label = as_symbol(AST_LabelRef, true);
  1383. }
  1384. if (label != null) {
  1385. ldef = S.labels.find((l) => l.name === label.name);
  1386. if (!ldef)
  1387. croak("Undefined label " + label.name);
  1388. label.thedef = ldef;
  1389. } else if (S.in_loop == 0)
  1390. croak(type.TYPE + " not inside a loop or switch");
  1391. semicolon();
  1392. var stat = new type({ label: label });
  1393. if (ldef) ldef.references.push(stat);
  1394. return stat;
  1395. }
  1396. function for_() {
  1397. var for_await_error = "`for await` invalid in this context";
  1398. var await_tok = S.token;
  1399. if (await_tok.type == "name" && await_tok.value == "await") {
  1400. if (!can_await()) {
  1401. token_error(await_tok, for_await_error);
  1402. }
  1403. next();
  1404. } else {
  1405. await_tok = false;
  1406. }
  1407. expect("(");
  1408. var init = null;
  1409. if (!is("punc", ";")) {
  1410. init =
  1411. is("keyword", "var") ? (next(), var_(true)) :
  1412. is("keyword", "let") ? (next(), let_(true)) :
  1413. is("keyword", "const") ? (next(), const_(true)) :
  1414. expression(true, true);
  1415. var is_in = is("operator", "in");
  1416. var is_of = is("name", "of");
  1417. if (await_tok && !is_of) {
  1418. token_error(await_tok, for_await_error);
  1419. }
  1420. if (is_in || is_of) {
  1421. if (init instanceof AST_Definitions) {
  1422. if (init.definitions.length > 1)
  1423. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  1424. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  1425. token_error(init.start, "Invalid left-hand side in for..in loop");
  1426. }
  1427. next();
  1428. if (is_in) {
  1429. return for_in(init);
  1430. } else {
  1431. return for_of(init, !!await_tok);
  1432. }
  1433. }
  1434. } else if (await_tok) {
  1435. token_error(await_tok, for_await_error);
  1436. }
  1437. return regular_for(init);
  1438. }
  1439. function regular_for(init) {
  1440. expect(";");
  1441. var test = is("punc", ";") ? null : expression(true);
  1442. expect(";");
  1443. var step = is("punc", ")") ? null : expression(true);
  1444. expect(")");
  1445. return new AST_For({
  1446. init : init,
  1447. condition : test,
  1448. step : step,
  1449. body : in_loop(function() { return statement(false, true); })
  1450. });
  1451. }
  1452. function for_of(init, is_await) {
  1453. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  1454. var obj = expression(true);
  1455. expect(")");
  1456. return new AST_ForOf({
  1457. await : is_await,
  1458. init : init,
  1459. name : lhs,
  1460. object : obj,
  1461. body : in_loop(function() { return statement(false, true); })
  1462. });
  1463. }
  1464. function for_in(init) {
  1465. var obj = expression(true);
  1466. expect(")");
  1467. return new AST_ForIn({
  1468. init : init,
  1469. object : obj,
  1470. body : in_loop(function() { return statement(false, true); })
  1471. });
  1472. }
  1473. var arrow_function = function(start, argnames, is_async) {
  1474. if (has_newline_before(S.token)) {
  1475. croak("Unexpected newline before arrow (=>)");
  1476. }
  1477. expect_token("arrow", "=>");
  1478. var body = _function_body(is("punc", "{"), false, is_async);
  1479. var end =
  1480. body instanceof Array && body.length ? body[body.length - 1].end :
  1481. body instanceof Array ? start :
  1482. body.end;
  1483. return new AST_Arrow({
  1484. start : start,
  1485. end : end,
  1486. async : is_async,
  1487. argnames : argnames,
  1488. body : body
  1489. });
  1490. };
  1491. var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
  1492. var in_statement = ctor === AST_Defun;
  1493. var is_generator = is("operator", "*");
  1494. if (is_generator) {
  1495. next();
  1496. }
  1497. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  1498. if (in_statement && !name) {
  1499. if (is_export_default) {
  1500. ctor = AST_Function;
  1501. } else {
  1502. unexpected();
  1503. }
  1504. }
  1505. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  1506. unexpected(prev());
  1507. var args = [];
  1508. var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
  1509. return new ctor({
  1510. start : args.start,
  1511. end : body.end,
  1512. is_generator: is_generator,
  1513. async : is_async,
  1514. name : name,
  1515. argnames: args,
  1516. body : body
  1517. });
  1518. };
  1519. class UsedParametersTracker {
  1520. constructor(is_parameter, strict, duplicates_ok = false) {
  1521. this.is_parameter = is_parameter;
  1522. this.duplicates_ok = duplicates_ok;
  1523. this.parameters = new Set();
  1524. this.duplicate = null;
  1525. this.default_assignment = false;
  1526. this.spread = false;
  1527. this.strict_mode = !!strict;
  1528. }
  1529. add_parameter(token) {
  1530. if (this.parameters.has(token.value)) {
  1531. if (this.duplicate === null) {
  1532. this.duplicate = token;
  1533. }
  1534. this.check_strict();
  1535. } else {
  1536. this.parameters.add(token.value);
  1537. if (this.is_parameter) {
  1538. switch (token.value) {
  1539. case "arguments":
  1540. case "eval":
  1541. case "yield":
  1542. if (this.strict_mode) {
  1543. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1544. }
  1545. break;
  1546. default:
  1547. if (RESERVED_WORDS.has(token.value)) {
  1548. unexpected();
  1549. }
  1550. }
  1551. }
  1552. }
  1553. }
  1554. mark_default_assignment(token) {
  1555. if (this.default_assignment === false) {
  1556. this.default_assignment = token;
  1557. }
  1558. }
  1559. mark_spread(token) {
  1560. if (this.spread === false) {
  1561. this.spread = token;
  1562. }
  1563. }
  1564. mark_strict_mode() {
  1565. this.strict_mode = true;
  1566. }
  1567. is_strict() {
  1568. return this.default_assignment !== false || this.spread !== false || this.strict_mode;
  1569. }
  1570. check_strict() {
  1571. if (this.is_strict() && this.duplicate !== null && !this.duplicates_ok) {
  1572. token_error(this.duplicate, "Parameter " + this.duplicate.value + " was used already");
  1573. }
  1574. }
  1575. }
  1576. function parameters(params) {
  1577. var used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1578. expect("(");
  1579. while (!is("punc", ")")) {
  1580. var param = parameter(used_parameters);
  1581. params.push(param);
  1582. if (!is("punc", ")")) {
  1583. expect(",");
  1584. }
  1585. if (param instanceof AST_Expansion) {
  1586. break;
  1587. }
  1588. }
  1589. next();
  1590. }
  1591. function parameter(used_parameters, symbol_type) {
  1592. var param;
  1593. var expand = false;
  1594. if (used_parameters === undefined) {
  1595. used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1596. }
  1597. if (is("expand", "...")) {
  1598. expand = S.token;
  1599. used_parameters.mark_spread(S.token);
  1600. next();
  1601. }
  1602. param = binding_element(used_parameters, symbol_type);
  1603. if (is("operator", "=") && expand === false) {
  1604. used_parameters.mark_default_assignment(S.token);
  1605. next();
  1606. param = new AST_DefaultAssign({
  1607. start: param.start,
  1608. left: param,
  1609. operator: "=",
  1610. right: expression(false),
  1611. end: S.token
  1612. });
  1613. }
  1614. if (expand !== false) {
  1615. if (!is("punc", ")")) {
  1616. unexpected();
  1617. }
  1618. param = new AST_Expansion({
  1619. start: expand,
  1620. expression: param,
  1621. end: expand
  1622. });
  1623. }
  1624. used_parameters.check_strict();
  1625. return param;
  1626. }
  1627. function binding_element(used_parameters, symbol_type) {
  1628. var elements = [];
  1629. var first = true;
  1630. var is_expand = false;
  1631. var expand_token;
  1632. var first_token = S.token;
  1633. if (used_parameters === undefined) {
  1634. const strict = S.input.has_directive("use strict");
  1635. const duplicates_ok = symbol_type === AST_SymbolVar;
  1636. used_parameters = new UsedParametersTracker(false, strict, duplicates_ok);
  1637. }
  1638. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1639. if (is("punc", "[")) {
  1640. next();
  1641. while (!is("punc", "]")) {
  1642. if (first) {
  1643. first = false;
  1644. } else {
  1645. expect(",");
  1646. }
  1647. if (is("expand", "...")) {
  1648. is_expand = true;
  1649. expand_token = S.token;
  1650. used_parameters.mark_spread(S.token);
  1651. next();
  1652. }
  1653. if (is("punc")) {
  1654. switch (S.token.value) {
  1655. case ",":
  1656. elements.push(new AST_Hole({
  1657. start: S.token,
  1658. end: S.token
  1659. }));
  1660. continue;
  1661. case "]": // Trailing comma after last element
  1662. break;
  1663. case "[":
  1664. case "{":
  1665. elements.push(binding_element(used_parameters, symbol_type));
  1666. break;
  1667. default:
  1668. unexpected();
  1669. }
  1670. } else if (is("name")) {
  1671. used_parameters.add_parameter(S.token);
  1672. elements.push(as_symbol(symbol_type));
  1673. } else {
  1674. croak("Invalid function parameter");
  1675. }
  1676. if (is("operator", "=") && is_expand === false) {
  1677. used_parameters.mark_default_assignment(S.token);
  1678. next();
  1679. elements[elements.length - 1] = new AST_DefaultAssign({
  1680. start: elements[elements.length - 1].start,
  1681. left: elements[elements.length - 1],
  1682. operator: "=",
  1683. right: expression(false),
  1684. end: S.token
  1685. });
  1686. }
  1687. if (is_expand) {
  1688. if (!is("punc", "]")) {
  1689. croak("Rest element must be last element");
  1690. }
  1691. elements[elements.length - 1] = new AST_Expansion({
  1692. start: expand_token,
  1693. expression: elements[elements.length - 1],
  1694. end: expand_token
  1695. });
  1696. }
  1697. }
  1698. expect("]");
  1699. used_parameters.check_strict();
  1700. return new AST_Destructuring({
  1701. start: first_token,
  1702. names: elements,
  1703. is_array: true,
  1704. end: prev()
  1705. });
  1706. } else if (is("punc", "{")) {
  1707. next();
  1708. while (!is("punc", "}")) {
  1709. if (first) {
  1710. first = false;
  1711. } else {
  1712. expect(",");
  1713. }
  1714. if (is("expand", "...")) {
  1715. is_expand = true;
  1716. expand_token = S.token;
  1717. used_parameters.mark_spread(S.token);
  1718. next();
  1719. }
  1720. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1721. used_parameters.add_parameter(S.token);
  1722. var start = prev();
  1723. var value = as_symbol(symbol_type);
  1724. if (is_expand) {
  1725. elements.push(new AST_Expansion({
  1726. start: expand_token,
  1727. expression: value,
  1728. end: value.end,
  1729. }));
  1730. } else {
  1731. elements.push(new AST_ObjectKeyVal({
  1732. start: start,
  1733. key: value.name,
  1734. value: value,
  1735. end: value.end,
  1736. }));
  1737. }
  1738. } else if (is("punc", "}")) {
  1739. continue; // Allow trailing hole
  1740. } else {
  1741. var property_token = S.token;
  1742. var property = as_property_name();
  1743. if (property === null) {
  1744. unexpected(prev());
  1745. } else if (prev().type === "name" && !is("punc", ":")) {
  1746. elements.push(new AST_ObjectKeyVal({
  1747. start: prev(),
  1748. key: property,
  1749. value: new symbol_type({
  1750. start: prev(),
  1751. name: property,
  1752. end: prev()
  1753. }),
  1754. end: prev()
  1755. }));
  1756. } else {
  1757. expect(":");
  1758. elements.push(new AST_ObjectKeyVal({
  1759. start: property_token,
  1760. quote: property_token.quote,
  1761. key: property,
  1762. value: binding_element(used_parameters, symbol_type),
  1763. end: prev()
  1764. }));
  1765. }
  1766. }
  1767. if (is_expand) {
  1768. if (!is("punc", "}")) {
  1769. croak("Rest element must be last element");
  1770. }
  1771. } else if (is("operator", "=")) {
  1772. used_parameters.mark_default_assignment(S.token);
  1773. next();
  1774. elements[elements.length - 1].value = new AST_DefaultAssign({
  1775. start: elements[elements.length - 1].value.start,
  1776. left: elements[elements.length - 1].value,
  1777. operator: "=",
  1778. right: expression(false),
  1779. end: S.token
  1780. });
  1781. }
  1782. }
  1783. expect("}");
  1784. used_parameters.check_strict();
  1785. return new AST_Destructuring({
  1786. start: first_token,
  1787. names: elements,
  1788. is_array: false,
  1789. end: prev()
  1790. });
  1791. } else if (is("name")) {
  1792. used_parameters.add_parameter(S.token);
  1793. return as_symbol(symbol_type);
  1794. } else {
  1795. croak("Invalid function parameter");
  1796. }
  1797. }
  1798. function params_or_seq_(allow_arrows, maybe_sequence) {
  1799. var spread_token;
  1800. var invalid_sequence;
  1801. var trailing_comma;
  1802. var a = [];
  1803. expect("(");
  1804. while (!is("punc", ")")) {
  1805. if (spread_token) unexpected(spread_token);
  1806. if (is("expand", "...")) {
  1807. spread_token = S.token;
  1808. if (maybe_sequence) invalid_sequence = S.token;
  1809. next();
  1810. a.push(new AST_Expansion({
  1811. start: prev(),
  1812. expression: expression(),
  1813. end: S.token,
  1814. }));
  1815. } else {
  1816. a.push(expression());
  1817. }
  1818. if (!is("punc", ")")) {
  1819. expect(",");
  1820. if (is("punc", ")")) {
  1821. trailing_comma = prev();
  1822. if (maybe_sequence) invalid_sequence = trailing_comma;
  1823. }
  1824. }
  1825. }
  1826. expect(")");
  1827. if (allow_arrows && is("arrow", "=>")) {
  1828. if (spread_token && trailing_comma) unexpected(trailing_comma);
  1829. } else if (invalid_sequence) {
  1830. unexpected(invalid_sequence);
  1831. }
  1832. return a;
  1833. }
  1834. function _function_body(block, generator, is_async, name, args) {
  1835. var loop = S.in_loop;
  1836. var labels = S.labels;
  1837. var current_generator = S.in_generator;
  1838. var current_async = S.in_async;
  1839. ++S.in_function;
  1840. if (generator)
  1841. S.in_generator = S.in_function;
  1842. if (is_async)
  1843. S.in_async = S.in_function;
  1844. if (args) parameters(args);
  1845. if (block)
  1846. S.in_directives = true;
  1847. S.in_loop = 0;
  1848. S.labels = [];
  1849. if (block) {
  1850. S.input.push_directives_stack();
  1851. var a = block_();
  1852. if (name) _verify_symbol(name);
  1853. if (args) args.forEach(_verify_symbol);
  1854. S.input.pop_directives_stack();
  1855. } else {
  1856. var a = [new AST_Return({
  1857. start: S.token,
  1858. value: expression(false),
  1859. end: S.token
  1860. })];
  1861. }
  1862. --S.in_function;
  1863. S.in_loop = loop;
  1864. S.labels = labels;
  1865. S.in_generator = current_generator;
  1866. S.in_async = current_async;
  1867. return a;
  1868. }
  1869. function _await_expression() {
  1870. // Previous token must be "await" and not be interpreted as an identifier
  1871. if (!can_await()) {
  1872. croak("Unexpected await expression outside async function",
  1873. S.prev.line, S.prev.col, S.prev.pos);
  1874. }
  1875. // the await expression is parsed as a unary expression in Babel
  1876. return new AST_Await({
  1877. start: prev(),
  1878. end: S.token,
  1879. expression : maybe_unary(true),
  1880. });
  1881. }
  1882. function _yield_expression() {
  1883. // Previous token must be keyword yield and not be interpret as an identifier
  1884. if (!is_in_generator()) {
  1885. croak("Unexpected yield expression outside generator function",
  1886. S.prev.line, S.prev.col, S.prev.pos);
  1887. }
  1888. var start = S.token;
  1889. var star = false;
  1890. var has_expression = true;
  1891. // Attempt to get expression or star (and then the mandatory expression)
  1892. // behind yield on the same line.
  1893. //
  1894. // If nothing follows on the same line of the yieldExpression,
  1895. // it should default to the value `undefined` for yield to return.
  1896. // In that case, the `undefined` stored as `null` in ast.
  1897. //
  1898. // Note 1: It isn't allowed for yield* to close without an expression
  1899. // Note 2: If there is a nlb between yield and star, it is interpret as
  1900. // yield <explicit undefined> <inserted automatic semicolon> *
  1901. if (can_insert_semicolon() ||
  1902. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  1903. has_expression = false;
  1904. } else if (is("operator", "*")) {
  1905. star = true;
  1906. next();
  1907. }
  1908. return new AST_Yield({
  1909. start : start,
  1910. is_star : star,
  1911. expression : has_expression ? expression() : null,
  1912. end : prev()
  1913. });
  1914. }
  1915. function if_() {
  1916. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  1917. if (is("keyword", "else")) {
  1918. next();
  1919. belse = statement(false, false, true);
  1920. }
  1921. return new AST_If({
  1922. condition : cond,
  1923. body : body,
  1924. alternative : belse
  1925. });
  1926. }
  1927. function block_() {
  1928. expect("{");
  1929. var a = [];
  1930. while (!is("punc", "}")) {
  1931. if (is("eof")) unexpected();
  1932. a.push(statement());
  1933. }
  1934. next();
  1935. return a;
  1936. }
  1937. function switch_body_() {
  1938. expect("{");
  1939. var a = [], cur = null, branch = null, tmp;
  1940. while (!is("punc", "}")) {
  1941. if (is("eof")) unexpected();
  1942. if (is("keyword", "case")) {
  1943. if (branch) branch.end = prev();
  1944. cur = [];
  1945. branch = new AST_Case({
  1946. start : (tmp = S.token, next(), tmp),
  1947. expression : expression(true),
  1948. body : cur
  1949. });
  1950. a.push(branch);
  1951. expect(":");
  1952. } else if (is("keyword", "default")) {
  1953. if (branch) branch.end = prev();
  1954. cur = [];
  1955. branch = new AST_Default({
  1956. start : (tmp = S.token, next(), expect(":"), tmp),
  1957. body : cur
  1958. });
  1959. a.push(branch);
  1960. } else {
  1961. if (!cur) unexpected();
  1962. cur.push(statement());
  1963. }
  1964. }
  1965. if (branch) branch.end = prev();
  1966. next();
  1967. return a;
  1968. }
  1969. function try_() {
  1970. var body, bcatch = null, bfinally = null;
  1971. body = new AST_TryBlock({
  1972. start : S.token,
  1973. body : block_(),
  1974. end : prev(),
  1975. });
  1976. if (is("keyword", "catch")) {
  1977. var start = S.token;
  1978. next();
  1979. if (is("punc", "{")) {
  1980. var name = null;
  1981. } else {
  1982. expect("(");
  1983. var name = parameter(undefined, AST_SymbolCatch);
  1984. expect(")");
  1985. }
  1986. bcatch = new AST_Catch({
  1987. start : start,
  1988. argname : name,
  1989. body : block_(),
  1990. end : prev()
  1991. });
  1992. }
  1993. if (is("keyword", "finally")) {
  1994. var start = S.token;
  1995. next();
  1996. bfinally = new AST_Finally({
  1997. start : start,
  1998. body : block_(),
  1999. end : prev()
  2000. });
  2001. }
  2002. if (!bcatch && !bfinally)
  2003. croak("Missing catch/finally blocks");
  2004. return new AST_Try({
  2005. body : body,
  2006. bcatch : bcatch,
  2007. bfinally : bfinally
  2008. });
  2009. }
  2010. /**
  2011. * var
  2012. * vardef1 = 2,
  2013. * vardef2 = 3;
  2014. */
  2015. function vardefs(no_in, kind) {
  2016. var var_defs = [];
  2017. var def;
  2018. for (;;) {
  2019. var sym_type =
  2020. kind === "var" ? AST_SymbolVar :
  2021. kind === "const" ? AST_SymbolConst :
  2022. kind === "let" ? AST_SymbolLet : null;
  2023. // var { a } = b
  2024. if (is("punc", "{") || is("punc", "[")) {
  2025. def = new AST_VarDef({
  2026. start: S.token,
  2027. name: binding_element(undefined, sym_type),
  2028. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  2029. end: prev()
  2030. });
  2031. } else {
  2032. def = new AST_VarDef({
  2033. start : S.token,
  2034. name : as_symbol(sym_type),
  2035. value : is("operator", "=")
  2036. ? (next(), expression(false, no_in))
  2037. : !no_in && kind === "const"
  2038. ? croak("Missing initializer in const declaration") : null,
  2039. end : prev()
  2040. });
  2041. if (def.name.name == "import") croak("Unexpected token: import");
  2042. }
  2043. var_defs.push(def);
  2044. if (!is("punc", ","))
  2045. break;
  2046. next();
  2047. }
  2048. return var_defs;
  2049. }
  2050. var var_ = function(no_in) {
  2051. return new AST_Var({
  2052. start : prev(),
  2053. definitions : vardefs(no_in, "var"),
  2054. end : prev()
  2055. });
  2056. };
  2057. var let_ = function(no_in) {
  2058. return new AST_Let({
  2059. start : prev(),
  2060. definitions : vardefs(no_in, "let"),
  2061. end : prev()
  2062. });
  2063. };
  2064. var const_ = function(no_in) {
  2065. return new AST_Const({
  2066. start : prev(),
  2067. definitions : vardefs(no_in, "const"),
  2068. end : prev()
  2069. });
  2070. };
  2071. var new_ = function(allow_calls) {
  2072. var start = S.token;
  2073. expect_token("operator", "new");
  2074. if (is("punc", ".")) {
  2075. next();
  2076. expect_token("name", "target");
  2077. return subscripts(new AST_NewTarget({
  2078. start : start,
  2079. end : prev()
  2080. }), allow_calls);
  2081. }
  2082. var newexp = expr_atom(false), args;
  2083. if (is("punc", "(")) {
  2084. next();
  2085. args = expr_list(")", true);
  2086. } else {
  2087. args = [];
  2088. }
  2089. var call = new AST_New({
  2090. start : start,
  2091. expression : newexp,
  2092. args : args,
  2093. end : prev()
  2094. });
  2095. annotate(call);
  2096. return subscripts(call, allow_calls);
  2097. };
  2098. function as_atom_node() {
  2099. var tok = S.token, ret;
  2100. switch (tok.type) {
  2101. case "name":
  2102. ret = _make_symbol(AST_SymbolRef);
  2103. break;
  2104. case "num":
  2105. ret = new AST_Number({
  2106. start: tok,
  2107. end: tok,
  2108. value: tok.value,
  2109. raw: LATEST_RAW
  2110. });
  2111. break;
  2112. case "big_int":
  2113. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  2114. break;
  2115. case "string":
  2116. ret = new AST_String({
  2117. start : tok,
  2118. end : tok,
  2119. value : tok.value,
  2120. quote : tok.quote
  2121. });
  2122. annotate(ret);
  2123. break;
  2124. case "regexp":
  2125. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  2126. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  2127. break;
  2128. case "atom":
  2129. switch (tok.value) {
  2130. case "false":
  2131. ret = new AST_False({ start: tok, end: tok });
  2132. break;
  2133. case "true":
  2134. ret = new AST_True({ start: tok, end: tok });
  2135. break;
  2136. case "null":
  2137. ret = new AST_Null({ start: tok, end: tok });
  2138. break;
  2139. }
  2140. break;
  2141. }
  2142. next();
  2143. return ret;
  2144. }
  2145. function to_fun_args(ex, default_seen_above) {
  2146. var insert_default = function(ex, default_value) {
  2147. if (default_value) {
  2148. return new AST_DefaultAssign({
  2149. start: ex.start,
  2150. left: ex,
  2151. operator: "=",
  2152. right: default_value,
  2153. end: default_value.end
  2154. });
  2155. }
  2156. return ex;
  2157. };
  2158. if (ex instanceof AST_Object) {
  2159. return insert_default(new AST_Destructuring({
  2160. start: ex.start,
  2161. end: ex.end,
  2162. is_array: false,
  2163. names: ex.properties.map(prop => to_fun_args(prop))
  2164. }), default_seen_above);
  2165. } else if (ex instanceof AST_ObjectKeyVal) {
  2166. ex.value = to_fun_args(ex.value);
  2167. return insert_default(ex, default_seen_above);
  2168. } else if (ex instanceof AST_Hole) {
  2169. return ex;
  2170. } else if (ex instanceof AST_Destructuring) {
  2171. ex.names = ex.names.map(name => to_fun_args(name));
  2172. return insert_default(ex, default_seen_above);
  2173. } else if (ex instanceof AST_SymbolRef) {
  2174. return insert_default(new AST_SymbolFunarg({
  2175. name: ex.name,
  2176. start: ex.start,
  2177. end: ex.end
  2178. }), default_seen_above);
  2179. } else if (ex instanceof AST_Expansion) {
  2180. ex.expression = to_fun_args(ex.expression);
  2181. return insert_default(ex, default_seen_above);
  2182. } else if (ex instanceof AST_Array) {
  2183. return insert_default(new AST_Destructuring({
  2184. start: ex.start,
  2185. end: ex.end,
  2186. is_array: true,
  2187. names: ex.elements.map(elm => to_fun_args(elm))
  2188. }), default_seen_above);
  2189. } else if (ex instanceof AST_Assign) {
  2190. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2191. } else if (ex instanceof AST_DefaultAssign) {
  2192. ex.left = to_fun_args(ex.left);
  2193. return ex;
  2194. } else {
  2195. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2196. }
  2197. }
  2198. var expr_atom = function(allow_calls, allow_arrows) {
  2199. if (is("operator", "new")) {
  2200. return new_(allow_calls);
  2201. }
  2202. if (is("name", "import") && is_token(peek(), "punc", ".")) {
  2203. return import_meta(allow_calls);
  2204. }
  2205. var start = S.token;
  2206. var peeked;
  2207. var async = is("name", "async")
  2208. && (peeked = peek()).value != "["
  2209. && peeked.type != "arrow"
  2210. && as_atom_node();
  2211. if (is("punc")) {
  2212. switch (S.token.value) {
  2213. case "(":
  2214. if (async && !allow_calls) break;
  2215. var exprs = params_or_seq_(allow_arrows, !async);
  2216. if (allow_arrows && is("arrow", "=>")) {
  2217. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2218. }
  2219. var ex = async ? new AST_Call({
  2220. expression: async,
  2221. args: exprs
  2222. }) : exprs.length == 1 ? exprs[0] : new AST_Sequence({
  2223. expressions: exprs
  2224. });
  2225. if (ex.start) {
  2226. const outer_comments_before = start.comments_before.length;
  2227. outer_comments_before_counts.set(start, outer_comments_before);
  2228. ex.start.comments_before.unshift(...start.comments_before);
  2229. start.comments_before = ex.start.comments_before;
  2230. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2231. var comment = start.comments_before[0];
  2232. if (!comment.nlb) {
  2233. comment.nlb = start.nlb;
  2234. start.nlb = false;
  2235. }
  2236. }
  2237. start.comments_after = ex.start.comments_after;
  2238. }
  2239. ex.start = start;
  2240. var end = prev();
  2241. if (ex.end) {
  2242. end.comments_before = ex.end.comments_before;
  2243. ex.end.comments_after.push(...end.comments_after);
  2244. end.comments_after = ex.end.comments_after;
  2245. }
  2246. ex.end = end;
  2247. if (ex instanceof AST_Call) annotate(ex);
  2248. return subscripts(ex, allow_calls);
  2249. case "[":
  2250. return subscripts(array_(), allow_calls);
  2251. case "{":
  2252. return subscripts(object_or_destructuring_(), allow_calls);
  2253. }
  2254. if (!async) unexpected();
  2255. }
  2256. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2257. var param = new AST_SymbolFunarg({
  2258. name: S.token.value,
  2259. start: start,
  2260. end: start,
  2261. });
  2262. next();
  2263. return arrow_function(start, [param], !!async);
  2264. }
  2265. if (is("keyword", "function")) {
  2266. next();
  2267. var func = function_(AST_Function, false, !!async);
  2268. func.start = start;
  2269. func.end = prev();
  2270. return subscripts(func, allow_calls);
  2271. }
  2272. if (async) return subscripts(async, allow_calls);
  2273. if (is("keyword", "class")) {
  2274. next();
  2275. var cls = class_(AST_ClassExpression);
  2276. cls.start = start;
  2277. cls.end = prev();
  2278. return subscripts(cls, allow_calls);
  2279. }
  2280. if (is("template_head")) {
  2281. return subscripts(template_string(), allow_calls);
  2282. }
  2283. if (is("privatename")) {
  2284. if(!S.in_class) {
  2285. croak("Private field must be used in an enclosing class");
  2286. }
  2287. const start = S.token;
  2288. const key = new AST_SymbolPrivateProperty({
  2289. start,
  2290. name: start.value,
  2291. end: start
  2292. });
  2293. next();
  2294. expect_token("operator", "in");
  2295. const private_in = new AST_PrivateIn({
  2296. start,
  2297. key,
  2298. value: subscripts(as_atom_node(), allow_calls),
  2299. end: prev()
  2300. });
  2301. return subscripts(private_in, allow_calls);
  2302. }
  2303. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2304. return subscripts(as_atom_node(), allow_calls);
  2305. }
  2306. unexpected();
  2307. };
  2308. function template_string() {
  2309. var segments = [], start = S.token;
  2310. segments.push(new AST_TemplateSegment({
  2311. start: S.token,
  2312. raw: TEMPLATE_RAWS.get(S.token),
  2313. value: S.token.value,
  2314. end: S.token
  2315. }));
  2316. while (!S.token.template_end) {
  2317. next();
  2318. handle_regexp();
  2319. segments.push(expression(true));
  2320. segments.push(new AST_TemplateSegment({
  2321. start: S.token,
  2322. raw: TEMPLATE_RAWS.get(S.token),
  2323. value: S.token.value,
  2324. end: S.token
  2325. }));
  2326. }
  2327. next();
  2328. return new AST_TemplateString({
  2329. start: start,
  2330. segments: segments,
  2331. end: S.token
  2332. });
  2333. }
  2334. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2335. var first = true, a = [];
  2336. while (!is("punc", closing)) {
  2337. if (first) first = false; else expect(",");
  2338. if (allow_trailing_comma && is("punc", closing)) break;
  2339. if (is("punc", ",") && allow_empty) {
  2340. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2341. } else if (is("expand", "...")) {
  2342. next();
  2343. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2344. } else {
  2345. a.push(expression(false));
  2346. }
  2347. }
  2348. next();
  2349. return a;
  2350. }
  2351. var array_ = embed_tokens(function() {
  2352. expect("[");
  2353. return new AST_Array({
  2354. elements: expr_list("]", !options.strict, true)
  2355. });
  2356. });
  2357. var create_accessor = embed_tokens((is_generator, is_async) => {
  2358. return function_(AST_Accessor, is_generator, is_async);
  2359. });
  2360. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2361. var start = S.token, first = true, a = [];
  2362. expect("{");
  2363. while (!is("punc", "}")) {
  2364. if (first) first = false; else expect(",");
  2365. if (!options.strict && is("punc", "}"))
  2366. // allow trailing comma
  2367. break;
  2368. start = S.token;
  2369. if (start.type == "expand") {
  2370. next();
  2371. a.push(new AST_Expansion({
  2372. start: start,
  2373. expression: expression(false),
  2374. end: prev(),
  2375. }));
  2376. continue;
  2377. }
  2378. if(is("privatename")) {
  2379. croak("private fields are not allowed in an object");
  2380. }
  2381. var name = as_property_name();
  2382. var value;
  2383. // Check property and fetch value
  2384. if (!is("punc", ":")) {
  2385. var concise = concise_method_or_getset(name, start);
  2386. if (concise) {
  2387. a.push(concise);
  2388. continue;
  2389. }
  2390. value = new AST_SymbolRef({
  2391. start: prev(),
  2392. name: name,
  2393. end: prev()
  2394. });
  2395. } else if (name === null) {
  2396. unexpected(prev());
  2397. } else {
  2398. next(); // `:` - see first condition
  2399. value = expression(false);
  2400. }
  2401. // Check for default value and alter value accordingly if necessary
  2402. if (is("operator", "=")) {
  2403. next();
  2404. value = new AST_Assign({
  2405. start: start,
  2406. left: value,
  2407. operator: "=",
  2408. right: expression(false),
  2409. logical: false,
  2410. end: prev()
  2411. });
  2412. }
  2413. // Create property
  2414. const kv = new AST_ObjectKeyVal({
  2415. start: start,
  2416. quote: start.quote,
  2417. key: name instanceof AST_Node ? name : "" + name,
  2418. value: value,
  2419. end: prev()
  2420. });
  2421. a.push(annotate(kv));
  2422. }
  2423. next();
  2424. return new AST_Object({ properties: a });
  2425. });
  2426. function class_(KindOfClass, is_export_default) {
  2427. var start, method, class_name, extends_, a = [];
  2428. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2429. S.input.add_directive("use strict");
  2430. if (S.token.type == "name" && S.token.value != "extends") {
  2431. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2432. }
  2433. if (KindOfClass === AST_DefClass && !class_name) {
  2434. if (is_export_default) {
  2435. KindOfClass = AST_ClassExpression;
  2436. } else {
  2437. unexpected();
  2438. }
  2439. }
  2440. if (S.token.value == "extends") {
  2441. next();
  2442. extends_ = expression(true);
  2443. }
  2444. expect("{");
  2445. // mark in class feild,
  2446. const save_in_class = S.in_class;
  2447. S.in_class = true;
  2448. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2449. while (!is("punc", "}")) {
  2450. start = S.token;
  2451. method = concise_method_or_getset(as_property_name(), start, true);
  2452. if (!method) { unexpected(); }
  2453. a.push(method);
  2454. while (is("punc", ";")) { next(); }
  2455. }
  2456. // mark in class feild,
  2457. S.in_class = save_in_class;
  2458. S.input.pop_directives_stack();
  2459. next();
  2460. return new KindOfClass({
  2461. start: start,
  2462. name: class_name,
  2463. extends: extends_,
  2464. properties: a,
  2465. end: prev(),
  2466. });
  2467. }
  2468. function concise_method_or_getset(name, start, is_class) {
  2469. const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
  2470. if (typeof name === "string" || typeof name === "number") {
  2471. return new SymbolClass({
  2472. start,
  2473. name: "" + name,
  2474. end: prev()
  2475. });
  2476. } else if (name === null) {
  2477. unexpected();
  2478. }
  2479. return name;
  2480. };
  2481. const is_not_method_start = () =>
  2482. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=");
  2483. var is_async = false;
  2484. var is_static = false;
  2485. var is_generator = false;
  2486. var is_private = false;
  2487. var accessor_type = null;
  2488. if (is_class && name === "static" && is_not_method_start()) {
  2489. const static_block = class_static_block();
  2490. if (static_block != null) {
  2491. return static_block;
  2492. }
  2493. is_static = true;
  2494. name = as_property_name();
  2495. }
  2496. if (name === "async" && is_not_method_start()) {
  2497. is_async = true;
  2498. name = as_property_name();
  2499. }
  2500. if (prev().type === "operator" && prev().value === "*") {
  2501. is_generator = true;
  2502. name = as_property_name();
  2503. }
  2504. if ((name === "get" || name === "set") && is_not_method_start()) {
  2505. accessor_type = name;
  2506. name = as_property_name();
  2507. }
  2508. if (prev().type === "privatename") {
  2509. is_private = true;
  2510. }
  2511. const property_token = prev();
  2512. if (accessor_type != null) {
  2513. if (!is_private) {
  2514. const AccessorClass = accessor_type === "get"
  2515. ? AST_ObjectGetter
  2516. : AST_ObjectSetter;
  2517. name = get_symbol_ast(name);
  2518. return annotate(new AccessorClass({
  2519. start,
  2520. static: is_static,
  2521. key: name,
  2522. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  2523. value: create_accessor(),
  2524. end: prev()
  2525. }));
  2526. } else {
  2527. const AccessorClass = accessor_type === "get"
  2528. ? AST_PrivateGetter
  2529. : AST_PrivateSetter;
  2530. return annotate(new AccessorClass({
  2531. start,
  2532. static: is_static,
  2533. key: get_symbol_ast(name),
  2534. value: create_accessor(),
  2535. end: prev(),
  2536. }));
  2537. }
  2538. }
  2539. if (is("punc", "(")) {
  2540. name = get_symbol_ast(name);
  2541. const AST_MethodVariant = is_private
  2542. ? AST_PrivateMethod
  2543. : AST_ConciseMethod;
  2544. var node = new AST_MethodVariant({
  2545. start : start,
  2546. static : is_static,
  2547. is_generator: is_generator,
  2548. async : is_async,
  2549. key : name,
  2550. quote : name instanceof AST_SymbolMethod ?
  2551. property_token.quote : undefined,
  2552. value : create_accessor(is_generator, is_async),
  2553. end : prev()
  2554. });
  2555. return annotate(node);
  2556. }
  2557. if (is_class) {
  2558. const key = get_symbol_ast(name, AST_SymbolClassProperty);
  2559. const quote = key instanceof AST_SymbolClassProperty
  2560. ? property_token.quote
  2561. : undefined;
  2562. const AST_ClassPropertyVariant = is_private
  2563. ? AST_ClassPrivateProperty
  2564. : AST_ClassProperty;
  2565. if (is("operator", "=")) {
  2566. next();
  2567. return annotate(
  2568. new AST_ClassPropertyVariant({
  2569. start,
  2570. static: is_static,
  2571. quote,
  2572. key,
  2573. value: expression(false),
  2574. end: prev()
  2575. })
  2576. );
  2577. } else if (
  2578. is("name")
  2579. || is("privatename")
  2580. || is("operator", "*")
  2581. || is("punc", ";")
  2582. || is("punc", "}")
  2583. ) {
  2584. return annotate(
  2585. new AST_ClassPropertyVariant({
  2586. start,
  2587. static: is_static,
  2588. quote,
  2589. key,
  2590. end: prev()
  2591. })
  2592. );
  2593. }
  2594. }
  2595. }
  2596. function class_static_block() {
  2597. if (!is("punc", "{")) {
  2598. return null;
  2599. }
  2600. const start = S.token;
  2601. const body = [];
  2602. next();
  2603. while (!is("punc", "}")) {
  2604. body.push(statement());
  2605. }
  2606. next();
  2607. return new AST_ClassStaticBlock({ start, body, end: prev() });
  2608. }
  2609. function maybe_import_assertion() {
  2610. if (is("name", "assert") && !has_newline_before(S.token)) {
  2611. next();
  2612. return object_or_destructuring_();
  2613. }
  2614. return null;
  2615. }
  2616. function import_statement() {
  2617. var start = prev();
  2618. var imported_name;
  2619. var imported_names;
  2620. if (is("name")) {
  2621. imported_name = as_symbol(AST_SymbolImport);
  2622. }
  2623. if (is("punc", ",")) {
  2624. next();
  2625. }
  2626. imported_names = map_names(true);
  2627. if (imported_names || imported_name) {
  2628. expect_token("name", "from");
  2629. }
  2630. var mod_str = S.token;
  2631. if (mod_str.type !== "string") {
  2632. unexpected();
  2633. }
  2634. next();
  2635. const assert_clause = maybe_import_assertion();
  2636. return new AST_Import({
  2637. start,
  2638. imported_name,
  2639. imported_names,
  2640. module_name: new AST_String({
  2641. start: mod_str,
  2642. value: mod_str.value,
  2643. quote: mod_str.quote,
  2644. end: mod_str,
  2645. }),
  2646. assert_clause,
  2647. end: S.token,
  2648. });
  2649. }
  2650. function import_meta(allow_calls) {
  2651. var start = S.token;
  2652. expect_token("name", "import");
  2653. expect_token("punc", ".");
  2654. expect_token("name", "meta");
  2655. return subscripts(new AST_ImportMeta({
  2656. start: start,
  2657. end: prev()
  2658. }), allow_calls);
  2659. }
  2660. function map_name(is_import) {
  2661. function make_symbol(type, quote) {
  2662. return new type({
  2663. name: as_property_name(),
  2664. quote: quote || undefined,
  2665. start: prev(),
  2666. end: prev()
  2667. });
  2668. }
  2669. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2670. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2671. var start = S.token;
  2672. var foreign_name;
  2673. var name;
  2674. if (is_import) {
  2675. foreign_name = make_symbol(foreign_type, start.quote);
  2676. } else {
  2677. name = make_symbol(type, start.quote);
  2678. }
  2679. if (is("name", "as")) {
  2680. next(); // The "as" word
  2681. if (is_import) {
  2682. name = make_symbol(type);
  2683. } else {
  2684. foreign_name = make_symbol(foreign_type, S.token.quote);
  2685. }
  2686. } else if (is_import) {
  2687. name = new type(foreign_name);
  2688. } else {
  2689. foreign_name = new foreign_type(name);
  2690. }
  2691. return new AST_NameMapping({
  2692. start: start,
  2693. foreign_name: foreign_name,
  2694. name: name,
  2695. end: prev(),
  2696. });
  2697. }
  2698. function map_nameAsterisk(is_import, import_or_export_foreign_name) {
  2699. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2700. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2701. var start = S.token;
  2702. var name, foreign_name;
  2703. var end = prev();
  2704. if (is_import) {
  2705. name = import_or_export_foreign_name;
  2706. } else {
  2707. foreign_name = import_or_export_foreign_name;
  2708. }
  2709. name = name || new type({
  2710. start: start,
  2711. name: "*",
  2712. end: end,
  2713. });
  2714. foreign_name = foreign_name || new foreign_type({
  2715. start: start,
  2716. name: "*",
  2717. end: end,
  2718. });
  2719. return new AST_NameMapping({
  2720. start: start,
  2721. foreign_name: foreign_name,
  2722. name: name,
  2723. end: end,
  2724. });
  2725. }
  2726. function map_names(is_import) {
  2727. var names;
  2728. if (is("punc", "{")) {
  2729. next();
  2730. names = [];
  2731. while (!is("punc", "}")) {
  2732. names.push(map_name(is_import));
  2733. if (is("punc", ",")) {
  2734. next();
  2735. }
  2736. }
  2737. next();
  2738. } else if (is("operator", "*")) {
  2739. var name;
  2740. next();
  2741. if (is("name", "as")) {
  2742. next(); // The "as" word
  2743. name = is_import ? as_symbol(AST_SymbolImport) : as_symbol_or_string(AST_SymbolExportForeign);
  2744. }
  2745. names = [map_nameAsterisk(is_import, name)];
  2746. }
  2747. return names;
  2748. }
  2749. function export_statement() {
  2750. var start = S.token;
  2751. var is_default;
  2752. var exported_names;
  2753. if (is("keyword", "default")) {
  2754. is_default = true;
  2755. next();
  2756. } else if (exported_names = map_names(false)) {
  2757. if (is("name", "from")) {
  2758. next();
  2759. var mod_str = S.token;
  2760. if (mod_str.type !== "string") {
  2761. unexpected();
  2762. }
  2763. next();
  2764. const assert_clause = maybe_import_assertion();
  2765. return new AST_Export({
  2766. start: start,
  2767. is_default: is_default,
  2768. exported_names: exported_names,
  2769. module_name: new AST_String({
  2770. start: mod_str,
  2771. value: mod_str.value,
  2772. quote: mod_str.quote,
  2773. end: mod_str,
  2774. }),
  2775. end: prev(),
  2776. assert_clause
  2777. });
  2778. } else {
  2779. return new AST_Export({
  2780. start: start,
  2781. is_default: is_default,
  2782. exported_names: exported_names,
  2783. end: prev(),
  2784. });
  2785. }
  2786. }
  2787. var node;
  2788. var exported_value;
  2789. var exported_definition;
  2790. if (is("punc", "{")
  2791. || is_default
  2792. && (is("keyword", "class") || is("keyword", "function"))
  2793. && is_token(peek(), "punc")) {
  2794. exported_value = expression(false);
  2795. semicolon();
  2796. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2797. unexpected(node.start);
  2798. } else if (
  2799. node instanceof AST_Definitions
  2800. || node instanceof AST_Defun
  2801. || node instanceof AST_DefClass
  2802. ) {
  2803. exported_definition = node;
  2804. } else if (
  2805. node instanceof AST_ClassExpression
  2806. || node instanceof AST_Function
  2807. ) {
  2808. exported_value = node;
  2809. } else if (node instanceof AST_SimpleStatement) {
  2810. exported_value = node.body;
  2811. } else {
  2812. unexpected(node.start);
  2813. }
  2814. return new AST_Export({
  2815. start: start,
  2816. is_default: is_default,
  2817. exported_value: exported_value,
  2818. exported_definition: exported_definition,
  2819. end: prev(),
  2820. assert_clause: null
  2821. });
  2822. }
  2823. function as_property_name() {
  2824. var tmp = S.token;
  2825. switch (tmp.type) {
  2826. case "punc":
  2827. if (tmp.value === "[") {
  2828. next();
  2829. var ex = expression(false);
  2830. expect("]");
  2831. return ex;
  2832. } else unexpected(tmp);
  2833. case "operator":
  2834. if (tmp.value === "*") {
  2835. next();
  2836. return null;
  2837. }
  2838. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2839. unexpected(tmp);
  2840. }
  2841. /* falls through */
  2842. case "name":
  2843. case "privatename":
  2844. case "string":
  2845. case "num":
  2846. case "big_int":
  2847. case "keyword":
  2848. case "atom":
  2849. next();
  2850. return tmp.value;
  2851. default:
  2852. unexpected(tmp);
  2853. }
  2854. }
  2855. function as_name() {
  2856. var tmp = S.token;
  2857. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  2858. next();
  2859. return tmp.value;
  2860. }
  2861. function _make_symbol(type) {
  2862. var name = S.token.value;
  2863. return new (name == "this" ? AST_This :
  2864. name == "super" ? AST_Super :
  2865. type)({
  2866. name : String(name),
  2867. start : S.token,
  2868. end : S.token
  2869. });
  2870. }
  2871. function _verify_symbol(sym) {
  2872. var name = sym.name;
  2873. if (is_in_generator() && name == "yield") {
  2874. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2875. }
  2876. if (S.input.has_directive("use strict")) {
  2877. if (name == "yield") {
  2878. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2879. }
  2880. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2881. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2882. }
  2883. }
  2884. }
  2885. function as_symbol(type, noerror) {
  2886. if (!is("name")) {
  2887. if (!noerror) croak("Name expected");
  2888. return null;
  2889. }
  2890. var sym = _make_symbol(type);
  2891. _verify_symbol(sym);
  2892. next();
  2893. return sym;
  2894. }
  2895. function as_symbol_or_string(type) {
  2896. if (!is("name")) {
  2897. if (!is("string")) {
  2898. croak("Name or string expected");
  2899. }
  2900. var tok = S.token;
  2901. var ret = new type({
  2902. start : tok,
  2903. end : tok,
  2904. name : tok.value,
  2905. quote : tok.quote
  2906. });
  2907. next();
  2908. return ret;
  2909. }
  2910. var sym = _make_symbol(type);
  2911. _verify_symbol(sym);
  2912. next();
  2913. return sym;
  2914. }
  2915. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2916. function annotate(node, before_token = node.start) {
  2917. var comments = before_token.comments_before;
  2918. const comments_outside_parens = outer_comments_before_counts.get(before_token);
  2919. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2920. while (--i >= 0) {
  2921. var comment = comments[i];
  2922. if (/[@#]__/.test(comment.value)) {
  2923. if (/[@#]__PURE__/.test(comment.value)) {
  2924. set_annotation(node, _PURE);
  2925. break;
  2926. }
  2927. if (/[@#]__INLINE__/.test(comment.value)) {
  2928. set_annotation(node, _INLINE);
  2929. break;
  2930. }
  2931. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2932. set_annotation(node, _NOINLINE);
  2933. break;
  2934. }
  2935. if (/[@#]__KEY__/.test(comment.value)) {
  2936. set_annotation(node, _KEY);
  2937. break;
  2938. }
  2939. if (/[@#]__MANGLE_PROP__/.test(comment.value)) {
  2940. set_annotation(node, _MANGLEPROP);
  2941. break;
  2942. }
  2943. }
  2944. }
  2945. return node;
  2946. }
  2947. var subscripts = function(expr, allow_calls, is_chain) {
  2948. var start = expr.start;
  2949. if (is("punc", ".")) {
  2950. next();
  2951. if(is("privatename") && !S.in_class)
  2952. croak("Private field must be used in an enclosing class");
  2953. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2954. return annotate(subscripts(new AST_DotVariant({
  2955. start : start,
  2956. expression : expr,
  2957. optional : false,
  2958. property : as_name(),
  2959. end : prev()
  2960. }), allow_calls, is_chain));
  2961. }
  2962. if (is("punc", "[")) {
  2963. next();
  2964. var prop = expression(true);
  2965. expect("]");
  2966. return annotate(subscripts(new AST_Sub({
  2967. start : start,
  2968. expression : expr,
  2969. optional : false,
  2970. property : prop,
  2971. end : prev()
  2972. }), allow_calls, is_chain));
  2973. }
  2974. if (allow_calls && is("punc", "(")) {
  2975. next();
  2976. var call = new AST_Call({
  2977. start : start,
  2978. expression : expr,
  2979. optional : false,
  2980. args : call_args(),
  2981. end : prev()
  2982. });
  2983. annotate(call);
  2984. return subscripts(call, true, is_chain);
  2985. }
  2986. if (is("punc", "?.")) {
  2987. next();
  2988. let chain_contents;
  2989. if (allow_calls && is("punc", "(")) {
  2990. next();
  2991. const call = new AST_Call({
  2992. start,
  2993. optional: true,
  2994. expression: expr,
  2995. args: call_args(),
  2996. end: prev()
  2997. });
  2998. annotate(call);
  2999. chain_contents = subscripts(call, true, true);
  3000. } else if (is("name") || is("privatename")) {
  3001. if(is("privatename") && !S.in_class)
  3002. croak("Private field must be used in an enclosing class");
  3003. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  3004. chain_contents = annotate(subscripts(new AST_DotVariant({
  3005. start,
  3006. expression: expr,
  3007. optional: true,
  3008. property: as_name(),
  3009. end: prev()
  3010. }), allow_calls, true));
  3011. } else if (is("punc", "[")) {
  3012. next();
  3013. const property = expression(true);
  3014. expect("]");
  3015. chain_contents = annotate(subscripts(new AST_Sub({
  3016. start,
  3017. expression: expr,
  3018. optional: true,
  3019. property,
  3020. end: prev()
  3021. }), allow_calls, true));
  3022. }
  3023. if (!chain_contents) unexpected();
  3024. if (chain_contents instanceof AST_Chain) return chain_contents;
  3025. return new AST_Chain({
  3026. start,
  3027. expression: chain_contents,
  3028. end: prev()
  3029. });
  3030. }
  3031. if (is("template_head")) {
  3032. if (is_chain) {
  3033. // a?.b`c` is a syntax error
  3034. unexpected();
  3035. }
  3036. return subscripts(new AST_PrefixedTemplateString({
  3037. start: start,
  3038. prefix: expr,
  3039. template_string: template_string(),
  3040. end: prev()
  3041. }), allow_calls);
  3042. }
  3043. return expr;
  3044. };
  3045. function call_args() {
  3046. var args = [];
  3047. while (!is("punc", ")")) {
  3048. if (is("expand", "...")) {
  3049. next();
  3050. args.push(new AST_Expansion({
  3051. start: prev(),
  3052. expression: expression(false),
  3053. end: prev()
  3054. }));
  3055. } else {
  3056. args.push(expression(false));
  3057. }
  3058. if (!is("punc", ")")) {
  3059. expect(",");
  3060. }
  3061. }
  3062. next();
  3063. return args;
  3064. }
  3065. var maybe_unary = function(allow_calls, allow_arrows) {
  3066. var start = S.token;
  3067. if (start.type == "name" && start.value == "await" && can_await()) {
  3068. next();
  3069. return _await_expression();
  3070. }
  3071. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  3072. next();
  3073. handle_regexp();
  3074. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  3075. ex.start = start;
  3076. ex.end = prev();
  3077. return ex;
  3078. }
  3079. var val = expr_atom(allow_calls, allow_arrows);
  3080. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  3081. if (val instanceof AST_Arrow) unexpected();
  3082. val = make_unary(AST_UnaryPostfix, S.token, val);
  3083. val.start = start;
  3084. val.end = S.token;
  3085. next();
  3086. }
  3087. return val;
  3088. };
  3089. function make_unary(ctor, token, expr) {
  3090. var op = token.value;
  3091. switch (op) {
  3092. case "++":
  3093. case "--":
  3094. if (!is_assignable(expr))
  3095. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  3096. break;
  3097. case "delete":
  3098. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3099. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3100. break;
  3101. }
  3102. return new ctor({ operator: op, expression: expr });
  3103. }
  3104. var expr_op = function(left, min_prec, no_in) {
  3105. var op = is("operator") ? S.token.value : null;
  3106. if (op == "in" && no_in) op = null;
  3107. if (op == "**" && left instanceof AST_UnaryPrefix
  3108. /* unary token in front not allowed - parenthesis required */
  3109. && !is_token(left.start, "punc", "(")
  3110. && left.operator !== "--" && left.operator !== "++")
  3111. unexpected(left.start);
  3112. var prec = op != null ? PRECEDENCE[op] : null;
  3113. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3114. next();
  3115. var right = expr_op(maybe_unary(true), prec, no_in);
  3116. return expr_op(new AST_Binary({
  3117. start : left.start,
  3118. left : left,
  3119. operator : op,
  3120. right : right,
  3121. end : right.end
  3122. }), min_prec, no_in);
  3123. }
  3124. return left;
  3125. };
  3126. function expr_ops(no_in) {
  3127. return expr_op(maybe_unary(true, true), 0, no_in);
  3128. }
  3129. var maybe_conditional = function(no_in) {
  3130. var start = S.token;
  3131. var expr = expr_ops(no_in);
  3132. if (is("operator", "?")) {
  3133. next();
  3134. var yes = expression(false);
  3135. expect(":");
  3136. return new AST_Conditional({
  3137. start : start,
  3138. condition : expr,
  3139. consequent : yes,
  3140. alternative : expression(false, no_in),
  3141. end : prev()
  3142. });
  3143. }
  3144. return expr;
  3145. };
  3146. function is_assignable(expr) {
  3147. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3148. }
  3149. function to_destructuring(node) {
  3150. if (node instanceof AST_Object) {
  3151. node = new AST_Destructuring({
  3152. start: node.start,
  3153. names: node.properties.map(to_destructuring),
  3154. is_array: false,
  3155. end: node.end
  3156. });
  3157. } else if (node instanceof AST_Array) {
  3158. var names = [];
  3159. for (var i = 0; i < node.elements.length; i++) {
  3160. // Only allow expansion as last element
  3161. if (node.elements[i] instanceof AST_Expansion) {
  3162. if (i + 1 !== node.elements.length) {
  3163. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3164. }
  3165. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3166. }
  3167. names.push(to_destructuring(node.elements[i]));
  3168. }
  3169. node = new AST_Destructuring({
  3170. start: node.start,
  3171. names: names,
  3172. is_array: true,
  3173. end: node.end
  3174. });
  3175. } else if (node instanceof AST_ObjectProperty) {
  3176. node.value = to_destructuring(node.value);
  3177. } else if (node instanceof AST_Assign) {
  3178. node = new AST_DefaultAssign({
  3179. start: node.start,
  3180. left: node.left,
  3181. operator: "=",
  3182. right: node.right,
  3183. end: node.end
  3184. });
  3185. }
  3186. return node;
  3187. }
  3188. // In ES6, AssignmentExpression can also be an ArrowFunction
  3189. var maybe_assign = function(no_in) {
  3190. handle_regexp();
  3191. var start = S.token;
  3192. if (start.type == "name" && start.value == "yield") {
  3193. if (is_in_generator()) {
  3194. next();
  3195. return _yield_expression();
  3196. } else if (S.input.has_directive("use strict")) {
  3197. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3198. }
  3199. }
  3200. var left = maybe_conditional(no_in);
  3201. var val = S.token.value;
  3202. if (is("operator") && ASSIGNMENT.has(val)) {
  3203. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3204. next();
  3205. return new AST_Assign({
  3206. start : start,
  3207. left : left,
  3208. operator : val,
  3209. right : maybe_assign(no_in),
  3210. logical : LOGICAL_ASSIGNMENT.has(val),
  3211. end : prev()
  3212. });
  3213. }
  3214. croak("Invalid assignment");
  3215. }
  3216. return left;
  3217. };
  3218. var expression = function(commas, no_in) {
  3219. var start = S.token;
  3220. var exprs = [];
  3221. while (true) {
  3222. exprs.push(maybe_assign(no_in));
  3223. if (!commas || !is("punc", ",")) break;
  3224. next();
  3225. commas = true;
  3226. }
  3227. return exprs.length == 1 ? exprs[0] : new AST_Sequence({
  3228. start : start,
  3229. expressions : exprs,
  3230. end : peek()
  3231. });
  3232. };
  3233. function in_loop(cont) {
  3234. ++S.in_loop;
  3235. var ret = cont();
  3236. --S.in_loop;
  3237. return ret;
  3238. }
  3239. if (options.expression) {
  3240. return expression(true);
  3241. }
  3242. return (function parse_toplevel() {
  3243. var start = S.token;
  3244. var body = [];
  3245. S.input.push_directives_stack();
  3246. if (options.module) S.input.add_directive("use strict");
  3247. while (!is("eof")) {
  3248. body.push(statement());
  3249. }
  3250. S.input.pop_directives_stack();
  3251. var end = prev();
  3252. var toplevel = options.toplevel;
  3253. if (toplevel) {
  3254. toplevel.body = toplevel.body.concat(body);
  3255. toplevel.end = end;
  3256. } else {
  3257. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3258. }
  3259. TEMPLATE_RAWS = new Map();
  3260. return toplevel;
  3261. })();
  3262. }
  3263. /***********************************************************************
  3264. A JavaScript tokenizer / parser / beautifier / compressor.
  3265. https://github.com/mishoo/UglifyJS2
  3266. -------------------------------- (C) ---------------------------------
  3267. Author: Mihai Bazon
  3268. <mihai.bazon@gmail.com>
  3269. http://mihai.bazon.net/blog
  3270. Distributed under the BSD license:
  3271. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3272. Redistribution and use in source and binary forms, with or without
  3273. modification, are permitted provided that the following conditions
  3274. are met:
  3275. * Redistributions of source code must retain the above
  3276. copyright notice, this list of conditions and the following
  3277. disclaimer.
  3278. * Redistributions in binary form must reproduce the above
  3279. copyright notice, this list of conditions and the following
  3280. disclaimer in the documentation and/or other materials
  3281. provided with the distribution.
  3282. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3283. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3284. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3285. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3286. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3287. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3288. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3289. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3290. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3291. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3292. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3293. SUCH DAMAGE.
  3294. ***********************************************************************/
  3295. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  3296. if (!props) props = [];
  3297. else props = props.split(/\s+/);
  3298. var self_props = props;
  3299. if (base && base.PROPS)
  3300. props = props.concat(base.PROPS);
  3301. const proto = base && Object.create(base.prototype);
  3302. if (proto) {
  3303. ctor.prototype = proto;
  3304. ctor.BASE = base;
  3305. }
  3306. if (base) base.SUBCLASSES.push(ctor);
  3307. ctor.prototype.CTOR = ctor;
  3308. ctor.prototype.constructor = ctor;
  3309. ctor.PROPS = props || null;
  3310. ctor.SELF_PROPS = self_props;
  3311. ctor.SUBCLASSES = [];
  3312. if (type) {
  3313. ctor.prototype.TYPE = ctor.TYPE = type;
  3314. }
  3315. if (methods) for (let i in methods) if (HOP(methods, i)) {
  3316. if (i[0] === "$") {
  3317. ctor[i.substr(1)] = methods[i];
  3318. } else {
  3319. ctor.prototype[i] = methods[i];
  3320. }
  3321. }
  3322. ctor.DEFMETHOD = function(name, method) {
  3323. this.prototype[name] = method;
  3324. };
  3325. return ctor;
  3326. }
  3327. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  3328. const set_tok_flag = (tok, flag, truth) => {
  3329. if (truth) {
  3330. tok.flags |= flag;
  3331. } else {
  3332. tok.flags &= ~flag;
  3333. }
  3334. };
  3335. const TOK_FLAG_NLB = 0b0001;
  3336. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  3337. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  3338. const TOK_FLAG_TEMPLATE_END = 0b1000;
  3339. class AST_Token {
  3340. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  3341. this.flags = (nlb ? 1 : 0);
  3342. this.type = type;
  3343. this.value = value;
  3344. this.line = line;
  3345. this.col = col;
  3346. this.pos = pos;
  3347. this.comments_before = comments_before;
  3348. this.comments_after = comments_after;
  3349. this.file = file;
  3350. Object.seal(this);
  3351. }
  3352. // Return a string summary of the token for node.js console.log
  3353. [Symbol.for("nodejs.util.inspect.custom")](_depth, options) {
  3354. const special = str => options.stylize(str, "special");
  3355. const quote = typeof this.value === "string" && this.value.includes("`") ? "'" : "`";
  3356. const value = `${quote}${this.value}${quote}`;
  3357. return `${special("[AST_Token")} ${value} at ${this.line}:${this.col}${special("]")}`;
  3358. }
  3359. get nlb() {
  3360. return has_tok_flag(this, TOK_FLAG_NLB);
  3361. }
  3362. set nlb(new_nlb) {
  3363. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  3364. }
  3365. get quote() {
  3366. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  3367. ? ""
  3368. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  3369. }
  3370. set quote(quote_type) {
  3371. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  3372. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  3373. }
  3374. get template_end() {
  3375. return has_tok_flag(this, TOK_FLAG_TEMPLATE_END);
  3376. }
  3377. set template_end(new_template_end) {
  3378. set_tok_flag(this, TOK_FLAG_TEMPLATE_END, new_template_end);
  3379. }
  3380. }
  3381. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  3382. if (props) {
  3383. this.start = props.start;
  3384. this.end = props.end;
  3385. }
  3386. this.flags = 0;
  3387. }, {
  3388. _clone: function(deep) {
  3389. if (deep) {
  3390. var self = this.clone();
  3391. return self.transform(new TreeTransformer(function(node) {
  3392. if (node !== self) {
  3393. return node.clone(true);
  3394. }
  3395. }));
  3396. }
  3397. return new this.CTOR(this);
  3398. },
  3399. clone: function(deep) {
  3400. return this._clone(deep);
  3401. },
  3402. $documentation: "Base class of all AST nodes",
  3403. $propdoc: {
  3404. start: "[AST_Token] The first token of this node",
  3405. end: "[AST_Token] The last token of this node"
  3406. },
  3407. _walk: function(visitor) {
  3408. return visitor._visit(this);
  3409. },
  3410. walk: function(visitor) {
  3411. return this._walk(visitor); // not sure the indirection will be any help
  3412. },
  3413. _children_backwards: () => {}
  3414. }, null);
  3415. /* -----[ statements ]----- */
  3416. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  3417. if (props) {
  3418. this.start = props.start;
  3419. this.end = props.end;
  3420. }
  3421. this.flags = 0;
  3422. }, {
  3423. $documentation: "Base class of all statements",
  3424. });
  3425. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  3426. if (props) {
  3427. this.start = props.start;
  3428. this.end = props.end;
  3429. }
  3430. this.flags = 0;
  3431. }, {
  3432. $documentation: "Represents a debugger statement",
  3433. }, AST_Statement);
  3434. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  3435. if (props) {
  3436. this.value = props.value;
  3437. this.quote = props.quote;
  3438. this.start = props.start;
  3439. this.end = props.end;
  3440. }
  3441. this.flags = 0;
  3442. }, {
  3443. $documentation: "Represents a directive, like \"use strict\";",
  3444. $propdoc: {
  3445. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3446. quote: "[string] the original quote character"
  3447. },
  3448. }, AST_Statement);
  3449. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  3450. if (props) {
  3451. this.body = props.body;
  3452. this.start = props.start;
  3453. this.end = props.end;
  3454. }
  3455. this.flags = 0;
  3456. }, {
  3457. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3458. $propdoc: {
  3459. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3460. },
  3461. _walk: function(visitor) {
  3462. return visitor._visit(this, function() {
  3463. this.body._walk(visitor);
  3464. });
  3465. },
  3466. _children_backwards(push) {
  3467. push(this.body);
  3468. }
  3469. }, AST_Statement);
  3470. function walk_body(node, visitor) {
  3471. const body = node.body;
  3472. for (var i = 0, len = body.length; i < len; i++) {
  3473. body[i]._walk(visitor);
  3474. }
  3475. }
  3476. function clone_block_scope(deep) {
  3477. var clone = this._clone(deep);
  3478. if (this.block_scope) {
  3479. clone.block_scope = this.block_scope.clone();
  3480. }
  3481. return clone;
  3482. }
  3483. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  3484. if (props) {
  3485. this.body = props.body;
  3486. this.block_scope = props.block_scope;
  3487. this.start = props.start;
  3488. this.end = props.end;
  3489. }
  3490. this.flags = 0;
  3491. }, {
  3492. $documentation: "A body of statements (usually braced)",
  3493. $propdoc: {
  3494. body: "[AST_Statement*] an array of statements",
  3495. block_scope: "[AST_Scope] the block scope"
  3496. },
  3497. _walk: function(visitor) {
  3498. return visitor._visit(this, function() {
  3499. walk_body(this, visitor);
  3500. });
  3501. },
  3502. _children_backwards(push) {
  3503. let i = this.body.length;
  3504. while (i--) push(this.body[i]);
  3505. },
  3506. clone: clone_block_scope
  3507. }, AST_Statement);
  3508. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  3509. if (props) {
  3510. this.body = props.body;
  3511. this.block_scope = props.block_scope;
  3512. this.start = props.start;
  3513. this.end = props.end;
  3514. }
  3515. this.flags = 0;
  3516. }, {
  3517. $documentation: "A block statement",
  3518. }, AST_Block);
  3519. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  3520. if (props) {
  3521. this.start = props.start;
  3522. this.end = props.end;
  3523. }
  3524. this.flags = 0;
  3525. }, {
  3526. $documentation: "The empty statement (empty block or simply a semicolon)"
  3527. }, AST_Statement);
  3528. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  3529. if (props) {
  3530. this.body = props.body;
  3531. this.start = props.start;
  3532. this.end = props.end;
  3533. }
  3534. this.flags = 0;
  3535. }, {
  3536. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3537. $propdoc: {
  3538. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3539. }
  3540. }, AST_Statement);
  3541. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  3542. if (props) {
  3543. this.label = props.label;
  3544. this.body = props.body;
  3545. this.start = props.start;
  3546. this.end = props.end;
  3547. }
  3548. this.flags = 0;
  3549. }, {
  3550. $documentation: "Statement with a label",
  3551. $propdoc: {
  3552. label: "[AST_Label] a label definition"
  3553. },
  3554. _walk: function(visitor) {
  3555. return visitor._visit(this, function() {
  3556. this.label._walk(visitor);
  3557. this.body._walk(visitor);
  3558. });
  3559. },
  3560. _children_backwards(push) {
  3561. push(this.body);
  3562. push(this.label);
  3563. },
  3564. clone: function(deep) {
  3565. var node = this._clone(deep);
  3566. if (deep) {
  3567. var label = node.label;
  3568. var def = this.label;
  3569. node.walk(new TreeWalker(function(node) {
  3570. if (node instanceof AST_LoopControl
  3571. && node.label && node.label.thedef === def) {
  3572. node.label.thedef = label;
  3573. label.references.push(node);
  3574. }
  3575. }));
  3576. }
  3577. return node;
  3578. }
  3579. }, AST_StatementWithBody);
  3580. var AST_IterationStatement = DEFNODE(
  3581. "IterationStatement",
  3582. "block_scope",
  3583. function AST_IterationStatement(props) {
  3584. if (props) {
  3585. this.block_scope = props.block_scope;
  3586. this.body = props.body;
  3587. this.start = props.start;
  3588. this.end = props.end;
  3589. }
  3590. this.flags = 0;
  3591. },
  3592. {
  3593. $documentation: "Internal class. All loops inherit from it.",
  3594. $propdoc: {
  3595. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3596. },
  3597. clone: clone_block_scope
  3598. },
  3599. AST_StatementWithBody
  3600. );
  3601. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  3602. if (props) {
  3603. this.condition = props.condition;
  3604. this.block_scope = props.block_scope;
  3605. this.body = props.body;
  3606. this.start = props.start;
  3607. this.end = props.end;
  3608. }
  3609. this.flags = 0;
  3610. }, {
  3611. $documentation: "Base class for do/while statements",
  3612. $propdoc: {
  3613. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3614. }
  3615. }, AST_IterationStatement);
  3616. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  3617. if (props) {
  3618. this.condition = props.condition;
  3619. this.block_scope = props.block_scope;
  3620. this.body = props.body;
  3621. this.start = props.start;
  3622. this.end = props.end;
  3623. }
  3624. this.flags = 0;
  3625. }, {
  3626. $documentation: "A `do` statement",
  3627. _walk: function(visitor) {
  3628. return visitor._visit(this, function() {
  3629. this.body._walk(visitor);
  3630. this.condition._walk(visitor);
  3631. });
  3632. },
  3633. _children_backwards(push) {
  3634. push(this.condition);
  3635. push(this.body);
  3636. }
  3637. }, AST_DWLoop);
  3638. var AST_While = DEFNODE("While", null, function AST_While(props) {
  3639. if (props) {
  3640. this.condition = props.condition;
  3641. this.block_scope = props.block_scope;
  3642. this.body = props.body;
  3643. this.start = props.start;
  3644. this.end = props.end;
  3645. }
  3646. this.flags = 0;
  3647. }, {
  3648. $documentation: "A `while` statement",
  3649. _walk: function(visitor) {
  3650. return visitor._visit(this, function() {
  3651. this.condition._walk(visitor);
  3652. this.body._walk(visitor);
  3653. });
  3654. },
  3655. _children_backwards(push) {
  3656. push(this.body);
  3657. push(this.condition);
  3658. },
  3659. }, AST_DWLoop);
  3660. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  3661. if (props) {
  3662. this.init = props.init;
  3663. this.condition = props.condition;
  3664. this.step = props.step;
  3665. this.block_scope = props.block_scope;
  3666. this.body = props.body;
  3667. this.start = props.start;
  3668. this.end = props.end;
  3669. }
  3670. this.flags = 0;
  3671. }, {
  3672. $documentation: "A `for` statement",
  3673. $propdoc: {
  3674. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3675. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3676. step: "[AST_Node?] the `for` update clause, or null if empty"
  3677. },
  3678. _walk: function(visitor) {
  3679. return visitor._visit(this, function() {
  3680. if (this.init) this.init._walk(visitor);
  3681. if (this.condition) this.condition._walk(visitor);
  3682. if (this.step) this.step._walk(visitor);
  3683. this.body._walk(visitor);
  3684. });
  3685. },
  3686. _children_backwards(push) {
  3687. push(this.body);
  3688. if (this.step) push(this.step);
  3689. if (this.condition) push(this.condition);
  3690. if (this.init) push(this.init);
  3691. },
  3692. }, AST_IterationStatement);
  3693. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  3694. if (props) {
  3695. this.init = props.init;
  3696. this.object = props.object;
  3697. this.block_scope = props.block_scope;
  3698. this.body = props.body;
  3699. this.start = props.start;
  3700. this.end = props.end;
  3701. }
  3702. this.flags = 0;
  3703. }, {
  3704. $documentation: "A `for ... in` statement",
  3705. $propdoc: {
  3706. init: "[AST_Node] the `for/in` initialization code",
  3707. object: "[AST_Node] the object that we're looping through"
  3708. },
  3709. _walk: function(visitor) {
  3710. return visitor._visit(this, function() {
  3711. this.init._walk(visitor);
  3712. this.object._walk(visitor);
  3713. this.body._walk(visitor);
  3714. });
  3715. },
  3716. _children_backwards(push) {
  3717. push(this.body);
  3718. if (this.object) push(this.object);
  3719. if (this.init) push(this.init);
  3720. },
  3721. }, AST_IterationStatement);
  3722. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  3723. if (props) {
  3724. this.await = props.await;
  3725. this.init = props.init;
  3726. this.object = props.object;
  3727. this.block_scope = props.block_scope;
  3728. this.body = props.body;
  3729. this.start = props.start;
  3730. this.end = props.end;
  3731. }
  3732. this.flags = 0;
  3733. }, {
  3734. $documentation: "A `for ... of` statement",
  3735. }, AST_ForIn);
  3736. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  3737. if (props) {
  3738. this.expression = props.expression;
  3739. this.body = props.body;
  3740. this.start = props.start;
  3741. this.end = props.end;
  3742. }
  3743. this.flags = 0;
  3744. }, {
  3745. $documentation: "A `with` statement",
  3746. $propdoc: {
  3747. expression: "[AST_Node] the `with` expression"
  3748. },
  3749. _walk: function(visitor) {
  3750. return visitor._visit(this, function() {
  3751. this.expression._walk(visitor);
  3752. this.body._walk(visitor);
  3753. });
  3754. },
  3755. _children_backwards(push) {
  3756. push(this.body);
  3757. push(this.expression);
  3758. },
  3759. }, AST_StatementWithBody);
  3760. /* -----[ scope and functions ]----- */
  3761. var AST_Scope = DEFNODE(
  3762. "Scope",
  3763. "variables uses_with uses_eval parent_scope enclosed cname",
  3764. function AST_Scope(props) {
  3765. if (props) {
  3766. this.variables = props.variables;
  3767. this.uses_with = props.uses_with;
  3768. this.uses_eval = props.uses_eval;
  3769. this.parent_scope = props.parent_scope;
  3770. this.enclosed = props.enclosed;
  3771. this.cname = props.cname;
  3772. this.body = props.body;
  3773. this.block_scope = props.block_scope;
  3774. this.start = props.start;
  3775. this.end = props.end;
  3776. }
  3777. this.flags = 0;
  3778. },
  3779. {
  3780. $documentation: "Base class for all statements introducing a lexical scope",
  3781. $propdoc: {
  3782. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3783. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3784. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3785. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3786. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3787. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3788. },
  3789. get_defun_scope: function() {
  3790. var self = this;
  3791. while (self.is_block_scope()) {
  3792. self = self.parent_scope;
  3793. }
  3794. return self;
  3795. },
  3796. clone: function(deep, toplevel) {
  3797. var node = this._clone(deep);
  3798. if (deep && this.variables && toplevel && !this._block_scope) {
  3799. node.figure_out_scope({}, {
  3800. toplevel: toplevel,
  3801. parent_scope: this.parent_scope
  3802. });
  3803. } else {
  3804. if (this.variables) node.variables = new Map(this.variables);
  3805. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3806. if (this._block_scope) node._block_scope = this._block_scope;
  3807. }
  3808. return node;
  3809. },
  3810. pinned: function() {
  3811. return this.uses_eval || this.uses_with;
  3812. }
  3813. },
  3814. AST_Block
  3815. );
  3816. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  3817. if (props) {
  3818. this.globals = props.globals;
  3819. this.variables = props.variables;
  3820. this.uses_with = props.uses_with;
  3821. this.uses_eval = props.uses_eval;
  3822. this.parent_scope = props.parent_scope;
  3823. this.enclosed = props.enclosed;
  3824. this.cname = props.cname;
  3825. this.body = props.body;
  3826. this.block_scope = props.block_scope;
  3827. this.start = props.start;
  3828. this.end = props.end;
  3829. }
  3830. this.flags = 0;
  3831. }, {
  3832. $documentation: "The toplevel scope",
  3833. $propdoc: {
  3834. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3835. },
  3836. wrap_commonjs: function(name) {
  3837. var body = this.body;
  3838. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3839. wrapped_tl = parse(wrapped_tl);
  3840. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3841. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3842. return MAP.splice(body);
  3843. }
  3844. }));
  3845. return wrapped_tl;
  3846. },
  3847. wrap_enclose: function(args_values) {
  3848. if (typeof args_values != "string") args_values = "";
  3849. var index = args_values.indexOf(":");
  3850. if (index < 0) index = args_values.length;
  3851. var body = this.body;
  3852. return parse([
  3853. "(function(",
  3854. args_values.slice(0, index),
  3855. '){"$ORIG"})(',
  3856. args_values.slice(index + 1),
  3857. ")"
  3858. ].join("")).transform(new TreeTransformer(function(node) {
  3859. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3860. return MAP.splice(body);
  3861. }
  3862. }));
  3863. }
  3864. }, AST_Scope);
  3865. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  3866. if (props) {
  3867. this.expression = props.expression;
  3868. this.start = props.start;
  3869. this.end = props.end;
  3870. }
  3871. this.flags = 0;
  3872. }, {
  3873. $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",
  3874. $propdoc: {
  3875. expression: "[AST_Node] the thing to be expanded"
  3876. },
  3877. _walk: function(visitor) {
  3878. return visitor._visit(this, function() {
  3879. this.expression.walk(visitor);
  3880. });
  3881. },
  3882. _children_backwards(push) {
  3883. push(this.expression);
  3884. },
  3885. });
  3886. var AST_Lambda = DEFNODE(
  3887. "Lambda",
  3888. "name argnames uses_arguments is_generator async",
  3889. function AST_Lambda(props) {
  3890. if (props) {
  3891. this.name = props.name;
  3892. this.argnames = props.argnames;
  3893. this.uses_arguments = props.uses_arguments;
  3894. this.is_generator = props.is_generator;
  3895. this.async = props.async;
  3896. this.variables = props.variables;
  3897. this.uses_with = props.uses_with;
  3898. this.uses_eval = props.uses_eval;
  3899. this.parent_scope = props.parent_scope;
  3900. this.enclosed = props.enclosed;
  3901. this.cname = props.cname;
  3902. this.body = props.body;
  3903. this.block_scope = props.block_scope;
  3904. this.start = props.start;
  3905. this.end = props.end;
  3906. }
  3907. this.flags = 0;
  3908. },
  3909. {
  3910. $documentation: "Base class for functions",
  3911. $propdoc: {
  3912. name: "[AST_SymbolDeclaration?] the name of this function",
  3913. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3914. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3915. is_generator: "[boolean] is this a generator method",
  3916. async: "[boolean] is this method async",
  3917. },
  3918. args_as_names: function () {
  3919. var out = [];
  3920. for (var i = 0; i < this.argnames.length; i++) {
  3921. if (this.argnames[i] instanceof AST_Destructuring) {
  3922. out.push(...this.argnames[i].all_symbols());
  3923. } else {
  3924. out.push(this.argnames[i]);
  3925. }
  3926. }
  3927. return out;
  3928. },
  3929. _walk: function(visitor) {
  3930. return visitor._visit(this, function() {
  3931. if (this.name) this.name._walk(visitor);
  3932. var argnames = this.argnames;
  3933. for (var i = 0, len = argnames.length; i < len; i++) {
  3934. argnames[i]._walk(visitor);
  3935. }
  3936. walk_body(this, visitor);
  3937. });
  3938. },
  3939. _children_backwards(push) {
  3940. let i = this.body.length;
  3941. while (i--) push(this.body[i]);
  3942. i = this.argnames.length;
  3943. while (i--) push(this.argnames[i]);
  3944. if (this.name) push(this.name);
  3945. },
  3946. is_braceless() {
  3947. return this.body[0] instanceof AST_Return && this.body[0].value;
  3948. },
  3949. // Default args and expansion don't count, so .argnames.length doesn't cut it
  3950. length_property() {
  3951. let length = 0;
  3952. for (const arg of this.argnames) {
  3953. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  3954. length++;
  3955. }
  3956. }
  3957. return length;
  3958. }
  3959. },
  3960. AST_Scope
  3961. );
  3962. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  3963. if (props) {
  3964. this.name = props.name;
  3965. this.argnames = props.argnames;
  3966. this.uses_arguments = props.uses_arguments;
  3967. this.is_generator = props.is_generator;
  3968. this.async = props.async;
  3969. this.variables = props.variables;
  3970. this.uses_with = props.uses_with;
  3971. this.uses_eval = props.uses_eval;
  3972. this.parent_scope = props.parent_scope;
  3973. this.enclosed = props.enclosed;
  3974. this.cname = props.cname;
  3975. this.body = props.body;
  3976. this.block_scope = props.block_scope;
  3977. this.start = props.start;
  3978. this.end = props.end;
  3979. }
  3980. this.flags = 0;
  3981. }, {
  3982. $documentation: "A setter/getter function. The `name` property is always null."
  3983. }, AST_Lambda);
  3984. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  3985. if (props) {
  3986. this.name = props.name;
  3987. this.argnames = props.argnames;
  3988. this.uses_arguments = props.uses_arguments;
  3989. this.is_generator = props.is_generator;
  3990. this.async = props.async;
  3991. this.variables = props.variables;
  3992. this.uses_with = props.uses_with;
  3993. this.uses_eval = props.uses_eval;
  3994. this.parent_scope = props.parent_scope;
  3995. this.enclosed = props.enclosed;
  3996. this.cname = props.cname;
  3997. this.body = props.body;
  3998. this.block_scope = props.block_scope;
  3999. this.start = props.start;
  4000. this.end = props.end;
  4001. }
  4002. this.flags = 0;
  4003. }, {
  4004. $documentation: "A function expression"
  4005. }, AST_Lambda);
  4006. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  4007. if (props) {
  4008. this.name = props.name;
  4009. this.argnames = props.argnames;
  4010. this.uses_arguments = props.uses_arguments;
  4011. this.is_generator = props.is_generator;
  4012. this.async = props.async;
  4013. this.variables = props.variables;
  4014. this.uses_with = props.uses_with;
  4015. this.uses_eval = props.uses_eval;
  4016. this.parent_scope = props.parent_scope;
  4017. this.enclosed = props.enclosed;
  4018. this.cname = props.cname;
  4019. this.body = props.body;
  4020. this.block_scope = props.block_scope;
  4021. this.start = props.start;
  4022. this.end = props.end;
  4023. }
  4024. this.flags = 0;
  4025. }, {
  4026. $documentation: "An ES6 Arrow function ((a) => b)"
  4027. }, AST_Lambda);
  4028. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  4029. if (props) {
  4030. this.name = props.name;
  4031. this.argnames = props.argnames;
  4032. this.uses_arguments = props.uses_arguments;
  4033. this.is_generator = props.is_generator;
  4034. this.async = props.async;
  4035. this.variables = props.variables;
  4036. this.uses_with = props.uses_with;
  4037. this.uses_eval = props.uses_eval;
  4038. this.parent_scope = props.parent_scope;
  4039. this.enclosed = props.enclosed;
  4040. this.cname = props.cname;
  4041. this.body = props.body;
  4042. this.block_scope = props.block_scope;
  4043. this.start = props.start;
  4044. this.end = props.end;
  4045. }
  4046. this.flags = 0;
  4047. }, {
  4048. $documentation: "A function definition"
  4049. }, AST_Lambda);
  4050. /* -----[ DESTRUCTURING ]----- */
  4051. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  4052. if (props) {
  4053. this.names = props.names;
  4054. this.is_array = props.is_array;
  4055. this.start = props.start;
  4056. this.end = props.end;
  4057. }
  4058. this.flags = 0;
  4059. }, {
  4060. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  4061. $propdoc: {
  4062. "names": "[AST_Node*] Array of properties or elements",
  4063. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  4064. },
  4065. _walk: function(visitor) {
  4066. return visitor._visit(this, function() {
  4067. this.names.forEach(function(name) {
  4068. name._walk(visitor);
  4069. });
  4070. });
  4071. },
  4072. _children_backwards(push) {
  4073. let i = this.names.length;
  4074. while (i--) push(this.names[i]);
  4075. },
  4076. all_symbols: function() {
  4077. var out = [];
  4078. walk(this, node => {
  4079. if (node instanceof AST_SymbolDeclaration) {
  4080. out.push(node);
  4081. }
  4082. if (node instanceof AST_Lambda) {
  4083. return true;
  4084. }
  4085. });
  4086. return out;
  4087. }
  4088. });
  4089. var AST_PrefixedTemplateString = DEFNODE(
  4090. "PrefixedTemplateString",
  4091. "template_string prefix",
  4092. function AST_PrefixedTemplateString(props) {
  4093. if (props) {
  4094. this.template_string = props.template_string;
  4095. this.prefix = props.prefix;
  4096. this.start = props.start;
  4097. this.end = props.end;
  4098. }
  4099. this.flags = 0;
  4100. },
  4101. {
  4102. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  4103. $propdoc: {
  4104. template_string: "[AST_TemplateString] The template string",
  4105. prefix: "[AST_Node] The prefix, which will get called."
  4106. },
  4107. _walk: function(visitor) {
  4108. return visitor._visit(this, function () {
  4109. this.prefix._walk(visitor);
  4110. this.template_string._walk(visitor);
  4111. });
  4112. },
  4113. _children_backwards(push) {
  4114. push(this.template_string);
  4115. push(this.prefix);
  4116. },
  4117. }
  4118. );
  4119. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  4120. if (props) {
  4121. this.segments = props.segments;
  4122. this.start = props.start;
  4123. this.end = props.end;
  4124. }
  4125. this.flags = 0;
  4126. }, {
  4127. $documentation: "A template string literal",
  4128. $propdoc: {
  4129. 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."
  4130. },
  4131. _walk: function(visitor) {
  4132. return visitor._visit(this, function() {
  4133. this.segments.forEach(function(seg) {
  4134. seg._walk(visitor);
  4135. });
  4136. });
  4137. },
  4138. _children_backwards(push) {
  4139. let i = this.segments.length;
  4140. while (i--) push(this.segments[i]);
  4141. }
  4142. });
  4143. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  4144. if (props) {
  4145. this.value = props.value;
  4146. this.raw = props.raw;
  4147. this.start = props.start;
  4148. this.end = props.end;
  4149. }
  4150. this.flags = 0;
  4151. }, {
  4152. $documentation: "A segment of a template string literal",
  4153. $propdoc: {
  4154. value: "Content of the segment",
  4155. raw: "Raw source of the segment",
  4156. }
  4157. });
  4158. /* -----[ JUMPS ]----- */
  4159. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  4160. if (props) {
  4161. this.start = props.start;
  4162. this.end = props.end;
  4163. }
  4164. this.flags = 0;
  4165. }, {
  4166. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  4167. }, AST_Statement);
  4168. /** Base class for “exits” (`return` and `throw`) */
  4169. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  4170. if (props) {
  4171. this.value = props.value;
  4172. this.start = props.start;
  4173. this.end = props.end;
  4174. }
  4175. this.flags = 0;
  4176. }, {
  4177. $documentation: "Base class for “exits” (`return` and `throw`)",
  4178. $propdoc: {
  4179. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  4180. },
  4181. _walk: function(visitor) {
  4182. return visitor._visit(this, this.value && function() {
  4183. this.value._walk(visitor);
  4184. });
  4185. },
  4186. _children_backwards(push) {
  4187. if (this.value) push(this.value);
  4188. },
  4189. }, AST_Jump);
  4190. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  4191. if (props) {
  4192. this.value = props.value;
  4193. this.start = props.start;
  4194. this.end = props.end;
  4195. }
  4196. this.flags = 0;
  4197. }, {
  4198. $documentation: "A `return` statement"
  4199. }, AST_Exit);
  4200. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  4201. if (props) {
  4202. this.value = props.value;
  4203. this.start = props.start;
  4204. this.end = props.end;
  4205. }
  4206. this.flags = 0;
  4207. }, {
  4208. $documentation: "A `throw` statement"
  4209. }, AST_Exit);
  4210. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  4211. if (props) {
  4212. this.label = props.label;
  4213. this.start = props.start;
  4214. this.end = props.end;
  4215. }
  4216. this.flags = 0;
  4217. }, {
  4218. $documentation: "Base class for loop control statements (`break` and `continue`)",
  4219. $propdoc: {
  4220. label: "[AST_LabelRef?] the label, or null if none",
  4221. },
  4222. _walk: function(visitor) {
  4223. return visitor._visit(this, this.label && function() {
  4224. this.label._walk(visitor);
  4225. });
  4226. },
  4227. _children_backwards(push) {
  4228. if (this.label) push(this.label);
  4229. },
  4230. }, AST_Jump);
  4231. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  4232. if (props) {
  4233. this.label = props.label;
  4234. this.start = props.start;
  4235. this.end = props.end;
  4236. }
  4237. this.flags = 0;
  4238. }, {
  4239. $documentation: "A `break` statement"
  4240. }, AST_LoopControl);
  4241. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  4242. if (props) {
  4243. this.label = props.label;
  4244. this.start = props.start;
  4245. this.end = props.end;
  4246. }
  4247. this.flags = 0;
  4248. }, {
  4249. $documentation: "A `continue` statement"
  4250. }, AST_LoopControl);
  4251. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  4252. if (props) {
  4253. this.expression = props.expression;
  4254. this.start = props.start;
  4255. this.end = props.end;
  4256. }
  4257. this.flags = 0;
  4258. }, {
  4259. $documentation: "An `await` statement",
  4260. $propdoc: {
  4261. expression: "[AST_Node] the mandatory expression being awaited",
  4262. },
  4263. _walk: function(visitor) {
  4264. return visitor._visit(this, function() {
  4265. this.expression._walk(visitor);
  4266. });
  4267. },
  4268. _children_backwards(push) {
  4269. push(this.expression);
  4270. },
  4271. });
  4272. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  4273. if (props) {
  4274. this.expression = props.expression;
  4275. this.is_star = props.is_star;
  4276. this.start = props.start;
  4277. this.end = props.end;
  4278. }
  4279. this.flags = 0;
  4280. }, {
  4281. $documentation: "A `yield` statement",
  4282. $propdoc: {
  4283. 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",
  4284. is_star: "[Boolean] Whether this is a yield or yield* statement"
  4285. },
  4286. _walk: function(visitor) {
  4287. return visitor._visit(this, this.expression && function() {
  4288. this.expression._walk(visitor);
  4289. });
  4290. },
  4291. _children_backwards(push) {
  4292. if (this.expression) push(this.expression);
  4293. }
  4294. });
  4295. /* -----[ IF ]----- */
  4296. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  4297. if (props) {
  4298. this.condition = props.condition;
  4299. this.alternative = props.alternative;
  4300. this.body = props.body;
  4301. this.start = props.start;
  4302. this.end = props.end;
  4303. }
  4304. this.flags = 0;
  4305. }, {
  4306. $documentation: "A `if` statement",
  4307. $propdoc: {
  4308. condition: "[AST_Node] the `if` condition",
  4309. alternative: "[AST_Statement?] the `else` part, or null if not present"
  4310. },
  4311. _walk: function(visitor) {
  4312. return visitor._visit(this, function() {
  4313. this.condition._walk(visitor);
  4314. this.body._walk(visitor);
  4315. if (this.alternative) this.alternative._walk(visitor);
  4316. });
  4317. },
  4318. _children_backwards(push) {
  4319. if (this.alternative) {
  4320. push(this.alternative);
  4321. }
  4322. push(this.body);
  4323. push(this.condition);
  4324. }
  4325. }, AST_StatementWithBody);
  4326. /* -----[ SWITCH ]----- */
  4327. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  4328. if (props) {
  4329. this.expression = props.expression;
  4330. this.body = props.body;
  4331. this.block_scope = props.block_scope;
  4332. this.start = props.start;
  4333. this.end = props.end;
  4334. }
  4335. this.flags = 0;
  4336. }, {
  4337. $documentation: "A `switch` statement",
  4338. $propdoc: {
  4339. expression: "[AST_Node] the `switch` “discriminant”"
  4340. },
  4341. _walk: function(visitor) {
  4342. return visitor._visit(this, function() {
  4343. this.expression._walk(visitor);
  4344. walk_body(this, visitor);
  4345. });
  4346. },
  4347. _children_backwards(push) {
  4348. let i = this.body.length;
  4349. while (i--) push(this.body[i]);
  4350. push(this.expression);
  4351. }
  4352. }, AST_Block);
  4353. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  4354. if (props) {
  4355. this.body = props.body;
  4356. this.block_scope = props.block_scope;
  4357. this.start = props.start;
  4358. this.end = props.end;
  4359. }
  4360. this.flags = 0;
  4361. }, {
  4362. $documentation: "Base class for `switch` branches",
  4363. }, AST_Block);
  4364. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  4365. if (props) {
  4366. this.body = props.body;
  4367. this.block_scope = props.block_scope;
  4368. this.start = props.start;
  4369. this.end = props.end;
  4370. }
  4371. this.flags = 0;
  4372. }, {
  4373. $documentation: "A `default` switch branch",
  4374. }, AST_SwitchBranch);
  4375. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  4376. if (props) {
  4377. this.expression = props.expression;
  4378. this.body = props.body;
  4379. this.block_scope = props.block_scope;
  4380. this.start = props.start;
  4381. this.end = props.end;
  4382. }
  4383. this.flags = 0;
  4384. }, {
  4385. $documentation: "A `case` switch branch",
  4386. $propdoc: {
  4387. expression: "[AST_Node] the `case` expression"
  4388. },
  4389. _walk: function(visitor) {
  4390. return visitor._visit(this, function() {
  4391. this.expression._walk(visitor);
  4392. walk_body(this, visitor);
  4393. });
  4394. },
  4395. _children_backwards(push) {
  4396. let i = this.body.length;
  4397. while (i--) push(this.body[i]);
  4398. push(this.expression);
  4399. },
  4400. }, AST_SwitchBranch);
  4401. /* -----[ EXCEPTIONS ]----- */
  4402. var AST_Try = DEFNODE("Try", "body bcatch bfinally", function AST_Try(props) {
  4403. if (props) {
  4404. this.body = props.body;
  4405. this.bcatch = props.bcatch;
  4406. this.bfinally = props.bfinally;
  4407. this.start = props.start;
  4408. this.end = props.end;
  4409. }
  4410. this.flags = 0;
  4411. }, {
  4412. $documentation: "A `try` statement",
  4413. $propdoc: {
  4414. body: "[AST_TryBlock] the try block",
  4415. bcatch: "[AST_Catch?] the catch block, or null if not present",
  4416. bfinally: "[AST_Finally?] the finally block, or null if not present"
  4417. },
  4418. _walk: function(visitor) {
  4419. return visitor._visit(this, function() {
  4420. this.body._walk(visitor);
  4421. if (this.bcatch) this.bcatch._walk(visitor);
  4422. if (this.bfinally) this.bfinally._walk(visitor);
  4423. });
  4424. },
  4425. _children_backwards(push) {
  4426. if (this.bfinally) push(this.bfinally);
  4427. if (this.bcatch) push(this.bcatch);
  4428. push(this.body);
  4429. },
  4430. }, AST_Statement);
  4431. var AST_TryBlock = DEFNODE("TryBlock", null, function AST_TryBlock(props) {
  4432. if (props) {
  4433. this.body = props.body;
  4434. this.block_scope = props.block_scope;
  4435. this.start = props.start;
  4436. this.end = props.end;
  4437. }
  4438. this.flags = 0;
  4439. }, {
  4440. $documentation: "The `try` block of a try statement"
  4441. }, AST_Block);
  4442. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  4443. if (props) {
  4444. this.argname = props.argname;
  4445. this.body = props.body;
  4446. this.block_scope = props.block_scope;
  4447. this.start = props.start;
  4448. this.end = props.end;
  4449. }
  4450. this.flags = 0;
  4451. }, {
  4452. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  4453. $propdoc: {
  4454. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  4455. },
  4456. _walk: function(visitor) {
  4457. return visitor._visit(this, function() {
  4458. if (this.argname) this.argname._walk(visitor);
  4459. walk_body(this, visitor);
  4460. });
  4461. },
  4462. _children_backwards(push) {
  4463. let i = this.body.length;
  4464. while (i--) push(this.body[i]);
  4465. if (this.argname) push(this.argname);
  4466. },
  4467. }, AST_Block);
  4468. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  4469. if (props) {
  4470. this.body = props.body;
  4471. this.block_scope = props.block_scope;
  4472. this.start = props.start;
  4473. this.end = props.end;
  4474. }
  4475. this.flags = 0;
  4476. }, {
  4477. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  4478. }, AST_Block);
  4479. /* -----[ VAR/CONST ]----- */
  4480. var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
  4481. if (props) {
  4482. this.definitions = props.definitions;
  4483. this.start = props.start;
  4484. this.end = props.end;
  4485. }
  4486. this.flags = 0;
  4487. }, {
  4488. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  4489. $propdoc: {
  4490. definitions: "[AST_VarDef*] array of variable definitions"
  4491. },
  4492. _walk: function(visitor) {
  4493. return visitor._visit(this, function() {
  4494. var definitions = this.definitions;
  4495. for (var i = 0, len = definitions.length; i < len; i++) {
  4496. definitions[i]._walk(visitor);
  4497. }
  4498. });
  4499. },
  4500. _children_backwards(push) {
  4501. let i = this.definitions.length;
  4502. while (i--) push(this.definitions[i]);
  4503. },
  4504. }, AST_Statement);
  4505. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  4506. if (props) {
  4507. this.definitions = props.definitions;
  4508. this.start = props.start;
  4509. this.end = props.end;
  4510. }
  4511. this.flags = 0;
  4512. }, {
  4513. $documentation: "A `var` statement"
  4514. }, AST_Definitions);
  4515. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  4516. if (props) {
  4517. this.definitions = props.definitions;
  4518. this.start = props.start;
  4519. this.end = props.end;
  4520. }
  4521. this.flags = 0;
  4522. }, {
  4523. $documentation: "A `let` statement"
  4524. }, AST_Definitions);
  4525. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  4526. if (props) {
  4527. this.definitions = props.definitions;
  4528. this.start = props.start;
  4529. this.end = props.end;
  4530. }
  4531. this.flags = 0;
  4532. }, {
  4533. $documentation: "A `const` statement"
  4534. }, AST_Definitions);
  4535. var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
  4536. if (props) {
  4537. this.name = props.name;
  4538. this.value = props.value;
  4539. this.start = props.start;
  4540. this.end = props.end;
  4541. }
  4542. this.flags = 0;
  4543. }, {
  4544. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  4545. $propdoc: {
  4546. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  4547. value: "[AST_Node?] initializer, or null of there's no initializer"
  4548. },
  4549. _walk: function(visitor) {
  4550. return visitor._visit(this, function() {
  4551. this.name._walk(visitor);
  4552. if (this.value) this.value._walk(visitor);
  4553. });
  4554. },
  4555. _children_backwards(push) {
  4556. if (this.value) push(this.value);
  4557. push(this.name);
  4558. },
  4559. declarations_as_names() {
  4560. if (this.name instanceof AST_SymbolDeclaration) {
  4561. return [this];
  4562. } else {
  4563. return this.name.all_symbols();
  4564. }
  4565. }
  4566. });
  4567. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  4568. if (props) {
  4569. this.foreign_name = props.foreign_name;
  4570. this.name = props.name;
  4571. this.start = props.start;
  4572. this.end = props.end;
  4573. }
  4574. this.flags = 0;
  4575. }, {
  4576. $documentation: "The part of the export/import statement that declare names from a module.",
  4577. $propdoc: {
  4578. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  4579. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  4580. },
  4581. _walk: function (visitor) {
  4582. return visitor._visit(this, function() {
  4583. this.foreign_name._walk(visitor);
  4584. this.name._walk(visitor);
  4585. });
  4586. },
  4587. _children_backwards(push) {
  4588. push(this.name);
  4589. push(this.foreign_name);
  4590. },
  4591. });
  4592. var AST_Import = DEFNODE(
  4593. "Import",
  4594. "imported_name imported_names module_name assert_clause",
  4595. function AST_Import(props) {
  4596. if (props) {
  4597. this.imported_name = props.imported_name;
  4598. this.imported_names = props.imported_names;
  4599. this.module_name = props.module_name;
  4600. this.assert_clause = props.assert_clause;
  4601. this.start = props.start;
  4602. this.end = props.end;
  4603. }
  4604. this.flags = 0;
  4605. },
  4606. {
  4607. $documentation: "An `import` statement",
  4608. $propdoc: {
  4609. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  4610. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  4611. module_name: "[AST_String] String literal describing where this module came from",
  4612. assert_clause: "[AST_Object?] The import assertion"
  4613. },
  4614. _walk: function(visitor) {
  4615. return visitor._visit(this, function() {
  4616. if (this.imported_name) {
  4617. this.imported_name._walk(visitor);
  4618. }
  4619. if (this.imported_names) {
  4620. this.imported_names.forEach(function(name_import) {
  4621. name_import._walk(visitor);
  4622. });
  4623. }
  4624. this.module_name._walk(visitor);
  4625. });
  4626. },
  4627. _children_backwards(push) {
  4628. push(this.module_name);
  4629. if (this.imported_names) {
  4630. let i = this.imported_names.length;
  4631. while (i--) push(this.imported_names[i]);
  4632. }
  4633. if (this.imported_name) push(this.imported_name);
  4634. },
  4635. }
  4636. );
  4637. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  4638. if (props) {
  4639. this.start = props.start;
  4640. this.end = props.end;
  4641. }
  4642. this.flags = 0;
  4643. }, {
  4644. $documentation: "A reference to import.meta",
  4645. });
  4646. var AST_Export = DEFNODE(
  4647. "Export",
  4648. "exported_definition exported_value is_default exported_names module_name assert_clause",
  4649. function AST_Export(props) {
  4650. if (props) {
  4651. this.exported_definition = props.exported_definition;
  4652. this.exported_value = props.exported_value;
  4653. this.is_default = props.is_default;
  4654. this.exported_names = props.exported_names;
  4655. this.module_name = props.module_name;
  4656. this.assert_clause = props.assert_clause;
  4657. this.start = props.start;
  4658. this.end = props.end;
  4659. }
  4660. this.flags = 0;
  4661. },
  4662. {
  4663. $documentation: "An `export` statement",
  4664. $propdoc: {
  4665. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  4666. exported_value: "[AST_Node?] An exported value",
  4667. exported_names: "[AST_NameMapping*?] List of exported names",
  4668. module_name: "[AST_String?] Name of the file to load exports from",
  4669. is_default: "[Boolean] Whether this is the default exported value of this module",
  4670. assert_clause: "[AST_Object?] The import assertion"
  4671. },
  4672. _walk: function (visitor) {
  4673. return visitor._visit(this, function () {
  4674. if (this.exported_definition) {
  4675. this.exported_definition._walk(visitor);
  4676. }
  4677. if (this.exported_value) {
  4678. this.exported_value._walk(visitor);
  4679. }
  4680. if (this.exported_names) {
  4681. this.exported_names.forEach(function(name_export) {
  4682. name_export._walk(visitor);
  4683. });
  4684. }
  4685. if (this.module_name) {
  4686. this.module_name._walk(visitor);
  4687. }
  4688. });
  4689. },
  4690. _children_backwards(push) {
  4691. if (this.module_name) push(this.module_name);
  4692. if (this.exported_names) {
  4693. let i = this.exported_names.length;
  4694. while (i--) push(this.exported_names[i]);
  4695. }
  4696. if (this.exported_value) push(this.exported_value);
  4697. if (this.exported_definition) push(this.exported_definition);
  4698. }
  4699. },
  4700. AST_Statement
  4701. );
  4702. /* -----[ OTHER ]----- */
  4703. var AST_Call = DEFNODE(
  4704. "Call",
  4705. "expression args optional _annotations",
  4706. function AST_Call(props) {
  4707. if (props) {
  4708. this.expression = props.expression;
  4709. this.args = props.args;
  4710. this.optional = props.optional;
  4711. this._annotations = props._annotations;
  4712. this.start = props.start;
  4713. this.end = props.end;
  4714. this.initialize();
  4715. }
  4716. this.flags = 0;
  4717. },
  4718. {
  4719. $documentation: "A function call expression",
  4720. $propdoc: {
  4721. expression: "[AST_Node] expression to invoke as function",
  4722. args: "[AST_Node*] array of arguments",
  4723. optional: "[boolean] whether this is an optional call (IE ?.() )",
  4724. _annotations: "[number] bitfield containing information about the call"
  4725. },
  4726. initialize() {
  4727. if (this._annotations == null) this._annotations = 0;
  4728. },
  4729. _walk(visitor) {
  4730. return visitor._visit(this, function() {
  4731. var args = this.args;
  4732. for (var i = 0, len = args.length; i < len; i++) {
  4733. args[i]._walk(visitor);
  4734. }
  4735. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  4736. });
  4737. },
  4738. _children_backwards(push) {
  4739. let i = this.args.length;
  4740. while (i--) push(this.args[i]);
  4741. push(this.expression);
  4742. },
  4743. }
  4744. );
  4745. var AST_New = DEFNODE("New", null, function AST_New(props) {
  4746. if (props) {
  4747. this.expression = props.expression;
  4748. this.args = props.args;
  4749. this.optional = props.optional;
  4750. this._annotations = props._annotations;
  4751. this.start = props.start;
  4752. this.end = props.end;
  4753. this.initialize();
  4754. }
  4755. this.flags = 0;
  4756. }, {
  4757. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  4758. }, AST_Call);
  4759. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  4760. if (props) {
  4761. this.expressions = props.expressions;
  4762. this.start = props.start;
  4763. this.end = props.end;
  4764. }
  4765. this.flags = 0;
  4766. }, {
  4767. $documentation: "A sequence expression (comma-separated expressions)",
  4768. $propdoc: {
  4769. expressions: "[AST_Node*] array of expressions (at least two)"
  4770. },
  4771. _walk: function(visitor) {
  4772. return visitor._visit(this, function() {
  4773. this.expressions.forEach(function(node) {
  4774. node._walk(visitor);
  4775. });
  4776. });
  4777. },
  4778. _children_backwards(push) {
  4779. let i = this.expressions.length;
  4780. while (i--) push(this.expressions[i]);
  4781. },
  4782. });
  4783. var AST_PropAccess = DEFNODE(
  4784. "PropAccess",
  4785. "expression property optional",
  4786. function AST_PropAccess(props) {
  4787. if (props) {
  4788. this.expression = props.expression;
  4789. this.property = props.property;
  4790. this.optional = props.optional;
  4791. this.start = props.start;
  4792. this.end = props.end;
  4793. }
  4794. this.flags = 0;
  4795. },
  4796. {
  4797. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  4798. $propdoc: {
  4799. expression: "[AST_Node] the “container” expression",
  4800. property: "[AST_Node|string] the property to access. For AST_Dot & AST_DotHash this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
  4801. optional: "[boolean] whether this is an optional property access (IE ?.)"
  4802. }
  4803. }
  4804. );
  4805. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  4806. if (props) {
  4807. this.quote = props.quote;
  4808. this.expression = props.expression;
  4809. this.property = props.property;
  4810. this.optional = props.optional;
  4811. this._annotations = props._annotations;
  4812. this.start = props.start;
  4813. this.end = props.end;
  4814. }
  4815. this.flags = 0;
  4816. }, {
  4817. $documentation: "A dotted property access expression",
  4818. $propdoc: {
  4819. quote: "[string] the original quote character when transformed from AST_Sub",
  4820. },
  4821. _walk: function(visitor) {
  4822. return visitor._visit(this, function() {
  4823. this.expression._walk(visitor);
  4824. });
  4825. },
  4826. _children_backwards(push) {
  4827. push(this.expression);
  4828. },
  4829. }, AST_PropAccess);
  4830. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  4831. if (props) {
  4832. this.expression = props.expression;
  4833. this.property = props.property;
  4834. this.optional = props.optional;
  4835. this.start = props.start;
  4836. this.end = props.end;
  4837. }
  4838. this.flags = 0;
  4839. }, {
  4840. $documentation: "A dotted property access to a private property",
  4841. _walk: function(visitor) {
  4842. return visitor._visit(this, function() {
  4843. this.expression._walk(visitor);
  4844. });
  4845. },
  4846. _children_backwards(push) {
  4847. push(this.expression);
  4848. },
  4849. }, AST_PropAccess);
  4850. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  4851. if (props) {
  4852. this.expression = props.expression;
  4853. this.property = props.property;
  4854. this.optional = props.optional;
  4855. this._annotations = props._annotations;
  4856. this.start = props.start;
  4857. this.end = props.end;
  4858. }
  4859. this.flags = 0;
  4860. }, {
  4861. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4862. _walk: function(visitor) {
  4863. return visitor._visit(this, function() {
  4864. this.expression._walk(visitor);
  4865. this.property._walk(visitor);
  4866. });
  4867. },
  4868. _children_backwards(push) {
  4869. push(this.property);
  4870. push(this.expression);
  4871. },
  4872. }, AST_PropAccess);
  4873. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  4874. if (props) {
  4875. this.expression = props.expression;
  4876. this.start = props.start;
  4877. this.end = props.end;
  4878. }
  4879. this.flags = 0;
  4880. }, {
  4881. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4882. $propdoc: {
  4883. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  4884. },
  4885. _walk: function (visitor) {
  4886. return visitor._visit(this, function() {
  4887. this.expression._walk(visitor);
  4888. });
  4889. },
  4890. _children_backwards(push) {
  4891. push(this.expression);
  4892. },
  4893. });
  4894. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  4895. if (props) {
  4896. this.operator = props.operator;
  4897. this.expression = props.expression;
  4898. this.start = props.start;
  4899. this.end = props.end;
  4900. }
  4901. this.flags = 0;
  4902. }, {
  4903. $documentation: "Base class for unary expressions",
  4904. $propdoc: {
  4905. operator: "[string] the operator",
  4906. expression: "[AST_Node] expression that this unary operator applies to"
  4907. },
  4908. _walk: function(visitor) {
  4909. return visitor._visit(this, function() {
  4910. this.expression._walk(visitor);
  4911. });
  4912. },
  4913. _children_backwards(push) {
  4914. push(this.expression);
  4915. },
  4916. });
  4917. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  4918. if (props) {
  4919. this.operator = props.operator;
  4920. this.expression = props.expression;
  4921. this.start = props.start;
  4922. this.end = props.end;
  4923. }
  4924. this.flags = 0;
  4925. }, {
  4926. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4927. }, AST_Unary);
  4928. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  4929. if (props) {
  4930. this.operator = props.operator;
  4931. this.expression = props.expression;
  4932. this.start = props.start;
  4933. this.end = props.end;
  4934. }
  4935. this.flags = 0;
  4936. }, {
  4937. $documentation: "Unary postfix expression, i.e. `i++`"
  4938. }, AST_Unary);
  4939. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  4940. if (props) {
  4941. this.operator = props.operator;
  4942. this.left = props.left;
  4943. this.right = props.right;
  4944. this.start = props.start;
  4945. this.end = props.end;
  4946. }
  4947. this.flags = 0;
  4948. }, {
  4949. $documentation: "Binary expression, i.e. `a + b`",
  4950. $propdoc: {
  4951. left: "[AST_Node] left-hand side expression",
  4952. operator: "[string] the operator",
  4953. right: "[AST_Node] right-hand side expression"
  4954. },
  4955. _walk: function(visitor) {
  4956. return visitor._visit(this, function() {
  4957. this.left._walk(visitor);
  4958. this.right._walk(visitor);
  4959. });
  4960. },
  4961. _children_backwards(push) {
  4962. push(this.right);
  4963. push(this.left);
  4964. },
  4965. });
  4966. var AST_Conditional = DEFNODE(
  4967. "Conditional",
  4968. "condition consequent alternative",
  4969. function AST_Conditional(props) {
  4970. if (props) {
  4971. this.condition = props.condition;
  4972. this.consequent = props.consequent;
  4973. this.alternative = props.alternative;
  4974. this.start = props.start;
  4975. this.end = props.end;
  4976. }
  4977. this.flags = 0;
  4978. },
  4979. {
  4980. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  4981. $propdoc: {
  4982. condition: "[AST_Node]",
  4983. consequent: "[AST_Node]",
  4984. alternative: "[AST_Node]"
  4985. },
  4986. _walk: function(visitor) {
  4987. return visitor._visit(this, function() {
  4988. this.condition._walk(visitor);
  4989. this.consequent._walk(visitor);
  4990. this.alternative._walk(visitor);
  4991. });
  4992. },
  4993. _children_backwards(push) {
  4994. push(this.alternative);
  4995. push(this.consequent);
  4996. push(this.condition);
  4997. },
  4998. }
  4999. );
  5000. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  5001. if (props) {
  5002. this.logical = props.logical;
  5003. this.operator = props.operator;
  5004. this.left = props.left;
  5005. this.right = props.right;
  5006. this.start = props.start;
  5007. this.end = props.end;
  5008. }
  5009. this.flags = 0;
  5010. }, {
  5011. $documentation: "An assignment expression — `a = b + 5`",
  5012. $propdoc: {
  5013. logical: "Whether it's a logical assignment"
  5014. }
  5015. }, AST_Binary);
  5016. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  5017. if (props) {
  5018. this.operator = props.operator;
  5019. this.left = props.left;
  5020. this.right = props.right;
  5021. this.start = props.start;
  5022. this.end = props.end;
  5023. }
  5024. this.flags = 0;
  5025. }, {
  5026. $documentation: "A default assignment expression like in `(a = 3) => a`"
  5027. }, AST_Binary);
  5028. /* -----[ LITERALS ]----- */
  5029. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  5030. if (props) {
  5031. this.elements = props.elements;
  5032. this.start = props.start;
  5033. this.end = props.end;
  5034. }
  5035. this.flags = 0;
  5036. }, {
  5037. $documentation: "An array literal",
  5038. $propdoc: {
  5039. elements: "[AST_Node*] array of elements"
  5040. },
  5041. _walk: function(visitor) {
  5042. return visitor._visit(this, function() {
  5043. var elements = this.elements;
  5044. for (var i = 0, len = elements.length; i < len; i++) {
  5045. elements[i]._walk(visitor);
  5046. }
  5047. });
  5048. },
  5049. _children_backwards(push) {
  5050. let i = this.elements.length;
  5051. while (i--) push(this.elements[i]);
  5052. },
  5053. });
  5054. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  5055. if (props) {
  5056. this.properties = props.properties;
  5057. this.start = props.start;
  5058. this.end = props.end;
  5059. }
  5060. this.flags = 0;
  5061. }, {
  5062. $documentation: "An object literal",
  5063. $propdoc: {
  5064. properties: "[AST_ObjectProperty*] array of properties"
  5065. },
  5066. _walk: function(visitor) {
  5067. return visitor._visit(this, function() {
  5068. var properties = this.properties;
  5069. for (var i = 0, len = properties.length; i < len; i++) {
  5070. properties[i]._walk(visitor);
  5071. }
  5072. });
  5073. },
  5074. _children_backwards(push) {
  5075. let i = this.properties.length;
  5076. while (i--) push(this.properties[i]);
  5077. },
  5078. });
  5079. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  5080. if (props) {
  5081. this.key = props.key;
  5082. this.value = props.value;
  5083. this.start = props.start;
  5084. this.end = props.end;
  5085. this._annotations = props._annotations;
  5086. }
  5087. this.flags = 0;
  5088. }, {
  5089. $documentation: "Base class for literal object properties",
  5090. $propdoc: {
  5091. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  5092. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  5093. },
  5094. _walk: function(visitor) {
  5095. return visitor._visit(this, function() {
  5096. if (this.key instanceof AST_Node)
  5097. this.key._walk(visitor);
  5098. this.value._walk(visitor);
  5099. });
  5100. },
  5101. _children_backwards(push) {
  5102. push(this.value);
  5103. if (this.key instanceof AST_Node) push(this.key);
  5104. }
  5105. });
  5106. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  5107. if (props) {
  5108. this.quote = props.quote;
  5109. this.key = props.key;
  5110. this.value = props.value;
  5111. this.start = props.start;
  5112. this.end = props.end;
  5113. this._annotations = props._annotations;
  5114. }
  5115. this.flags = 0;
  5116. }, {
  5117. $documentation: "A key: value object property",
  5118. $propdoc: {
  5119. quote: "[string] the original quote character"
  5120. },
  5121. computed_key() {
  5122. return this.key instanceof AST_Node;
  5123. }
  5124. }, AST_ObjectProperty);
  5125. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  5126. if (props) {
  5127. this.static = props.static;
  5128. this.key = props.key;
  5129. this.value = props.value;
  5130. this.start = props.start;
  5131. this.end = props.end;
  5132. }
  5133. this.flags = 0;
  5134. }, {
  5135. $propdoc: {
  5136. static: "[boolean] whether this is a static private setter"
  5137. },
  5138. $documentation: "A private setter property",
  5139. computed_key() {
  5140. return false;
  5141. }
  5142. }, AST_ObjectProperty);
  5143. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
  5144. if (props) {
  5145. this.static = props.static;
  5146. this.key = props.key;
  5147. this.value = props.value;
  5148. this.start = props.start;
  5149. this.end = props.end;
  5150. }
  5151. this.flags = 0;
  5152. }, {
  5153. $propdoc: {
  5154. static: "[boolean] whether this is a static private getter"
  5155. },
  5156. $documentation: "A private getter property",
  5157. computed_key() {
  5158. return false;
  5159. }
  5160. }, AST_ObjectProperty);
  5161. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  5162. if (props) {
  5163. this.quote = props.quote;
  5164. this.static = props.static;
  5165. this.key = props.key;
  5166. this.value = props.value;
  5167. this.start = props.start;
  5168. this.end = props.end;
  5169. this._annotations = props._annotations;
  5170. }
  5171. this.flags = 0;
  5172. }, {
  5173. $propdoc: {
  5174. quote: "[string|undefined] the original quote character, if any",
  5175. static: "[boolean] whether this is a static setter (classes only)"
  5176. },
  5177. $documentation: "An object setter property",
  5178. computed_key() {
  5179. return !(this.key instanceof AST_SymbolMethod);
  5180. }
  5181. }, AST_ObjectProperty);
  5182. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  5183. if (props) {
  5184. this.quote = props.quote;
  5185. this.static = props.static;
  5186. this.key = props.key;
  5187. this.value = props.value;
  5188. this.start = props.start;
  5189. this.end = props.end;
  5190. this._annotations = props._annotations;
  5191. }
  5192. this.flags = 0;
  5193. }, {
  5194. $propdoc: {
  5195. quote: "[string|undefined] the original quote character, if any",
  5196. static: "[boolean] whether this is a static getter (classes only)"
  5197. },
  5198. $documentation: "An object getter property",
  5199. computed_key() {
  5200. return !(this.key instanceof AST_SymbolMethod);
  5201. }
  5202. }, AST_ObjectProperty);
  5203. var AST_ConciseMethod = DEFNODE(
  5204. "ConciseMethod",
  5205. "quote static is_generator async",
  5206. function AST_ConciseMethod(props) {
  5207. if (props) {
  5208. this.quote = props.quote;
  5209. this.static = props.static;
  5210. this.is_generator = props.is_generator;
  5211. this.async = props.async;
  5212. this.key = props.key;
  5213. this.value = props.value;
  5214. this.start = props.start;
  5215. this.end = props.end;
  5216. this._annotations = props._annotations;
  5217. }
  5218. this.flags = 0;
  5219. },
  5220. {
  5221. $propdoc: {
  5222. quote: "[string|undefined] the original quote character, if any",
  5223. static: "[boolean] is this method static (classes only)",
  5224. is_generator: "[boolean] is this a generator method",
  5225. async: "[boolean] is this method async",
  5226. },
  5227. $documentation: "An ES6 concise method inside an object or class",
  5228. computed_key() {
  5229. return !(this.key instanceof AST_SymbolMethod);
  5230. }
  5231. },
  5232. AST_ObjectProperty
  5233. );
  5234. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
  5235. if (props) {
  5236. this.quote = props.quote;
  5237. this.static = props.static;
  5238. this.is_generator = props.is_generator;
  5239. this.async = props.async;
  5240. this.key = props.key;
  5241. this.value = props.value;
  5242. this.start = props.start;
  5243. this.end = props.end;
  5244. }
  5245. this.flags = 0;
  5246. }, {
  5247. $documentation: "A private class method inside a class",
  5248. }, AST_ConciseMethod);
  5249. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  5250. if (props) {
  5251. this.name = props.name;
  5252. this.extends = props.extends;
  5253. this.properties = props.properties;
  5254. this.variables = props.variables;
  5255. this.uses_with = props.uses_with;
  5256. this.uses_eval = props.uses_eval;
  5257. this.parent_scope = props.parent_scope;
  5258. this.enclosed = props.enclosed;
  5259. this.cname = props.cname;
  5260. this.body = props.body;
  5261. this.block_scope = props.block_scope;
  5262. this.start = props.start;
  5263. this.end = props.end;
  5264. }
  5265. this.flags = 0;
  5266. }, {
  5267. $propdoc: {
  5268. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  5269. extends: "[AST_Node]? optional parent class",
  5270. properties: "[AST_ObjectProperty*] array of properties"
  5271. },
  5272. $documentation: "An ES6 class",
  5273. _walk: function(visitor) {
  5274. return visitor._visit(this, function() {
  5275. if (this.name) {
  5276. this.name._walk(visitor);
  5277. }
  5278. if (this.extends) {
  5279. this.extends._walk(visitor);
  5280. }
  5281. this.properties.forEach((prop) => prop._walk(visitor));
  5282. });
  5283. },
  5284. _children_backwards(push) {
  5285. let i = this.properties.length;
  5286. while (i--) push(this.properties[i]);
  5287. if (this.extends) push(this.extends);
  5288. if (this.name) push(this.name);
  5289. },
  5290. /** go through the bits that are executed instantly, not when the class is `new`'d. Doesn't walk the name. */
  5291. visit_nondeferred_class_parts(visitor) {
  5292. if (this.extends) {
  5293. this.extends._walk(visitor);
  5294. }
  5295. this.properties.forEach((prop) => {
  5296. if (prop instanceof AST_ClassStaticBlock) {
  5297. prop._walk(visitor);
  5298. return;
  5299. }
  5300. if (prop.computed_key()) {
  5301. visitor.push(prop);
  5302. prop.key._walk(visitor);
  5303. visitor.pop();
  5304. }
  5305. if ((prop instanceof AST_ClassPrivateProperty || prop instanceof AST_ClassProperty) && prop.static && prop.value) {
  5306. visitor.push(prop);
  5307. prop.value._walk(visitor);
  5308. visitor.pop();
  5309. }
  5310. });
  5311. },
  5312. /** go through the bits that are executed later, when the class is `new`'d or a static method is called */
  5313. visit_deferred_class_parts(visitor) {
  5314. this.properties.forEach((prop) => {
  5315. if (prop instanceof AST_ConciseMethod) {
  5316. prop.walk(visitor);
  5317. } else if (prop instanceof AST_ClassProperty && !prop.static && prop.value) {
  5318. visitor.push(prop);
  5319. prop.value._walk(visitor);
  5320. visitor.pop();
  5321. }
  5322. });
  5323. },
  5324. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  5325. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  5326. if (props) {
  5327. this.static = props.static;
  5328. this.quote = props.quote;
  5329. this.key = props.key;
  5330. this.value = props.value;
  5331. this.start = props.start;
  5332. this.end = props.end;
  5333. this._annotations = props._annotations;
  5334. }
  5335. this.flags = 0;
  5336. }, {
  5337. $documentation: "A class property",
  5338. $propdoc: {
  5339. static: "[boolean] whether this is a static key",
  5340. quote: "[string] which quote is being used"
  5341. },
  5342. _walk: function(visitor) {
  5343. return visitor._visit(this, function() {
  5344. if (this.key instanceof AST_Node)
  5345. this.key._walk(visitor);
  5346. if (this.value instanceof AST_Node)
  5347. this.value._walk(visitor);
  5348. });
  5349. },
  5350. _children_backwards(push) {
  5351. if (this.value instanceof AST_Node) push(this.value);
  5352. if (this.key instanceof AST_Node) push(this.key);
  5353. },
  5354. computed_key() {
  5355. return !(this.key instanceof AST_SymbolClassProperty);
  5356. }
  5357. }, AST_ObjectProperty);
  5358. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  5359. if (props) {
  5360. this.static = props.static;
  5361. this.quote = props.quote;
  5362. this.key = props.key;
  5363. this.value = props.value;
  5364. this.start = props.start;
  5365. this.end = props.end;
  5366. }
  5367. this.flags = 0;
  5368. }, {
  5369. $documentation: "A class property for a private property",
  5370. }, AST_ClassProperty);
  5371. var AST_PrivateIn = DEFNODE("PrivateIn", "key value", function AST_PrivateIn(props) {
  5372. if (props) {
  5373. this.key = props.key;
  5374. this.value = props.value;
  5375. this.start = props.start;
  5376. this.end = props.end;
  5377. }
  5378. this.flags = 0;
  5379. }, {
  5380. $documentation: "An `in` binop when the key is private, eg #x in this",
  5381. _walk: function(visitor) {
  5382. return visitor._visit(this, function() {
  5383. this.key._walk(visitor);
  5384. this.value._walk(visitor);
  5385. });
  5386. },
  5387. _children_backwards(push) {
  5388. push(this.value);
  5389. push(this.key);
  5390. },
  5391. });
  5392. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  5393. if (props) {
  5394. this.name = props.name;
  5395. this.extends = props.extends;
  5396. this.properties = props.properties;
  5397. this.variables = props.variables;
  5398. this.uses_with = props.uses_with;
  5399. this.uses_eval = props.uses_eval;
  5400. this.parent_scope = props.parent_scope;
  5401. this.enclosed = props.enclosed;
  5402. this.cname = props.cname;
  5403. this.body = props.body;
  5404. this.block_scope = props.block_scope;
  5405. this.start = props.start;
  5406. this.end = props.end;
  5407. }
  5408. this.flags = 0;
  5409. }, {
  5410. $documentation: "A class definition",
  5411. }, AST_Class);
  5412. var AST_ClassStaticBlock = DEFNODE("ClassStaticBlock", "body block_scope", function AST_ClassStaticBlock (props) {
  5413. this.body = props.body;
  5414. this.block_scope = props.block_scope;
  5415. this.start = props.start;
  5416. this.end = props.end;
  5417. }, {
  5418. $documentation: "A block containing statements to be executed in the context of the class",
  5419. $propdoc: {
  5420. body: "[AST_Statement*] an array of statements",
  5421. },
  5422. _walk: function(visitor) {
  5423. return visitor._visit(this, function() {
  5424. walk_body(this, visitor);
  5425. });
  5426. },
  5427. _children_backwards(push) {
  5428. let i = this.body.length;
  5429. while (i--) push(this.body[i]);
  5430. },
  5431. clone: clone_block_scope,
  5432. computed_key: () => false
  5433. }, AST_Scope);
  5434. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  5435. if (props) {
  5436. this.name = props.name;
  5437. this.extends = props.extends;
  5438. this.properties = props.properties;
  5439. this.variables = props.variables;
  5440. this.uses_with = props.uses_with;
  5441. this.uses_eval = props.uses_eval;
  5442. this.parent_scope = props.parent_scope;
  5443. this.enclosed = props.enclosed;
  5444. this.cname = props.cname;
  5445. this.body = props.body;
  5446. this.block_scope = props.block_scope;
  5447. this.start = props.start;
  5448. this.end = props.end;
  5449. }
  5450. this.flags = 0;
  5451. }, {
  5452. $documentation: "A class expression."
  5453. }, AST_Class);
  5454. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  5455. if (props) {
  5456. this.scope = props.scope;
  5457. this.name = props.name;
  5458. this.thedef = props.thedef;
  5459. this.start = props.start;
  5460. this.end = props.end;
  5461. }
  5462. this.flags = 0;
  5463. }, {
  5464. $propdoc: {
  5465. name: "[string] name of this symbol",
  5466. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  5467. thedef: "[SymbolDef/S] the definition of this symbol"
  5468. },
  5469. $documentation: "Base class for all symbols"
  5470. });
  5471. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  5472. if (props) {
  5473. this.start = props.start;
  5474. this.end = props.end;
  5475. }
  5476. this.flags = 0;
  5477. }, {
  5478. $documentation: "A reference to new.target"
  5479. });
  5480. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  5481. if (props) {
  5482. this.init = props.init;
  5483. this.scope = props.scope;
  5484. this.name = props.name;
  5485. this.thedef = props.thedef;
  5486. this.start = props.start;
  5487. this.end = props.end;
  5488. }
  5489. this.flags = 0;
  5490. }, {
  5491. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  5492. }, AST_Symbol);
  5493. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
  5494. if (props) {
  5495. this.init = props.init;
  5496. this.scope = props.scope;
  5497. this.name = props.name;
  5498. this.thedef = props.thedef;
  5499. this.start = props.start;
  5500. this.end = props.end;
  5501. }
  5502. this.flags = 0;
  5503. }, {
  5504. $documentation: "Symbol defining a variable",
  5505. }, AST_SymbolDeclaration);
  5506. var AST_SymbolBlockDeclaration = DEFNODE(
  5507. "SymbolBlockDeclaration",
  5508. null,
  5509. function AST_SymbolBlockDeclaration(props) {
  5510. if (props) {
  5511. this.init = props.init;
  5512. this.scope = props.scope;
  5513. this.name = props.name;
  5514. this.thedef = props.thedef;
  5515. this.start = props.start;
  5516. this.end = props.end;
  5517. }
  5518. this.flags = 0;
  5519. },
  5520. {
  5521. $documentation: "Base class for block-scoped declaration symbols"
  5522. },
  5523. AST_SymbolDeclaration
  5524. );
  5525. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  5526. if (props) {
  5527. this.init = props.init;
  5528. this.scope = props.scope;
  5529. this.name = props.name;
  5530. this.thedef = props.thedef;
  5531. this.start = props.start;
  5532. this.end = props.end;
  5533. }
  5534. this.flags = 0;
  5535. }, {
  5536. $documentation: "A constant declaration"
  5537. }, AST_SymbolBlockDeclaration);
  5538. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(props) {
  5539. if (props) {
  5540. this.init = props.init;
  5541. this.scope = props.scope;
  5542. this.name = props.name;
  5543. this.thedef = props.thedef;
  5544. this.start = props.start;
  5545. this.end = props.end;
  5546. }
  5547. this.flags = 0;
  5548. }, {
  5549. $documentation: "A block-scoped `let` declaration"
  5550. }, AST_SymbolBlockDeclaration);
  5551. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
  5552. if (props) {
  5553. this.init = props.init;
  5554. this.scope = props.scope;
  5555. this.name = props.name;
  5556. this.thedef = props.thedef;
  5557. this.start = props.start;
  5558. this.end = props.end;
  5559. }
  5560. this.flags = 0;
  5561. }, {
  5562. $documentation: "Symbol naming a function argument",
  5563. }, AST_SymbolVar);
  5564. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
  5565. if (props) {
  5566. this.init = props.init;
  5567. this.scope = props.scope;
  5568. this.name = props.name;
  5569. this.thedef = props.thedef;
  5570. this.start = props.start;
  5571. this.end = props.end;
  5572. }
  5573. this.flags = 0;
  5574. }, {
  5575. $documentation: "Symbol defining a function",
  5576. }, AST_SymbolDeclaration);
  5577. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  5578. if (props) {
  5579. this.scope = props.scope;
  5580. this.name = props.name;
  5581. this.thedef = props.thedef;
  5582. this.start = props.start;
  5583. this.end = props.end;
  5584. }
  5585. this.flags = 0;
  5586. }, {
  5587. $documentation: "Symbol in an object defining a method",
  5588. }, AST_Symbol);
  5589. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  5590. if (props) {
  5591. this.scope = props.scope;
  5592. this.name = props.name;
  5593. this.thedef = props.thedef;
  5594. this.start = props.start;
  5595. this.end = props.end;
  5596. }
  5597. this.flags = 0;
  5598. }, {
  5599. $documentation: "Symbol for a class property",
  5600. }, AST_Symbol);
  5601. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  5602. if (props) {
  5603. this.init = props.init;
  5604. this.scope = props.scope;
  5605. this.name = props.name;
  5606. this.thedef = props.thedef;
  5607. this.start = props.start;
  5608. this.end = props.end;
  5609. }
  5610. this.flags = 0;
  5611. }, {
  5612. $documentation: "Symbol naming a function expression",
  5613. }, AST_SymbolDeclaration);
  5614. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
  5615. if (props) {
  5616. this.init = props.init;
  5617. this.scope = props.scope;
  5618. this.name = props.name;
  5619. this.thedef = props.thedef;
  5620. this.start = props.start;
  5621. this.end = props.end;
  5622. }
  5623. this.flags = 0;
  5624. }, {
  5625. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  5626. }, AST_SymbolBlockDeclaration);
  5627. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
  5628. if (props) {
  5629. this.init = props.init;
  5630. this.scope = props.scope;
  5631. this.name = props.name;
  5632. this.thedef = props.thedef;
  5633. this.start = props.start;
  5634. this.end = props.end;
  5635. }
  5636. this.flags = 0;
  5637. }, {
  5638. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  5639. }, AST_SymbolDeclaration);
  5640. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
  5641. if (props) {
  5642. this.init = props.init;
  5643. this.scope = props.scope;
  5644. this.name = props.name;
  5645. this.thedef = props.thedef;
  5646. this.start = props.start;
  5647. this.end = props.end;
  5648. }
  5649. this.flags = 0;
  5650. }, {
  5651. $documentation: "Symbol naming the exception in catch",
  5652. }, AST_SymbolBlockDeclaration);
  5653. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
  5654. if (props) {
  5655. this.init = props.init;
  5656. this.scope = props.scope;
  5657. this.name = props.name;
  5658. this.thedef = props.thedef;
  5659. this.start = props.start;
  5660. this.end = props.end;
  5661. }
  5662. this.flags = 0;
  5663. }, {
  5664. $documentation: "Symbol referring to an imported name",
  5665. }, AST_SymbolBlockDeclaration);
  5666. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
  5667. if (props) {
  5668. this.scope = props.scope;
  5669. this.name = props.name;
  5670. this.thedef = props.thedef;
  5671. this.quote = props.quote;
  5672. this.start = props.start;
  5673. this.end = props.end;
  5674. }
  5675. this.flags = 0;
  5676. }, {
  5677. $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",
  5678. }, AST_Symbol);
  5679. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  5680. if (props) {
  5681. this.references = props.references;
  5682. this.scope = props.scope;
  5683. this.name = props.name;
  5684. this.thedef = props.thedef;
  5685. this.start = props.start;
  5686. this.end = props.end;
  5687. this.initialize();
  5688. }
  5689. this.flags = 0;
  5690. }, {
  5691. $documentation: "Symbol naming a label (declaration)",
  5692. $propdoc: {
  5693. references: "[AST_LoopControl*] a list of nodes referring to this label"
  5694. },
  5695. initialize: function() {
  5696. this.references = [];
  5697. this.thedef = this;
  5698. }
  5699. }, AST_Symbol);
  5700. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  5701. if (props) {
  5702. this.scope = props.scope;
  5703. this.name = props.name;
  5704. this.thedef = props.thedef;
  5705. this.start = props.start;
  5706. this.end = props.end;
  5707. }
  5708. this.flags = 0;
  5709. }, {
  5710. $documentation: "Reference to some symbol (not definition/declaration)",
  5711. }, AST_Symbol);
  5712. var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
  5713. if (props) {
  5714. this.scope = props.scope;
  5715. this.name = props.name;
  5716. this.thedef = props.thedef;
  5717. this.quote = props.quote;
  5718. this.start = props.start;
  5719. this.end = props.end;
  5720. }
  5721. this.flags = 0;
  5722. }, {
  5723. $documentation: "Symbol referring to a name to export",
  5724. }, AST_SymbolRef);
  5725. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
  5726. if (props) {
  5727. this.scope = props.scope;
  5728. this.name = props.name;
  5729. this.thedef = props.thedef;
  5730. this.quote = props.quote;
  5731. this.start = props.start;
  5732. this.end = props.end;
  5733. }
  5734. this.flags = 0;
  5735. }, {
  5736. $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",
  5737. }, AST_Symbol);
  5738. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  5739. if (props) {
  5740. this.scope = props.scope;
  5741. this.name = props.name;
  5742. this.thedef = props.thedef;
  5743. this.start = props.start;
  5744. this.end = props.end;
  5745. }
  5746. this.flags = 0;
  5747. }, {
  5748. $documentation: "Reference to a label symbol",
  5749. }, AST_Symbol);
  5750. var AST_SymbolPrivateProperty = DEFNODE("SymbolPrivateProperty", null, function AST_SymbolPrivateProperty(props) {
  5751. if (props) {
  5752. this.scope = props.scope;
  5753. this.name = props.name;
  5754. this.thedef = props.thedef;
  5755. this.start = props.start;
  5756. this.end = props.end;
  5757. }
  5758. this.flags = 0;
  5759. }, {
  5760. $documentation: "A symbol that refers to a private property",
  5761. }, AST_Symbol);
  5762. var AST_This = DEFNODE("This", null, function AST_This(props) {
  5763. if (props) {
  5764. this.scope = props.scope;
  5765. this.name = props.name;
  5766. this.thedef = props.thedef;
  5767. this.start = props.start;
  5768. this.end = props.end;
  5769. }
  5770. this.flags = 0;
  5771. }, {
  5772. $documentation: "The `this` symbol",
  5773. }, AST_Symbol);
  5774. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  5775. if (props) {
  5776. this.scope = props.scope;
  5777. this.name = props.name;
  5778. this.thedef = props.thedef;
  5779. this.start = props.start;
  5780. this.end = props.end;
  5781. }
  5782. this.flags = 0;
  5783. }, {
  5784. $documentation: "The `super` symbol",
  5785. }, AST_This);
  5786. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  5787. if (props) {
  5788. this.start = props.start;
  5789. this.end = props.end;
  5790. }
  5791. this.flags = 0;
  5792. }, {
  5793. $documentation: "Base class for all constants",
  5794. getValue: function() {
  5795. return this.value;
  5796. }
  5797. });
  5798. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  5799. if (props) {
  5800. this.value = props.value;
  5801. this.quote = props.quote;
  5802. this.start = props.start;
  5803. this.end = props.end;
  5804. this._annotations = props._annotations;
  5805. }
  5806. this.flags = 0;
  5807. }, {
  5808. $documentation: "A string literal",
  5809. $propdoc: {
  5810. value: "[string] the contents of this string",
  5811. quote: "[string] the original quote character"
  5812. }
  5813. }, AST_Constant);
  5814. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  5815. if (props) {
  5816. this.value = props.value;
  5817. this.raw = props.raw;
  5818. this.start = props.start;
  5819. this.end = props.end;
  5820. }
  5821. this.flags = 0;
  5822. }, {
  5823. $documentation: "A number literal",
  5824. $propdoc: {
  5825. value: "[number] the numeric value",
  5826. raw: "[string] numeric value as string"
  5827. }
  5828. }, AST_Constant);
  5829. var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
  5830. if (props) {
  5831. this.value = props.value;
  5832. this.start = props.start;
  5833. this.end = props.end;
  5834. }
  5835. this.flags = 0;
  5836. }, {
  5837. $documentation: "A big int literal",
  5838. $propdoc: {
  5839. value: "[string] big int value"
  5840. }
  5841. }, AST_Constant);
  5842. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  5843. if (props) {
  5844. this.value = props.value;
  5845. this.start = props.start;
  5846. this.end = props.end;
  5847. }
  5848. this.flags = 0;
  5849. }, {
  5850. $documentation: "A regexp literal",
  5851. $propdoc: {
  5852. value: "[RegExp] the actual regexp",
  5853. }
  5854. }, AST_Constant);
  5855. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  5856. if (props) {
  5857. this.start = props.start;
  5858. this.end = props.end;
  5859. }
  5860. this.flags = 0;
  5861. }, {
  5862. $documentation: "Base class for atoms",
  5863. }, AST_Constant);
  5864. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  5865. if (props) {
  5866. this.start = props.start;
  5867. this.end = props.end;
  5868. }
  5869. this.flags = 0;
  5870. }, {
  5871. $documentation: "The `null` atom",
  5872. value: null
  5873. }, AST_Atom);
  5874. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  5875. if (props) {
  5876. this.start = props.start;
  5877. this.end = props.end;
  5878. }
  5879. this.flags = 0;
  5880. }, {
  5881. $documentation: "The impossible value",
  5882. value: 0/0
  5883. }, AST_Atom);
  5884. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  5885. if (props) {
  5886. this.start = props.start;
  5887. this.end = props.end;
  5888. }
  5889. this.flags = 0;
  5890. }, {
  5891. $documentation: "The `undefined` value",
  5892. value: (function() {}())
  5893. }, AST_Atom);
  5894. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  5895. if (props) {
  5896. this.start = props.start;
  5897. this.end = props.end;
  5898. }
  5899. this.flags = 0;
  5900. }, {
  5901. $documentation: "A hole in an array",
  5902. value: (function() {}())
  5903. }, AST_Atom);
  5904. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  5905. if (props) {
  5906. this.start = props.start;
  5907. this.end = props.end;
  5908. }
  5909. this.flags = 0;
  5910. }, {
  5911. $documentation: "The `Infinity` value",
  5912. value: 1/0
  5913. }, AST_Atom);
  5914. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  5915. if (props) {
  5916. this.start = props.start;
  5917. this.end = props.end;
  5918. }
  5919. this.flags = 0;
  5920. }, {
  5921. $documentation: "Base class for booleans",
  5922. }, AST_Atom);
  5923. var AST_False = DEFNODE("False", null, function AST_False(props) {
  5924. if (props) {
  5925. this.start = props.start;
  5926. this.end = props.end;
  5927. }
  5928. this.flags = 0;
  5929. }, {
  5930. $documentation: "The `false` atom",
  5931. value: false
  5932. }, AST_Boolean);
  5933. var AST_True = DEFNODE("True", null, function AST_True(props) {
  5934. if (props) {
  5935. this.start = props.start;
  5936. this.end = props.end;
  5937. }
  5938. this.flags = 0;
  5939. }, {
  5940. $documentation: "The `true` atom",
  5941. value: true
  5942. }, AST_Boolean);
  5943. /* -----[ Walk function ]---- */
  5944. /**
  5945. * Walk nodes in depth-first search fashion.
  5946. * Callback can return `walk_abort` symbol to stop iteration.
  5947. * It can also return `true` to stop iteration just for child nodes.
  5948. * Iteration can be stopped and continued by passing the `to_visit` argument,
  5949. * which is given to the callback in the second argument.
  5950. **/
  5951. function walk(node, cb, to_visit = [node]) {
  5952. const push = to_visit.push.bind(to_visit);
  5953. while (to_visit.length) {
  5954. const node = to_visit.pop();
  5955. const ret = cb(node, to_visit);
  5956. if (ret) {
  5957. if (ret === walk_abort) return true;
  5958. continue;
  5959. }
  5960. node._children_backwards(push);
  5961. }
  5962. return false;
  5963. }
  5964. /**
  5965. * Walks an AST node and its children.
  5966. *
  5967. * {cb} can return `walk_abort` to interrupt the walk.
  5968. *
  5969. * @param node
  5970. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  5971. *
  5972. * @returns {boolean} whether the walk was aborted
  5973. *
  5974. * @example
  5975. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  5976. * if (some_cond(node, parent())) return walk_abort
  5977. * });
  5978. */
  5979. function walk_parent(node, cb, initial_stack) {
  5980. const to_visit = [node];
  5981. const push = to_visit.push.bind(to_visit);
  5982. const stack = initial_stack ? initial_stack.slice() : [];
  5983. const parent_pop_indices = [];
  5984. let current;
  5985. const info = {
  5986. parent: (n = 0) => {
  5987. if (n === -1) {
  5988. return current;
  5989. }
  5990. // [ p1 p0 ] [ 1 0 ]
  5991. if (initial_stack && n >= stack.length) {
  5992. n -= stack.length;
  5993. return initial_stack[
  5994. initial_stack.length - (n + 1)
  5995. ];
  5996. }
  5997. return stack[stack.length - (1 + n)];
  5998. },
  5999. };
  6000. while (to_visit.length) {
  6001. current = to_visit.pop();
  6002. while (
  6003. parent_pop_indices.length &&
  6004. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  6005. ) {
  6006. stack.pop();
  6007. parent_pop_indices.pop();
  6008. }
  6009. const ret = cb(current, info);
  6010. if (ret) {
  6011. if (ret === walk_abort) return true;
  6012. continue;
  6013. }
  6014. const visit_length = to_visit.length;
  6015. current._children_backwards(push);
  6016. // Push only if we're going to traverse the children
  6017. if (to_visit.length > visit_length) {
  6018. stack.push(current);
  6019. parent_pop_indices.push(visit_length - 1);
  6020. }
  6021. }
  6022. return false;
  6023. }
  6024. const walk_abort = Symbol("abort walk");
  6025. /* -----[ TreeWalker ]----- */
  6026. class TreeWalker {
  6027. constructor(callback) {
  6028. this.visit = callback;
  6029. this.stack = [];
  6030. this.directives = Object.create(null);
  6031. }
  6032. _visit(node, descend) {
  6033. this.push(node);
  6034. var ret = this.visit(node, descend ? function() {
  6035. descend.call(node);
  6036. } : noop);
  6037. if (!ret && descend) {
  6038. descend.call(node);
  6039. }
  6040. this.pop();
  6041. return ret;
  6042. }
  6043. parent(n) {
  6044. return this.stack[this.stack.length - 2 - (n || 0)];
  6045. }
  6046. push(node) {
  6047. if (node instanceof AST_Lambda) {
  6048. this.directives = Object.create(this.directives);
  6049. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  6050. this.directives[node.value] = node;
  6051. } else if (node instanceof AST_Class) {
  6052. this.directives = Object.create(this.directives);
  6053. if (!this.directives["use strict"]) {
  6054. this.directives["use strict"] = node;
  6055. }
  6056. }
  6057. this.stack.push(node);
  6058. }
  6059. pop() {
  6060. var node = this.stack.pop();
  6061. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  6062. this.directives = Object.getPrototypeOf(this.directives);
  6063. }
  6064. }
  6065. self() {
  6066. return this.stack[this.stack.length - 1];
  6067. }
  6068. find_parent(type) {
  6069. var stack = this.stack;
  6070. for (var i = stack.length; --i >= 0;) {
  6071. var x = stack[i];
  6072. if (x instanceof type) return x;
  6073. }
  6074. }
  6075. find_scope() {
  6076. var stack = this.stack;
  6077. for (var i = stack.length; --i >= 0;) {
  6078. const p = stack[i];
  6079. if (p instanceof AST_Toplevel) return p;
  6080. if (p instanceof AST_Lambda) return p;
  6081. if (p.block_scope) return p.block_scope;
  6082. }
  6083. }
  6084. has_directive(type) {
  6085. var dir = this.directives[type];
  6086. if (dir) return dir;
  6087. var node = this.stack[this.stack.length - 1];
  6088. if (node instanceof AST_Scope && node.body) {
  6089. for (var i = 0; i < node.body.length; ++i) {
  6090. var st = node.body[i];
  6091. if (!(st instanceof AST_Directive)) break;
  6092. if (st.value == type) return st;
  6093. }
  6094. }
  6095. }
  6096. loopcontrol_target(node) {
  6097. var stack = this.stack;
  6098. if (node.label) for (var i = stack.length; --i >= 0;) {
  6099. var x = stack[i];
  6100. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  6101. return x.body;
  6102. } else for (var i = stack.length; --i >= 0;) {
  6103. var x = stack[i];
  6104. if (x instanceof AST_IterationStatement
  6105. || node instanceof AST_Break && x instanceof AST_Switch)
  6106. return x;
  6107. }
  6108. }
  6109. }
  6110. // Tree transformer helpers.
  6111. class TreeTransformer extends TreeWalker {
  6112. constructor(before, after) {
  6113. super();
  6114. this.before = before;
  6115. this.after = after;
  6116. }
  6117. }
  6118. const _PURE = 0b00000001;
  6119. const _INLINE = 0b00000010;
  6120. const _NOINLINE = 0b00000100;
  6121. const _KEY = 0b00001000;
  6122. const _MANGLEPROP = 0b00010000;
  6123. /***********************************************************************
  6124. A JavaScript tokenizer / parser / beautifier / compressor.
  6125. https://github.com/mishoo/UglifyJS2
  6126. -------------------------------- (C) ---------------------------------
  6127. Author: Mihai Bazon
  6128. <mihai.bazon@gmail.com>
  6129. http://mihai.bazon.net/blog
  6130. Distributed under the BSD license:
  6131. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6132. Redistribution and use in source and binary forms, with or without
  6133. modification, are permitted provided that the following conditions
  6134. are met:
  6135. * Redistributions of source code must retain the above
  6136. copyright notice, this list of conditions and the following
  6137. disclaimer.
  6138. * Redistributions in binary form must reproduce the above
  6139. copyright notice, this list of conditions and the following
  6140. disclaimer in the documentation and/or other materials
  6141. provided with the distribution.
  6142. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6143. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6144. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6145. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6146. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6147. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6148. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6149. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6150. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6151. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6152. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6153. SUCH DAMAGE.
  6154. ***********************************************************************/
  6155. function def_transform(node, descend) {
  6156. node.DEFMETHOD("transform", function(tw, in_list) {
  6157. let transformed = undefined;
  6158. tw.push(this);
  6159. if (tw.before) transformed = tw.before(this, descend, in_list);
  6160. if (transformed === undefined) {
  6161. transformed = this;
  6162. descend(transformed, tw);
  6163. if (tw.after) {
  6164. const after_ret = tw.after(transformed, in_list);
  6165. if (after_ret !== undefined) transformed = after_ret;
  6166. }
  6167. }
  6168. tw.pop();
  6169. return transformed;
  6170. });
  6171. }
  6172. def_transform(AST_Node, noop);
  6173. def_transform(AST_LabeledStatement, function(self, tw) {
  6174. self.label = self.label.transform(tw);
  6175. self.body = self.body.transform(tw);
  6176. });
  6177. def_transform(AST_SimpleStatement, function(self, tw) {
  6178. self.body = self.body.transform(tw);
  6179. });
  6180. def_transform(AST_Block, function(self, tw) {
  6181. self.body = MAP(self.body, tw);
  6182. });
  6183. def_transform(AST_Do, function(self, tw) {
  6184. self.body = self.body.transform(tw);
  6185. self.condition = self.condition.transform(tw);
  6186. });
  6187. def_transform(AST_While, function(self, tw) {
  6188. self.condition = self.condition.transform(tw);
  6189. self.body = self.body.transform(tw);
  6190. });
  6191. def_transform(AST_For, function(self, tw) {
  6192. if (self.init) self.init = self.init.transform(tw);
  6193. if (self.condition) self.condition = self.condition.transform(tw);
  6194. if (self.step) self.step = self.step.transform(tw);
  6195. self.body = self.body.transform(tw);
  6196. });
  6197. def_transform(AST_ForIn, function(self, tw) {
  6198. self.init = self.init.transform(tw);
  6199. self.object = self.object.transform(tw);
  6200. self.body = self.body.transform(tw);
  6201. });
  6202. def_transform(AST_With, function(self, tw) {
  6203. self.expression = self.expression.transform(tw);
  6204. self.body = self.body.transform(tw);
  6205. });
  6206. def_transform(AST_Exit, function(self, tw) {
  6207. if (self.value) self.value = self.value.transform(tw);
  6208. });
  6209. def_transform(AST_LoopControl, function(self, tw) {
  6210. if (self.label) self.label = self.label.transform(tw);
  6211. });
  6212. def_transform(AST_If, function(self, tw) {
  6213. self.condition = self.condition.transform(tw);
  6214. self.body = self.body.transform(tw);
  6215. if (self.alternative) self.alternative = self.alternative.transform(tw);
  6216. });
  6217. def_transform(AST_Switch, function(self, tw) {
  6218. self.expression = self.expression.transform(tw);
  6219. self.body = MAP(self.body, tw);
  6220. });
  6221. def_transform(AST_Case, function(self, tw) {
  6222. self.expression = self.expression.transform(tw);
  6223. self.body = MAP(self.body, tw);
  6224. });
  6225. def_transform(AST_Try, function(self, tw) {
  6226. self.body = self.body.transform(tw);
  6227. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  6228. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  6229. });
  6230. def_transform(AST_Catch, function(self, tw) {
  6231. if (self.argname) self.argname = self.argname.transform(tw);
  6232. self.body = MAP(self.body, tw);
  6233. });
  6234. def_transform(AST_Definitions, function(self, tw) {
  6235. self.definitions = MAP(self.definitions, tw);
  6236. });
  6237. def_transform(AST_VarDef, function(self, tw) {
  6238. self.name = self.name.transform(tw);
  6239. if (self.value) self.value = self.value.transform(tw);
  6240. });
  6241. def_transform(AST_Destructuring, function(self, tw) {
  6242. self.names = MAP(self.names, tw);
  6243. });
  6244. def_transform(AST_Lambda, function(self, tw) {
  6245. if (self.name) self.name = self.name.transform(tw);
  6246. self.argnames = MAP(self.argnames, tw, /* allow_splicing */ false);
  6247. if (self.body instanceof AST_Node) {
  6248. self.body = self.body.transform(tw);
  6249. } else {
  6250. self.body = MAP(self.body, tw);
  6251. }
  6252. });
  6253. def_transform(AST_Call, function(self, tw) {
  6254. self.expression = self.expression.transform(tw);
  6255. self.args = MAP(self.args, tw, /* allow_splicing */ false);
  6256. });
  6257. def_transform(AST_Sequence, function(self, tw) {
  6258. const result = MAP(self.expressions, tw);
  6259. self.expressions = result.length
  6260. ? result
  6261. : [new AST_Number({ value: 0 })];
  6262. });
  6263. def_transform(AST_PropAccess, function(self, tw) {
  6264. self.expression = self.expression.transform(tw);
  6265. });
  6266. def_transform(AST_Sub, function(self, tw) {
  6267. self.expression = self.expression.transform(tw);
  6268. self.property = self.property.transform(tw);
  6269. });
  6270. def_transform(AST_Chain, function(self, tw) {
  6271. self.expression = self.expression.transform(tw);
  6272. });
  6273. def_transform(AST_Yield, function(self, tw) {
  6274. if (self.expression) self.expression = self.expression.transform(tw);
  6275. });
  6276. def_transform(AST_Await, function(self, tw) {
  6277. self.expression = self.expression.transform(tw);
  6278. });
  6279. def_transform(AST_Unary, function(self, tw) {
  6280. self.expression = self.expression.transform(tw);
  6281. });
  6282. def_transform(AST_Binary, function(self, tw) {
  6283. self.left = self.left.transform(tw);
  6284. self.right = self.right.transform(tw);
  6285. });
  6286. def_transform(AST_PrivateIn, function(self, tw) {
  6287. self.key = self.key.transform(tw);
  6288. self.value = self.value.transform(tw);
  6289. });
  6290. def_transform(AST_Conditional, function(self, tw) {
  6291. self.condition = self.condition.transform(tw);
  6292. self.consequent = self.consequent.transform(tw);
  6293. self.alternative = self.alternative.transform(tw);
  6294. });
  6295. def_transform(AST_Array, function(self, tw) {
  6296. self.elements = MAP(self.elements, tw);
  6297. });
  6298. def_transform(AST_Object, function(self, tw) {
  6299. self.properties = MAP(self.properties, tw);
  6300. });
  6301. def_transform(AST_ObjectProperty, function(self, tw) {
  6302. if (self.key instanceof AST_Node) {
  6303. self.key = self.key.transform(tw);
  6304. }
  6305. if (self.value) self.value = self.value.transform(tw);
  6306. });
  6307. def_transform(AST_Class, function(self, tw) {
  6308. if (self.name) self.name = self.name.transform(tw);
  6309. if (self.extends) self.extends = self.extends.transform(tw);
  6310. self.properties = MAP(self.properties, tw);
  6311. });
  6312. def_transform(AST_ClassStaticBlock, function(self, tw) {
  6313. self.body = MAP(self.body, tw);
  6314. });
  6315. def_transform(AST_Expansion, function(self, tw) {
  6316. self.expression = self.expression.transform(tw);
  6317. });
  6318. def_transform(AST_NameMapping, function(self, tw) {
  6319. self.foreign_name = self.foreign_name.transform(tw);
  6320. self.name = self.name.transform(tw);
  6321. });
  6322. def_transform(AST_Import, function(self, tw) {
  6323. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  6324. if (self.imported_names) MAP(self.imported_names, tw);
  6325. self.module_name = self.module_name.transform(tw);
  6326. });
  6327. def_transform(AST_Export, function(self, tw) {
  6328. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  6329. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  6330. if (self.exported_names) MAP(self.exported_names, tw);
  6331. if (self.module_name) self.module_name = self.module_name.transform(tw);
  6332. });
  6333. def_transform(AST_TemplateString, function(self, tw) {
  6334. self.segments = MAP(self.segments, tw);
  6335. });
  6336. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  6337. self.prefix = self.prefix.transform(tw);
  6338. self.template_string = self.template_string.transform(tw);
  6339. });
  6340. /***********************************************************************
  6341. A JavaScript tokenizer / parser / beautifier / compressor.
  6342. https://github.com/mishoo/UglifyJS2
  6343. -------------------------------- (C) ---------------------------------
  6344. Author: Mihai Bazon
  6345. <mihai.bazon@gmail.com>
  6346. http://mihai.bazon.net/blog
  6347. Distributed under the BSD license:
  6348. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6349. Redistribution and use in source and binary forms, with or without
  6350. modification, are permitted provided that the following conditions
  6351. are met:
  6352. * Redistributions of source code must retain the above
  6353. copyright notice, this list of conditions and the following
  6354. disclaimer.
  6355. * Redistributions in binary form must reproduce the above
  6356. copyright notice, this list of conditions and the following
  6357. disclaimer in the documentation and/or other materials
  6358. provided with the distribution.
  6359. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6360. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6361. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6362. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6363. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6364. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6365. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6366. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6367. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6368. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6369. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6370. SUCH DAMAGE.
  6371. ***********************************************************************/
  6372. (function() {
  6373. var normalize_directives = function(body) {
  6374. var in_directive = true;
  6375. for (var i = 0; i < body.length; i++) {
  6376. if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  6377. body[i] = new AST_Directive({
  6378. start: body[i].start,
  6379. end: body[i].end,
  6380. value: body[i].body.value
  6381. });
  6382. } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
  6383. in_directive = false;
  6384. }
  6385. }
  6386. return body;
  6387. };
  6388. const assert_clause_from_moz = (assertions) => {
  6389. if (assertions && assertions.length > 0) {
  6390. return new AST_Object({
  6391. start: my_start_token(assertions),
  6392. end: my_end_token(assertions),
  6393. properties: assertions.map((assertion_kv) =>
  6394. new AST_ObjectKeyVal({
  6395. start: my_start_token(assertion_kv),
  6396. end: my_end_token(assertion_kv),
  6397. key: assertion_kv.key.name || assertion_kv.key.value,
  6398. value: from_moz(assertion_kv.value)
  6399. })
  6400. )
  6401. });
  6402. }
  6403. return null;
  6404. };
  6405. var MOZ_TO_ME = {
  6406. Program: function(M) {
  6407. return new AST_Toplevel({
  6408. start: my_start_token(M),
  6409. end: my_end_token(M),
  6410. body: normalize_directives(M.body.map(from_moz))
  6411. });
  6412. },
  6413. ArrayPattern: function(M) {
  6414. return new AST_Destructuring({
  6415. start: my_start_token(M),
  6416. end: my_end_token(M),
  6417. names: M.elements.map(function(elm) {
  6418. if (elm === null) {
  6419. return new AST_Hole();
  6420. }
  6421. return from_moz(elm);
  6422. }),
  6423. is_array: true
  6424. });
  6425. },
  6426. ObjectPattern: function(M) {
  6427. return new AST_Destructuring({
  6428. start: my_start_token(M),
  6429. end: my_end_token(M),
  6430. names: M.properties.map(from_moz),
  6431. is_array: false
  6432. });
  6433. },
  6434. AssignmentPattern: function(M) {
  6435. return new AST_DefaultAssign({
  6436. start: my_start_token(M),
  6437. end: my_end_token(M),
  6438. left: from_moz(M.left),
  6439. operator: "=",
  6440. right: from_moz(M.right)
  6441. });
  6442. },
  6443. SpreadElement: function(M) {
  6444. return new AST_Expansion({
  6445. start: my_start_token(M),
  6446. end: my_end_token(M),
  6447. expression: from_moz(M.argument)
  6448. });
  6449. },
  6450. RestElement: function(M) {
  6451. return new AST_Expansion({
  6452. start: my_start_token(M),
  6453. end: my_end_token(M),
  6454. expression: from_moz(M.argument)
  6455. });
  6456. },
  6457. TemplateElement: function(M) {
  6458. return new AST_TemplateSegment({
  6459. start: my_start_token(M),
  6460. end: my_end_token(M),
  6461. value: M.value.cooked,
  6462. raw: M.value.raw
  6463. });
  6464. },
  6465. TemplateLiteral: function(M) {
  6466. var segments = [];
  6467. for (var i = 0; i < M.quasis.length; i++) {
  6468. segments.push(from_moz(M.quasis[i]));
  6469. if (M.expressions[i]) {
  6470. segments.push(from_moz(M.expressions[i]));
  6471. }
  6472. }
  6473. return new AST_TemplateString({
  6474. start: my_start_token(M),
  6475. end: my_end_token(M),
  6476. segments: segments
  6477. });
  6478. },
  6479. TaggedTemplateExpression: function(M) {
  6480. return new AST_PrefixedTemplateString({
  6481. start: my_start_token(M),
  6482. end: my_end_token(M),
  6483. template_string: from_moz(M.quasi),
  6484. prefix: from_moz(M.tag)
  6485. });
  6486. },
  6487. FunctionDeclaration: function(M) {
  6488. return new AST_Defun({
  6489. start: my_start_token(M),
  6490. end: my_end_token(M),
  6491. name: from_moz(M.id),
  6492. argnames: M.params.map(from_moz),
  6493. is_generator: M.generator,
  6494. async: M.async,
  6495. body: normalize_directives(from_moz(M.body).body)
  6496. });
  6497. },
  6498. FunctionExpression: function(M) {
  6499. return new AST_Function({
  6500. start: my_start_token(M),
  6501. end: my_end_token(M),
  6502. name: from_moz(M.id),
  6503. argnames: M.params.map(from_moz),
  6504. is_generator: M.generator,
  6505. async: M.async,
  6506. body: normalize_directives(from_moz(M.body).body)
  6507. });
  6508. },
  6509. ArrowFunctionExpression: function(M) {
  6510. const body = M.body.type === "BlockStatement"
  6511. ? from_moz(M.body).body
  6512. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  6513. return new AST_Arrow({
  6514. start: my_start_token(M),
  6515. end: my_end_token(M),
  6516. argnames: M.params.map(from_moz),
  6517. body,
  6518. async: M.async,
  6519. });
  6520. },
  6521. ExpressionStatement: function(M) {
  6522. return new AST_SimpleStatement({
  6523. start: my_start_token(M),
  6524. end: my_end_token(M),
  6525. body: from_moz(M.expression)
  6526. });
  6527. },
  6528. TryStatement: function(M) {
  6529. var handlers = M.handlers || [M.handler];
  6530. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  6531. throw new Error("Multiple catch clauses are not supported.");
  6532. }
  6533. return new AST_Try({
  6534. start : my_start_token(M),
  6535. end : my_end_token(M),
  6536. body : new AST_TryBlock(from_moz(M.block)),
  6537. bcatch : from_moz(handlers[0]),
  6538. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  6539. });
  6540. },
  6541. Property: function(M) {
  6542. var key = M.key;
  6543. var args = {
  6544. start : my_start_token(key || M.value),
  6545. end : my_end_token(M.value),
  6546. key : key.type == "Identifier" ? key.name : key.value,
  6547. value : from_moz(M.value)
  6548. };
  6549. if (M.computed) {
  6550. args.key = from_moz(M.key);
  6551. }
  6552. if (M.method) {
  6553. args.is_generator = M.value.generator;
  6554. args.async = M.value.async;
  6555. if (!M.computed) {
  6556. args.key = new AST_SymbolMethod({ name: args.key });
  6557. } else {
  6558. args.key = from_moz(M.key);
  6559. }
  6560. return new AST_ConciseMethod(args);
  6561. }
  6562. if (M.kind == "init") {
  6563. if (key.type != "Identifier" && key.type != "Literal") {
  6564. args.key = from_moz(key);
  6565. }
  6566. return new AST_ObjectKeyVal(args);
  6567. }
  6568. if (typeof args.key === "string" || typeof args.key === "number") {
  6569. args.key = new AST_SymbolMethod({
  6570. name: args.key
  6571. });
  6572. }
  6573. args.value = new AST_Accessor(args.value);
  6574. if (M.kind == "get") return new AST_ObjectGetter(args);
  6575. if (M.kind == "set") return new AST_ObjectSetter(args);
  6576. if (M.kind == "method") {
  6577. args.async = M.value.async;
  6578. args.is_generator = M.value.generator;
  6579. args.quote = M.computed ? "\"" : null;
  6580. return new AST_ConciseMethod(args);
  6581. }
  6582. },
  6583. MethodDefinition: function(M) {
  6584. const is_private = M.key.type === "PrivateIdentifier";
  6585. const key = M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value });
  6586. var args = {
  6587. start : my_start_token(M),
  6588. end : my_end_token(M),
  6589. key,
  6590. value : from_moz(M.value),
  6591. static : M.static,
  6592. };
  6593. if (M.kind == "get") {
  6594. return new (is_private ? AST_PrivateGetter : AST_ObjectGetter)(args);
  6595. }
  6596. if (M.kind == "set") {
  6597. return new (is_private ? AST_PrivateSetter : AST_ObjectSetter)(args);
  6598. }
  6599. args.is_generator = M.value.generator;
  6600. args.async = M.value.async;
  6601. return new (is_private ? AST_PrivateMethod : AST_ConciseMethod)(args);
  6602. },
  6603. FieldDefinition: function(M) {
  6604. let key;
  6605. if (M.computed) {
  6606. key = from_moz(M.key);
  6607. } else {
  6608. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  6609. key = from_moz(M.key);
  6610. }
  6611. return new AST_ClassProperty({
  6612. start : my_start_token(M),
  6613. end : my_end_token(M),
  6614. key,
  6615. value : from_moz(M.value),
  6616. static : M.static,
  6617. });
  6618. },
  6619. PropertyDefinition: function(M) {
  6620. let key;
  6621. if (M.computed) {
  6622. key = from_moz(M.key);
  6623. } else if (M.key.type === "PrivateIdentifier") {
  6624. return new AST_ClassPrivateProperty({
  6625. start : my_start_token(M),
  6626. end : my_end_token(M),
  6627. key : from_moz(M.key),
  6628. value : from_moz(M.value),
  6629. static : M.static,
  6630. });
  6631. } else {
  6632. if (M.key.type !== "Identifier") {
  6633. throw new Error("Non-Identifier key in PropertyDefinition");
  6634. }
  6635. key = from_moz(M.key);
  6636. }
  6637. return new AST_ClassProperty({
  6638. start : my_start_token(M),
  6639. end : my_end_token(M),
  6640. key,
  6641. value : from_moz(M.value),
  6642. static : M.static,
  6643. });
  6644. },
  6645. PrivateIdentifier: function (M) {
  6646. return new AST_SymbolPrivateProperty({
  6647. start: my_start_token(M),
  6648. end: my_end_token(M),
  6649. name: M.name
  6650. });
  6651. },
  6652. StaticBlock: function(M) {
  6653. return new AST_ClassStaticBlock({
  6654. start : my_start_token(M),
  6655. end : my_end_token(M),
  6656. body : M.body.map(from_moz),
  6657. });
  6658. },
  6659. ArrayExpression: function(M) {
  6660. return new AST_Array({
  6661. start : my_start_token(M),
  6662. end : my_end_token(M),
  6663. elements : M.elements.map(function(elem) {
  6664. return elem === null ? new AST_Hole() : from_moz(elem);
  6665. })
  6666. });
  6667. },
  6668. ObjectExpression: function(M) {
  6669. return new AST_Object({
  6670. start : my_start_token(M),
  6671. end : my_end_token(M),
  6672. properties : M.properties.map(function(prop) {
  6673. if (prop.type === "SpreadElement") {
  6674. return from_moz(prop);
  6675. }
  6676. prop.type = "Property";
  6677. return from_moz(prop);
  6678. })
  6679. });
  6680. },
  6681. SequenceExpression: function(M) {
  6682. return new AST_Sequence({
  6683. start : my_start_token(M),
  6684. end : my_end_token(M),
  6685. expressions: M.expressions.map(from_moz)
  6686. });
  6687. },
  6688. MemberExpression: function(M) {
  6689. if (M.property.type === "PrivateIdentifier") {
  6690. return new AST_DotHash({
  6691. start : my_start_token(M),
  6692. end : my_end_token(M),
  6693. property : M.property.name,
  6694. expression : from_moz(M.object),
  6695. optional : M.optional || false
  6696. });
  6697. }
  6698. return new (M.computed ? AST_Sub : AST_Dot)({
  6699. start : my_start_token(M),
  6700. end : my_end_token(M),
  6701. property : M.computed ? from_moz(M.property) : M.property.name,
  6702. expression : from_moz(M.object),
  6703. optional : M.optional || false
  6704. });
  6705. },
  6706. ChainExpression: function(M) {
  6707. return new AST_Chain({
  6708. start : my_start_token(M),
  6709. end : my_end_token(M),
  6710. expression : from_moz(M.expression)
  6711. });
  6712. },
  6713. SwitchCase: function(M) {
  6714. return new (M.test ? AST_Case : AST_Default)({
  6715. start : my_start_token(M),
  6716. end : my_end_token(M),
  6717. expression : from_moz(M.test),
  6718. body : M.consequent.map(from_moz)
  6719. });
  6720. },
  6721. VariableDeclaration: function(M) {
  6722. return new (M.kind === "const" ? AST_Const :
  6723. M.kind === "let" ? AST_Let : AST_Var)({
  6724. start : my_start_token(M),
  6725. end : my_end_token(M),
  6726. definitions : M.declarations.map(from_moz)
  6727. });
  6728. },
  6729. ImportDeclaration: function(M) {
  6730. var imported_name = null;
  6731. var imported_names = null;
  6732. M.specifiers.forEach(function (specifier) {
  6733. if (specifier.type === "ImportSpecifier" || specifier.type === "ImportNamespaceSpecifier") {
  6734. if (!imported_names) { imported_names = []; }
  6735. imported_names.push(from_moz(specifier));
  6736. } else if (specifier.type === "ImportDefaultSpecifier") {
  6737. imported_name = from_moz(specifier);
  6738. }
  6739. });
  6740. return new AST_Import({
  6741. start : my_start_token(M),
  6742. end : my_end_token(M),
  6743. imported_name: imported_name,
  6744. imported_names : imported_names,
  6745. module_name : from_moz(M.source),
  6746. assert_clause: assert_clause_from_moz(M.assertions)
  6747. });
  6748. },
  6749. ImportSpecifier: function(M) {
  6750. return new AST_NameMapping({
  6751. start: my_start_token(M),
  6752. end: my_end_token(M),
  6753. foreign_name: from_moz(M.imported),
  6754. name: from_moz(M.local)
  6755. });
  6756. },
  6757. ImportDefaultSpecifier: function(M) {
  6758. return from_moz(M.local);
  6759. },
  6760. ImportNamespaceSpecifier: function(M) {
  6761. return new AST_NameMapping({
  6762. start: my_start_token(M),
  6763. end: my_end_token(M),
  6764. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  6765. name: from_moz(M.local)
  6766. });
  6767. },
  6768. ExportAllDeclaration: function(M) {
  6769. var foreign_name = M.exported == null ?
  6770. new AST_SymbolExportForeign({ name: "*" }) :
  6771. from_moz(M.exported);
  6772. return new AST_Export({
  6773. start: my_start_token(M),
  6774. end: my_end_token(M),
  6775. exported_names: [
  6776. new AST_NameMapping({
  6777. name: new AST_SymbolExportForeign({ name: "*" }),
  6778. foreign_name: foreign_name
  6779. })
  6780. ],
  6781. module_name: from_moz(M.source),
  6782. assert_clause: assert_clause_from_moz(M.assertions)
  6783. });
  6784. },
  6785. ExportNamedDeclaration: function(M) {
  6786. return new AST_Export({
  6787. start: my_start_token(M),
  6788. end: my_end_token(M),
  6789. exported_definition: from_moz(M.declaration),
  6790. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(function (specifier) {
  6791. return from_moz(specifier);
  6792. }) : null,
  6793. module_name: from_moz(M.source),
  6794. assert_clause: assert_clause_from_moz(M.assertions)
  6795. });
  6796. },
  6797. ExportDefaultDeclaration: function(M) {
  6798. return new AST_Export({
  6799. start: my_start_token(M),
  6800. end: my_end_token(M),
  6801. exported_value: from_moz(M.declaration),
  6802. is_default: true
  6803. });
  6804. },
  6805. ExportSpecifier: function(M) {
  6806. return new AST_NameMapping({
  6807. foreign_name: from_moz(M.exported),
  6808. name: from_moz(M.local)
  6809. });
  6810. },
  6811. Literal: function(M) {
  6812. var val = M.value, args = {
  6813. start : my_start_token(M),
  6814. end : my_end_token(M)
  6815. };
  6816. var rx = M.regex;
  6817. if (rx && rx.pattern) {
  6818. // RegExpLiteral as per ESTree AST spec
  6819. args.value = {
  6820. source: rx.pattern,
  6821. flags: rx.flags
  6822. };
  6823. return new AST_RegExp(args);
  6824. } else if (rx) {
  6825. // support legacy RegExp
  6826. const rx_source = M.raw || val;
  6827. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  6828. if (!match) throw new Error("Invalid regex source " + rx_source);
  6829. const [_, source, flags] = match;
  6830. args.value = { source, flags };
  6831. return new AST_RegExp(args);
  6832. }
  6833. if (val === null) return new AST_Null(args);
  6834. switch (typeof val) {
  6835. case "string":
  6836. args.quote = "\"";
  6837. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6838. if (p.type == "ImportSpecifier") {
  6839. args.name = val;
  6840. return new AST_SymbolImportForeign(args);
  6841. } else if (p.type == "ExportSpecifier") {
  6842. args.name = val;
  6843. if (M == p.exported) {
  6844. return new AST_SymbolExportForeign(args);
  6845. } else {
  6846. return new AST_SymbolExport(args);
  6847. }
  6848. } else if (p.type == "ExportAllDeclaration" && M == p.exported) {
  6849. args.name = val;
  6850. return new AST_SymbolExportForeign(args);
  6851. }
  6852. args.value = val;
  6853. return new AST_String(args);
  6854. case "number":
  6855. args.value = val;
  6856. args.raw = M.raw || val.toString();
  6857. return new AST_Number(args);
  6858. case "boolean":
  6859. return new (val ? AST_True : AST_False)(args);
  6860. }
  6861. },
  6862. MetaProperty: function(M) {
  6863. if (M.meta.name === "new" && M.property.name === "target") {
  6864. return new AST_NewTarget({
  6865. start: my_start_token(M),
  6866. end: my_end_token(M)
  6867. });
  6868. } else if (M.meta.name === "import" && M.property.name === "meta") {
  6869. return new AST_ImportMeta({
  6870. start: my_start_token(M),
  6871. end: my_end_token(M)
  6872. });
  6873. }
  6874. },
  6875. Identifier: function(M) {
  6876. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6877. return new ( p.type == "LabeledStatement" ? AST_Label
  6878. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  6879. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  6880. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  6881. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  6882. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  6883. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  6884. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  6885. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  6886. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  6887. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  6888. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  6889. : p.type == "CatchClause" ? AST_SymbolCatch
  6890. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  6891. : AST_SymbolRef)({
  6892. start : my_start_token(M),
  6893. end : my_end_token(M),
  6894. name : M.name
  6895. });
  6896. },
  6897. BigIntLiteral(M) {
  6898. return new AST_BigInt({
  6899. start : my_start_token(M),
  6900. end : my_end_token(M),
  6901. value : M.value
  6902. });
  6903. },
  6904. EmptyStatement: function(M) {
  6905. return new AST_EmptyStatement({
  6906. start: my_start_token(M),
  6907. end: my_end_token(M)
  6908. });
  6909. },
  6910. BlockStatement: function(M) {
  6911. return new AST_BlockStatement({
  6912. start: my_start_token(M),
  6913. end: my_end_token(M),
  6914. body: M.body.map(from_moz)
  6915. });
  6916. },
  6917. IfStatement: function(M) {
  6918. return new AST_If({
  6919. start: my_start_token(M),
  6920. end: my_end_token(M),
  6921. condition: from_moz(M.test),
  6922. body: from_moz(M.consequent),
  6923. alternative: from_moz(M.alternate)
  6924. });
  6925. },
  6926. LabeledStatement: function(M) {
  6927. return new AST_LabeledStatement({
  6928. start: my_start_token(M),
  6929. end: my_end_token(M),
  6930. label: from_moz(M.label),
  6931. body: from_moz(M.body)
  6932. });
  6933. },
  6934. BreakStatement: function(M) {
  6935. return new AST_Break({
  6936. start: my_start_token(M),
  6937. end: my_end_token(M),
  6938. label: from_moz(M.label)
  6939. });
  6940. },
  6941. ContinueStatement: function(M) {
  6942. return new AST_Continue({
  6943. start: my_start_token(M),
  6944. end: my_end_token(M),
  6945. label: from_moz(M.label)
  6946. });
  6947. },
  6948. WithStatement: function(M) {
  6949. return new AST_With({
  6950. start: my_start_token(M),
  6951. end: my_end_token(M),
  6952. expression: from_moz(M.object),
  6953. body: from_moz(M.body)
  6954. });
  6955. },
  6956. SwitchStatement: function(M) {
  6957. return new AST_Switch({
  6958. start: my_start_token(M),
  6959. end: my_end_token(M),
  6960. expression: from_moz(M.discriminant),
  6961. body: M.cases.map(from_moz)
  6962. });
  6963. },
  6964. ReturnStatement: function(M) {
  6965. return new AST_Return({
  6966. start: my_start_token(M),
  6967. end: my_end_token(M),
  6968. value: from_moz(M.argument)
  6969. });
  6970. },
  6971. ThrowStatement: function(M) {
  6972. return new AST_Throw({
  6973. start: my_start_token(M),
  6974. end: my_end_token(M),
  6975. value: from_moz(M.argument)
  6976. });
  6977. },
  6978. WhileStatement: function(M) {
  6979. return new AST_While({
  6980. start: my_start_token(M),
  6981. end: my_end_token(M),
  6982. condition: from_moz(M.test),
  6983. body: from_moz(M.body)
  6984. });
  6985. },
  6986. DoWhileStatement: function(M) {
  6987. return new AST_Do({
  6988. start: my_start_token(M),
  6989. end: my_end_token(M),
  6990. condition: from_moz(M.test),
  6991. body: from_moz(M.body)
  6992. });
  6993. },
  6994. ForStatement: function(M) {
  6995. return new AST_For({
  6996. start: my_start_token(M),
  6997. end: my_end_token(M),
  6998. init: from_moz(M.init),
  6999. condition: from_moz(M.test),
  7000. step: from_moz(M.update),
  7001. body: from_moz(M.body)
  7002. });
  7003. },
  7004. ForInStatement: function(M) {
  7005. return new AST_ForIn({
  7006. start: my_start_token(M),
  7007. end: my_end_token(M),
  7008. init: from_moz(M.left),
  7009. object: from_moz(M.right),
  7010. body: from_moz(M.body)
  7011. });
  7012. },
  7013. ForOfStatement: function(M) {
  7014. return new AST_ForOf({
  7015. start: my_start_token(M),
  7016. end: my_end_token(M),
  7017. init: from_moz(M.left),
  7018. object: from_moz(M.right),
  7019. body: from_moz(M.body),
  7020. await: M.await
  7021. });
  7022. },
  7023. AwaitExpression: function(M) {
  7024. return new AST_Await({
  7025. start: my_start_token(M),
  7026. end: my_end_token(M),
  7027. expression: from_moz(M.argument)
  7028. });
  7029. },
  7030. YieldExpression: function(M) {
  7031. return new AST_Yield({
  7032. start: my_start_token(M),
  7033. end: my_end_token(M),
  7034. expression: from_moz(M.argument),
  7035. is_star: M.delegate
  7036. });
  7037. },
  7038. DebuggerStatement: function(M) {
  7039. return new AST_Debugger({
  7040. start: my_start_token(M),
  7041. end: my_end_token(M)
  7042. });
  7043. },
  7044. VariableDeclarator: function(M) {
  7045. return new AST_VarDef({
  7046. start: my_start_token(M),
  7047. end: my_end_token(M),
  7048. name: from_moz(M.id),
  7049. value: from_moz(M.init)
  7050. });
  7051. },
  7052. CatchClause: function(M) {
  7053. return new AST_Catch({
  7054. start: my_start_token(M),
  7055. end: my_end_token(M),
  7056. argname: from_moz(M.param),
  7057. body: from_moz(M.body).body
  7058. });
  7059. },
  7060. ThisExpression: function(M) {
  7061. return new AST_This({
  7062. start: my_start_token(M),
  7063. end: my_end_token(M)
  7064. });
  7065. },
  7066. Super: function(M) {
  7067. return new AST_Super({
  7068. start: my_start_token(M),
  7069. end: my_end_token(M)
  7070. });
  7071. },
  7072. BinaryExpression: function(M) {
  7073. if (M.left.type === "PrivateIdentifier") {
  7074. return new AST_PrivateIn({
  7075. start: my_start_token(M),
  7076. end: my_end_token(M),
  7077. key: new AST_SymbolPrivateProperty({
  7078. start: my_start_token(M.left),
  7079. end: my_end_token(M.left),
  7080. name: M.left.name
  7081. }),
  7082. value: from_moz(M.right),
  7083. });
  7084. }
  7085. return new AST_Binary({
  7086. start: my_start_token(M),
  7087. end: my_end_token(M),
  7088. operator: M.operator,
  7089. left: from_moz(M.left),
  7090. right: from_moz(M.right)
  7091. });
  7092. },
  7093. LogicalExpression: function(M) {
  7094. return new AST_Binary({
  7095. start: my_start_token(M),
  7096. end: my_end_token(M),
  7097. operator: M.operator,
  7098. left: from_moz(M.left),
  7099. right: from_moz(M.right)
  7100. });
  7101. },
  7102. AssignmentExpression: function(M) {
  7103. return new AST_Assign({
  7104. start: my_start_token(M),
  7105. end: my_end_token(M),
  7106. operator: M.operator,
  7107. left: from_moz(M.left),
  7108. right: from_moz(M.right)
  7109. });
  7110. },
  7111. ConditionalExpression: function(M) {
  7112. return new AST_Conditional({
  7113. start: my_start_token(M),
  7114. end: my_end_token(M),
  7115. condition: from_moz(M.test),
  7116. consequent: from_moz(M.consequent),
  7117. alternative: from_moz(M.alternate)
  7118. });
  7119. },
  7120. NewExpression: function(M) {
  7121. return new AST_New({
  7122. start: my_start_token(M),
  7123. end: my_end_token(M),
  7124. expression: from_moz(M.callee),
  7125. args: M.arguments.map(from_moz)
  7126. });
  7127. },
  7128. CallExpression: function(M) {
  7129. return new AST_Call({
  7130. start: my_start_token(M),
  7131. end: my_end_token(M),
  7132. expression: from_moz(M.callee),
  7133. optional: M.optional,
  7134. args: M.arguments.map(from_moz)
  7135. });
  7136. }
  7137. };
  7138. MOZ_TO_ME.UpdateExpression =
  7139. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  7140. var prefix = "prefix" in M ? M.prefix
  7141. : M.type == "UnaryExpression" ? true : false;
  7142. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  7143. start : my_start_token(M),
  7144. end : my_end_token(M),
  7145. operator : M.operator,
  7146. expression : from_moz(M.argument)
  7147. });
  7148. };
  7149. MOZ_TO_ME.ClassDeclaration =
  7150. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  7151. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  7152. start : my_start_token(M),
  7153. end : my_end_token(M),
  7154. name : from_moz(M.id),
  7155. extends : from_moz(M.superClass),
  7156. properties: M.body.body.map(from_moz)
  7157. });
  7158. };
  7159. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  7160. return {
  7161. type: "EmptyStatement"
  7162. };
  7163. });
  7164. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  7165. return {
  7166. type: "BlockStatement",
  7167. body: M.body.map(to_moz)
  7168. };
  7169. });
  7170. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  7171. return {
  7172. type: "IfStatement",
  7173. test: to_moz(M.condition),
  7174. consequent: to_moz(M.body),
  7175. alternate: to_moz(M.alternative)
  7176. };
  7177. });
  7178. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  7179. return {
  7180. type: "LabeledStatement",
  7181. label: to_moz(M.label),
  7182. body: to_moz(M.body)
  7183. };
  7184. });
  7185. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  7186. return {
  7187. type: "BreakStatement",
  7188. label: to_moz(M.label)
  7189. };
  7190. });
  7191. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  7192. return {
  7193. type: "ContinueStatement",
  7194. label: to_moz(M.label)
  7195. };
  7196. });
  7197. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  7198. return {
  7199. type: "WithStatement",
  7200. object: to_moz(M.expression),
  7201. body: to_moz(M.body)
  7202. };
  7203. });
  7204. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  7205. return {
  7206. type: "SwitchStatement",
  7207. discriminant: to_moz(M.expression),
  7208. cases: M.body.map(to_moz)
  7209. };
  7210. });
  7211. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  7212. return {
  7213. type: "ReturnStatement",
  7214. argument: to_moz(M.value)
  7215. };
  7216. });
  7217. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  7218. return {
  7219. type: "ThrowStatement",
  7220. argument: to_moz(M.value)
  7221. };
  7222. });
  7223. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  7224. return {
  7225. type: "WhileStatement",
  7226. test: to_moz(M.condition),
  7227. body: to_moz(M.body)
  7228. };
  7229. });
  7230. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  7231. return {
  7232. type: "DoWhileStatement",
  7233. test: to_moz(M.condition),
  7234. body: to_moz(M.body)
  7235. };
  7236. });
  7237. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  7238. return {
  7239. type: "ForStatement",
  7240. init: to_moz(M.init),
  7241. test: to_moz(M.condition),
  7242. update: to_moz(M.step),
  7243. body: to_moz(M.body)
  7244. };
  7245. });
  7246. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  7247. return {
  7248. type: "ForInStatement",
  7249. left: to_moz(M.init),
  7250. right: to_moz(M.object),
  7251. body: to_moz(M.body)
  7252. };
  7253. });
  7254. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  7255. return {
  7256. type: "ForOfStatement",
  7257. left: to_moz(M.init),
  7258. right: to_moz(M.object),
  7259. body: to_moz(M.body),
  7260. await: M.await
  7261. };
  7262. });
  7263. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  7264. return {
  7265. type: "AwaitExpression",
  7266. argument: to_moz(M.expression)
  7267. };
  7268. });
  7269. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  7270. return {
  7271. type: "YieldExpression",
  7272. argument: to_moz(M.expression),
  7273. delegate: M.is_star
  7274. };
  7275. });
  7276. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  7277. return {
  7278. type: "DebuggerStatement"
  7279. };
  7280. });
  7281. def_to_moz(AST_VarDef, function To_Moz_VariableDeclarator(M) {
  7282. return {
  7283. type: "VariableDeclarator",
  7284. id: to_moz(M.name),
  7285. init: to_moz(M.value)
  7286. };
  7287. });
  7288. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7289. return {
  7290. type: "CatchClause",
  7291. param: to_moz(M.argname),
  7292. body: to_moz_block(M)
  7293. };
  7294. });
  7295. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  7296. return {
  7297. type: "ThisExpression"
  7298. };
  7299. });
  7300. def_to_moz(AST_Super, function To_Moz_Super() {
  7301. return {
  7302. type: "Super"
  7303. };
  7304. });
  7305. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7306. return {
  7307. type: "BinaryExpression",
  7308. operator: M.operator,
  7309. left: to_moz(M.left),
  7310. right: to_moz(M.right)
  7311. };
  7312. });
  7313. def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
  7314. return {
  7315. type: "LogicalExpression",
  7316. operator: M.operator,
  7317. left: to_moz(M.left),
  7318. right: to_moz(M.right)
  7319. };
  7320. });
  7321. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  7322. return {
  7323. type: "AssignmentExpression",
  7324. operator: M.operator,
  7325. left: to_moz(M.left),
  7326. right: to_moz(M.right)
  7327. };
  7328. });
  7329. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  7330. return {
  7331. type: "ConditionalExpression",
  7332. test: to_moz(M.condition),
  7333. consequent: to_moz(M.consequent),
  7334. alternate: to_moz(M.alternative)
  7335. };
  7336. });
  7337. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  7338. return {
  7339. type: "NewExpression",
  7340. callee: to_moz(M.expression),
  7341. arguments: M.args.map(to_moz)
  7342. };
  7343. });
  7344. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  7345. return {
  7346. type: "CallExpression",
  7347. callee: to_moz(M.expression),
  7348. optional: M.optional,
  7349. arguments: M.args.map(to_moz)
  7350. };
  7351. });
  7352. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  7353. return to_moz_scope("Program", M);
  7354. });
  7355. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  7356. return {
  7357. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  7358. argument: to_moz(M.expression)
  7359. };
  7360. });
  7361. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  7362. return {
  7363. type: "TaggedTemplateExpression",
  7364. tag: to_moz(M.prefix),
  7365. quasi: to_moz(M.template_string)
  7366. };
  7367. });
  7368. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  7369. var quasis = [];
  7370. var expressions = [];
  7371. for (var i = 0; i < M.segments.length; i++) {
  7372. if (i % 2 !== 0) {
  7373. expressions.push(to_moz(M.segments[i]));
  7374. } else {
  7375. quasis.push({
  7376. type: "TemplateElement",
  7377. value: {
  7378. raw: M.segments[i].raw,
  7379. cooked: M.segments[i].value
  7380. },
  7381. tail: i === M.segments.length - 1
  7382. });
  7383. }
  7384. }
  7385. return {
  7386. type: "TemplateLiteral",
  7387. quasis: quasis,
  7388. expressions: expressions
  7389. };
  7390. });
  7391. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  7392. return {
  7393. type: "FunctionDeclaration",
  7394. id: to_moz(M.name),
  7395. params: M.argnames.map(to_moz),
  7396. generator: M.is_generator,
  7397. async: M.async,
  7398. body: to_moz_scope("BlockStatement", M)
  7399. };
  7400. });
  7401. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  7402. var is_generator = parent.is_generator !== undefined ?
  7403. parent.is_generator : M.is_generator;
  7404. return {
  7405. type: "FunctionExpression",
  7406. id: to_moz(M.name),
  7407. params: M.argnames.map(to_moz),
  7408. generator: is_generator,
  7409. async: M.async,
  7410. body: to_moz_scope("BlockStatement", M)
  7411. };
  7412. });
  7413. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  7414. var body = {
  7415. type: "BlockStatement",
  7416. body: M.body.map(to_moz)
  7417. };
  7418. return {
  7419. type: "ArrowFunctionExpression",
  7420. params: M.argnames.map(to_moz),
  7421. async: M.async,
  7422. body: body
  7423. };
  7424. });
  7425. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  7426. if (M.is_array) {
  7427. return {
  7428. type: "ArrayPattern",
  7429. elements: M.names.map(to_moz)
  7430. };
  7431. }
  7432. return {
  7433. type: "ObjectPattern",
  7434. properties: M.names.map(to_moz)
  7435. };
  7436. });
  7437. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  7438. return {
  7439. type: "ExpressionStatement",
  7440. expression: {
  7441. type: "Literal",
  7442. value: M.value,
  7443. raw: M.print_to_string()
  7444. },
  7445. directive: M.value
  7446. };
  7447. });
  7448. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  7449. return {
  7450. type: "ExpressionStatement",
  7451. expression: to_moz(M.body)
  7452. };
  7453. });
  7454. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  7455. return {
  7456. type: "SwitchCase",
  7457. test: to_moz(M.expression),
  7458. consequent: M.body.map(to_moz)
  7459. };
  7460. });
  7461. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  7462. return {
  7463. type: "TryStatement",
  7464. block: to_moz_block(M.body),
  7465. handler: to_moz(M.bcatch),
  7466. guardedHandlers: [],
  7467. finalizer: to_moz(M.bfinally)
  7468. };
  7469. });
  7470. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7471. return {
  7472. type: "CatchClause",
  7473. param: to_moz(M.argname),
  7474. guard: null,
  7475. body: to_moz_block(M)
  7476. };
  7477. });
  7478. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  7479. return {
  7480. type: "VariableDeclaration",
  7481. kind:
  7482. M instanceof AST_Const ? "const" :
  7483. M instanceof AST_Let ? "let" : "var",
  7484. declarations: M.definitions.map(to_moz)
  7485. };
  7486. });
  7487. const assert_clause_to_moz = assert_clause => {
  7488. const assertions = [];
  7489. if (assert_clause) {
  7490. for (const { key, value } of assert_clause.properties) {
  7491. const key_moz = is_basic_identifier_string(key)
  7492. ? { type: "Identifier", name: key }
  7493. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  7494. assertions.push({
  7495. type: "ImportAttribute",
  7496. key: key_moz,
  7497. value: to_moz(value)
  7498. });
  7499. }
  7500. }
  7501. return assertions;
  7502. };
  7503. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  7504. if (M.exported_names) {
  7505. var first_exported = M.exported_names[0];
  7506. var first_exported_name = first_exported.name;
  7507. if (first_exported_name.name === "*" && !first_exported_name.quote) {
  7508. var foreign_name = first_exported.foreign_name;
  7509. var exported = foreign_name.name === "*" && !foreign_name.quote
  7510. ? null
  7511. : to_moz(foreign_name);
  7512. return {
  7513. type: "ExportAllDeclaration",
  7514. source: to_moz(M.module_name),
  7515. exported: exported,
  7516. assertions: assert_clause_to_moz(M.assert_clause)
  7517. };
  7518. }
  7519. return {
  7520. type: "ExportNamedDeclaration",
  7521. specifiers: M.exported_names.map(function (name_mapping) {
  7522. return {
  7523. type: "ExportSpecifier",
  7524. exported: to_moz(name_mapping.foreign_name),
  7525. local: to_moz(name_mapping.name)
  7526. };
  7527. }),
  7528. declaration: to_moz(M.exported_definition),
  7529. source: to_moz(M.module_name),
  7530. assertions: assert_clause_to_moz(M.assert_clause)
  7531. };
  7532. }
  7533. return {
  7534. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  7535. declaration: to_moz(M.exported_value || M.exported_definition)
  7536. };
  7537. });
  7538. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  7539. var specifiers = [];
  7540. if (M.imported_name) {
  7541. specifiers.push({
  7542. type: "ImportDefaultSpecifier",
  7543. local: to_moz(M.imported_name)
  7544. });
  7545. }
  7546. if (M.imported_names) {
  7547. var first_imported_foreign_name = M.imported_names[0].foreign_name;
  7548. if (first_imported_foreign_name.name === "*" && !first_imported_foreign_name.quote) {
  7549. specifiers.push({
  7550. type: "ImportNamespaceSpecifier",
  7551. local: to_moz(M.imported_names[0].name)
  7552. });
  7553. } else {
  7554. M.imported_names.forEach(function(name_mapping) {
  7555. specifiers.push({
  7556. type: "ImportSpecifier",
  7557. local: to_moz(name_mapping.name),
  7558. imported: to_moz(name_mapping.foreign_name)
  7559. });
  7560. });
  7561. }
  7562. }
  7563. return {
  7564. type: "ImportDeclaration",
  7565. specifiers: specifiers,
  7566. source: to_moz(M.module_name),
  7567. assertions: assert_clause_to_moz(M.assert_clause)
  7568. };
  7569. });
  7570. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  7571. return {
  7572. type: "MetaProperty",
  7573. meta: {
  7574. type: "Identifier",
  7575. name: "import"
  7576. },
  7577. property: {
  7578. type: "Identifier",
  7579. name: "meta"
  7580. }
  7581. };
  7582. });
  7583. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  7584. return {
  7585. type: "SequenceExpression",
  7586. expressions: M.expressions.map(to_moz)
  7587. };
  7588. });
  7589. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  7590. return {
  7591. type: "MemberExpression",
  7592. object: to_moz(M.expression),
  7593. computed: false,
  7594. property: {
  7595. type: "PrivateIdentifier",
  7596. name: M.property
  7597. },
  7598. optional: M.optional
  7599. };
  7600. });
  7601. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  7602. var isComputed = M instanceof AST_Sub;
  7603. return {
  7604. type: "MemberExpression",
  7605. object: to_moz(M.expression),
  7606. computed: isComputed,
  7607. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  7608. optional: M.optional
  7609. };
  7610. });
  7611. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  7612. return {
  7613. type: "ChainExpression",
  7614. expression: to_moz(M.expression)
  7615. };
  7616. });
  7617. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  7618. return {
  7619. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  7620. operator: M.operator,
  7621. prefix: M instanceof AST_UnaryPrefix,
  7622. argument: to_moz(M.expression)
  7623. };
  7624. });
  7625. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7626. if (M.operator == "=" && to_moz_in_destructuring()) {
  7627. return {
  7628. type: "AssignmentPattern",
  7629. left: to_moz(M.left),
  7630. right: to_moz(M.right)
  7631. };
  7632. }
  7633. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  7634. ? "LogicalExpression"
  7635. : "BinaryExpression";
  7636. return {
  7637. type,
  7638. left: to_moz(M.left),
  7639. operator: M.operator,
  7640. right: to_moz(M.right)
  7641. };
  7642. });
  7643. def_to_moz(AST_PrivateIn, function To_Moz_BinaryExpression_PrivateIn(M) {
  7644. return {
  7645. type: "BinaryExpression",
  7646. left: { type: "PrivateIdentifier", name: M.key.name },
  7647. operator: "in",
  7648. right: to_moz(M.value),
  7649. };
  7650. });
  7651. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  7652. return {
  7653. type: "ArrayExpression",
  7654. elements: M.elements.map(to_moz)
  7655. };
  7656. });
  7657. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  7658. return {
  7659. type: "ObjectExpression",
  7660. properties: M.properties.map(to_moz)
  7661. };
  7662. });
  7663. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  7664. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  7665. type: "Identifier",
  7666. value: M.key
  7667. };
  7668. if (typeof M.key === "number") {
  7669. key = {
  7670. type: "Literal",
  7671. value: Number(M.key)
  7672. };
  7673. }
  7674. if (typeof M.key === "string") {
  7675. key = {
  7676. type: "Identifier",
  7677. name: M.key
  7678. };
  7679. }
  7680. var kind;
  7681. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  7682. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  7683. if (M instanceof AST_ObjectKeyVal) {
  7684. kind = "init";
  7685. computed = !string_or_num;
  7686. } else
  7687. if (M instanceof AST_ObjectGetter) {
  7688. kind = "get";
  7689. } else
  7690. if (M instanceof AST_ObjectSetter) {
  7691. kind = "set";
  7692. }
  7693. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  7694. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  7695. return {
  7696. type: "MethodDefinition",
  7697. computed: false,
  7698. kind: kind,
  7699. static: M.static,
  7700. key: {
  7701. type: "PrivateIdentifier",
  7702. name: M.key.name
  7703. },
  7704. value: to_moz(M.value)
  7705. };
  7706. }
  7707. if (M instanceof AST_ClassPrivateProperty) {
  7708. return {
  7709. type: "PropertyDefinition",
  7710. key: {
  7711. type: "PrivateIdentifier",
  7712. name: M.key.name
  7713. },
  7714. value: to_moz(M.value),
  7715. computed: false,
  7716. static: M.static
  7717. };
  7718. }
  7719. if (M instanceof AST_ClassProperty) {
  7720. return {
  7721. type: "PropertyDefinition",
  7722. key,
  7723. value: to_moz(M.value),
  7724. computed,
  7725. static: M.static
  7726. };
  7727. }
  7728. if (parent instanceof AST_Class) {
  7729. return {
  7730. type: "MethodDefinition",
  7731. computed: computed,
  7732. kind: kind,
  7733. static: M.static,
  7734. key: to_moz(M.key),
  7735. value: to_moz(M.value)
  7736. };
  7737. }
  7738. return {
  7739. type: "Property",
  7740. computed: computed,
  7741. kind: kind,
  7742. key: key,
  7743. value: to_moz(M.value)
  7744. };
  7745. });
  7746. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  7747. if (parent instanceof AST_Object) {
  7748. return {
  7749. type: "Property",
  7750. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7751. kind: "init",
  7752. method: true,
  7753. shorthand: false,
  7754. key: to_moz(M.key),
  7755. value: to_moz(M.value)
  7756. };
  7757. }
  7758. const key = M instanceof AST_PrivateMethod
  7759. ? {
  7760. type: "PrivateIdentifier",
  7761. name: M.key.name
  7762. }
  7763. : to_moz(M.key);
  7764. return {
  7765. type: "MethodDefinition",
  7766. kind: M.key === "constructor" ? "constructor" : "method",
  7767. key,
  7768. value: to_moz(M.value),
  7769. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7770. static: M.static,
  7771. };
  7772. });
  7773. def_to_moz(AST_Class, function To_Moz_Class(M) {
  7774. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  7775. return {
  7776. type: type,
  7777. superClass: to_moz(M.extends),
  7778. id: M.name ? to_moz(M.name) : null,
  7779. body: {
  7780. type: "ClassBody",
  7781. body: M.properties.map(to_moz)
  7782. }
  7783. };
  7784. });
  7785. def_to_moz(AST_ClassStaticBlock, function To_Moz_StaticBlock(M) {
  7786. return {
  7787. type: "StaticBlock",
  7788. body: M.body.map(to_moz),
  7789. };
  7790. });
  7791. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  7792. return {
  7793. type: "MetaProperty",
  7794. meta: {
  7795. type: "Identifier",
  7796. name: "new"
  7797. },
  7798. property: {
  7799. type: "Identifier",
  7800. name: "target"
  7801. }
  7802. };
  7803. });
  7804. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  7805. if (
  7806. (M instanceof AST_SymbolMethod && parent.quote) ||
  7807. ((
  7808. M instanceof AST_SymbolImportForeign ||
  7809. M instanceof AST_SymbolExportForeign ||
  7810. M instanceof AST_SymbolExport
  7811. ) && M.quote)
  7812. ) {
  7813. return {
  7814. type: "Literal",
  7815. value: M.name
  7816. };
  7817. }
  7818. var def = M.definition();
  7819. return {
  7820. type: "Identifier",
  7821. name: def ? def.mangled_name || def.name : M.name
  7822. };
  7823. });
  7824. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  7825. const pattern = M.value.source;
  7826. const flags = M.value.flags;
  7827. return {
  7828. type: "Literal",
  7829. value: null,
  7830. raw: M.print_to_string(),
  7831. regex: { pattern, flags }
  7832. };
  7833. });
  7834. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  7835. var value = M.value;
  7836. return {
  7837. type: "Literal",
  7838. value: value,
  7839. raw: M.raw || M.print_to_string()
  7840. };
  7841. });
  7842. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  7843. return {
  7844. type: "Identifier",
  7845. name: String(M.value)
  7846. };
  7847. });
  7848. def_to_moz(AST_BigInt, M => ({
  7849. type: "BigIntLiteral",
  7850. value: M.value
  7851. }));
  7852. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7853. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7854. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  7855. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  7856. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  7857. /* -----[ tools ]----- */
  7858. function my_start_token(moznode) {
  7859. var loc = moznode.loc, start = loc && loc.start;
  7860. var range = moznode.range;
  7861. return new AST_Token(
  7862. "",
  7863. "",
  7864. start && start.line || 0,
  7865. start && start.column || 0,
  7866. range ? range [0] : moznode.start,
  7867. false,
  7868. [],
  7869. [],
  7870. loc && loc.source,
  7871. );
  7872. }
  7873. function my_end_token(moznode) {
  7874. var loc = moznode.loc, end = loc && loc.end;
  7875. var range = moznode.range;
  7876. return new AST_Token(
  7877. "",
  7878. "",
  7879. end && end.line || 0,
  7880. end && end.column || 0,
  7881. range ? range [0] : moznode.end,
  7882. false,
  7883. [],
  7884. [],
  7885. loc && loc.source,
  7886. );
  7887. }
  7888. var FROM_MOZ_STACK = null;
  7889. function from_moz(node) {
  7890. FROM_MOZ_STACK.push(node);
  7891. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  7892. FROM_MOZ_STACK.pop();
  7893. return ret;
  7894. }
  7895. AST_Node.from_mozilla_ast = function(node) {
  7896. var save_stack = FROM_MOZ_STACK;
  7897. FROM_MOZ_STACK = [];
  7898. var ast = from_moz(node);
  7899. FROM_MOZ_STACK = save_stack;
  7900. return ast;
  7901. };
  7902. function set_moz_loc(mynode, moznode) {
  7903. var start = mynode.start;
  7904. var end = mynode.end;
  7905. if (!(start && end)) {
  7906. return moznode;
  7907. }
  7908. if (start.pos != null && end.endpos != null) {
  7909. moznode.range = [start.pos, end.endpos];
  7910. }
  7911. if (start.line) {
  7912. moznode.loc = {
  7913. start: {line: start.line, column: start.col},
  7914. end: end.endline ? {line: end.endline, column: end.endcol} : null
  7915. };
  7916. if (start.file) {
  7917. moznode.loc.source = start.file;
  7918. }
  7919. }
  7920. return moznode;
  7921. }
  7922. function def_to_moz(mytype, handler) {
  7923. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  7924. return set_moz_loc(this, handler(this, parent));
  7925. });
  7926. }
  7927. var TO_MOZ_STACK = null;
  7928. function to_moz(node) {
  7929. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  7930. TO_MOZ_STACK.push(node);
  7931. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  7932. TO_MOZ_STACK.pop();
  7933. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  7934. return ast;
  7935. }
  7936. function to_moz_in_destructuring() {
  7937. var i = TO_MOZ_STACK.length;
  7938. while (i--) {
  7939. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  7940. return true;
  7941. }
  7942. }
  7943. return false;
  7944. }
  7945. function to_moz_block(node) {
  7946. return {
  7947. type: "BlockStatement",
  7948. body: node.body.map(to_moz)
  7949. };
  7950. }
  7951. function to_moz_scope(type, node) {
  7952. var body = node.body.map(to_moz);
  7953. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  7954. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  7955. }
  7956. return {
  7957. type: type,
  7958. body: body
  7959. };
  7960. }
  7961. })();
  7962. // return true if the node at the top of the stack (that means the
  7963. // innermost node in the current output) is lexically the first in
  7964. // a statement.
  7965. function first_in_statement(stack) {
  7966. let node = stack.parent(-1);
  7967. for (let i = 0, p; p = stack.parent(i); i++) {
  7968. if (p instanceof AST_Statement && p.body === node)
  7969. return true;
  7970. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  7971. (p.TYPE === "Call" && p.expression === node) ||
  7972. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  7973. (p instanceof AST_Dot && p.expression === node) ||
  7974. (p instanceof AST_Sub && p.expression === node) ||
  7975. (p instanceof AST_Chain && p.expression === node) ||
  7976. (p instanceof AST_Conditional && p.condition === node) ||
  7977. (p instanceof AST_Binary && p.left === node) ||
  7978. (p instanceof AST_UnaryPostfix && p.expression === node)
  7979. ) {
  7980. node = p;
  7981. } else {
  7982. return false;
  7983. }
  7984. }
  7985. }
  7986. // Returns whether the leftmost item in the expression is an object
  7987. function left_is_object(node) {
  7988. if (node instanceof AST_Object) return true;
  7989. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  7990. if (node.TYPE === "Call") return left_is_object(node.expression);
  7991. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  7992. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  7993. if (node instanceof AST_Chain) return left_is_object(node.expression);
  7994. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  7995. if (node instanceof AST_Binary) return left_is_object(node.left);
  7996. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  7997. return false;
  7998. }
  7999. /***********************************************************************
  8000. A JavaScript tokenizer / parser / beautifier / compressor.
  8001. https://github.com/mishoo/UglifyJS2
  8002. -------------------------------- (C) ---------------------------------
  8003. Author: Mihai Bazon
  8004. <mihai.bazon@gmail.com>
  8005. http://mihai.bazon.net/blog
  8006. Distributed under the BSD license:
  8007. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8008. Redistribution and use in source and binary forms, with or without
  8009. modification, are permitted provided that the following conditions
  8010. are met:
  8011. * Redistributions of source code must retain the above
  8012. copyright notice, this list of conditions and the following
  8013. disclaimer.
  8014. * Redistributions in binary form must reproduce the above
  8015. copyright notice, this list of conditions and the following
  8016. disclaimer in the documentation and/or other materials
  8017. provided with the distribution.
  8018. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8019. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8020. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8021. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8022. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8023. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8024. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8025. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8026. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8027. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8028. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8029. SUCH DAMAGE.
  8030. ***********************************************************************/
  8031. const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
  8032. const CODE_LINE_BREAK = 10;
  8033. const CODE_SPACE = 32;
  8034. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/g;
  8035. function is_some_comments(comment) {
  8036. // multiline comment
  8037. return (
  8038. (comment.type === "comment2" || comment.type === "comment1")
  8039. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  8040. );
  8041. }
  8042. class Rope {
  8043. constructor() {
  8044. this.committed = "";
  8045. this.current = "";
  8046. }
  8047. append(str) {
  8048. this.current += str;
  8049. }
  8050. insertAt(char, index) {
  8051. const { committed, current } = this;
  8052. if (index < committed.length) {
  8053. this.committed = committed.slice(0, index) + char + committed.slice(index);
  8054. } else if (index === committed.length) {
  8055. this.committed += char;
  8056. } else {
  8057. index -= committed.length;
  8058. this.committed += current.slice(0, index) + char;
  8059. this.current = current.slice(index);
  8060. }
  8061. }
  8062. charAt(index) {
  8063. const { committed } = this;
  8064. if (index < committed.length) return committed[index];
  8065. return this.current[index - committed.length];
  8066. }
  8067. curLength() {
  8068. return this.current.length;
  8069. }
  8070. length() {
  8071. return this.committed.length + this.current.length;
  8072. }
  8073. toString() {
  8074. return this.committed + this.current;
  8075. }
  8076. }
  8077. function OutputStream(options) {
  8078. var readonly = !options;
  8079. options = defaults(options, {
  8080. ascii_only : false,
  8081. beautify : false,
  8082. braces : false,
  8083. comments : "some",
  8084. ecma : 5,
  8085. ie8 : false,
  8086. indent_level : 4,
  8087. indent_start : 0,
  8088. inline_script : true,
  8089. keep_numbers : false,
  8090. keep_quoted_props : false,
  8091. max_line_len : false,
  8092. preamble : null,
  8093. preserve_annotations : false,
  8094. quote_keys : false,
  8095. quote_style : 0,
  8096. safari10 : false,
  8097. semicolons : true,
  8098. shebang : true,
  8099. shorthand : undefined,
  8100. source_map : null,
  8101. webkit : false,
  8102. width : 80,
  8103. wrap_iife : false,
  8104. wrap_func_args : true,
  8105. _destroy_ast : false
  8106. }, true);
  8107. if (options.shorthand === undefined)
  8108. options.shorthand = options.ecma > 5;
  8109. // Convert comment option to RegExp if necessary and set up comments filter
  8110. var comment_filter = return_false; // Default case, throw all comments away
  8111. if (options.comments) {
  8112. let comments = options.comments;
  8113. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  8114. var regex_pos = options.comments.lastIndexOf("/");
  8115. comments = new RegExp(
  8116. options.comments.substr(1, regex_pos - 1),
  8117. options.comments.substr(regex_pos + 1)
  8118. );
  8119. }
  8120. if (comments instanceof RegExp) {
  8121. comment_filter = function(comment) {
  8122. return comment.type != "comment5" && comments.test(comment.value);
  8123. };
  8124. } else if (typeof comments === "function") {
  8125. comment_filter = function(comment) {
  8126. return comment.type != "comment5" && comments(this, comment);
  8127. };
  8128. } else if (comments === "some") {
  8129. comment_filter = is_some_comments;
  8130. } else { // NOTE includes "all" option
  8131. comment_filter = return_true;
  8132. }
  8133. }
  8134. var indentation = 0;
  8135. var current_col = 0;
  8136. var current_line = 1;
  8137. var current_pos = 0;
  8138. var OUTPUT = new Rope();
  8139. let printed_comments = new Set();
  8140. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  8141. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  8142. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  8143. var code = get_full_char_code(ch, 0).toString(16);
  8144. return "\\u{" + code + "}";
  8145. });
  8146. }
  8147. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  8148. var code = ch.charCodeAt(0).toString(16);
  8149. if (code.length <= 2 && !identifier) {
  8150. while (code.length < 2) code = "0" + code;
  8151. return "\\x" + code;
  8152. } else {
  8153. while (code.length < 4) code = "0" + code;
  8154. return "\\u" + code;
  8155. }
  8156. });
  8157. } : function(str) {
  8158. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  8159. if (lone) {
  8160. return "\\u" + lone.charCodeAt(0).toString(16);
  8161. }
  8162. return match;
  8163. });
  8164. };
  8165. function make_string(str, quote) {
  8166. var dq = 0, sq = 0;
  8167. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  8168. function(s, i) {
  8169. switch (s) {
  8170. case '"': ++dq; return '"';
  8171. case "'": ++sq; return "'";
  8172. case "\\": return "\\\\";
  8173. case "\n": return "\\n";
  8174. case "\r": return "\\r";
  8175. case "\t": return "\\t";
  8176. case "\b": return "\\b";
  8177. case "\f": return "\\f";
  8178. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  8179. case "\u2028": return "\\u2028";
  8180. case "\u2029": return "\\u2029";
  8181. case "\ufeff": return "\\ufeff";
  8182. case "\0":
  8183. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  8184. }
  8185. return s;
  8186. });
  8187. function quote_single() {
  8188. return "'" + str.replace(/\x27/g, "\\'") + "'";
  8189. }
  8190. function quote_double() {
  8191. return '"' + str.replace(/\x22/g, '\\"') + '"';
  8192. }
  8193. function quote_template() {
  8194. return "`" + str.replace(/`/g, "\\`") + "`";
  8195. }
  8196. str = to_utf8(str);
  8197. if (quote === "`") return quote_template();
  8198. switch (options.quote_style) {
  8199. case 1:
  8200. return quote_single();
  8201. case 2:
  8202. return quote_double();
  8203. case 3:
  8204. return quote == "'" ? quote_single() : quote_double();
  8205. default:
  8206. return dq > sq ? quote_single() : quote_double();
  8207. }
  8208. }
  8209. function encode_string(str, quote) {
  8210. var ret = make_string(str, quote);
  8211. if (options.inline_script) {
  8212. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  8213. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  8214. ret = ret.replace(/--\x3e/g, "--\\x3e");
  8215. }
  8216. return ret;
  8217. }
  8218. function make_name(name) {
  8219. name = name.toString();
  8220. name = to_utf8(name, true);
  8221. return name;
  8222. }
  8223. function make_indent(back) {
  8224. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  8225. }
  8226. /* -----[ beautification/minification ]----- */
  8227. var has_parens = false;
  8228. var might_need_space = false;
  8229. var might_need_semicolon = false;
  8230. var might_add_newline = 0;
  8231. var need_newline_indented = false;
  8232. var need_space = false;
  8233. var newline_insert = -1;
  8234. var last = "";
  8235. var mapping_token, mapping_name, mappings = options.source_map && [];
  8236. var do_add_mapping = mappings ? function() {
  8237. mappings.forEach(function(mapping) {
  8238. try {
  8239. let { name, token } = mapping;
  8240. if (name !== false) {
  8241. if (token.type == "name" || token.type === "privatename") {
  8242. name = token.value;
  8243. } else if (name instanceof AST_Symbol) {
  8244. name = token.type === "string" ? token.value : name.name;
  8245. }
  8246. }
  8247. options.source_map.add(
  8248. mapping.token.file,
  8249. mapping.line, mapping.col,
  8250. mapping.token.line, mapping.token.col,
  8251. is_basic_identifier_string(name) ? name : undefined
  8252. );
  8253. } catch(ex) {
  8254. // Ignore bad mapping
  8255. }
  8256. });
  8257. mappings = [];
  8258. } : noop;
  8259. var ensure_line_len = options.max_line_len ? function() {
  8260. if (current_col > options.max_line_len) {
  8261. if (might_add_newline) {
  8262. OUTPUT.insertAt("\n", might_add_newline);
  8263. const curLength = OUTPUT.curLength();
  8264. if (mappings) {
  8265. var delta = curLength - current_col;
  8266. mappings.forEach(function(mapping) {
  8267. mapping.line++;
  8268. mapping.col += delta;
  8269. });
  8270. }
  8271. current_line++;
  8272. current_pos++;
  8273. current_col = curLength;
  8274. }
  8275. }
  8276. if (might_add_newline) {
  8277. might_add_newline = 0;
  8278. do_add_mapping();
  8279. }
  8280. } : noop;
  8281. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  8282. function print(str) {
  8283. str = String(str);
  8284. var ch = get_full_char(str, 0);
  8285. if (need_newline_indented && ch) {
  8286. need_newline_indented = false;
  8287. if (ch !== "\n") {
  8288. print("\n");
  8289. indent();
  8290. }
  8291. }
  8292. if (need_space && ch) {
  8293. need_space = false;
  8294. if (!/[\s;})]/.test(ch)) {
  8295. space();
  8296. }
  8297. }
  8298. newline_insert = -1;
  8299. var prev = last.charAt(last.length - 1);
  8300. if (might_need_semicolon) {
  8301. might_need_semicolon = false;
  8302. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  8303. if (options.semicolons || requireSemicolonChars.has(ch)) {
  8304. OUTPUT.append(";");
  8305. current_col++;
  8306. current_pos++;
  8307. } else {
  8308. ensure_line_len();
  8309. if (current_col > 0) {
  8310. OUTPUT.append("\n");
  8311. current_pos++;
  8312. current_line++;
  8313. current_col = 0;
  8314. }
  8315. if (/^\s+$/.test(str)) {
  8316. // reset the semicolon flag, since we didn't print one
  8317. // now and might still have to later
  8318. might_need_semicolon = true;
  8319. }
  8320. }
  8321. if (!options.beautify)
  8322. might_need_space = false;
  8323. }
  8324. }
  8325. if (might_need_space) {
  8326. if ((is_identifier_char(prev)
  8327. && (is_identifier_char(ch) || ch == "\\"))
  8328. || (ch == "/" && ch == prev)
  8329. || ((ch == "+" || ch == "-") && ch == last)
  8330. ) {
  8331. OUTPUT.append(" ");
  8332. current_col++;
  8333. current_pos++;
  8334. }
  8335. might_need_space = false;
  8336. }
  8337. if (mapping_token) {
  8338. mappings.push({
  8339. token: mapping_token,
  8340. name: mapping_name,
  8341. line: current_line,
  8342. col: current_col
  8343. });
  8344. mapping_token = false;
  8345. if (!might_add_newline) do_add_mapping();
  8346. }
  8347. OUTPUT.append(str);
  8348. has_parens = str[str.length - 1] == "(";
  8349. current_pos += str.length;
  8350. var a = str.split(/\r?\n/), n = a.length - 1;
  8351. current_line += n;
  8352. current_col += a[0].length;
  8353. if (n > 0) {
  8354. ensure_line_len();
  8355. current_col = a[n].length;
  8356. }
  8357. last = str;
  8358. }
  8359. var star = function() {
  8360. print("*");
  8361. };
  8362. var space = options.beautify ? function() {
  8363. print(" ");
  8364. } : function() {
  8365. might_need_space = true;
  8366. };
  8367. var indent = options.beautify ? function(half) {
  8368. if (options.beautify) {
  8369. print(make_indent(half ? 0.5 : 0));
  8370. }
  8371. } : noop;
  8372. var with_indent = options.beautify ? function(col, cont) {
  8373. if (col === true) col = next_indent();
  8374. var save_indentation = indentation;
  8375. indentation = col;
  8376. var ret = cont();
  8377. indentation = save_indentation;
  8378. return ret;
  8379. } : function(col, cont) { return cont(); };
  8380. var newline = options.beautify ? function() {
  8381. if (newline_insert < 0) return print("\n");
  8382. if (OUTPUT.charAt(newline_insert) != "\n") {
  8383. OUTPUT.insertAt("\n", newline_insert);
  8384. current_pos++;
  8385. current_line++;
  8386. }
  8387. newline_insert++;
  8388. } : options.max_line_len ? function() {
  8389. ensure_line_len();
  8390. might_add_newline = OUTPUT.length();
  8391. } : noop;
  8392. var semicolon = options.beautify ? function() {
  8393. print(";");
  8394. } : function() {
  8395. might_need_semicolon = true;
  8396. };
  8397. function force_semicolon() {
  8398. might_need_semicolon = false;
  8399. print(";");
  8400. }
  8401. function next_indent() {
  8402. return indentation + options.indent_level;
  8403. }
  8404. function with_block(cont) {
  8405. var ret;
  8406. print("{");
  8407. newline();
  8408. with_indent(next_indent(), function() {
  8409. ret = cont();
  8410. });
  8411. indent();
  8412. print("}");
  8413. return ret;
  8414. }
  8415. function with_parens(cont) {
  8416. print("(");
  8417. //XXX: still nice to have that for argument lists
  8418. //var ret = with_indent(current_col, cont);
  8419. var ret = cont();
  8420. print(")");
  8421. return ret;
  8422. }
  8423. function with_square(cont) {
  8424. print("[");
  8425. //var ret = with_indent(current_col, cont);
  8426. var ret = cont();
  8427. print("]");
  8428. return ret;
  8429. }
  8430. function comma() {
  8431. print(",");
  8432. space();
  8433. }
  8434. function colon() {
  8435. print(":");
  8436. space();
  8437. }
  8438. var add_mapping = mappings ? function(token, name) {
  8439. mapping_token = token;
  8440. mapping_name = name;
  8441. } : noop;
  8442. function get() {
  8443. if (might_add_newline) {
  8444. ensure_line_len();
  8445. }
  8446. return OUTPUT.toString();
  8447. }
  8448. function has_nlb() {
  8449. const output = OUTPUT.toString();
  8450. let n = output.length - 1;
  8451. while (n >= 0) {
  8452. const code = output.charCodeAt(n);
  8453. if (code === CODE_LINE_BREAK) {
  8454. return true;
  8455. }
  8456. if (code !== CODE_SPACE) {
  8457. return false;
  8458. }
  8459. n--;
  8460. }
  8461. return true;
  8462. }
  8463. function filter_comment(comment) {
  8464. if (!options.preserve_annotations) {
  8465. comment = comment.replace(r_annotation, " ");
  8466. }
  8467. if (/^\s*$/.test(comment)) {
  8468. return "";
  8469. }
  8470. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  8471. }
  8472. function prepend_comments(node) {
  8473. var self = this;
  8474. var start = node.start;
  8475. if (!start) return;
  8476. var printed_comments = self.printed_comments;
  8477. // There cannot be a newline between return/yield and its value.
  8478. const keyword_with_value =
  8479. node instanceof AST_Exit && node.value
  8480. || (node instanceof AST_Await || node instanceof AST_Yield)
  8481. && node.expression;
  8482. if (
  8483. start.comments_before
  8484. && printed_comments.has(start.comments_before)
  8485. ) {
  8486. if (keyword_with_value) {
  8487. start.comments_before = [];
  8488. } else {
  8489. return;
  8490. }
  8491. }
  8492. var comments = start.comments_before;
  8493. if (!comments) {
  8494. comments = start.comments_before = [];
  8495. }
  8496. printed_comments.add(comments);
  8497. if (keyword_with_value) {
  8498. var tw = new TreeWalker(function(node) {
  8499. var parent = tw.parent();
  8500. if (parent instanceof AST_Exit
  8501. || parent instanceof AST_Await
  8502. || parent instanceof AST_Yield
  8503. || parent instanceof AST_Binary && parent.left === node
  8504. || parent.TYPE == "Call" && parent.expression === node
  8505. || parent instanceof AST_Conditional && parent.condition === node
  8506. || parent instanceof AST_Dot && parent.expression === node
  8507. || parent instanceof AST_Sequence && parent.expressions[0] === node
  8508. || parent instanceof AST_Sub && parent.expression === node
  8509. || parent instanceof AST_UnaryPostfix) {
  8510. if (!node.start) return;
  8511. var text = node.start.comments_before;
  8512. if (text && !printed_comments.has(text)) {
  8513. printed_comments.add(text);
  8514. comments = comments.concat(text);
  8515. }
  8516. } else {
  8517. return true;
  8518. }
  8519. });
  8520. tw.push(node);
  8521. keyword_with_value.walk(tw);
  8522. }
  8523. if (current_pos == 0) {
  8524. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  8525. && !printed_comments.has(comments[0])) {
  8526. print("#!" + comments.shift().value + "\n");
  8527. indent();
  8528. }
  8529. var preamble = options.preamble;
  8530. if (preamble) {
  8531. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  8532. }
  8533. }
  8534. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  8535. if (comments.length == 0) return;
  8536. var last_nlb = has_nlb();
  8537. comments.forEach(function(c, i) {
  8538. printed_comments.add(c);
  8539. if (!last_nlb) {
  8540. if (c.nlb) {
  8541. print("\n");
  8542. indent();
  8543. last_nlb = true;
  8544. } else if (i > 0) {
  8545. space();
  8546. }
  8547. }
  8548. if (/comment[134]/.test(c.type)) {
  8549. var value = filter_comment(c.value);
  8550. if (value) {
  8551. print("//" + value + "\n");
  8552. indent();
  8553. }
  8554. last_nlb = true;
  8555. } else if (c.type == "comment2") {
  8556. var value = filter_comment(c.value);
  8557. if (value) {
  8558. print("/*" + value + "*/");
  8559. }
  8560. last_nlb = false;
  8561. }
  8562. });
  8563. if (!last_nlb) {
  8564. if (start.nlb) {
  8565. print("\n");
  8566. indent();
  8567. } else {
  8568. space();
  8569. }
  8570. }
  8571. }
  8572. function append_comments(node, tail) {
  8573. var self = this;
  8574. var token = node.end;
  8575. if (!token) return;
  8576. var printed_comments = self.printed_comments;
  8577. var comments = token[tail ? "comments_before" : "comments_after"];
  8578. if (!comments || printed_comments.has(comments)) return;
  8579. if (!(node instanceof AST_Statement || comments.every((c) =>
  8580. !/comment[134]/.test(c.type)
  8581. ))) return;
  8582. printed_comments.add(comments);
  8583. var insert = OUTPUT.length();
  8584. comments.filter(comment_filter, node).forEach(function(c, i) {
  8585. if (printed_comments.has(c)) return;
  8586. printed_comments.add(c);
  8587. need_space = false;
  8588. if (need_newline_indented) {
  8589. print("\n");
  8590. indent();
  8591. need_newline_indented = false;
  8592. } else if (c.nlb && (i > 0 || !has_nlb())) {
  8593. print("\n");
  8594. indent();
  8595. } else if (i > 0 || !tail) {
  8596. space();
  8597. }
  8598. if (/comment[134]/.test(c.type)) {
  8599. const value = filter_comment(c.value);
  8600. if (value) {
  8601. print("//" + value);
  8602. }
  8603. need_newline_indented = true;
  8604. } else if (c.type == "comment2") {
  8605. const value = filter_comment(c.value);
  8606. if (value) {
  8607. print("/*" + value + "*/");
  8608. }
  8609. need_space = true;
  8610. }
  8611. });
  8612. if (OUTPUT.length() > insert) newline_insert = insert;
  8613. }
  8614. /**
  8615. * When output.option("_destroy_ast") is enabled, destroy the function.
  8616. * Call this after printing it.
  8617. */
  8618. const gc_scope =
  8619. options["_destroy_ast"]
  8620. ? function gc_scope(scope) {
  8621. scope.body.length = 0;
  8622. scope.argnames.length = 0;
  8623. }
  8624. : noop;
  8625. var stack = [];
  8626. return {
  8627. get : get,
  8628. toString : get,
  8629. indent : indent,
  8630. in_directive : false,
  8631. use_asm : null,
  8632. active_scope : null,
  8633. indentation : function() { return indentation; },
  8634. current_width : function() { return current_col - indentation; },
  8635. should_break : function() { return options.width && this.current_width() >= options.width; },
  8636. has_parens : function() { return has_parens; },
  8637. newline : newline,
  8638. print : print,
  8639. star : star,
  8640. space : space,
  8641. comma : comma,
  8642. colon : colon,
  8643. last : function() { return last; },
  8644. semicolon : semicolon,
  8645. force_semicolon : force_semicolon,
  8646. to_utf8 : to_utf8,
  8647. print_name : function(name) { print(make_name(name)); },
  8648. print_string : function(str, quote, escape_directive) {
  8649. var encoded = encode_string(str, quote);
  8650. if (escape_directive === true && !encoded.includes("\\")) {
  8651. // Insert semicolons to break directive prologue
  8652. if (!EXPECT_DIRECTIVE.test(OUTPUT.toString())) {
  8653. force_semicolon();
  8654. }
  8655. force_semicolon();
  8656. }
  8657. print(encoded);
  8658. },
  8659. print_template_string_chars: function(str) {
  8660. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  8661. return print(encoded.substr(1, encoded.length - 2));
  8662. },
  8663. encode_string : encode_string,
  8664. next_indent : next_indent,
  8665. with_indent : with_indent,
  8666. with_block : with_block,
  8667. with_parens : with_parens,
  8668. with_square : with_square,
  8669. add_mapping : add_mapping,
  8670. option : function(opt) { return options[opt]; },
  8671. gc_scope,
  8672. printed_comments: printed_comments,
  8673. prepend_comments: readonly ? noop : prepend_comments,
  8674. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  8675. line : function() { return current_line; },
  8676. col : function() { return current_col; },
  8677. pos : function() { return current_pos; },
  8678. push_node : function(node) { stack.push(node); },
  8679. pop_node : function() { return stack.pop(); },
  8680. parent : function(n) {
  8681. return stack[stack.length - 2 - (n || 0)];
  8682. }
  8683. };
  8684. }
  8685. /* -----[ code generators ]----- */
  8686. (function() {
  8687. /* -----[ utils ]----- */
  8688. function DEFPRINT(nodetype, generator) {
  8689. nodetype.DEFMETHOD("_codegen", generator);
  8690. }
  8691. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  8692. var self = this, generator = self._codegen;
  8693. if (self instanceof AST_Scope) {
  8694. output.active_scope = self;
  8695. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  8696. output.use_asm = output.active_scope;
  8697. }
  8698. function doit() {
  8699. output.prepend_comments(self);
  8700. self.add_source_map(output);
  8701. generator(self, output);
  8702. output.append_comments(self);
  8703. }
  8704. output.push_node(self);
  8705. if (force_parens || self.needs_parens(output)) {
  8706. output.with_parens(doit);
  8707. } else {
  8708. doit();
  8709. }
  8710. output.pop_node();
  8711. if (self === output.use_asm) {
  8712. output.use_asm = null;
  8713. }
  8714. });
  8715. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  8716. AST_Node.DEFMETHOD("print_to_string", function(options) {
  8717. var output = OutputStream(options);
  8718. this.print(output);
  8719. return output.get();
  8720. });
  8721. /* -----[ PARENTHESES ]----- */
  8722. function PARENS(nodetype, func) {
  8723. if (Array.isArray(nodetype)) {
  8724. nodetype.forEach(function(nodetype) {
  8725. PARENS(nodetype, func);
  8726. });
  8727. } else {
  8728. nodetype.DEFMETHOD("needs_parens", func);
  8729. }
  8730. }
  8731. PARENS(AST_Node, return_false);
  8732. // a function expression needs parens around it when it's provably
  8733. // the first token to appear in a statement.
  8734. PARENS(AST_Function, function(output) {
  8735. if (!output.has_parens() && first_in_statement(output)) {
  8736. return true;
  8737. }
  8738. if (output.option("webkit")) {
  8739. var p = output.parent();
  8740. if (p instanceof AST_PropAccess && p.expression === this) {
  8741. return true;
  8742. }
  8743. }
  8744. if (output.option("wrap_iife")) {
  8745. var p = output.parent();
  8746. if (p instanceof AST_Call && p.expression === this) {
  8747. return true;
  8748. }
  8749. }
  8750. if (output.option("wrap_func_args")) {
  8751. var p = output.parent();
  8752. if (p instanceof AST_Call && p.args.includes(this)) {
  8753. return true;
  8754. }
  8755. }
  8756. return false;
  8757. });
  8758. PARENS(AST_Arrow, function(output) {
  8759. var p = output.parent();
  8760. if (
  8761. output.option("wrap_func_args")
  8762. && p instanceof AST_Call
  8763. && p.args.includes(this)
  8764. ) {
  8765. return true;
  8766. }
  8767. return p instanceof AST_PropAccess && p.expression === this;
  8768. });
  8769. // same goes for an object literal (as in AST_Function), because
  8770. // otherwise {...} would be interpreted as a block of code.
  8771. PARENS(AST_Object, function(output) {
  8772. return !output.has_parens() && first_in_statement(output);
  8773. });
  8774. PARENS(AST_ClassExpression, first_in_statement);
  8775. PARENS(AST_Unary, function(output) {
  8776. var p = output.parent();
  8777. return p instanceof AST_PropAccess && p.expression === this
  8778. || p instanceof AST_Call && p.expression === this
  8779. || p instanceof AST_Binary
  8780. && p.operator === "**"
  8781. && this instanceof AST_UnaryPrefix
  8782. && p.left === this
  8783. && this.operator !== "++"
  8784. && this.operator !== "--";
  8785. });
  8786. PARENS(AST_Await, function(output) {
  8787. var p = output.parent();
  8788. return p instanceof AST_PropAccess && p.expression === this
  8789. || p instanceof AST_Call && p.expression === this
  8790. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  8791. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  8792. });
  8793. PARENS(AST_Sequence, function(output) {
  8794. var p = output.parent();
  8795. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  8796. || p instanceof AST_Unary // !(foo, bar, baz)
  8797. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  8798. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  8799. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  8800. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  8801. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  8802. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  8803. * ==> 20 (side effect, set a := 10 and b := 20) */
  8804. || p instanceof AST_Arrow // x => (x, x)
  8805. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  8806. || p instanceof AST_Expansion // [...(a, b)]
  8807. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  8808. || p instanceof AST_Yield // yield (foo, bar)
  8809. || p instanceof AST_Export // export default (foo, bar)
  8810. ;
  8811. });
  8812. PARENS(AST_Binary, function(output) {
  8813. var p = output.parent();
  8814. // (foo && bar)()
  8815. if (p instanceof AST_Call && p.expression === this)
  8816. return true;
  8817. // typeof (foo && bar)
  8818. if (p instanceof AST_Unary)
  8819. return true;
  8820. // (foo && bar)["prop"], (foo && bar).prop
  8821. if (p instanceof AST_PropAccess && p.expression === this)
  8822. return true;
  8823. // this deals with precedence: 3 * (2 + 1)
  8824. if (p instanceof AST_Binary) {
  8825. const po = p.operator;
  8826. const so = this.operator;
  8827. if (so === "??" && (po === "||" || po === "&&")) {
  8828. return true;
  8829. }
  8830. if (po === "??" && (so === "||" || so === "&&")) {
  8831. return true;
  8832. }
  8833. const pp = PRECEDENCE[po];
  8834. const sp = PRECEDENCE[so];
  8835. if (pp > sp
  8836. || (pp == sp
  8837. && (this === p.right || po == "**"))) {
  8838. return true;
  8839. }
  8840. }
  8841. });
  8842. PARENS(AST_Yield, function(output) {
  8843. var p = output.parent();
  8844. // (yield 1) + (yield 2)
  8845. // a = yield 3
  8846. if (p instanceof AST_Binary && p.operator !== "=")
  8847. return true;
  8848. // (yield 1)()
  8849. // new (yield 1)()
  8850. if (p instanceof AST_Call && p.expression === this)
  8851. return true;
  8852. // (yield 1) ? yield 2 : yield 3
  8853. if (p instanceof AST_Conditional && p.condition === this)
  8854. return true;
  8855. // -(yield 4)
  8856. if (p instanceof AST_Unary)
  8857. return true;
  8858. // (yield x).foo
  8859. // (yield x)['foo']
  8860. if (p instanceof AST_PropAccess && p.expression === this)
  8861. return true;
  8862. });
  8863. PARENS(AST_Chain, function(output) {
  8864. var p = output.parent();
  8865. if (!(p instanceof AST_Call || p instanceof AST_PropAccess)) return false;
  8866. return p.expression === this;
  8867. });
  8868. PARENS(AST_PropAccess, function(output) {
  8869. var p = output.parent();
  8870. if (p instanceof AST_New && p.expression === this) {
  8871. // i.e. new (foo.bar().baz)
  8872. //
  8873. // if there's one call into this subtree, then we need
  8874. // parens around it too, otherwise the call will be
  8875. // interpreted as passing the arguments to the upper New
  8876. // expression.
  8877. return walk(this, node => {
  8878. if (node instanceof AST_Scope) return true;
  8879. if (node instanceof AST_Call) {
  8880. return walk_abort; // makes walk() return true.
  8881. }
  8882. });
  8883. }
  8884. });
  8885. PARENS(AST_Call, function(output) {
  8886. var p = output.parent(), p1;
  8887. if (p instanceof AST_New && p.expression === this
  8888. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  8889. return true;
  8890. // workaround for Safari bug.
  8891. // https://bugs.webkit.org/show_bug.cgi?id=123506
  8892. return this.expression instanceof AST_Function
  8893. && p instanceof AST_PropAccess
  8894. && p.expression === this
  8895. && (p1 = output.parent(1)) instanceof AST_Assign
  8896. && p1.left === p;
  8897. });
  8898. PARENS(AST_New, function(output) {
  8899. var p = output.parent();
  8900. if (this.args.length === 0
  8901. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  8902. || p instanceof AST_Call && p.expression === this
  8903. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  8904. return true;
  8905. });
  8906. PARENS(AST_Number, function(output) {
  8907. var p = output.parent();
  8908. if (p instanceof AST_PropAccess && p.expression === this) {
  8909. var value = this.getValue();
  8910. if (value < 0 || /^0/.test(make_num(value))) {
  8911. return true;
  8912. }
  8913. }
  8914. });
  8915. PARENS(AST_BigInt, function(output) {
  8916. var p = output.parent();
  8917. if (p instanceof AST_PropAccess && p.expression === this) {
  8918. var value = this.getValue();
  8919. if (value.startsWith("-")) {
  8920. return true;
  8921. }
  8922. }
  8923. });
  8924. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  8925. var p = output.parent();
  8926. // !(a = false) → true
  8927. if (p instanceof AST_Unary)
  8928. return true;
  8929. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  8930. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  8931. return true;
  8932. // (a = func)() —or— new (a = Object)()
  8933. if (p instanceof AST_Call && p.expression === this)
  8934. return true;
  8935. // (a = foo) ? bar : baz
  8936. if (p instanceof AST_Conditional && p.condition === this)
  8937. return true;
  8938. // (a = foo)["prop"] —or— (a = foo).prop
  8939. if (p instanceof AST_PropAccess && p.expression === this)
  8940. return true;
  8941. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  8942. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  8943. return true;
  8944. });
  8945. /* -----[ PRINTERS ]----- */
  8946. DEFPRINT(AST_Directive, function(self, output) {
  8947. output.print_string(self.value, self.quote);
  8948. output.semicolon();
  8949. });
  8950. DEFPRINT(AST_Expansion, function (self, output) {
  8951. output.print("...");
  8952. self.expression.print(output);
  8953. });
  8954. DEFPRINT(AST_Destructuring, function (self, output) {
  8955. output.print(self.is_array ? "[" : "{");
  8956. var len = self.names.length;
  8957. self.names.forEach(function (name, i) {
  8958. if (i > 0) output.comma();
  8959. name.print(output);
  8960. // If the final element is a hole, we need to make sure it
  8961. // doesn't look like a trailing comma, by inserting an actual
  8962. // trailing comma.
  8963. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  8964. });
  8965. output.print(self.is_array ? "]" : "}");
  8966. });
  8967. DEFPRINT(AST_Debugger, function(self, output) {
  8968. output.print("debugger");
  8969. output.semicolon();
  8970. });
  8971. /* -----[ statements ]----- */
  8972. function display_body(body, is_toplevel, output, allow_directives) {
  8973. var last = body.length - 1;
  8974. output.in_directive = allow_directives;
  8975. body.forEach(function(stmt, i) {
  8976. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  8977. stmt instanceof AST_EmptyStatement ||
  8978. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  8979. )) {
  8980. output.in_directive = false;
  8981. }
  8982. if (!(stmt instanceof AST_EmptyStatement)) {
  8983. output.indent();
  8984. stmt.print(output);
  8985. if (!(i == last && is_toplevel)) {
  8986. output.newline();
  8987. if (is_toplevel) output.newline();
  8988. }
  8989. }
  8990. if (output.in_directive === true &&
  8991. stmt instanceof AST_SimpleStatement &&
  8992. stmt.body instanceof AST_String
  8993. ) {
  8994. output.in_directive = false;
  8995. }
  8996. });
  8997. output.in_directive = false;
  8998. }
  8999. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  9000. print_maybe_braced_body(this.body, output);
  9001. });
  9002. DEFPRINT(AST_Statement, function(self, output) {
  9003. self.body.print(output);
  9004. output.semicolon();
  9005. });
  9006. DEFPRINT(AST_Toplevel, function(self, output) {
  9007. display_body(self.body, true, output, true);
  9008. output.print("");
  9009. });
  9010. DEFPRINT(AST_LabeledStatement, function(self, output) {
  9011. self.label.print(output);
  9012. output.colon();
  9013. self.body.print(output);
  9014. });
  9015. DEFPRINT(AST_SimpleStatement, function(self, output) {
  9016. self.body.print(output);
  9017. output.semicolon();
  9018. });
  9019. function print_braced_empty(self, output) {
  9020. output.print("{");
  9021. output.with_indent(output.next_indent(), function() {
  9022. output.append_comments(self, true);
  9023. });
  9024. output.add_mapping(self.end);
  9025. output.print("}");
  9026. }
  9027. function print_braced(self, output, allow_directives) {
  9028. if (self.body.length > 0) {
  9029. output.with_block(function() {
  9030. display_body(self.body, false, output, allow_directives);
  9031. output.add_mapping(self.end);
  9032. });
  9033. } else print_braced_empty(self, output);
  9034. }
  9035. DEFPRINT(AST_BlockStatement, function(self, output) {
  9036. print_braced(self, output);
  9037. });
  9038. DEFPRINT(AST_EmptyStatement, function(self, output) {
  9039. output.semicolon();
  9040. });
  9041. DEFPRINT(AST_Do, function(self, output) {
  9042. output.print("do");
  9043. output.space();
  9044. make_block(self.body, output);
  9045. output.space();
  9046. output.print("while");
  9047. output.space();
  9048. output.with_parens(function() {
  9049. self.condition.print(output);
  9050. });
  9051. output.semicolon();
  9052. });
  9053. DEFPRINT(AST_While, function(self, output) {
  9054. output.print("while");
  9055. output.space();
  9056. output.with_parens(function() {
  9057. self.condition.print(output);
  9058. });
  9059. output.space();
  9060. self._do_print_body(output);
  9061. });
  9062. DEFPRINT(AST_For, function(self, output) {
  9063. output.print("for");
  9064. output.space();
  9065. output.with_parens(function() {
  9066. if (self.init) {
  9067. if (self.init instanceof AST_Definitions) {
  9068. self.init.print(output);
  9069. } else {
  9070. parenthesize_for_noin(self.init, output, true);
  9071. }
  9072. output.print(";");
  9073. output.space();
  9074. } else {
  9075. output.print(";");
  9076. }
  9077. if (self.condition) {
  9078. self.condition.print(output);
  9079. output.print(";");
  9080. output.space();
  9081. } else {
  9082. output.print(";");
  9083. }
  9084. if (self.step) {
  9085. self.step.print(output);
  9086. }
  9087. });
  9088. output.space();
  9089. self._do_print_body(output);
  9090. });
  9091. DEFPRINT(AST_ForIn, function(self, output) {
  9092. output.print("for");
  9093. if (self.await) {
  9094. output.space();
  9095. output.print("await");
  9096. }
  9097. output.space();
  9098. output.with_parens(function() {
  9099. self.init.print(output);
  9100. output.space();
  9101. output.print(self instanceof AST_ForOf ? "of" : "in");
  9102. output.space();
  9103. self.object.print(output);
  9104. });
  9105. output.space();
  9106. self._do_print_body(output);
  9107. });
  9108. DEFPRINT(AST_With, function(self, output) {
  9109. output.print("with");
  9110. output.space();
  9111. output.with_parens(function() {
  9112. self.expression.print(output);
  9113. });
  9114. output.space();
  9115. self._do_print_body(output);
  9116. });
  9117. /* -----[ functions ]----- */
  9118. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  9119. var self = this;
  9120. if (!nokeyword) {
  9121. if (self.async) {
  9122. output.print("async");
  9123. output.space();
  9124. }
  9125. output.print("function");
  9126. if (self.is_generator) {
  9127. output.star();
  9128. }
  9129. if (self.name) {
  9130. output.space();
  9131. }
  9132. }
  9133. if (self.name instanceof AST_Symbol) {
  9134. self.name.print(output);
  9135. } else if (nokeyword && self.name instanceof AST_Node) {
  9136. output.with_square(function() {
  9137. self.name.print(output); // Computed method name
  9138. });
  9139. }
  9140. output.with_parens(function() {
  9141. self.argnames.forEach(function(arg, i) {
  9142. if (i) output.comma();
  9143. arg.print(output);
  9144. });
  9145. });
  9146. output.space();
  9147. print_braced(self, output, true);
  9148. });
  9149. DEFPRINT(AST_Lambda, function(self, output) {
  9150. self._do_print(output);
  9151. output.gc_scope(self);
  9152. });
  9153. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  9154. var tag = self.prefix;
  9155. var parenthesize_tag = tag instanceof AST_Lambda
  9156. || tag instanceof AST_Binary
  9157. || tag instanceof AST_Conditional
  9158. || tag instanceof AST_Sequence
  9159. || tag instanceof AST_Unary
  9160. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  9161. if (parenthesize_tag) output.print("(");
  9162. self.prefix.print(output);
  9163. if (parenthesize_tag) output.print(")");
  9164. self.template_string.print(output);
  9165. });
  9166. DEFPRINT(AST_TemplateString, function(self, output) {
  9167. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  9168. output.print("`");
  9169. for (var i = 0; i < self.segments.length; i++) {
  9170. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  9171. output.print("${");
  9172. self.segments[i].print(output);
  9173. output.print("}");
  9174. } else if (is_tagged) {
  9175. output.print(self.segments[i].raw);
  9176. } else {
  9177. output.print_template_string_chars(self.segments[i].value);
  9178. }
  9179. }
  9180. output.print("`");
  9181. });
  9182. DEFPRINT(AST_TemplateSegment, function(self, output) {
  9183. output.print_template_string_chars(self.value);
  9184. });
  9185. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  9186. var self = this;
  9187. var parent = output.parent();
  9188. var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
  9189. parent instanceof AST_Unary ||
  9190. (parent instanceof AST_Call && self === parent.expression);
  9191. if (needs_parens) { output.print("("); }
  9192. if (self.async) {
  9193. output.print("async");
  9194. output.space();
  9195. }
  9196. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  9197. self.argnames[0].print(output);
  9198. } else {
  9199. output.with_parens(function() {
  9200. self.argnames.forEach(function(arg, i) {
  9201. if (i) output.comma();
  9202. arg.print(output);
  9203. });
  9204. });
  9205. }
  9206. output.space();
  9207. output.print("=>");
  9208. output.space();
  9209. const first_statement = self.body[0];
  9210. if (
  9211. self.body.length === 1
  9212. && first_statement instanceof AST_Return
  9213. ) {
  9214. const returned = first_statement.value;
  9215. if (!returned) {
  9216. output.print("{}");
  9217. } else if (left_is_object(returned)) {
  9218. output.print("(");
  9219. returned.print(output);
  9220. output.print(")");
  9221. } else {
  9222. returned.print(output);
  9223. }
  9224. } else {
  9225. print_braced(self, output);
  9226. }
  9227. if (needs_parens) { output.print(")"); }
  9228. output.gc_scope(self);
  9229. });
  9230. /* -----[ exits ]----- */
  9231. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  9232. output.print(kind);
  9233. if (this.value) {
  9234. output.space();
  9235. const comments = this.value.start.comments_before;
  9236. if (comments && comments.length && !output.printed_comments.has(comments)) {
  9237. output.print("(");
  9238. this.value.print(output);
  9239. output.print(")");
  9240. } else {
  9241. this.value.print(output);
  9242. }
  9243. }
  9244. output.semicolon();
  9245. });
  9246. DEFPRINT(AST_Return, function(self, output) {
  9247. self._do_print(output, "return");
  9248. });
  9249. DEFPRINT(AST_Throw, function(self, output) {
  9250. self._do_print(output, "throw");
  9251. });
  9252. /* -----[ yield ]----- */
  9253. DEFPRINT(AST_Yield, function(self, output) {
  9254. var star = self.is_star ? "*" : "";
  9255. output.print("yield" + star);
  9256. if (self.expression) {
  9257. output.space();
  9258. self.expression.print(output);
  9259. }
  9260. });
  9261. DEFPRINT(AST_Await, function(self, output) {
  9262. output.print("await");
  9263. output.space();
  9264. var e = self.expression;
  9265. var parens = !(
  9266. e instanceof AST_Call
  9267. || e instanceof AST_SymbolRef
  9268. || e instanceof AST_PropAccess
  9269. || e instanceof AST_Unary
  9270. || e instanceof AST_Constant
  9271. || e instanceof AST_Await
  9272. || e instanceof AST_Object
  9273. );
  9274. if (parens) output.print("(");
  9275. self.expression.print(output);
  9276. if (parens) output.print(")");
  9277. });
  9278. /* -----[ loop control ]----- */
  9279. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  9280. output.print(kind);
  9281. if (this.label) {
  9282. output.space();
  9283. this.label.print(output);
  9284. }
  9285. output.semicolon();
  9286. });
  9287. DEFPRINT(AST_Break, function(self, output) {
  9288. self._do_print(output, "break");
  9289. });
  9290. DEFPRINT(AST_Continue, function(self, output) {
  9291. self._do_print(output, "continue");
  9292. });
  9293. /* -----[ if ]----- */
  9294. function make_then(self, output) {
  9295. var b = self.body;
  9296. if (output.option("braces")
  9297. || output.option("ie8") && b instanceof AST_Do)
  9298. return make_block(b, output);
  9299. // The squeezer replaces "block"-s that contain only a single
  9300. // statement with the statement itself; technically, the AST
  9301. // is correct, but this can create problems when we output an
  9302. // IF having an ELSE clause where the THEN clause ends in an
  9303. // IF *without* an ELSE block (then the outer ELSE would refer
  9304. // to the inner IF). This function checks for this case and
  9305. // adds the block braces if needed.
  9306. if (!b) return output.force_semicolon();
  9307. while (true) {
  9308. if (b instanceof AST_If) {
  9309. if (!b.alternative) {
  9310. make_block(self.body, output);
  9311. return;
  9312. }
  9313. b = b.alternative;
  9314. } else if (b instanceof AST_StatementWithBody) {
  9315. b = b.body;
  9316. } else break;
  9317. }
  9318. print_maybe_braced_body(self.body, output);
  9319. }
  9320. DEFPRINT(AST_If, function(self, output) {
  9321. output.print("if");
  9322. output.space();
  9323. output.with_parens(function() {
  9324. self.condition.print(output);
  9325. });
  9326. output.space();
  9327. if (self.alternative) {
  9328. make_then(self, output);
  9329. output.space();
  9330. output.print("else");
  9331. output.space();
  9332. if (self.alternative instanceof AST_If)
  9333. self.alternative.print(output);
  9334. else
  9335. print_maybe_braced_body(self.alternative, output);
  9336. } else {
  9337. self._do_print_body(output);
  9338. }
  9339. });
  9340. /* -----[ switch ]----- */
  9341. DEFPRINT(AST_Switch, function(self, output) {
  9342. output.print("switch");
  9343. output.space();
  9344. output.with_parens(function() {
  9345. self.expression.print(output);
  9346. });
  9347. output.space();
  9348. var last = self.body.length - 1;
  9349. if (last < 0) print_braced_empty(self, output);
  9350. else output.with_block(function() {
  9351. self.body.forEach(function(branch, i) {
  9352. output.indent(true);
  9353. branch.print(output);
  9354. if (i < last && branch.body.length > 0)
  9355. output.newline();
  9356. });
  9357. });
  9358. });
  9359. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  9360. output.newline();
  9361. this.body.forEach(function(stmt) {
  9362. output.indent();
  9363. stmt.print(output);
  9364. output.newline();
  9365. });
  9366. });
  9367. DEFPRINT(AST_Default, function(self, output) {
  9368. output.print("default:");
  9369. self._do_print_body(output);
  9370. });
  9371. DEFPRINT(AST_Case, function(self, output) {
  9372. output.print("case");
  9373. output.space();
  9374. self.expression.print(output);
  9375. output.print(":");
  9376. self._do_print_body(output);
  9377. });
  9378. /* -----[ exceptions ]----- */
  9379. DEFPRINT(AST_Try, function(self, output) {
  9380. output.print("try");
  9381. output.space();
  9382. self.body.print(output);
  9383. if (self.bcatch) {
  9384. output.space();
  9385. self.bcatch.print(output);
  9386. }
  9387. if (self.bfinally) {
  9388. output.space();
  9389. self.bfinally.print(output);
  9390. }
  9391. });
  9392. DEFPRINT(AST_TryBlock, function(self, output) {
  9393. print_braced(self, output);
  9394. });
  9395. DEFPRINT(AST_Catch, function(self, output) {
  9396. output.print("catch");
  9397. if (self.argname) {
  9398. output.space();
  9399. output.with_parens(function() {
  9400. self.argname.print(output);
  9401. });
  9402. }
  9403. output.space();
  9404. print_braced(self, output);
  9405. });
  9406. DEFPRINT(AST_Finally, function(self, output) {
  9407. output.print("finally");
  9408. output.space();
  9409. print_braced(self, output);
  9410. });
  9411. /* -----[ var/const ]----- */
  9412. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  9413. output.print(kind);
  9414. output.space();
  9415. this.definitions.forEach(function(def, i) {
  9416. if (i) output.comma();
  9417. def.print(output);
  9418. });
  9419. var p = output.parent();
  9420. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  9421. var output_semicolon = !in_for || p && p.init !== this;
  9422. if (output_semicolon)
  9423. output.semicolon();
  9424. });
  9425. DEFPRINT(AST_Let, function(self, output) {
  9426. self._do_print(output, "let");
  9427. });
  9428. DEFPRINT(AST_Var, function(self, output) {
  9429. self._do_print(output, "var");
  9430. });
  9431. DEFPRINT(AST_Const, function(self, output) {
  9432. self._do_print(output, "const");
  9433. });
  9434. DEFPRINT(AST_Import, function(self, output) {
  9435. output.print("import");
  9436. output.space();
  9437. if (self.imported_name) {
  9438. self.imported_name.print(output);
  9439. }
  9440. if (self.imported_name && self.imported_names) {
  9441. output.print(",");
  9442. output.space();
  9443. }
  9444. if (self.imported_names) {
  9445. if (self.imported_names.length === 1 &&
  9446. self.imported_names[0].foreign_name.name === "*" &&
  9447. !self.imported_names[0].foreign_name.quote) {
  9448. self.imported_names[0].print(output);
  9449. } else {
  9450. output.print("{");
  9451. self.imported_names.forEach(function (name_import, i) {
  9452. output.space();
  9453. name_import.print(output);
  9454. if (i < self.imported_names.length - 1) {
  9455. output.print(",");
  9456. }
  9457. });
  9458. output.space();
  9459. output.print("}");
  9460. }
  9461. }
  9462. if (self.imported_name || self.imported_names) {
  9463. output.space();
  9464. output.print("from");
  9465. output.space();
  9466. }
  9467. self.module_name.print(output);
  9468. if (self.assert_clause) {
  9469. output.print("assert");
  9470. self.assert_clause.print(output);
  9471. }
  9472. output.semicolon();
  9473. });
  9474. DEFPRINT(AST_ImportMeta, function(self, output) {
  9475. output.print("import.meta");
  9476. });
  9477. DEFPRINT(AST_NameMapping, function(self, output) {
  9478. var is_import = output.parent() instanceof AST_Import;
  9479. var definition = self.name.definition();
  9480. var foreign_name = self.foreign_name;
  9481. var names_are_different =
  9482. (definition && definition.mangled_name || self.name.name) !==
  9483. foreign_name.name;
  9484. if (!names_are_different &&
  9485. foreign_name.name === "*" &&
  9486. foreign_name.quote != self.name.quote) {
  9487. // export * as "*"
  9488. names_are_different = true;
  9489. }
  9490. var foreign_name_is_name = foreign_name.quote == null;
  9491. if (names_are_different) {
  9492. if (is_import) {
  9493. if (foreign_name_is_name) {
  9494. output.print(foreign_name.name);
  9495. } else {
  9496. output.print_string(foreign_name.name, foreign_name.quote);
  9497. }
  9498. } else {
  9499. if (self.name.quote == null) {
  9500. self.name.print(output);
  9501. } else {
  9502. output.print_string(self.name.name, self.name.quote);
  9503. }
  9504. }
  9505. output.space();
  9506. output.print("as");
  9507. output.space();
  9508. if (is_import) {
  9509. self.name.print(output);
  9510. } else {
  9511. if (foreign_name_is_name) {
  9512. output.print(foreign_name.name);
  9513. } else {
  9514. output.print_string(foreign_name.name, foreign_name.quote);
  9515. }
  9516. }
  9517. } else {
  9518. if (self.name.quote == null) {
  9519. self.name.print(output);
  9520. } else {
  9521. output.print_string(self.name.name, self.name.quote);
  9522. }
  9523. }
  9524. });
  9525. DEFPRINT(AST_Export, function(self, output) {
  9526. output.print("export");
  9527. output.space();
  9528. if (self.is_default) {
  9529. output.print("default");
  9530. output.space();
  9531. }
  9532. if (self.exported_names) {
  9533. if (self.exported_names.length === 1 &&
  9534. self.exported_names[0].name.name === "*" &&
  9535. !self.exported_names[0].name.quote) {
  9536. self.exported_names[0].print(output);
  9537. } else {
  9538. output.print("{");
  9539. self.exported_names.forEach(function(name_export, i) {
  9540. output.space();
  9541. name_export.print(output);
  9542. if (i < self.exported_names.length - 1) {
  9543. output.print(",");
  9544. }
  9545. });
  9546. output.space();
  9547. output.print("}");
  9548. }
  9549. } else if (self.exported_value) {
  9550. self.exported_value.print(output);
  9551. } else if (self.exported_definition) {
  9552. self.exported_definition.print(output);
  9553. if (self.exported_definition instanceof AST_Definitions) return;
  9554. }
  9555. if (self.module_name) {
  9556. output.space();
  9557. output.print("from");
  9558. output.space();
  9559. self.module_name.print(output);
  9560. }
  9561. if (self.assert_clause) {
  9562. output.print("assert");
  9563. self.assert_clause.print(output);
  9564. }
  9565. if (self.exported_value
  9566. && !(self.exported_value instanceof AST_Defun ||
  9567. self.exported_value instanceof AST_Function ||
  9568. self.exported_value instanceof AST_Class)
  9569. || self.module_name
  9570. || self.exported_names
  9571. ) {
  9572. output.semicolon();
  9573. }
  9574. });
  9575. function parenthesize_for_noin(node, output, noin) {
  9576. var parens = false;
  9577. // need to take some precautions here:
  9578. // https://github.com/mishoo/UglifyJS2/issues/60
  9579. if (noin) {
  9580. parens = walk(node, node => {
  9581. // Don't go into scopes -- except arrow functions:
  9582. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  9583. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  9584. return true;
  9585. }
  9586. if (
  9587. node instanceof AST_Binary && node.operator == "in"
  9588. || node instanceof AST_PrivateIn
  9589. ) {
  9590. return walk_abort; // makes walk() return true
  9591. }
  9592. });
  9593. }
  9594. node.print(output, parens);
  9595. }
  9596. DEFPRINT(AST_VarDef, function(self, output) {
  9597. self.name.print(output);
  9598. if (self.value) {
  9599. output.space();
  9600. output.print("=");
  9601. output.space();
  9602. var p = output.parent(1);
  9603. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  9604. parenthesize_for_noin(self.value, output, noin);
  9605. }
  9606. });
  9607. /* -----[ other expressions ]----- */
  9608. DEFPRINT(AST_Call, function(self, output) {
  9609. self.expression.print(output);
  9610. if (self instanceof AST_New && self.args.length === 0)
  9611. return;
  9612. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  9613. output.add_mapping(self.start);
  9614. }
  9615. if (self.optional) output.print("?.");
  9616. output.with_parens(function() {
  9617. self.args.forEach(function(expr, i) {
  9618. if (i) output.comma();
  9619. expr.print(output);
  9620. });
  9621. });
  9622. });
  9623. DEFPRINT(AST_New, function(self, output) {
  9624. output.print("new");
  9625. output.space();
  9626. AST_Call.prototype._codegen(self, output);
  9627. });
  9628. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  9629. this.expressions.forEach(function(node, index) {
  9630. if (index > 0) {
  9631. output.comma();
  9632. if (output.should_break()) {
  9633. output.newline();
  9634. output.indent();
  9635. }
  9636. }
  9637. node.print(output);
  9638. });
  9639. });
  9640. DEFPRINT(AST_Sequence, function(self, output) {
  9641. self._do_print(output);
  9642. // var p = output.parent();
  9643. // if (p instanceof AST_Statement) {
  9644. // output.with_indent(output.next_indent(), function(){
  9645. // self._do_print(output);
  9646. // });
  9647. // } else {
  9648. // self._do_print(output);
  9649. // }
  9650. });
  9651. DEFPRINT(AST_Dot, function(self, output) {
  9652. var expr = self.expression;
  9653. expr.print(output);
  9654. var prop = self.property;
  9655. var print_computed = ALL_RESERVED_WORDS.has(prop)
  9656. ? output.option("ie8")
  9657. : !is_identifier_string(
  9658. prop,
  9659. output.option("ecma") >= 2015 && !output.option("safari10")
  9660. );
  9661. if (self.optional) output.print("?.");
  9662. if (print_computed) {
  9663. output.print("[");
  9664. output.add_mapping(self.end);
  9665. output.print_string(prop);
  9666. output.print("]");
  9667. } else {
  9668. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  9669. if (!/[xa-f.)]/i.test(output.last())) {
  9670. output.print(".");
  9671. }
  9672. }
  9673. if (!self.optional) output.print(".");
  9674. // the name after dot would be mapped about here.
  9675. output.add_mapping(self.end);
  9676. output.print_name(prop);
  9677. }
  9678. });
  9679. DEFPRINT(AST_DotHash, function(self, output) {
  9680. var expr = self.expression;
  9681. expr.print(output);
  9682. var prop = self.property;
  9683. if (self.optional) output.print("?");
  9684. output.print(".#");
  9685. output.add_mapping(self.end);
  9686. output.print_name(prop);
  9687. });
  9688. DEFPRINT(AST_Sub, function(self, output) {
  9689. self.expression.print(output);
  9690. if (self.optional) output.print("?.");
  9691. output.print("[");
  9692. self.property.print(output);
  9693. output.print("]");
  9694. });
  9695. DEFPRINT(AST_Chain, function(self, output) {
  9696. self.expression.print(output);
  9697. });
  9698. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  9699. var op = self.operator;
  9700. if (op === "--" && output.last().endsWith("!")) {
  9701. // avoid printing "<!--"
  9702. output.print(" ");
  9703. }
  9704. output.print(op);
  9705. if (/^[a-z]/i.test(op)
  9706. || (/[+-]$/.test(op)
  9707. && self.expression instanceof AST_UnaryPrefix
  9708. && /^[+-]/.test(self.expression.operator))) {
  9709. output.space();
  9710. }
  9711. self.expression.print(output);
  9712. });
  9713. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  9714. self.expression.print(output);
  9715. output.print(self.operator);
  9716. });
  9717. DEFPRINT(AST_Binary, function(self, output) {
  9718. var op = self.operator;
  9719. self.left.print(output);
  9720. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  9721. && output.last().endsWith("--")) {
  9722. // space is mandatory to avoid outputting -->
  9723. output.print(" ");
  9724. } else {
  9725. // the space is optional depending on "beautify"
  9726. output.space();
  9727. }
  9728. output.print(op);
  9729. output.space();
  9730. self.right.print(output);
  9731. });
  9732. DEFPRINT(AST_Conditional, function(self, output) {
  9733. self.condition.print(output);
  9734. output.space();
  9735. output.print("?");
  9736. output.space();
  9737. self.consequent.print(output);
  9738. output.space();
  9739. output.colon();
  9740. self.alternative.print(output);
  9741. });
  9742. /* -----[ literals ]----- */
  9743. DEFPRINT(AST_Array, function(self, output) {
  9744. output.with_square(function() {
  9745. var a = self.elements, len = a.length;
  9746. if (len > 0) output.space();
  9747. a.forEach(function(exp, i) {
  9748. if (i) output.comma();
  9749. exp.print(output);
  9750. // If the final element is a hole, we need to make sure it
  9751. // doesn't look like a trailing comma, by inserting an actual
  9752. // trailing comma.
  9753. if (i === len - 1 && exp instanceof AST_Hole)
  9754. output.comma();
  9755. });
  9756. if (len > 0) output.space();
  9757. });
  9758. });
  9759. DEFPRINT(AST_Object, function(self, output) {
  9760. if (self.properties.length > 0) output.with_block(function() {
  9761. self.properties.forEach(function(prop, i) {
  9762. if (i) {
  9763. output.print(",");
  9764. output.newline();
  9765. }
  9766. output.indent();
  9767. prop.print(output);
  9768. });
  9769. output.newline();
  9770. });
  9771. else print_braced_empty(self, output);
  9772. });
  9773. DEFPRINT(AST_Class, function(self, output) {
  9774. output.print("class");
  9775. output.space();
  9776. if (self.name) {
  9777. self.name.print(output);
  9778. output.space();
  9779. }
  9780. if (self.extends) {
  9781. var parens = (
  9782. !(self.extends instanceof AST_SymbolRef)
  9783. && !(self.extends instanceof AST_PropAccess)
  9784. && !(self.extends instanceof AST_ClassExpression)
  9785. && !(self.extends instanceof AST_Function)
  9786. );
  9787. output.print("extends");
  9788. if (parens) {
  9789. output.print("(");
  9790. } else {
  9791. output.space();
  9792. }
  9793. self.extends.print(output);
  9794. if (parens) {
  9795. output.print(")");
  9796. } else {
  9797. output.space();
  9798. }
  9799. }
  9800. if (self.properties.length > 0) output.with_block(function() {
  9801. self.properties.forEach(function(prop, i) {
  9802. if (i) {
  9803. output.newline();
  9804. }
  9805. output.indent();
  9806. prop.print(output);
  9807. });
  9808. output.newline();
  9809. });
  9810. else output.print("{}");
  9811. });
  9812. DEFPRINT(AST_NewTarget, function(self, output) {
  9813. output.print("new.target");
  9814. });
  9815. /** Prints a prop name. Returns whether it can be used as a shorthand. */
  9816. function print_property_name(key, quote, output) {
  9817. if (output.option("quote_keys")) {
  9818. output.print_string(key);
  9819. return false;
  9820. }
  9821. if ("" + +key == key && key >= 0) {
  9822. if (output.option("keep_numbers")) {
  9823. output.print(key);
  9824. return false;
  9825. }
  9826. output.print(make_num(key));
  9827. return false;
  9828. }
  9829. var print_string = ALL_RESERVED_WORDS.has(key)
  9830. ? output.option("ie8")
  9831. : (
  9832. output.option("ecma") < 2015 || output.option("safari10")
  9833. ? !is_basic_identifier_string(key)
  9834. : !is_identifier_string(key, true)
  9835. );
  9836. if (print_string || (quote && output.option("keep_quoted_props"))) {
  9837. output.print_string(key, quote);
  9838. return false;
  9839. }
  9840. output.print_name(key);
  9841. return true;
  9842. }
  9843. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  9844. function get_name(self) {
  9845. var def = self.definition();
  9846. return def ? def.mangled_name || def.name : self.name;
  9847. }
  9848. const try_shorthand = output.option("shorthand") && !(self.key instanceof AST_Node);
  9849. if (
  9850. try_shorthand
  9851. && self.value instanceof AST_Symbol
  9852. && get_name(self.value) === self.key
  9853. && !ALL_RESERVED_WORDS.has(self.key)
  9854. ) {
  9855. const was_shorthand = print_property_name(self.key, self.quote, output);
  9856. if (!was_shorthand) {
  9857. output.colon();
  9858. self.value.print(output);
  9859. }
  9860. } else if (
  9861. try_shorthand
  9862. && self.value instanceof AST_DefaultAssign
  9863. && self.value.left instanceof AST_Symbol
  9864. && get_name(self.value.left) === self.key
  9865. ) {
  9866. const was_shorthand = print_property_name(self.key, self.quote, output);
  9867. if (!was_shorthand) {
  9868. output.colon();
  9869. self.value.left.print(output);
  9870. }
  9871. output.space();
  9872. output.print("=");
  9873. output.space();
  9874. self.value.right.print(output);
  9875. } else {
  9876. if (!(self.key instanceof AST_Node)) {
  9877. print_property_name(self.key, self.quote, output);
  9878. } else {
  9879. output.with_square(function() {
  9880. self.key.print(output);
  9881. });
  9882. }
  9883. output.colon();
  9884. self.value.print(output);
  9885. }
  9886. });
  9887. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  9888. if (self.static) {
  9889. output.print("static");
  9890. output.space();
  9891. }
  9892. output.print("#");
  9893. print_property_name(self.key.name, self.quote, output);
  9894. if (self.value) {
  9895. output.print("=");
  9896. self.value.print(output);
  9897. }
  9898. output.semicolon();
  9899. });
  9900. DEFPRINT(AST_ClassProperty, (self, output) => {
  9901. if (self.static) {
  9902. output.print("static");
  9903. output.space();
  9904. }
  9905. if (self.key instanceof AST_SymbolClassProperty) {
  9906. print_property_name(self.key.name, self.quote, output);
  9907. } else {
  9908. output.print("[");
  9909. self.key.print(output);
  9910. output.print("]");
  9911. }
  9912. if (self.value) {
  9913. output.print("=");
  9914. self.value.print(output);
  9915. }
  9916. output.semicolon();
  9917. });
  9918. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  9919. var self = this;
  9920. if (self.static) {
  9921. output.print("static");
  9922. output.space();
  9923. }
  9924. if (type) {
  9925. output.print(type);
  9926. output.space();
  9927. }
  9928. if (self.key instanceof AST_SymbolMethod) {
  9929. if (is_private) output.print("#");
  9930. print_property_name(self.key.name, self.quote, output);
  9931. self.key.add_source_map(output);
  9932. } else {
  9933. output.with_square(function() {
  9934. self.key.print(output);
  9935. });
  9936. }
  9937. self.value._do_print(output, true);
  9938. });
  9939. DEFPRINT(AST_ObjectSetter, function(self, output) {
  9940. self._print_getter_setter("set", false, output);
  9941. });
  9942. DEFPRINT(AST_ObjectGetter, function(self, output) {
  9943. self._print_getter_setter("get", false, output);
  9944. });
  9945. DEFPRINT(AST_PrivateSetter, function(self, output) {
  9946. self._print_getter_setter("set", true, output);
  9947. });
  9948. DEFPRINT(AST_PrivateGetter, function(self, output) {
  9949. self._print_getter_setter("get", true, output);
  9950. });
  9951. DEFPRINT(AST_PrivateMethod, function(self, output) {
  9952. var type;
  9953. if (self.is_generator && self.async) {
  9954. type = "async*";
  9955. } else if (self.is_generator) {
  9956. type = "*";
  9957. } else if (self.async) {
  9958. type = "async";
  9959. }
  9960. self._print_getter_setter(type, true, output);
  9961. });
  9962. DEFPRINT(AST_PrivateIn, function(self, output) {
  9963. self.key.print(output);
  9964. output.space();
  9965. output.print("in");
  9966. output.space();
  9967. self.value.print(output);
  9968. });
  9969. DEFPRINT(AST_SymbolPrivateProperty, function(self, output) {
  9970. output.print("#" + self.name);
  9971. });
  9972. DEFPRINT(AST_ConciseMethod, function(self, output) {
  9973. var type;
  9974. if (self.is_generator && self.async) {
  9975. type = "async*";
  9976. } else if (self.is_generator) {
  9977. type = "*";
  9978. } else if (self.async) {
  9979. type = "async";
  9980. }
  9981. self._print_getter_setter(type, false, output);
  9982. });
  9983. DEFPRINT(AST_ClassStaticBlock, function (self, output) {
  9984. output.print("static");
  9985. output.space();
  9986. print_braced(self, output);
  9987. });
  9988. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  9989. var def = this.definition();
  9990. output.print_name(def ? def.mangled_name || def.name : this.name);
  9991. });
  9992. DEFPRINT(AST_Symbol, function (self, output) {
  9993. self._do_print(output);
  9994. });
  9995. DEFPRINT(AST_Hole, noop);
  9996. DEFPRINT(AST_This, function(self, output) {
  9997. output.print("this");
  9998. });
  9999. DEFPRINT(AST_Super, function(self, output) {
  10000. output.print("super");
  10001. });
  10002. DEFPRINT(AST_Constant, function(self, output) {
  10003. output.print(self.getValue());
  10004. });
  10005. DEFPRINT(AST_String, function(self, output) {
  10006. output.print_string(self.getValue(), self.quote, output.in_directive);
  10007. });
  10008. DEFPRINT(AST_Number, function(self, output) {
  10009. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  10010. output.print(self.raw);
  10011. } else {
  10012. output.print(make_num(self.getValue()));
  10013. }
  10014. });
  10015. DEFPRINT(AST_BigInt, function(self, output) {
  10016. output.print(self.getValue() + "n");
  10017. });
  10018. const r_slash_script = /(<\s*\/\s*script)/i;
  10019. const r_starts_with_script = /^\s*script/i;
  10020. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  10021. DEFPRINT(AST_RegExp, function(self, output) {
  10022. let { source, flags } = self.getValue();
  10023. source = regexp_source_fix(source);
  10024. flags = flags ? sort_regexp_flags(flags) : "";
  10025. // Avoid outputting end of script tag
  10026. source = source.replace(r_slash_script, slash_script_replace);
  10027. if (r_starts_with_script.test(source) && output.last().endsWith("<")) {
  10028. output.print(" ");
  10029. }
  10030. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  10031. const parent = output.parent();
  10032. if (
  10033. parent instanceof AST_Binary
  10034. && /^\w/.test(parent.operator)
  10035. && parent.left === self
  10036. ) {
  10037. output.print(" ");
  10038. }
  10039. });
  10040. /** if, for, while, may or may not have braces surrounding its body */
  10041. function print_maybe_braced_body(stat, output) {
  10042. if (output.option("braces")) {
  10043. make_block(stat, output);
  10044. } else {
  10045. if (!stat || stat instanceof AST_EmptyStatement)
  10046. output.force_semicolon();
  10047. else if (stat instanceof AST_Let || stat instanceof AST_Const || stat instanceof AST_Class)
  10048. make_block(stat, output);
  10049. else
  10050. stat.print(output);
  10051. }
  10052. }
  10053. function best_of(a) {
  10054. var best = a[0], len = best.length;
  10055. for (var i = 1; i < a.length; ++i) {
  10056. if (a[i].length < len) {
  10057. best = a[i];
  10058. len = best.length;
  10059. }
  10060. }
  10061. return best;
  10062. }
  10063. function make_num(num) {
  10064. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  10065. var candidates = [ str ];
  10066. if (Math.floor(num) === num) {
  10067. if (num < 0) {
  10068. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  10069. } else {
  10070. candidates.push("0x" + num.toString(16).toLowerCase());
  10071. }
  10072. }
  10073. var match, len, digits;
  10074. if (match = /^\.0+/.exec(str)) {
  10075. len = match[0].length;
  10076. digits = str.slice(len);
  10077. candidates.push(digits + "e-" + (digits.length + len - 1));
  10078. } else if (match = /0+$/.exec(str)) {
  10079. len = match[0].length;
  10080. candidates.push(str.slice(0, -len) + "e" + len);
  10081. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  10082. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  10083. }
  10084. return best_of(candidates);
  10085. }
  10086. function make_block(stmt, output) {
  10087. if (!stmt || stmt instanceof AST_EmptyStatement)
  10088. output.print("{}");
  10089. else if (stmt instanceof AST_BlockStatement)
  10090. stmt.print(output);
  10091. else output.with_block(function() {
  10092. output.indent();
  10093. stmt.print(output);
  10094. output.newline();
  10095. });
  10096. }
  10097. /* -----[ source map generators ]----- */
  10098. function DEFMAP(nodetype, generator) {
  10099. nodetype.forEach(function(nodetype) {
  10100. nodetype.DEFMETHOD("add_source_map", generator);
  10101. });
  10102. }
  10103. DEFMAP([
  10104. // We could easily add info for ALL nodes, but it seems to me that
  10105. // would be quite wasteful, hence this noop in the base class.
  10106. AST_Node,
  10107. // since the label symbol will mark it
  10108. AST_LabeledStatement,
  10109. AST_Toplevel,
  10110. ], noop);
  10111. // XXX: I'm not exactly sure if we need it for all of these nodes,
  10112. // or if we should add even more.
  10113. DEFMAP([
  10114. AST_Array,
  10115. AST_BlockStatement,
  10116. AST_Catch,
  10117. AST_Class,
  10118. AST_Constant,
  10119. AST_Debugger,
  10120. AST_Definitions,
  10121. AST_Directive,
  10122. AST_Finally,
  10123. AST_Jump,
  10124. AST_Lambda,
  10125. AST_New,
  10126. AST_Object,
  10127. AST_StatementWithBody,
  10128. AST_Symbol,
  10129. AST_Switch,
  10130. AST_SwitchBranch,
  10131. AST_TemplateString,
  10132. AST_TemplateSegment,
  10133. AST_Try,
  10134. ], function(output) {
  10135. output.add_mapping(this.start);
  10136. });
  10137. DEFMAP([
  10138. AST_ObjectGetter,
  10139. AST_ObjectSetter,
  10140. AST_PrivateGetter,
  10141. AST_PrivateSetter,
  10142. AST_ConciseMethod,
  10143. AST_PrivateMethod,
  10144. ], function(output) {
  10145. output.add_mapping(this.start, false /*name handled below*/);
  10146. });
  10147. DEFMAP([
  10148. AST_SymbolMethod,
  10149. AST_SymbolPrivateProperty
  10150. ], function(output) {
  10151. const tok_type = this.end && this.end.type;
  10152. if (tok_type === "name" || tok_type === "privatename") {
  10153. output.add_mapping(this.end, this.name);
  10154. } else {
  10155. output.add_mapping(this.end);
  10156. }
  10157. });
  10158. DEFMAP([ AST_ObjectProperty ], function(output) {
  10159. output.add_mapping(this.start, this.key);
  10160. });
  10161. })();
  10162. const shallow_cmp = (node1, node2) => {
  10163. return (
  10164. node1 === null && node2 === null
  10165. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  10166. );
  10167. };
  10168. const equivalent_to = (tree1, tree2) => {
  10169. if (!shallow_cmp(tree1, tree2)) return false;
  10170. const walk_1_state = [tree1];
  10171. const walk_2_state = [tree2];
  10172. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  10173. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  10174. while (walk_1_state.length && walk_2_state.length) {
  10175. const node_1 = walk_1_state.pop();
  10176. const node_2 = walk_2_state.pop();
  10177. if (!shallow_cmp(node_1, node_2)) return false;
  10178. node_1._children_backwards(walk_1_push);
  10179. node_2._children_backwards(walk_2_push);
  10180. if (walk_1_state.length !== walk_2_state.length) {
  10181. // Different number of children
  10182. return false;
  10183. }
  10184. }
  10185. return walk_1_state.length == 0 && walk_2_state.length == 0;
  10186. };
  10187. const pass_through = () => true;
  10188. AST_Node.prototype.shallow_cmp = function () {
  10189. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  10190. };
  10191. AST_Debugger.prototype.shallow_cmp = pass_through;
  10192. AST_Directive.prototype.shallow_cmp = function(other) {
  10193. return this.value === other.value;
  10194. };
  10195. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  10196. AST_Block.prototype.shallow_cmp = pass_through;
  10197. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  10198. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  10199. return this.label.name === other.label.name;
  10200. };
  10201. AST_Do.prototype.shallow_cmp = pass_through;
  10202. AST_While.prototype.shallow_cmp = pass_through;
  10203. AST_For.prototype.shallow_cmp = function(other) {
  10204. return (this.init == null ? other.init == null : this.init === other.init) && (this.condition == null ? other.condition == null : this.condition === other.condition) && (this.step == null ? other.step == null : this.step === other.step);
  10205. };
  10206. AST_ForIn.prototype.shallow_cmp = pass_through;
  10207. AST_ForOf.prototype.shallow_cmp = pass_through;
  10208. AST_With.prototype.shallow_cmp = pass_through;
  10209. AST_Toplevel.prototype.shallow_cmp = pass_through;
  10210. AST_Expansion.prototype.shallow_cmp = pass_through;
  10211. AST_Lambda.prototype.shallow_cmp = function(other) {
  10212. return this.is_generator === other.is_generator && this.async === other.async;
  10213. };
  10214. AST_Destructuring.prototype.shallow_cmp = function(other) {
  10215. return this.is_array === other.is_array;
  10216. };
  10217. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  10218. AST_TemplateString.prototype.shallow_cmp = pass_through;
  10219. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  10220. return this.value === other.value;
  10221. };
  10222. AST_Jump.prototype.shallow_cmp = pass_through;
  10223. AST_LoopControl.prototype.shallow_cmp = pass_through;
  10224. AST_Await.prototype.shallow_cmp = pass_through;
  10225. AST_Yield.prototype.shallow_cmp = function(other) {
  10226. return this.is_star === other.is_star;
  10227. };
  10228. AST_If.prototype.shallow_cmp = function(other) {
  10229. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  10230. };
  10231. AST_Switch.prototype.shallow_cmp = pass_through;
  10232. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  10233. AST_Try.prototype.shallow_cmp = function(other) {
  10234. return (this.body === other.body) && (this.bcatch == null ? other.bcatch == null : this.bcatch === other.bcatch) && (this.bfinally == null ? other.bfinally == null : this.bfinally === other.bfinally);
  10235. };
  10236. AST_Catch.prototype.shallow_cmp = function(other) {
  10237. return this.argname == null ? other.argname == null : this.argname === other.argname;
  10238. };
  10239. AST_Finally.prototype.shallow_cmp = pass_through;
  10240. AST_Definitions.prototype.shallow_cmp = pass_through;
  10241. AST_VarDef.prototype.shallow_cmp = function(other) {
  10242. return this.value == null ? other.value == null : this.value === other.value;
  10243. };
  10244. AST_NameMapping.prototype.shallow_cmp = pass_through;
  10245. AST_Import.prototype.shallow_cmp = function(other) {
  10246. return (this.imported_name == null ? other.imported_name == null : this.imported_name === other.imported_name) && (this.imported_names == null ? other.imported_names == null : this.imported_names === other.imported_names);
  10247. };
  10248. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  10249. AST_Export.prototype.shallow_cmp = function(other) {
  10250. return (this.exported_definition == null ? other.exported_definition == null : this.exported_definition === other.exported_definition) && (this.exported_value == null ? other.exported_value == null : this.exported_value === other.exported_value) && (this.exported_names == null ? other.exported_names == null : this.exported_names === other.exported_names) && this.module_name === other.module_name && this.is_default === other.is_default;
  10251. };
  10252. AST_Call.prototype.shallow_cmp = pass_through;
  10253. AST_Sequence.prototype.shallow_cmp = pass_through;
  10254. AST_PropAccess.prototype.shallow_cmp = pass_through;
  10255. AST_Chain.prototype.shallow_cmp = pass_through;
  10256. AST_Dot.prototype.shallow_cmp = function(other) {
  10257. return this.property === other.property;
  10258. };
  10259. AST_DotHash.prototype.shallow_cmp = function(other) {
  10260. return this.property === other.property;
  10261. };
  10262. AST_Unary.prototype.shallow_cmp = function(other) {
  10263. return this.operator === other.operator;
  10264. };
  10265. AST_Binary.prototype.shallow_cmp = function(other) {
  10266. return this.operator === other.operator;
  10267. };
  10268. AST_Conditional.prototype.shallow_cmp = pass_through;
  10269. AST_Array.prototype.shallow_cmp = pass_through;
  10270. AST_Object.prototype.shallow_cmp = pass_through;
  10271. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  10272. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  10273. return this.key === other.key;
  10274. };
  10275. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  10276. return this.static === other.static;
  10277. };
  10278. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  10279. return this.static === other.static;
  10280. };
  10281. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  10282. return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
  10283. };
  10284. AST_Class.prototype.shallow_cmp = function(other) {
  10285. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  10286. };
  10287. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  10288. return this.static === other.static;
  10289. };
  10290. AST_Symbol.prototype.shallow_cmp = function(other) {
  10291. return this.name === other.name;
  10292. };
  10293. AST_NewTarget.prototype.shallow_cmp = pass_through;
  10294. AST_This.prototype.shallow_cmp = pass_through;
  10295. AST_Super.prototype.shallow_cmp = pass_through;
  10296. AST_String.prototype.shallow_cmp = function(other) {
  10297. return this.value === other.value;
  10298. };
  10299. AST_Number.prototype.shallow_cmp = function(other) {
  10300. return this.value === other.value;
  10301. };
  10302. AST_BigInt.prototype.shallow_cmp = function(other) {
  10303. return this.value === other.value;
  10304. };
  10305. AST_RegExp.prototype.shallow_cmp = function (other) {
  10306. return (
  10307. this.value.flags === other.value.flags
  10308. && this.value.source === other.value.source
  10309. );
  10310. };
  10311. AST_Atom.prototype.shallow_cmp = pass_through;
  10312. /***********************************************************************
  10313. A JavaScript tokenizer / parser / beautifier / compressor.
  10314. https://github.com/mishoo/UglifyJS2
  10315. -------------------------------- (C) ---------------------------------
  10316. Author: Mihai Bazon
  10317. <mihai.bazon@gmail.com>
  10318. http://mihai.bazon.net/blog
  10319. Distributed under the BSD license:
  10320. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10321. Redistribution and use in source and binary forms, with or without
  10322. modification, are permitted provided that the following conditions
  10323. are met:
  10324. * Redistributions of source code must retain the above
  10325. copyright notice, this list of conditions and the following
  10326. disclaimer.
  10327. * Redistributions in binary form must reproduce the above
  10328. copyright notice, this list of conditions and the following
  10329. disclaimer in the documentation and/or other materials
  10330. provided with the distribution.
  10331. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10332. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10333. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10334. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10335. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10336. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10337. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10338. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10339. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10340. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10341. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10342. SUCH DAMAGE.
  10343. ***********************************************************************/
  10344. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  10345. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  10346. let function_defs = null;
  10347. let unmangleable_names = null;
  10348. /**
  10349. * When defined, there is a function declaration somewhere that's inside of a block.
  10350. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  10351. */
  10352. let scopes_with_block_defuns = null;
  10353. class SymbolDef {
  10354. constructor(scope, orig, init) {
  10355. this.name = orig.name;
  10356. this.orig = [ orig ];
  10357. this.init = init;
  10358. this.eliminated = 0;
  10359. this.assignments = 0;
  10360. this.scope = scope;
  10361. this.replaced = 0;
  10362. this.global = false;
  10363. this.export = 0;
  10364. this.mangled_name = null;
  10365. this.undeclared = false;
  10366. this.id = SymbolDef.next_id++;
  10367. this.chained = false;
  10368. this.direct_access = false;
  10369. this.escaped = 0;
  10370. this.recursive_refs = 0;
  10371. this.references = [];
  10372. this.should_replace = undefined;
  10373. this.single_use = false;
  10374. this.fixed = false;
  10375. Object.seal(this);
  10376. }
  10377. fixed_value() {
  10378. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  10379. return this.fixed();
  10380. }
  10381. unmangleable(options) {
  10382. if (!options) options = {};
  10383. if (
  10384. function_defs &&
  10385. function_defs.has(this.id) &&
  10386. keep_name(options.keep_fnames, this.orig[0].name)
  10387. ) return true;
  10388. return this.global && !options.toplevel
  10389. || (this.export & MASK_EXPORT_DONT_MANGLE)
  10390. || this.undeclared
  10391. || !options.eval && this.scope.pinned()
  10392. || (this.orig[0] instanceof AST_SymbolLambda
  10393. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  10394. || this.orig[0] instanceof AST_SymbolMethod
  10395. || (this.orig[0] instanceof AST_SymbolClass
  10396. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  10397. }
  10398. mangle(options) {
  10399. const cache = options.cache && options.cache.props;
  10400. if (this.global && cache && cache.has(this.name)) {
  10401. this.mangled_name = cache.get(this.name);
  10402. } else if (!this.mangled_name && !this.unmangleable(options)) {
  10403. var s = this.scope;
  10404. var sym = this.orig[0];
  10405. if (options.ie8 && sym instanceof AST_SymbolLambda)
  10406. s = s.parent_scope;
  10407. const redefinition = redefined_catch_def(this);
  10408. this.mangled_name = redefinition
  10409. ? redefinition.mangled_name || redefinition.name
  10410. : s.next_mangled(options, this);
  10411. if (this.global && cache) {
  10412. cache.set(this.name, this.mangled_name);
  10413. }
  10414. }
  10415. }
  10416. }
  10417. SymbolDef.next_id = 1;
  10418. function redefined_catch_def(def) {
  10419. if (def.orig[0] instanceof AST_SymbolCatch
  10420. && def.scope.is_block_scope()
  10421. ) {
  10422. return def.scope.get_defun_scope().variables.get(def.name);
  10423. }
  10424. }
  10425. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  10426. options = defaults(options, {
  10427. cache: null,
  10428. ie8: false,
  10429. safari10: false,
  10430. });
  10431. if (!(toplevel instanceof AST_Toplevel)) {
  10432. throw new Error("Invalid toplevel scope");
  10433. }
  10434. // pass 1: setup scope chaining and handle definitions
  10435. var scope = this.parent_scope = parent_scope;
  10436. var labels = new Map();
  10437. var defun = null;
  10438. var in_destructuring = null;
  10439. var for_scopes = [];
  10440. var tw = new TreeWalker((node, descend) => {
  10441. if (node.is_block_scope()) {
  10442. const save_scope = scope;
  10443. node.block_scope = scope = new AST_Scope(node);
  10444. scope._block_scope = true;
  10445. scope.init_scope_vars(save_scope);
  10446. scope.uses_with = save_scope.uses_with;
  10447. scope.uses_eval = save_scope.uses_eval;
  10448. if (options.safari10) {
  10449. if (node instanceof AST_For || node instanceof AST_ForIn || node instanceof AST_ForOf) {
  10450. for_scopes.push(scope);
  10451. }
  10452. }
  10453. if (node instanceof AST_Switch) {
  10454. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  10455. // AST_Switch has a scope within the body, but it itself "is a block scope"
  10456. // This means the switched expression has to belong to the outer scope
  10457. // while the body inside belongs to the switch itself.
  10458. // This is pretty nasty and warrants an AST change
  10459. const the_block_scope = scope;
  10460. scope = save_scope;
  10461. node.expression.walk(tw);
  10462. scope = the_block_scope;
  10463. for (let i = 0; i < node.body.length; i++) {
  10464. node.body[i].walk(tw);
  10465. }
  10466. } else {
  10467. descend();
  10468. }
  10469. scope = save_scope;
  10470. return true;
  10471. }
  10472. if (node instanceof AST_Destructuring) {
  10473. const save_destructuring = in_destructuring;
  10474. in_destructuring = node;
  10475. descend();
  10476. in_destructuring = save_destructuring;
  10477. return true;
  10478. }
  10479. if (node instanceof AST_Scope) {
  10480. node.init_scope_vars(scope);
  10481. var save_scope = scope;
  10482. var save_defun = defun;
  10483. var save_labels = labels;
  10484. defun = scope = node;
  10485. labels = new Map();
  10486. descend();
  10487. scope = save_scope;
  10488. defun = save_defun;
  10489. labels = save_labels;
  10490. return true; // don't descend again in TreeWalker
  10491. }
  10492. if (node instanceof AST_LabeledStatement) {
  10493. var l = node.label;
  10494. if (labels.has(l.name)) {
  10495. throw new Error(string_template("Label {name} defined twice", l));
  10496. }
  10497. labels.set(l.name, l);
  10498. descend();
  10499. labels.delete(l.name);
  10500. return true; // no descend again
  10501. }
  10502. if (node instanceof AST_With) {
  10503. for (var s = scope; s; s = s.parent_scope)
  10504. s.uses_with = true;
  10505. return;
  10506. }
  10507. if (node instanceof AST_Symbol) {
  10508. node.scope = scope;
  10509. }
  10510. if (node instanceof AST_Label) {
  10511. node.thedef = node;
  10512. node.references = [];
  10513. }
  10514. if (node instanceof AST_SymbolLambda) {
  10515. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  10516. } else if (node instanceof AST_SymbolDefun) {
  10517. // Careful here, the scope where this should be defined is
  10518. // the parent scope. The reason is that we enter a new
  10519. // scope when we encounter the AST_Defun node (which is
  10520. // instanceof AST_Scope) but we get to the symbol a bit
  10521. // later.
  10522. const closest_scope = defun.parent_scope;
  10523. // In strict mode, function definitions are block-scoped
  10524. node.scope = tw.directives["use strict"]
  10525. ? closest_scope
  10526. : closest_scope.get_defun_scope();
  10527. mark_export(node.scope.def_function(node, defun), 1);
  10528. } else if (node instanceof AST_SymbolClass) {
  10529. mark_export(defun.def_variable(node, defun), 1);
  10530. } else if (node instanceof AST_SymbolImport) {
  10531. scope.def_variable(node);
  10532. } else if (node instanceof AST_SymbolDefClass) {
  10533. // This deals with the name of the class being available
  10534. // inside the class.
  10535. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  10536. } else if (
  10537. node instanceof AST_SymbolVar
  10538. || node instanceof AST_SymbolLet
  10539. || node instanceof AST_SymbolConst
  10540. || node instanceof AST_SymbolCatch
  10541. ) {
  10542. var def;
  10543. if (node instanceof AST_SymbolBlockDeclaration) {
  10544. def = scope.def_variable(node, null);
  10545. } else {
  10546. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  10547. }
  10548. if (!def.orig.every((sym) => {
  10549. if (sym === node) return true;
  10550. if (node instanceof AST_SymbolBlockDeclaration) {
  10551. return sym instanceof AST_SymbolLambda;
  10552. }
  10553. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  10554. })) {
  10555. js_error(
  10556. `"${node.name}" is redeclared`,
  10557. node.start.file,
  10558. node.start.line,
  10559. node.start.col,
  10560. node.start.pos
  10561. );
  10562. }
  10563. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  10564. if (defun !== scope) {
  10565. node.mark_enclosed();
  10566. var def = scope.find_variable(node);
  10567. if (node.thedef !== def) {
  10568. node.thedef = def;
  10569. node.reference();
  10570. }
  10571. }
  10572. } else if (node instanceof AST_LabelRef) {
  10573. var sym = labels.get(node.name);
  10574. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  10575. name: node.name,
  10576. line: node.start.line,
  10577. col: node.start.col
  10578. }));
  10579. node.thedef = sym;
  10580. }
  10581. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  10582. js_error(
  10583. `"${node.TYPE}" statement may only appear at the top level`,
  10584. node.start.file,
  10585. node.start.line,
  10586. node.start.col,
  10587. node.start.pos
  10588. );
  10589. }
  10590. });
  10591. this.walk(tw);
  10592. function mark_export(def, level) {
  10593. if (in_destructuring) {
  10594. var i = 0;
  10595. do {
  10596. level++;
  10597. } while (tw.parent(i++) !== in_destructuring);
  10598. }
  10599. var node = tw.parent(level);
  10600. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  10601. var exported = node.exported_definition;
  10602. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  10603. def.export = MASK_EXPORT_WANT_MANGLE;
  10604. }
  10605. }
  10606. }
  10607. // pass 2: find back references and eval
  10608. const is_toplevel = this instanceof AST_Toplevel;
  10609. if (is_toplevel) {
  10610. this.globals = new Map();
  10611. }
  10612. var tw = new TreeWalker(node => {
  10613. if (node instanceof AST_LoopControl && node.label) {
  10614. node.label.thedef.references.push(node);
  10615. return true;
  10616. }
  10617. if (node instanceof AST_SymbolRef) {
  10618. var name = node.name;
  10619. if (name == "eval" && tw.parent() instanceof AST_Call) {
  10620. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  10621. s.uses_eval = true;
  10622. }
  10623. }
  10624. var sym;
  10625. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  10626. || !(sym = node.scope.find_variable(name))) {
  10627. sym = toplevel.def_global(node);
  10628. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  10629. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  10630. sym.scope.get_defun_scope().uses_arguments = true;
  10631. }
  10632. node.thedef = sym;
  10633. node.reference();
  10634. if (node.scope.is_block_scope()
  10635. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  10636. node.scope = node.scope.get_defun_scope();
  10637. }
  10638. return true;
  10639. }
  10640. // ensure mangling works if catch reuses a scope variable
  10641. var def;
  10642. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  10643. var s = node.scope;
  10644. while (s) {
  10645. push_uniq(s.enclosed, def);
  10646. if (s === def.scope) break;
  10647. s = s.parent_scope;
  10648. }
  10649. }
  10650. });
  10651. this.walk(tw);
  10652. // pass 3: work around IE8 and Safari catch scope bugs
  10653. if (options.ie8 || options.safari10) {
  10654. walk(this, node => {
  10655. if (node instanceof AST_SymbolCatch) {
  10656. var name = node.name;
  10657. var refs = node.thedef.references;
  10658. var scope = node.scope.get_defun_scope();
  10659. var def = scope.find_variable(name)
  10660. || toplevel.globals.get(name)
  10661. || scope.def_variable(node);
  10662. refs.forEach(function(ref) {
  10663. ref.thedef = def;
  10664. ref.reference();
  10665. });
  10666. node.thedef = def;
  10667. node.reference();
  10668. return true;
  10669. }
  10670. });
  10671. }
  10672. // pass 4: add symbol definitions to loop scopes
  10673. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  10674. // https://github.com/mishoo/UglifyJS2/issues/1753
  10675. // https://bugs.webkit.org/show_bug.cgi?id=171041
  10676. if (options.safari10) {
  10677. for (const scope of for_scopes) {
  10678. scope.parent_scope.variables.forEach(function(def) {
  10679. push_uniq(scope.enclosed, def);
  10680. });
  10681. }
  10682. }
  10683. });
  10684. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  10685. var globals = this.globals, name = node.name;
  10686. if (globals.has(name)) {
  10687. return globals.get(name);
  10688. } else {
  10689. var g = new SymbolDef(this, node);
  10690. g.undeclared = true;
  10691. g.global = true;
  10692. globals.set(name, g);
  10693. return g;
  10694. }
  10695. });
  10696. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  10697. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  10698. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  10699. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  10700. this.parent_scope = parent_scope; // the parent scope
  10701. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  10702. this.cname = -1; // the current index for mangling functions/variables
  10703. });
  10704. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  10705. return (
  10706. this.enclosed.find(def => def.name === name)
  10707. || this.variables.has(name)
  10708. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  10709. );
  10710. });
  10711. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  10712. return (
  10713. this.enclosed.find(def => def.name === name)
  10714. || this.variables.has(name)
  10715. );
  10716. });
  10717. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  10718. // `scope` is going to be moved into `this` right now.
  10719. // Update the required scopes' information
  10720. if (scope.parent_scope === this) return;
  10721. scope.parent_scope = this;
  10722. // Propagate to this.uses_arguments from arrow functions
  10723. if ((scope instanceof AST_Arrow) && !this.uses_arguments) {
  10724. this.uses_arguments = walk(scope, node => {
  10725. if (
  10726. node instanceof AST_SymbolRef
  10727. && node.scope instanceof AST_Lambda
  10728. && node.name === "arguments"
  10729. ) {
  10730. return walk_abort;
  10731. }
  10732. if (node instanceof AST_Lambda && !(node instanceof AST_Arrow)) {
  10733. return true;
  10734. }
  10735. });
  10736. }
  10737. this.uses_with = this.uses_with || scope.uses_with;
  10738. this.uses_eval = this.uses_eval || scope.uses_eval;
  10739. const scope_ancestry = (() => {
  10740. const ancestry = [];
  10741. let cur = this;
  10742. do {
  10743. ancestry.push(cur);
  10744. } while ((cur = cur.parent_scope));
  10745. ancestry.reverse();
  10746. return ancestry;
  10747. })();
  10748. const new_scope_enclosed_set = new Set(scope.enclosed);
  10749. const to_enclose = [];
  10750. for (const scope_topdown of scope_ancestry) {
  10751. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  10752. for (const def of scope_topdown.variables.values()) {
  10753. if (new_scope_enclosed_set.has(def)) {
  10754. push_uniq(to_enclose, def);
  10755. push_uniq(scope_topdown.enclosed, def);
  10756. }
  10757. }
  10758. }
  10759. });
  10760. function find_scopes_visible_from(scopes) {
  10761. const found_scopes = new Set();
  10762. for (const scope of new Set(scopes)) {
  10763. (function bubble_up(scope) {
  10764. if (scope == null || found_scopes.has(scope)) return;
  10765. found_scopes.add(scope);
  10766. bubble_up(scope.parent_scope);
  10767. })(scope);
  10768. }
  10769. return [...found_scopes];
  10770. }
  10771. // Creates a symbol during compression
  10772. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  10773. source,
  10774. tentative_name,
  10775. scope,
  10776. conflict_scopes = [scope],
  10777. init = null
  10778. } = {}) {
  10779. let symbol_name;
  10780. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  10781. if (tentative_name) {
  10782. // Implement hygiene (no new names are conflicting with existing names)
  10783. tentative_name =
  10784. symbol_name =
  10785. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  10786. let i = 0;
  10787. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  10788. symbol_name = tentative_name + "$" + i++;
  10789. }
  10790. }
  10791. if (!symbol_name) {
  10792. throw new Error("No symbol name could be generated in create_symbol()");
  10793. }
  10794. const symbol = make_node(SymClass, source, {
  10795. name: symbol_name,
  10796. scope
  10797. });
  10798. this.def_variable(symbol, init || null);
  10799. symbol.mark_enclosed();
  10800. return symbol;
  10801. });
  10802. AST_Node.DEFMETHOD("is_block_scope", return_false);
  10803. AST_Class.DEFMETHOD("is_block_scope", return_false);
  10804. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  10805. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  10806. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  10807. AST_Block.DEFMETHOD("is_block_scope", return_true);
  10808. AST_Scope.DEFMETHOD("is_block_scope", function () {
  10809. return this._block_scope || false;
  10810. });
  10811. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  10812. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  10813. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10814. this.uses_arguments = false;
  10815. this.def_variable(new AST_SymbolFunarg({
  10816. name: "arguments",
  10817. start: this.start,
  10818. end: this.end
  10819. }));
  10820. });
  10821. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  10822. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10823. this.uses_arguments = false;
  10824. });
  10825. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  10826. var def = this.definition();
  10827. var s = this.scope;
  10828. while (s) {
  10829. push_uniq(s.enclosed, def);
  10830. if (s === def.scope) break;
  10831. s = s.parent_scope;
  10832. }
  10833. });
  10834. AST_Symbol.DEFMETHOD("reference", function() {
  10835. this.definition().references.push(this);
  10836. this.mark_enclosed();
  10837. });
  10838. AST_Scope.DEFMETHOD("find_variable", function(name) {
  10839. if (name instanceof AST_Symbol) name = name.name;
  10840. return this.variables.get(name)
  10841. || (this.parent_scope && this.parent_scope.find_variable(name));
  10842. });
  10843. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  10844. var def = this.def_variable(symbol, init);
  10845. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  10846. return def;
  10847. });
  10848. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  10849. var def = this.variables.get(symbol.name);
  10850. if (def) {
  10851. def.orig.push(symbol);
  10852. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  10853. def.init = init;
  10854. }
  10855. } else {
  10856. def = new SymbolDef(this, symbol, init);
  10857. this.variables.set(symbol.name, def);
  10858. def.global = !this.parent_scope;
  10859. }
  10860. return symbol.thedef = def;
  10861. });
  10862. function next_mangled(scope, options) {
  10863. let defun_scope;
  10864. if (
  10865. scopes_with_block_defuns
  10866. && (defun_scope = scope.get_defun_scope())
  10867. && scopes_with_block_defuns.has(defun_scope)
  10868. ) {
  10869. scope = defun_scope;
  10870. }
  10871. var ext = scope.enclosed;
  10872. var nth_identifier = options.nth_identifier;
  10873. out: while (true) {
  10874. var m = nth_identifier.get(++scope.cname);
  10875. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  10876. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  10877. // shadow a name reserved from mangling.
  10878. if (options.reserved.has(m)) continue;
  10879. // Functions with short names might collide with base54 output
  10880. // and therefore cause collisions when keep_fnames is true.
  10881. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  10882. // we must ensure that the mangled name does not shadow a name
  10883. // from some parent scope that is referenced in this or in
  10884. // inner scopes.
  10885. for (let i = ext.length; --i >= 0;) {
  10886. const def = ext[i];
  10887. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  10888. if (m == name) continue out;
  10889. }
  10890. return m;
  10891. }
  10892. }
  10893. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  10894. return next_mangled(this, options);
  10895. });
  10896. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  10897. let name;
  10898. const mangled_names = this.mangled_names;
  10899. do {
  10900. name = next_mangled(this, options);
  10901. } while (mangled_names.has(name));
  10902. return name;
  10903. });
  10904. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  10905. // #179, #326
  10906. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  10907. // a function expression's argument cannot shadow the function expression's name
  10908. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  10909. // the function's mangled_name is null when keep_fnames is true
  10910. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  10911. while (true) {
  10912. var name = next_mangled(this, options);
  10913. if (!tricky_name || tricky_name != name)
  10914. return name;
  10915. }
  10916. });
  10917. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  10918. var def = this.definition();
  10919. return !def || def.unmangleable(options);
  10920. });
  10921. // labels are always mangleable
  10922. AST_Label.DEFMETHOD("unmangleable", return_false);
  10923. AST_Symbol.DEFMETHOD("unreferenced", function() {
  10924. return !this.definition().references.length && !this.scope.pinned();
  10925. });
  10926. AST_Symbol.DEFMETHOD("definition", function() {
  10927. return this.thedef;
  10928. });
  10929. AST_Symbol.DEFMETHOD("global", function() {
  10930. return this.thedef.global;
  10931. });
  10932. /**
  10933. * Format the mangler options (if any) into their appropriate types
  10934. */
  10935. function format_mangler_options(options) {
  10936. options = defaults(options, {
  10937. eval : false,
  10938. nth_identifier : base54,
  10939. ie8 : false,
  10940. keep_classnames: false,
  10941. keep_fnames : false,
  10942. module : false,
  10943. reserved : [],
  10944. toplevel : false,
  10945. });
  10946. if (options.module) options.toplevel = true;
  10947. if (!Array.isArray(options.reserved)
  10948. && !(options.reserved instanceof Set)
  10949. ) {
  10950. options.reserved = [];
  10951. }
  10952. options.reserved = new Set(options.reserved);
  10953. // Never mangle arguments
  10954. options.reserved.add("arguments");
  10955. return options;
  10956. }
  10957. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  10958. options = format_mangler_options(options);
  10959. var nth_identifier = options.nth_identifier;
  10960. // We only need to mangle declaration nodes. Special logic wired
  10961. // into the code generator will display the mangled name if it's
  10962. // present (and for AST_SymbolRef-s it'll use the mangled name of
  10963. // the AST_SymbolDeclaration that it points to).
  10964. var lname = -1;
  10965. var to_mangle = [];
  10966. if (options.keep_fnames) {
  10967. function_defs = new Set();
  10968. }
  10969. const mangled_names = this.mangled_names = new Set();
  10970. unmangleable_names = new Set();
  10971. if (options.cache) {
  10972. this.globals.forEach(collect);
  10973. if (options.cache.props) {
  10974. options.cache.props.forEach(function(mangled_name) {
  10975. mangled_names.add(mangled_name);
  10976. });
  10977. }
  10978. }
  10979. var tw = new TreeWalker(function(node, descend) {
  10980. if (node instanceof AST_LabeledStatement) {
  10981. // lname is incremented when we get to the AST_Label
  10982. var save_nesting = lname;
  10983. descend();
  10984. lname = save_nesting;
  10985. return true; // don't descend again in TreeWalker
  10986. }
  10987. if (
  10988. node instanceof AST_Defun
  10989. && !(tw.parent() instanceof AST_Scope)
  10990. ) {
  10991. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  10992. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  10993. }
  10994. if (node instanceof AST_Scope) {
  10995. node.variables.forEach(collect);
  10996. return;
  10997. }
  10998. if (node.is_block_scope()) {
  10999. node.block_scope.variables.forEach(collect);
  11000. return;
  11001. }
  11002. if (
  11003. function_defs
  11004. && node instanceof AST_VarDef
  11005. && node.value instanceof AST_Lambda
  11006. && !node.value.name
  11007. && keep_name(options.keep_fnames, node.name.name)
  11008. ) {
  11009. function_defs.add(node.name.definition().id);
  11010. return;
  11011. }
  11012. if (node instanceof AST_Label) {
  11013. let name;
  11014. do {
  11015. name = nth_identifier.get(++lname);
  11016. } while (ALL_RESERVED_WORDS.has(name));
  11017. node.mangled_name = name;
  11018. return true;
  11019. }
  11020. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  11021. to_mangle.push(node.definition());
  11022. return;
  11023. }
  11024. });
  11025. this.walk(tw);
  11026. if (options.keep_fnames || options.keep_classnames) {
  11027. // Collect a set of short names which are unmangleable,
  11028. // for use in avoiding collisions in next_mangled.
  11029. to_mangle.forEach(def => {
  11030. if (def.name.length < 6 && def.unmangleable(options)) {
  11031. unmangleable_names.add(def.name);
  11032. }
  11033. });
  11034. }
  11035. to_mangle.forEach(def => { def.mangle(options); });
  11036. function_defs = null;
  11037. unmangleable_names = null;
  11038. scopes_with_block_defuns = null;
  11039. function collect(symbol) {
  11040. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  11041. unmangleable_names.add(symbol.name);
  11042. } else if (!options.reserved.has(symbol.name)) {
  11043. to_mangle.push(symbol);
  11044. }
  11045. }
  11046. });
  11047. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  11048. const cache = options.cache && options.cache.props;
  11049. const avoid = new Set();
  11050. options.reserved.forEach(to_avoid);
  11051. this.globals.forEach(add_def);
  11052. this.walk(new TreeWalker(function(node) {
  11053. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  11054. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  11055. }));
  11056. return avoid;
  11057. function to_avoid(name) {
  11058. avoid.add(name);
  11059. }
  11060. function add_def(def) {
  11061. var name = def.name;
  11062. if (def.global && cache && cache.has(name)) name = cache.get(name);
  11063. else if (!def.unmangleable(options)) return;
  11064. to_avoid(name);
  11065. }
  11066. });
  11067. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  11068. options = format_mangler_options(options);
  11069. var nth_identifier = options.nth_identifier;
  11070. if (nth_identifier.reset && nth_identifier.sort) {
  11071. nth_identifier.reset();
  11072. nth_identifier.sort();
  11073. }
  11074. var avoid = this.find_colliding_names(options);
  11075. var cname = 0;
  11076. this.globals.forEach(rename);
  11077. this.walk(new TreeWalker(function(node) {
  11078. if (node instanceof AST_Scope) node.variables.forEach(rename);
  11079. if (node instanceof AST_SymbolCatch) rename(node.definition());
  11080. }));
  11081. function next_name() {
  11082. var name;
  11083. do {
  11084. name = nth_identifier.get(cname++);
  11085. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  11086. return name;
  11087. }
  11088. function rename(def) {
  11089. if (def.global && options.cache) return;
  11090. if (def.unmangleable(options)) return;
  11091. if (options.reserved.has(def.name)) return;
  11092. const redefinition = redefined_catch_def(def);
  11093. const name = def.name = redefinition ? redefinition.name : next_name();
  11094. def.orig.forEach(function(sym) {
  11095. sym.name = name;
  11096. });
  11097. def.references.forEach(function(sym) {
  11098. sym.name = name;
  11099. });
  11100. }
  11101. });
  11102. AST_Node.DEFMETHOD("tail_node", return_this);
  11103. AST_Sequence.DEFMETHOD("tail_node", function() {
  11104. return this.expressions[this.expressions.length - 1];
  11105. });
  11106. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  11107. options = format_mangler_options(options);
  11108. var nth_identifier = options.nth_identifier;
  11109. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  11110. // If the identifier mangler is invariant, skip computing character frequency.
  11111. return;
  11112. }
  11113. nth_identifier.reset();
  11114. try {
  11115. AST_Node.prototype.print = function(stream, force_parens) {
  11116. this._print(stream, force_parens);
  11117. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  11118. nth_identifier.consider(this.name, -1);
  11119. } else if (options.properties) {
  11120. if (this instanceof AST_DotHash) {
  11121. nth_identifier.consider("#" + this.property, -1);
  11122. } else if (this instanceof AST_Dot) {
  11123. nth_identifier.consider(this.property, -1);
  11124. } else if (this instanceof AST_Sub) {
  11125. skip_string(this.property);
  11126. }
  11127. }
  11128. };
  11129. nth_identifier.consider(this.print_to_string(), 1);
  11130. } finally {
  11131. AST_Node.prototype.print = AST_Node.prototype._print;
  11132. }
  11133. nth_identifier.sort();
  11134. function skip_string(node) {
  11135. if (node instanceof AST_String) {
  11136. nth_identifier.consider(node.value, -1);
  11137. } else if (node instanceof AST_Conditional) {
  11138. skip_string(node.consequent);
  11139. skip_string(node.alternative);
  11140. } else if (node instanceof AST_Sequence) {
  11141. skip_string(node.tail_node());
  11142. }
  11143. }
  11144. });
  11145. const base54 = (() => {
  11146. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  11147. const digits = "0123456789".split("");
  11148. let chars;
  11149. let frequency;
  11150. function reset() {
  11151. frequency = new Map();
  11152. leading.forEach(function(ch) {
  11153. frequency.set(ch, 0);
  11154. });
  11155. digits.forEach(function(ch) {
  11156. frequency.set(ch, 0);
  11157. });
  11158. }
  11159. function consider(str, delta) {
  11160. for (var i = str.length; --i >= 0;) {
  11161. frequency.set(str[i], frequency.get(str[i]) + delta);
  11162. }
  11163. }
  11164. function compare(a, b) {
  11165. return frequency.get(b) - frequency.get(a);
  11166. }
  11167. function sort() {
  11168. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  11169. }
  11170. // Ensure this is in a usable initial state.
  11171. reset();
  11172. sort();
  11173. function base54(num) {
  11174. var ret = "", base = 54;
  11175. num++;
  11176. do {
  11177. num--;
  11178. ret += chars[num % base];
  11179. num = Math.floor(num / base);
  11180. base = 64;
  11181. } while (num > 0);
  11182. return ret;
  11183. }
  11184. return {
  11185. get: base54,
  11186. consider,
  11187. reset,
  11188. sort
  11189. };
  11190. })();
  11191. let mangle_options = undefined;
  11192. AST_Node.prototype.size = function (compressor, stack) {
  11193. mangle_options = compressor && compressor.mangle_options;
  11194. let size = 0;
  11195. walk_parent(this, (node, info) => {
  11196. size += node._size(info);
  11197. // Braceless arrow functions have fake "return" statements
  11198. if (node instanceof AST_Arrow && node.is_braceless()) {
  11199. size += node.body[0].value._size(info);
  11200. return true;
  11201. }
  11202. }, stack || (compressor && compressor.stack));
  11203. // just to save a bit of memory
  11204. mangle_options = undefined;
  11205. return size;
  11206. };
  11207. AST_Node.prototype._size = () => 0;
  11208. AST_Debugger.prototype._size = () => 8;
  11209. AST_Directive.prototype._size = function () {
  11210. // TODO string encoding stuff
  11211. return 2 + this.value.length;
  11212. };
  11213. /** Count commas/semicolons necessary to show a list of expressions/statements */
  11214. const list_overhead = (array) => array.length && array.length - 1;
  11215. AST_Block.prototype._size = function () {
  11216. return 2 + list_overhead(this.body);
  11217. };
  11218. AST_Toplevel.prototype._size = function() {
  11219. return list_overhead(this.body);
  11220. };
  11221. AST_EmptyStatement.prototype._size = () => 1;
  11222. AST_LabeledStatement.prototype._size = () => 2; // x:
  11223. AST_Do.prototype._size = () => 9;
  11224. AST_While.prototype._size = () => 7;
  11225. AST_For.prototype._size = () => 8;
  11226. AST_ForIn.prototype._size = () => 8;
  11227. // AST_ForOf inherits ^
  11228. AST_With.prototype._size = () => 6;
  11229. AST_Expansion.prototype._size = () => 3;
  11230. const lambda_modifiers = func =>
  11231. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  11232. AST_Accessor.prototype._size = function () {
  11233. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  11234. };
  11235. AST_Function.prototype._size = function (info) {
  11236. const first = !!first_in_statement(info);
  11237. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  11238. };
  11239. AST_Defun.prototype._size = function () {
  11240. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  11241. };
  11242. AST_Arrow.prototype._size = function () {
  11243. let args_and_arrow = 2 + list_overhead(this.argnames);
  11244. if (
  11245. !(
  11246. this.argnames.length === 1
  11247. && this.argnames[0] instanceof AST_Symbol
  11248. )
  11249. ) {
  11250. args_and_arrow += 2; // parens around the args
  11251. }
  11252. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  11253. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  11254. };
  11255. AST_Destructuring.prototype._size = () => 2;
  11256. AST_TemplateString.prototype._size = function () {
  11257. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  11258. };
  11259. AST_TemplateSegment.prototype._size = function () {
  11260. return this.value.length;
  11261. };
  11262. AST_Return.prototype._size = function () {
  11263. return this.value ? 7 : 6;
  11264. };
  11265. AST_Throw.prototype._size = () => 6;
  11266. AST_Break.prototype._size = function () {
  11267. return this.label ? 6 : 5;
  11268. };
  11269. AST_Continue.prototype._size = function () {
  11270. return this.label ? 9 : 8;
  11271. };
  11272. AST_If.prototype._size = () => 4;
  11273. AST_Switch.prototype._size = function () {
  11274. return 8 + list_overhead(this.body);
  11275. };
  11276. AST_Case.prototype._size = function () {
  11277. return 5 + list_overhead(this.body);
  11278. };
  11279. AST_Default.prototype._size = function () {
  11280. return 8 + list_overhead(this.body);
  11281. };
  11282. AST_Try.prototype._size = () => 3;
  11283. AST_Catch.prototype._size = function () {
  11284. let size = 7 + list_overhead(this.body);
  11285. if (this.argname) {
  11286. size += 2;
  11287. }
  11288. return size;
  11289. };
  11290. AST_Finally.prototype._size = function () {
  11291. return 7 + list_overhead(this.body);
  11292. };
  11293. AST_Var.prototype._size = function () {
  11294. return 4 + list_overhead(this.definitions);
  11295. };
  11296. AST_Let.prototype._size = function () {
  11297. return 4 + list_overhead(this.definitions);
  11298. };
  11299. AST_Const.prototype._size = function () {
  11300. return 6 + list_overhead(this.definitions);
  11301. };
  11302. AST_VarDef.prototype._size = function () {
  11303. return this.value ? 1 : 0;
  11304. };
  11305. AST_NameMapping.prototype._size = function () {
  11306. // foreign name isn't mangled
  11307. return this.name ? 4 : 0;
  11308. };
  11309. AST_Import.prototype._size = function () {
  11310. // import
  11311. let size = 6;
  11312. if (this.imported_name) size += 1;
  11313. // from
  11314. if (this.imported_name || this.imported_names) size += 5;
  11315. // braces, and the commas
  11316. if (this.imported_names) {
  11317. size += 2 + list_overhead(this.imported_names);
  11318. }
  11319. return size;
  11320. };
  11321. AST_ImportMeta.prototype._size = () => 11;
  11322. AST_Export.prototype._size = function () {
  11323. let size = 7 + (this.is_default ? 8 : 0);
  11324. if (this.exported_value) {
  11325. size += this.exported_value._size();
  11326. }
  11327. if (this.exported_names) {
  11328. // Braces and commas
  11329. size += 2 + list_overhead(this.exported_names);
  11330. }
  11331. if (this.module_name) {
  11332. // "from "
  11333. size += 5;
  11334. }
  11335. return size;
  11336. };
  11337. AST_Call.prototype._size = function () {
  11338. if (this.optional) {
  11339. return 4 + list_overhead(this.args);
  11340. }
  11341. return 2 + list_overhead(this.args);
  11342. };
  11343. AST_New.prototype._size = function () {
  11344. return 6 + list_overhead(this.args);
  11345. };
  11346. AST_Sequence.prototype._size = function () {
  11347. return list_overhead(this.expressions);
  11348. };
  11349. AST_Dot.prototype._size = function () {
  11350. if (this.optional) {
  11351. return this.property.length + 2;
  11352. }
  11353. return this.property.length + 1;
  11354. };
  11355. AST_DotHash.prototype._size = function () {
  11356. if (this.optional) {
  11357. return this.property.length + 3;
  11358. }
  11359. return this.property.length + 2;
  11360. };
  11361. AST_Sub.prototype._size = function () {
  11362. return this.optional ? 4 : 2;
  11363. };
  11364. AST_Unary.prototype._size = function () {
  11365. if (this.operator === "typeof") return 7;
  11366. if (this.operator === "void") return 5;
  11367. return this.operator.length;
  11368. };
  11369. AST_Binary.prototype._size = function (info) {
  11370. if (this.operator === "in") return 4;
  11371. let size = this.operator.length;
  11372. if (
  11373. (this.operator === "+" || this.operator === "-")
  11374. && this.right instanceof AST_Unary && this.right.operator === this.operator
  11375. ) {
  11376. // 1+ +a > needs space between the +
  11377. size += 1;
  11378. }
  11379. if (this.needs_parens(info)) {
  11380. size += 2;
  11381. }
  11382. return size;
  11383. };
  11384. AST_Conditional.prototype._size = () => 3;
  11385. AST_Array.prototype._size = function () {
  11386. return 2 + list_overhead(this.elements);
  11387. };
  11388. AST_Object.prototype._size = function (info) {
  11389. let base = 2;
  11390. if (first_in_statement(info)) {
  11391. base += 2; // parens
  11392. }
  11393. return base + list_overhead(this.properties);
  11394. };
  11395. /*#__INLINE__*/
  11396. const key_size = key =>
  11397. typeof key === "string" ? key.length : 0;
  11398. AST_ObjectKeyVal.prototype._size = function () {
  11399. return key_size(this.key) + 1;
  11400. };
  11401. /*#__INLINE__*/
  11402. const static_size = is_static => is_static ? 7 : 0;
  11403. AST_ObjectGetter.prototype._size = function () {
  11404. return 5 + static_size(this.static) + key_size(this.key);
  11405. };
  11406. AST_ObjectSetter.prototype._size = function () {
  11407. return 5 + static_size(this.static) + key_size(this.key);
  11408. };
  11409. AST_ConciseMethod.prototype._size = function () {
  11410. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  11411. };
  11412. AST_PrivateMethod.prototype._size = function () {
  11413. return AST_ConciseMethod.prototype._size.call(this) + 1;
  11414. };
  11415. AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
  11416. return AST_ConciseMethod.prototype._size.call(this) + 4;
  11417. };
  11418. AST_PrivateIn.prototype._size = function () {
  11419. return 5; // "#", and " in "
  11420. };
  11421. AST_Class.prototype._size = function () {
  11422. return (
  11423. (this.name ? 8 : 7)
  11424. + (this.extends ? 8 : 0)
  11425. );
  11426. };
  11427. AST_ClassStaticBlock.prototype._size = function () {
  11428. // "class{}" + semicolons
  11429. return 7 + list_overhead(this.body);
  11430. };
  11431. AST_ClassProperty.prototype._size = function () {
  11432. return (
  11433. static_size(this.static)
  11434. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  11435. + (this.value ? 1 : 0)
  11436. );
  11437. };
  11438. AST_ClassPrivateProperty.prototype._size = function () {
  11439. return AST_ClassProperty.prototype._size.call(this) + 1;
  11440. };
  11441. AST_Symbol.prototype._size = function () {
  11442. if (!(mangle_options && this.thedef && !this.thedef.unmangleable(mangle_options))) {
  11443. return this.name.length;
  11444. } else {
  11445. return 1;
  11446. }
  11447. };
  11448. // TODO take propmangle into account
  11449. AST_SymbolClassProperty.prototype._size = function () {
  11450. return this.name.length;
  11451. };
  11452. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  11453. if (this.name === "arguments") return 9;
  11454. return AST_Symbol.prototype._size.call(this);
  11455. };
  11456. AST_NewTarget.prototype._size = () => 10;
  11457. AST_SymbolImportForeign.prototype._size = function () {
  11458. return this.name.length;
  11459. };
  11460. AST_SymbolExportForeign.prototype._size = function () {
  11461. return this.name.length;
  11462. };
  11463. AST_This.prototype._size = () => 4;
  11464. AST_Super.prototype._size = () => 5;
  11465. AST_String.prototype._size = function () {
  11466. return this.value.length + 2;
  11467. };
  11468. AST_Number.prototype._size = function () {
  11469. const { value } = this;
  11470. if (value === 0) return 1;
  11471. if (value > 0 && Math.floor(value) === value) {
  11472. return Math.floor(Math.log10(value) + 1);
  11473. }
  11474. return value.toString().length;
  11475. };
  11476. AST_BigInt.prototype._size = function () {
  11477. return this.value.length;
  11478. };
  11479. AST_RegExp.prototype._size = function () {
  11480. return this.value.toString().length;
  11481. };
  11482. AST_Null.prototype._size = () => 4;
  11483. AST_NaN.prototype._size = () => 3;
  11484. AST_Undefined.prototype._size = () => 6; // "void 0"
  11485. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  11486. AST_Infinity.prototype._size = () => 8;
  11487. AST_True.prototype._size = () => 4;
  11488. AST_False.prototype._size = () => 5;
  11489. AST_Await.prototype._size = () => 6;
  11490. AST_Yield.prototype._size = () => 6;
  11491. /***********************************************************************
  11492. A JavaScript tokenizer / parser / beautifier / compressor.
  11493. https://github.com/mishoo/UglifyJS2
  11494. -------------------------------- (C) ---------------------------------
  11495. Author: Mihai Bazon
  11496. <mihai.bazon@gmail.com>
  11497. http://mihai.bazon.net/blog
  11498. Distributed under the BSD license:
  11499. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11500. Redistribution and use in source and binary forms, with or without
  11501. modification, are permitted provided that the following conditions
  11502. are met:
  11503. * Redistributions of source code must retain the above
  11504. copyright notice, this list of conditions and the following
  11505. disclaimer.
  11506. * Redistributions in binary form must reproduce the above
  11507. copyright notice, this list of conditions and the following
  11508. disclaimer in the documentation and/or other materials
  11509. provided with the distribution.
  11510. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11511. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11512. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11513. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11514. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11515. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11516. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11517. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11518. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11519. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11520. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11521. SUCH DAMAGE.
  11522. ***********************************************************************/
  11523. // bitfield flags to be stored in node.flags.
  11524. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  11525. const UNUSED = 0b00000001;
  11526. const TRUTHY = 0b00000010;
  11527. const FALSY = 0b00000100;
  11528. const UNDEFINED = 0b00001000;
  11529. const INLINED = 0b00010000;
  11530. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  11531. const WRITE_ONLY = 0b00100000;
  11532. // information specific to a single compression pass
  11533. const SQUEEZED = 0b0000000100000000;
  11534. const OPTIMIZED = 0b0000001000000000;
  11535. const TOP = 0b0000010000000000;
  11536. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  11537. const has_flag = (node, flag) => node.flags & flag;
  11538. const set_flag = (node, flag) => { node.flags |= flag; };
  11539. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  11540. /***********************************************************************
  11541. A JavaScript tokenizer / parser / beautifier / compressor.
  11542. https://github.com/mishoo/UglifyJS2
  11543. -------------------------------- (C) ---------------------------------
  11544. Author: Mihai Bazon
  11545. <mihai.bazon@gmail.com>
  11546. http://mihai.bazon.net/blog
  11547. Distributed under the BSD license:
  11548. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11549. Redistribution and use in source and binary forms, with or without
  11550. modification, are permitted provided that the following conditions
  11551. are met:
  11552. * Redistributions of source code must retain the above
  11553. copyright notice, this list of conditions and the following
  11554. disclaimer.
  11555. * Redistributions in binary form must reproduce the above
  11556. copyright notice, this list of conditions and the following
  11557. disclaimer in the documentation and/or other materials
  11558. provided with the distribution.
  11559. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11560. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11561. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11562. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11563. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11564. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11565. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11566. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11567. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11568. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11569. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11570. SUCH DAMAGE.
  11571. ***********************************************************************/
  11572. function merge_sequence(array, node) {
  11573. if (node instanceof AST_Sequence) {
  11574. array.push(...node.expressions);
  11575. } else {
  11576. array.push(node);
  11577. }
  11578. return array;
  11579. }
  11580. function make_sequence(orig, expressions) {
  11581. if (expressions.length == 1) return expressions[0];
  11582. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  11583. return make_node(AST_Sequence, orig, {
  11584. expressions: expressions.reduce(merge_sequence, [])
  11585. });
  11586. }
  11587. function make_node_from_constant(val, orig) {
  11588. switch (typeof val) {
  11589. case "string":
  11590. return make_node(AST_String, orig, {
  11591. value: val
  11592. });
  11593. case "number":
  11594. if (isNaN(val)) return make_node(AST_NaN, orig);
  11595. if (isFinite(val)) {
  11596. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11597. operator: "-",
  11598. expression: make_node(AST_Number, orig, { value: -val })
  11599. }) : make_node(AST_Number, orig, { value: val });
  11600. }
  11601. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11602. operator: "-",
  11603. expression: make_node(AST_Infinity, orig)
  11604. }) : make_node(AST_Infinity, orig);
  11605. case "boolean":
  11606. return make_node(val ? AST_True : AST_False, orig);
  11607. case "undefined":
  11608. return make_node(AST_Undefined, orig);
  11609. default:
  11610. if (val === null) {
  11611. return make_node(AST_Null, orig, { value: null });
  11612. }
  11613. if (val instanceof RegExp) {
  11614. return make_node(AST_RegExp, orig, {
  11615. value: {
  11616. source: regexp_source_fix(val.source),
  11617. flags: val.flags
  11618. }
  11619. });
  11620. }
  11621. throw new Error(string_template("Can't handle constant of type: {type}", {
  11622. type: typeof val
  11623. }));
  11624. }
  11625. }
  11626. function best_of_expression(ast1, ast2) {
  11627. return ast1.size() > ast2.size() ? ast2 : ast1;
  11628. }
  11629. function best_of_statement(ast1, ast2) {
  11630. return best_of_expression(
  11631. make_node(AST_SimpleStatement, ast1, {
  11632. body: ast1
  11633. }),
  11634. make_node(AST_SimpleStatement, ast2, {
  11635. body: ast2
  11636. })
  11637. ).body;
  11638. }
  11639. /** Find which node is smaller, and return that */
  11640. function best_of(compressor, ast1, ast2) {
  11641. if (first_in_statement(compressor)) {
  11642. return best_of_statement(ast1, ast2);
  11643. } else {
  11644. return best_of_expression(ast1, ast2);
  11645. }
  11646. }
  11647. /** Simplify an object property's key, if possible */
  11648. function get_simple_key(key) {
  11649. if (key instanceof AST_Constant) {
  11650. return key.getValue();
  11651. }
  11652. if (key instanceof AST_UnaryPrefix
  11653. && key.operator == "void"
  11654. && key.expression instanceof AST_Constant) {
  11655. return;
  11656. }
  11657. return key;
  11658. }
  11659. function read_property(obj, key) {
  11660. key = get_simple_key(key);
  11661. if (key instanceof AST_Node) return;
  11662. var value;
  11663. if (obj instanceof AST_Array) {
  11664. var elements = obj.elements;
  11665. if (key == "length") return make_node_from_constant(elements.length, obj);
  11666. if (typeof key == "number" && key in elements) value = elements[key];
  11667. } else if (obj instanceof AST_Object) {
  11668. key = "" + key;
  11669. var props = obj.properties;
  11670. for (var i = props.length; --i >= 0;) {
  11671. var prop = props[i];
  11672. if (!(prop instanceof AST_ObjectKeyVal)) return;
  11673. if (!value && props[i].key === key) value = props[i].value;
  11674. }
  11675. }
  11676. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  11677. }
  11678. function has_break_or_continue(loop, parent) {
  11679. var found = false;
  11680. var tw = new TreeWalker(function(node) {
  11681. if (found || node instanceof AST_Scope) return true;
  11682. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  11683. return found = true;
  11684. }
  11685. });
  11686. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  11687. tw.push(loop);
  11688. loop.body.walk(tw);
  11689. return found;
  11690. }
  11691. // we shouldn't compress (1,func)(something) to
  11692. // func(something) because that changes the meaning of
  11693. // the func (becomes lexical instead of global).
  11694. function maintain_this_binding(parent, orig, val) {
  11695. if (
  11696. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  11697. || parent instanceof AST_Call && parent.expression === orig
  11698. && (
  11699. val instanceof AST_Chain
  11700. || val instanceof AST_PropAccess
  11701. || val instanceof AST_SymbolRef && val.name == "eval"
  11702. )
  11703. ) {
  11704. const zero = make_node(AST_Number, orig, { value: 0 });
  11705. return make_sequence(orig, [ zero, val ]);
  11706. } else {
  11707. return val;
  11708. }
  11709. }
  11710. function is_func_expr(node) {
  11711. return node instanceof AST_Arrow || node instanceof AST_Function;
  11712. }
  11713. /**
  11714. * Used to determine whether the node can benefit from negation.
  11715. * Not the case with arrow functions (you need an extra set of parens). */
  11716. function is_iife_call(node) {
  11717. if (node.TYPE != "Call") return false;
  11718. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  11719. }
  11720. function is_empty(thing) {
  11721. if (thing === null) return true;
  11722. if (thing instanceof AST_EmptyStatement) return true;
  11723. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  11724. return false;
  11725. }
  11726. const identifier_atom = makePredicate("Infinity NaN undefined");
  11727. function is_identifier_atom(node) {
  11728. return node instanceof AST_Infinity
  11729. || node instanceof AST_NaN
  11730. || node instanceof AST_Undefined;
  11731. }
  11732. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  11733. function is_ref_of(ref, type) {
  11734. if (!(ref instanceof AST_SymbolRef)) return false;
  11735. var orig = ref.definition().orig;
  11736. for (var i = orig.length; --i >= 0;) {
  11737. if (orig[i] instanceof type) return true;
  11738. }
  11739. }
  11740. /**Can we turn { block contents... } into just the block contents ?
  11741. * Not if one of these is inside.
  11742. **/
  11743. function can_be_evicted_from_block(node) {
  11744. return !(
  11745. node instanceof AST_DefClass ||
  11746. node instanceof AST_Defun ||
  11747. node instanceof AST_Let ||
  11748. node instanceof AST_Const ||
  11749. node instanceof AST_Export ||
  11750. node instanceof AST_Import
  11751. );
  11752. }
  11753. function as_statement_array(thing) {
  11754. if (thing === null) return [];
  11755. if (thing instanceof AST_BlockStatement) return thing.body;
  11756. if (thing instanceof AST_EmptyStatement) return [];
  11757. if (thing instanceof AST_Statement) return [ thing ];
  11758. throw new Error("Can't convert thing to statement array");
  11759. }
  11760. function is_reachable(scope_node, defs) {
  11761. const find_ref = node => {
  11762. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  11763. return walk_abort;
  11764. }
  11765. };
  11766. return walk_parent(scope_node, (node, info) => {
  11767. if (node instanceof AST_Scope && node !== scope_node) {
  11768. var parent = info.parent();
  11769. if (
  11770. parent instanceof AST_Call
  11771. && parent.expression === node
  11772. // Async/Generators aren't guaranteed to sync evaluate all of
  11773. // their body steps, so it's possible they close over the variable.
  11774. && !(node.async || node.is_generator)
  11775. ) {
  11776. return;
  11777. }
  11778. if (walk(node, find_ref)) return walk_abort;
  11779. return true;
  11780. }
  11781. });
  11782. }
  11783. /** Check if a ref refers to the name of a function/class it's defined within */
  11784. function is_recursive_ref(compressor, def) {
  11785. var node;
  11786. for (var i = 0; node = compressor.parent(i); i++) {
  11787. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  11788. var name = node.name;
  11789. if (name && name.definition() === def) {
  11790. return true;
  11791. }
  11792. }
  11793. }
  11794. return false;
  11795. }
  11796. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  11797. function retain_top_func(fn, compressor) {
  11798. return compressor.top_retain
  11799. && fn instanceof AST_Defun
  11800. && has_flag(fn, TOP)
  11801. && fn.name
  11802. && compressor.top_retain(fn.name);
  11803. }
  11804. /***********************************************************************
  11805. A JavaScript tokenizer / parser / beautifier / compressor.
  11806. https://github.com/mishoo/UglifyJS2
  11807. -------------------------------- (C) ---------------------------------
  11808. Author: Mihai Bazon
  11809. <mihai.bazon@gmail.com>
  11810. http://mihai.bazon.net/blog
  11811. Distributed under the BSD license:
  11812. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11813. Redistribution and use in source and binary forms, with or without
  11814. modification, are permitted provided that the following conditions
  11815. are met:
  11816. * Redistributions of source code must retain the above
  11817. copyright notice, this list of conditions and the following
  11818. disclaimer.
  11819. * Redistributions in binary form must reproduce the above
  11820. copyright notice, this list of conditions and the following
  11821. disclaimer in the documentation and/or other materials
  11822. provided with the distribution.
  11823. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11824. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11825. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11826. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11827. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11828. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11829. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11830. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11831. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11832. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11833. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11834. SUCH DAMAGE.
  11835. ***********************************************************************/
  11836. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  11837. // Note: Lots of methods and functions are missing here, in case they aren't pure
  11838. // or not available in all JS environments.
  11839. function make_nested_lookup(obj) {
  11840. const out = new Map();
  11841. for (var key of Object.keys(obj)) {
  11842. out.set(key, makePredicate(obj[key]));
  11843. }
  11844. const does_have = (global_name, fname) => {
  11845. const inner_map = out.get(global_name);
  11846. return inner_map != null && inner_map.has(fname);
  11847. };
  11848. return does_have;
  11849. }
  11850. // Objects which are safe to access without throwing or causing a side effect.
  11851. // Usually we'd check the `unsafe` option first but these are way too common for that
  11852. const pure_prop_access_globals = new Set([
  11853. "Number",
  11854. "String",
  11855. "Array",
  11856. "Object",
  11857. "Function",
  11858. "Promise",
  11859. ]);
  11860. const object_methods = [
  11861. "constructor",
  11862. "toString",
  11863. "valueOf",
  11864. ];
  11865. const is_pure_native_method = make_nested_lookup({
  11866. Array: [
  11867. "at",
  11868. "flat",
  11869. "includes",
  11870. "indexOf",
  11871. "join",
  11872. "lastIndexOf",
  11873. "slice",
  11874. ...object_methods,
  11875. ],
  11876. Boolean: object_methods,
  11877. Function: object_methods,
  11878. Number: [
  11879. "toExponential",
  11880. "toFixed",
  11881. "toPrecision",
  11882. ...object_methods,
  11883. ],
  11884. Object: object_methods,
  11885. RegExp: [
  11886. "test",
  11887. ...object_methods,
  11888. ],
  11889. String: [
  11890. "at",
  11891. "charAt",
  11892. "charCodeAt",
  11893. "charPointAt",
  11894. "concat",
  11895. "endsWith",
  11896. "fromCharCode",
  11897. "fromCodePoint",
  11898. "includes",
  11899. "indexOf",
  11900. "italics",
  11901. "lastIndexOf",
  11902. "localeCompare",
  11903. "match",
  11904. "matchAll",
  11905. "normalize",
  11906. "padStart",
  11907. "padEnd",
  11908. "repeat",
  11909. "replace",
  11910. "replaceAll",
  11911. "search",
  11912. "slice",
  11913. "split",
  11914. "startsWith",
  11915. "substr",
  11916. "substring",
  11917. "repeat",
  11918. "toLocaleLowerCase",
  11919. "toLocaleUpperCase",
  11920. "toLowerCase",
  11921. "toUpperCase",
  11922. "trim",
  11923. "trimEnd",
  11924. "trimStart",
  11925. ...object_methods,
  11926. ],
  11927. });
  11928. const is_pure_native_fn = make_nested_lookup({
  11929. Array: [
  11930. "isArray",
  11931. ],
  11932. Math: [
  11933. "abs",
  11934. "acos",
  11935. "asin",
  11936. "atan",
  11937. "ceil",
  11938. "cos",
  11939. "exp",
  11940. "floor",
  11941. "log",
  11942. "round",
  11943. "sin",
  11944. "sqrt",
  11945. "tan",
  11946. "atan2",
  11947. "pow",
  11948. "max",
  11949. "min",
  11950. ],
  11951. Number: [
  11952. "isFinite",
  11953. "isNaN",
  11954. ],
  11955. Object: [
  11956. "create",
  11957. "getOwnPropertyDescriptor",
  11958. "getOwnPropertyNames",
  11959. "getPrototypeOf",
  11960. "isExtensible",
  11961. "isFrozen",
  11962. "isSealed",
  11963. "hasOwn",
  11964. "keys",
  11965. ],
  11966. String: [
  11967. "fromCharCode",
  11968. ],
  11969. });
  11970. // Known numeric values which come with JS environments
  11971. const is_pure_native_value = make_nested_lookup({
  11972. Math: [
  11973. "E",
  11974. "LN10",
  11975. "LN2",
  11976. "LOG2E",
  11977. "LOG10E",
  11978. "PI",
  11979. "SQRT1_2",
  11980. "SQRT2",
  11981. ],
  11982. Number: [
  11983. "MAX_VALUE",
  11984. "MIN_VALUE",
  11985. "NaN",
  11986. "NEGATIVE_INFINITY",
  11987. "POSITIVE_INFINITY",
  11988. ],
  11989. });
  11990. /***********************************************************************
  11991. A JavaScript tokenizer / parser / beautifier / compressor.
  11992. https://github.com/mishoo/UglifyJS2
  11993. -------------------------------- (C) ---------------------------------
  11994. Author: Mihai Bazon
  11995. <mihai.bazon@gmail.com>
  11996. http://mihai.bazon.net/blog
  11997. Distributed under the BSD license:
  11998. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11999. Redistribution and use in source and binary forms, with or without
  12000. modification, are permitted provided that the following conditions
  12001. are met:
  12002. * Redistributions of source code must retain the above
  12003. copyright notice, this list of conditions and the following
  12004. disclaimer.
  12005. * Redistributions in binary form must reproduce the above
  12006. copyright notice, this list of conditions and the following
  12007. disclaimer in the documentation and/or other materials
  12008. provided with the distribution.
  12009. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12010. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12011. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12012. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12013. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12014. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12015. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12016. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12017. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12018. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12019. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12020. SUCH DAMAGE.
  12021. ***********************************************************************/
  12022. // Functions and methods to infer certain facts about expressions
  12023. // It's not always possible to be 100% sure about something just by static analysis,
  12024. // so `true` means yes, and `false` means maybe
  12025. const is_undeclared_ref = (node) =>
  12026. node instanceof AST_SymbolRef && node.definition().undeclared;
  12027. const lazy_op = makePredicate("&& || ??");
  12028. const unary_side_effects = makePredicate("delete ++ --");
  12029. // methods to determine whether an expression has a boolean result type
  12030. (function(def_is_boolean) {
  12031. const unary_bool = makePredicate("! delete");
  12032. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  12033. def_is_boolean(AST_Node, return_false);
  12034. def_is_boolean(AST_UnaryPrefix, function() {
  12035. return unary_bool.has(this.operator);
  12036. });
  12037. def_is_boolean(AST_Binary, function() {
  12038. return binary_bool.has(this.operator)
  12039. || lazy_op.has(this.operator)
  12040. && this.left.is_boolean()
  12041. && this.right.is_boolean();
  12042. });
  12043. def_is_boolean(AST_Conditional, function() {
  12044. return this.consequent.is_boolean() && this.alternative.is_boolean();
  12045. });
  12046. def_is_boolean(AST_Assign, function() {
  12047. return this.operator == "=" && this.right.is_boolean();
  12048. });
  12049. def_is_boolean(AST_Sequence, function() {
  12050. return this.tail_node().is_boolean();
  12051. });
  12052. def_is_boolean(AST_True, return_true);
  12053. def_is_boolean(AST_False, return_true);
  12054. })(function(node, func) {
  12055. node.DEFMETHOD("is_boolean", func);
  12056. });
  12057. // methods to determine if an expression has a numeric result type
  12058. (function(def_is_number) {
  12059. def_is_number(AST_Node, return_false);
  12060. def_is_number(AST_Number, return_true);
  12061. const unary = makePredicate("+ - ~ ++ --");
  12062. def_is_number(AST_Unary, function() {
  12063. return unary.has(this.operator) && !(this.expression instanceof AST_BigInt);
  12064. });
  12065. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  12066. def_is_number(AST_Binary, function(compressor) {
  12067. return numeric_ops.has(this.operator) || this.operator == "+"
  12068. && this.left.is_number(compressor)
  12069. && this.right.is_number(compressor);
  12070. });
  12071. def_is_number(AST_Assign, function(compressor) {
  12072. return numeric_ops.has(this.operator.slice(0, -1))
  12073. || this.operator == "=" && this.right.is_number(compressor);
  12074. });
  12075. def_is_number(AST_Sequence, function(compressor) {
  12076. return this.tail_node().is_number(compressor);
  12077. });
  12078. def_is_number(AST_Conditional, function(compressor) {
  12079. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  12080. });
  12081. })(function(node, func) {
  12082. node.DEFMETHOD("is_number", func);
  12083. });
  12084. // methods to determine if an expression has a string result type
  12085. (function(def_is_string) {
  12086. def_is_string(AST_Node, return_false);
  12087. def_is_string(AST_String, return_true);
  12088. def_is_string(AST_TemplateString, return_true);
  12089. def_is_string(AST_UnaryPrefix, function() {
  12090. return this.operator == "typeof";
  12091. });
  12092. def_is_string(AST_Binary, function(compressor) {
  12093. return this.operator == "+" &&
  12094. (this.left.is_string(compressor) || this.right.is_string(compressor));
  12095. });
  12096. def_is_string(AST_Assign, function(compressor) {
  12097. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  12098. });
  12099. def_is_string(AST_Sequence, function(compressor) {
  12100. return this.tail_node().is_string(compressor);
  12101. });
  12102. def_is_string(AST_Conditional, function(compressor) {
  12103. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  12104. });
  12105. })(function(node, func) {
  12106. node.DEFMETHOD("is_string", func);
  12107. });
  12108. function is_undefined(node, compressor) {
  12109. return (
  12110. has_flag(node, UNDEFINED)
  12111. || node instanceof AST_Undefined
  12112. || node instanceof AST_UnaryPrefix
  12113. && node.operator == "void"
  12114. && !node.expression.has_side_effects(compressor)
  12115. );
  12116. }
  12117. // Is the node explicitly null or undefined.
  12118. function is_null_or_undefined(node, compressor) {
  12119. let fixed;
  12120. return (
  12121. node instanceof AST_Null
  12122. || is_undefined(node, compressor)
  12123. || (
  12124. node instanceof AST_SymbolRef
  12125. && (fixed = node.definition().fixed) instanceof AST_Node
  12126. && is_nullish(fixed, compressor)
  12127. )
  12128. );
  12129. }
  12130. // Find out if this expression is optionally chained from a base-point that we
  12131. // can statically analyze as null or undefined.
  12132. function is_nullish_shortcircuited(node, compressor) {
  12133. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  12134. return (
  12135. (node.optional && is_null_or_undefined(node.expression, compressor))
  12136. || is_nullish_shortcircuited(node.expression, compressor)
  12137. );
  12138. }
  12139. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  12140. return false;
  12141. }
  12142. // Find out if something is == null, or can short circuit into nullish.
  12143. // Used to optimize ?. and ??
  12144. function is_nullish(node, compressor) {
  12145. if (is_null_or_undefined(node, compressor)) return true;
  12146. return is_nullish_shortcircuited(node, compressor);
  12147. }
  12148. // Determine if expression might cause side effects
  12149. // If there's a possibility that a node may change something when it's executed, this returns true
  12150. (function(def_has_side_effects) {
  12151. def_has_side_effects(AST_Node, return_true);
  12152. def_has_side_effects(AST_EmptyStatement, return_false);
  12153. def_has_side_effects(AST_Constant, return_false);
  12154. def_has_side_effects(AST_This, return_false);
  12155. function any(list, compressor) {
  12156. for (var i = list.length; --i >= 0;)
  12157. if (list[i].has_side_effects(compressor))
  12158. return true;
  12159. return false;
  12160. }
  12161. def_has_side_effects(AST_Block, function(compressor) {
  12162. return any(this.body, compressor);
  12163. });
  12164. def_has_side_effects(AST_Call, function(compressor) {
  12165. if (
  12166. !this.is_callee_pure(compressor)
  12167. && (!this.expression.is_call_pure(compressor)
  12168. || this.expression.has_side_effects(compressor))
  12169. ) {
  12170. return true;
  12171. }
  12172. return any(this.args, compressor);
  12173. });
  12174. def_has_side_effects(AST_Switch, function(compressor) {
  12175. return this.expression.has_side_effects(compressor)
  12176. || any(this.body, compressor);
  12177. });
  12178. def_has_side_effects(AST_Case, function(compressor) {
  12179. return this.expression.has_side_effects(compressor)
  12180. || any(this.body, compressor);
  12181. });
  12182. def_has_side_effects(AST_Try, function(compressor) {
  12183. return this.body.has_side_effects(compressor)
  12184. || this.bcatch && this.bcatch.has_side_effects(compressor)
  12185. || this.bfinally && this.bfinally.has_side_effects(compressor);
  12186. });
  12187. def_has_side_effects(AST_If, function(compressor) {
  12188. return this.condition.has_side_effects(compressor)
  12189. || this.body && this.body.has_side_effects(compressor)
  12190. || this.alternative && this.alternative.has_side_effects(compressor);
  12191. });
  12192. def_has_side_effects(AST_ImportMeta, return_false);
  12193. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  12194. return this.body.has_side_effects(compressor);
  12195. });
  12196. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  12197. return this.body.has_side_effects(compressor);
  12198. });
  12199. def_has_side_effects(AST_Lambda, return_false);
  12200. def_has_side_effects(AST_Class, function (compressor) {
  12201. if (this.extends && this.extends.has_side_effects(compressor)) {
  12202. return true;
  12203. }
  12204. return any(this.properties, compressor);
  12205. });
  12206. def_has_side_effects(AST_ClassStaticBlock, function(compressor) {
  12207. return any(this.body, compressor);
  12208. });
  12209. def_has_side_effects(AST_Binary, function(compressor) {
  12210. return this.left.has_side_effects(compressor)
  12211. || this.right.has_side_effects(compressor);
  12212. });
  12213. def_has_side_effects(AST_Assign, return_true);
  12214. def_has_side_effects(AST_Conditional, function(compressor) {
  12215. return this.condition.has_side_effects(compressor)
  12216. || this.consequent.has_side_effects(compressor)
  12217. || this.alternative.has_side_effects(compressor);
  12218. });
  12219. def_has_side_effects(AST_Unary, function(compressor) {
  12220. return unary_side_effects.has(this.operator)
  12221. || this.expression.has_side_effects(compressor);
  12222. });
  12223. def_has_side_effects(AST_SymbolRef, function(compressor) {
  12224. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12225. });
  12226. def_has_side_effects(AST_SymbolClassProperty, return_false);
  12227. def_has_side_effects(AST_SymbolDeclaration, return_false);
  12228. def_has_side_effects(AST_Object, function(compressor) {
  12229. return any(this.properties, compressor);
  12230. });
  12231. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  12232. return (
  12233. this.computed_key() && this.key.has_side_effects(compressor)
  12234. || this.value && this.value.has_side_effects(compressor)
  12235. );
  12236. });
  12237. def_has_side_effects(AST_ClassProperty, function(compressor) {
  12238. return (
  12239. this.computed_key() && this.key.has_side_effects(compressor)
  12240. || this.static && this.value && this.value.has_side_effects(compressor)
  12241. );
  12242. });
  12243. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  12244. return this.computed_key() && this.key.has_side_effects(compressor);
  12245. });
  12246. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  12247. return this.computed_key() && this.key.has_side_effects(compressor);
  12248. });
  12249. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  12250. return this.computed_key() && this.key.has_side_effects(compressor);
  12251. });
  12252. def_has_side_effects(AST_Array, function(compressor) {
  12253. return any(this.elements, compressor);
  12254. });
  12255. def_has_side_effects(AST_Dot, function(compressor) {
  12256. if (is_nullish(this, compressor)) return false;
  12257. return !this.optional && this.expression.may_throw_on_access(compressor)
  12258. || this.expression.has_side_effects(compressor);
  12259. });
  12260. def_has_side_effects(AST_Sub, function(compressor) {
  12261. if (is_nullish(this, compressor)) return false;
  12262. return !this.optional && this.expression.may_throw_on_access(compressor)
  12263. || this.expression.has_side_effects(compressor)
  12264. || this.property.has_side_effects(compressor);
  12265. });
  12266. def_has_side_effects(AST_Chain, function (compressor) {
  12267. return this.expression.has_side_effects(compressor);
  12268. });
  12269. def_has_side_effects(AST_Sequence, function(compressor) {
  12270. return any(this.expressions, compressor);
  12271. });
  12272. def_has_side_effects(AST_Definitions, function(compressor) {
  12273. return any(this.definitions, compressor);
  12274. });
  12275. def_has_side_effects(AST_VarDef, function() {
  12276. return this.value;
  12277. });
  12278. def_has_side_effects(AST_TemplateSegment, return_false);
  12279. def_has_side_effects(AST_TemplateString, function(compressor) {
  12280. return any(this.segments, compressor);
  12281. });
  12282. })(function(node, func) {
  12283. node.DEFMETHOD("has_side_effects", func);
  12284. });
  12285. // determine if expression may throw
  12286. (function(def_may_throw) {
  12287. def_may_throw(AST_Node, return_true);
  12288. def_may_throw(AST_Constant, return_false);
  12289. def_may_throw(AST_EmptyStatement, return_false);
  12290. def_may_throw(AST_Lambda, return_false);
  12291. def_may_throw(AST_SymbolDeclaration, return_false);
  12292. def_may_throw(AST_This, return_false);
  12293. def_may_throw(AST_ImportMeta, return_false);
  12294. function any(list, compressor) {
  12295. for (var i = list.length; --i >= 0;)
  12296. if (list[i].may_throw(compressor))
  12297. return true;
  12298. return false;
  12299. }
  12300. def_may_throw(AST_Class, function(compressor) {
  12301. if (this.extends && this.extends.may_throw(compressor)) return true;
  12302. return any(this.properties, compressor);
  12303. });
  12304. def_may_throw(AST_ClassStaticBlock, function (compressor) {
  12305. return any(this.body, compressor);
  12306. });
  12307. def_may_throw(AST_Array, function(compressor) {
  12308. return any(this.elements, compressor);
  12309. });
  12310. def_may_throw(AST_Assign, function(compressor) {
  12311. if (this.right.may_throw(compressor)) return true;
  12312. if (!compressor.has_directive("use strict")
  12313. && this.operator == "="
  12314. && this.left instanceof AST_SymbolRef) {
  12315. return false;
  12316. }
  12317. return this.left.may_throw(compressor);
  12318. });
  12319. def_may_throw(AST_Binary, function(compressor) {
  12320. return this.left.may_throw(compressor)
  12321. || this.right.may_throw(compressor);
  12322. });
  12323. def_may_throw(AST_Block, function(compressor) {
  12324. return any(this.body, compressor);
  12325. });
  12326. def_may_throw(AST_Call, function(compressor) {
  12327. if (is_nullish(this, compressor)) return false;
  12328. if (any(this.args, compressor)) return true;
  12329. if (this.is_callee_pure(compressor)) return false;
  12330. if (this.expression.may_throw(compressor)) return true;
  12331. return !(this.expression instanceof AST_Lambda)
  12332. || any(this.expression.body, compressor);
  12333. });
  12334. def_may_throw(AST_Case, function(compressor) {
  12335. return this.expression.may_throw(compressor)
  12336. || any(this.body, compressor);
  12337. });
  12338. def_may_throw(AST_Conditional, function(compressor) {
  12339. return this.condition.may_throw(compressor)
  12340. || this.consequent.may_throw(compressor)
  12341. || this.alternative.may_throw(compressor);
  12342. });
  12343. def_may_throw(AST_Definitions, function(compressor) {
  12344. return any(this.definitions, compressor);
  12345. });
  12346. def_may_throw(AST_If, function(compressor) {
  12347. return this.condition.may_throw(compressor)
  12348. || this.body && this.body.may_throw(compressor)
  12349. || this.alternative && this.alternative.may_throw(compressor);
  12350. });
  12351. def_may_throw(AST_LabeledStatement, function(compressor) {
  12352. return this.body.may_throw(compressor);
  12353. });
  12354. def_may_throw(AST_Object, function(compressor) {
  12355. return any(this.properties, compressor);
  12356. });
  12357. def_may_throw(AST_ObjectProperty, function(compressor) {
  12358. // TODO key may throw too
  12359. return this.value ? this.value.may_throw(compressor) : false;
  12360. });
  12361. def_may_throw(AST_ClassProperty, function(compressor) {
  12362. return (
  12363. this.computed_key() && this.key.may_throw(compressor)
  12364. || this.static && this.value && this.value.may_throw(compressor)
  12365. );
  12366. });
  12367. def_may_throw(AST_ConciseMethod, function(compressor) {
  12368. return this.computed_key() && this.key.may_throw(compressor);
  12369. });
  12370. def_may_throw(AST_ObjectGetter, function(compressor) {
  12371. return this.computed_key() && this.key.may_throw(compressor);
  12372. });
  12373. def_may_throw(AST_ObjectSetter, function(compressor) {
  12374. return this.computed_key() && this.key.may_throw(compressor);
  12375. });
  12376. def_may_throw(AST_Return, function(compressor) {
  12377. return this.value && this.value.may_throw(compressor);
  12378. });
  12379. def_may_throw(AST_Sequence, function(compressor) {
  12380. return any(this.expressions, compressor);
  12381. });
  12382. def_may_throw(AST_SimpleStatement, function(compressor) {
  12383. return this.body.may_throw(compressor);
  12384. });
  12385. def_may_throw(AST_Dot, function(compressor) {
  12386. if (is_nullish(this, compressor)) return false;
  12387. return !this.optional && this.expression.may_throw_on_access(compressor)
  12388. || this.expression.may_throw(compressor);
  12389. });
  12390. def_may_throw(AST_Sub, function(compressor) {
  12391. if (is_nullish(this, compressor)) return false;
  12392. return !this.optional && this.expression.may_throw_on_access(compressor)
  12393. || this.expression.may_throw(compressor)
  12394. || this.property.may_throw(compressor);
  12395. });
  12396. def_may_throw(AST_Chain, function(compressor) {
  12397. return this.expression.may_throw(compressor);
  12398. });
  12399. def_may_throw(AST_Switch, function(compressor) {
  12400. return this.expression.may_throw(compressor)
  12401. || any(this.body, compressor);
  12402. });
  12403. def_may_throw(AST_SymbolRef, function(compressor) {
  12404. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  12405. });
  12406. def_may_throw(AST_SymbolClassProperty, return_false);
  12407. def_may_throw(AST_Try, function(compressor) {
  12408. return this.bcatch ? this.bcatch.may_throw(compressor) : this.body.may_throw(compressor)
  12409. || this.bfinally && this.bfinally.may_throw(compressor);
  12410. });
  12411. def_may_throw(AST_Unary, function(compressor) {
  12412. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12413. return false;
  12414. return this.expression.may_throw(compressor);
  12415. });
  12416. def_may_throw(AST_VarDef, function(compressor) {
  12417. if (!this.value) return false;
  12418. return this.value.may_throw(compressor);
  12419. });
  12420. })(function(node, func) {
  12421. node.DEFMETHOD("may_throw", func);
  12422. });
  12423. // determine if expression is constant
  12424. (function(def_is_constant_expression) {
  12425. function all_refs_local(scope) {
  12426. let result = true;
  12427. walk(this, node => {
  12428. if (node instanceof AST_SymbolRef) {
  12429. if (has_flag(this, INLINED)) {
  12430. result = false;
  12431. return walk_abort;
  12432. }
  12433. var def = node.definition();
  12434. if (
  12435. member(def, this.enclosed)
  12436. && !this.variables.has(def.name)
  12437. ) {
  12438. if (scope) {
  12439. var scope_def = scope.find_variable(node);
  12440. if (def.undeclared ? !scope_def : scope_def === def) {
  12441. result = "f";
  12442. return true;
  12443. }
  12444. }
  12445. result = false;
  12446. return walk_abort;
  12447. }
  12448. return true;
  12449. }
  12450. if (node instanceof AST_This && this instanceof AST_Arrow) {
  12451. result = false;
  12452. return walk_abort;
  12453. }
  12454. });
  12455. return result;
  12456. }
  12457. def_is_constant_expression(AST_Node, return_false);
  12458. def_is_constant_expression(AST_Constant, return_true);
  12459. def_is_constant_expression(AST_Class, function(scope) {
  12460. if (this.extends && !this.extends.is_constant_expression(scope)) {
  12461. return false;
  12462. }
  12463. for (const prop of this.properties) {
  12464. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  12465. return false;
  12466. }
  12467. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  12468. return false;
  12469. }
  12470. if (prop instanceof AST_ClassStaticBlock) {
  12471. return false;
  12472. }
  12473. }
  12474. return all_refs_local.call(this, scope);
  12475. });
  12476. def_is_constant_expression(AST_Lambda, all_refs_local);
  12477. def_is_constant_expression(AST_Unary, function() {
  12478. return this.expression.is_constant_expression();
  12479. });
  12480. def_is_constant_expression(AST_Binary, function() {
  12481. return this.left.is_constant_expression()
  12482. && this.right.is_constant_expression();
  12483. });
  12484. def_is_constant_expression(AST_Array, function() {
  12485. return this.elements.every((l) => l.is_constant_expression());
  12486. });
  12487. def_is_constant_expression(AST_Object, function() {
  12488. return this.properties.every((l) => l.is_constant_expression());
  12489. });
  12490. def_is_constant_expression(AST_ObjectProperty, function() {
  12491. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  12492. });
  12493. })(function(node, func) {
  12494. node.DEFMETHOD("is_constant_expression", func);
  12495. });
  12496. // may_throw_on_access()
  12497. // returns true if this node may be null, undefined or contain `AST_Accessor`
  12498. (function(def_may_throw_on_access) {
  12499. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  12500. return !compressor.option("pure_getters")
  12501. || this._dot_throw(compressor);
  12502. });
  12503. function is_strict(compressor) {
  12504. return /strict/.test(compressor.option("pure_getters"));
  12505. }
  12506. def_may_throw_on_access(AST_Node, is_strict);
  12507. def_may_throw_on_access(AST_Null, return_true);
  12508. def_may_throw_on_access(AST_Undefined, return_true);
  12509. def_may_throw_on_access(AST_Constant, return_false);
  12510. def_may_throw_on_access(AST_Array, return_false);
  12511. def_may_throw_on_access(AST_Object, function(compressor) {
  12512. if (!is_strict(compressor)) return false;
  12513. for (var i = this.properties.length; --i >=0;)
  12514. if (this.properties[i]._dot_throw(compressor)) return true;
  12515. return false;
  12516. });
  12517. // Do not be as strict with classes as we are with objects.
  12518. // Hopefully the community is not going to abuse static getters and setters.
  12519. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  12520. def_may_throw_on_access(AST_Class, return_false);
  12521. def_may_throw_on_access(AST_ObjectProperty, return_false);
  12522. def_may_throw_on_access(AST_ObjectGetter, return_true);
  12523. def_may_throw_on_access(AST_Expansion, function(compressor) {
  12524. return this.expression._dot_throw(compressor);
  12525. });
  12526. def_may_throw_on_access(AST_Function, return_false);
  12527. def_may_throw_on_access(AST_Arrow, return_false);
  12528. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  12529. def_may_throw_on_access(AST_UnaryPrefix, function() {
  12530. return this.operator == "void";
  12531. });
  12532. def_may_throw_on_access(AST_Binary, function(compressor) {
  12533. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  12534. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  12535. });
  12536. def_may_throw_on_access(AST_Assign, function(compressor) {
  12537. if (this.logical) return true;
  12538. return this.operator == "="
  12539. && this.right._dot_throw(compressor);
  12540. });
  12541. def_may_throw_on_access(AST_Conditional, function(compressor) {
  12542. return this.consequent._dot_throw(compressor)
  12543. || this.alternative._dot_throw(compressor);
  12544. });
  12545. def_may_throw_on_access(AST_Dot, function(compressor) {
  12546. if (!is_strict(compressor)) return false;
  12547. if (this.property == "prototype") {
  12548. return !(
  12549. this.expression instanceof AST_Function
  12550. || this.expression instanceof AST_Class
  12551. );
  12552. }
  12553. return true;
  12554. });
  12555. def_may_throw_on_access(AST_Chain, function(compressor) {
  12556. return this.expression._dot_throw(compressor);
  12557. });
  12558. def_may_throw_on_access(AST_Sequence, function(compressor) {
  12559. return this.tail_node()._dot_throw(compressor);
  12560. });
  12561. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  12562. if (this.name === "arguments" && this.scope instanceof AST_Lambda) return false;
  12563. if (has_flag(this, UNDEFINED)) return true;
  12564. if (!is_strict(compressor)) return false;
  12565. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  12566. if (this.is_immutable()) return false;
  12567. var fixed = this.fixed_value();
  12568. return !fixed || fixed._dot_throw(compressor);
  12569. });
  12570. })(function(node, func) {
  12571. node.DEFMETHOD("_dot_throw", func);
  12572. });
  12573. function is_lhs(node, parent) {
  12574. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  12575. if (parent instanceof AST_Assign && parent.left === node) return node;
  12576. if (parent instanceof AST_ForIn && parent.init === node) return node;
  12577. }
  12578. (function(def_find_defs) {
  12579. function to_node(value, orig) {
  12580. if (value instanceof AST_Node) {
  12581. if (!(value instanceof AST_Constant)) {
  12582. // Value may be a function, an array including functions and even a complex assign / block expression,
  12583. // so it should never be shared in different places.
  12584. // Otherwise wrong information may be used in the compression phase
  12585. value = value.clone(true);
  12586. }
  12587. return make_node(value.CTOR, orig, value);
  12588. }
  12589. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  12590. elements: value.map(function(value) {
  12591. return to_node(value, orig);
  12592. })
  12593. });
  12594. if (value && typeof value == "object") {
  12595. var props = [];
  12596. for (var key in value) if (HOP(value, key)) {
  12597. props.push(make_node(AST_ObjectKeyVal, orig, {
  12598. key: key,
  12599. value: to_node(value[key], orig)
  12600. }));
  12601. }
  12602. return make_node(AST_Object, orig, {
  12603. properties: props
  12604. });
  12605. }
  12606. return make_node_from_constant(value, orig);
  12607. }
  12608. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  12609. if (!compressor.option("global_defs")) return this;
  12610. this.figure_out_scope({ ie8: compressor.option("ie8") });
  12611. return this.transform(new TreeTransformer(function(node) {
  12612. var def = node._find_defs(compressor, "");
  12613. if (!def) return;
  12614. var level = 0, child = node, parent;
  12615. while (parent = this.parent(level++)) {
  12616. if (!(parent instanceof AST_PropAccess)) break;
  12617. if (parent.expression !== child) break;
  12618. child = parent;
  12619. }
  12620. if (is_lhs(child, parent)) {
  12621. return;
  12622. }
  12623. return def;
  12624. }));
  12625. });
  12626. def_find_defs(AST_Node, noop);
  12627. def_find_defs(AST_Chain, function(compressor, suffix) {
  12628. return this.expression._find_defs(compressor, suffix);
  12629. });
  12630. def_find_defs(AST_Dot, function(compressor, suffix) {
  12631. return this.expression._find_defs(compressor, "." + this.property + suffix);
  12632. });
  12633. def_find_defs(AST_SymbolDeclaration, function() {
  12634. if (!this.global()) return;
  12635. });
  12636. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  12637. if (!this.global()) return;
  12638. var defines = compressor.option("global_defs");
  12639. var name = this.name + suffix;
  12640. if (HOP(defines, name)) return to_node(defines[name], this);
  12641. });
  12642. def_find_defs(AST_ImportMeta, function(compressor, suffix) {
  12643. var defines = compressor.option("global_defs");
  12644. var name = "import.meta" + suffix;
  12645. if (HOP(defines, name)) return to_node(defines[name], this);
  12646. });
  12647. })(function(node, func) {
  12648. node.DEFMETHOD("_find_defs", func);
  12649. });
  12650. // method to negate an expression
  12651. (function(def_negate) {
  12652. function basic_negation(exp) {
  12653. return make_node(AST_UnaryPrefix, exp, {
  12654. operator: "!",
  12655. expression: exp
  12656. });
  12657. }
  12658. function best(orig, alt, first_in_statement) {
  12659. var negated = basic_negation(orig);
  12660. if (first_in_statement) {
  12661. var stat = make_node(AST_SimpleStatement, alt, {
  12662. body: alt
  12663. });
  12664. return best_of_expression(negated, stat) === stat ? alt : negated;
  12665. }
  12666. return best_of_expression(negated, alt);
  12667. }
  12668. def_negate(AST_Node, function() {
  12669. return basic_negation(this);
  12670. });
  12671. def_negate(AST_Statement, function() {
  12672. throw new Error("Cannot negate a statement");
  12673. });
  12674. def_negate(AST_Function, function() {
  12675. return basic_negation(this);
  12676. });
  12677. def_negate(AST_Class, function() {
  12678. return basic_negation(this);
  12679. });
  12680. def_negate(AST_Arrow, function() {
  12681. return basic_negation(this);
  12682. });
  12683. def_negate(AST_UnaryPrefix, function() {
  12684. if (this.operator == "!")
  12685. return this.expression;
  12686. return basic_negation(this);
  12687. });
  12688. def_negate(AST_Sequence, function(compressor) {
  12689. var expressions = this.expressions.slice();
  12690. expressions.push(expressions.pop().negate(compressor));
  12691. return make_sequence(this, expressions);
  12692. });
  12693. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  12694. var self = this.clone();
  12695. self.consequent = self.consequent.negate(compressor);
  12696. self.alternative = self.alternative.negate(compressor);
  12697. return best(this, self, first_in_statement);
  12698. });
  12699. def_negate(AST_Binary, function(compressor, first_in_statement) {
  12700. var self = this.clone(), op = this.operator;
  12701. if (compressor.option("unsafe_comps")) {
  12702. switch (op) {
  12703. case "<=" : self.operator = ">" ; return self;
  12704. case "<" : self.operator = ">=" ; return self;
  12705. case ">=" : self.operator = "<" ; return self;
  12706. case ">" : self.operator = "<=" ; return self;
  12707. }
  12708. }
  12709. switch (op) {
  12710. case "==" : self.operator = "!="; return self;
  12711. case "!=" : self.operator = "=="; return self;
  12712. case "===": self.operator = "!=="; return self;
  12713. case "!==": self.operator = "==="; return self;
  12714. case "&&":
  12715. self.operator = "||";
  12716. self.left = self.left.negate(compressor, first_in_statement);
  12717. self.right = self.right.negate(compressor);
  12718. return best(this, self, first_in_statement);
  12719. case "||":
  12720. self.operator = "&&";
  12721. self.left = self.left.negate(compressor, first_in_statement);
  12722. self.right = self.right.negate(compressor);
  12723. return best(this, self, first_in_statement);
  12724. }
  12725. return basic_negation(this);
  12726. });
  12727. })(function(node, func) {
  12728. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  12729. return func.call(this, compressor, first_in_statement);
  12730. });
  12731. });
  12732. // Is the callee of this function pure?
  12733. 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");
  12734. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  12735. if (compressor.option("unsafe")) {
  12736. var expr = this.expression;
  12737. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  12738. if (
  12739. expr.expression && expr.expression.name === "hasOwnProperty" &&
  12740. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  12741. ) {
  12742. return false;
  12743. }
  12744. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  12745. if (
  12746. expr instanceof AST_Dot
  12747. && is_undeclared_ref(expr.expression)
  12748. && is_pure_native_fn(expr.expression.name, expr.property)
  12749. ) {
  12750. return true;
  12751. }
  12752. }
  12753. return !!has_annotation(this, _PURE) || !compressor.pure_funcs(this);
  12754. });
  12755. // If I call this, is it a pure function?
  12756. AST_Node.DEFMETHOD("is_call_pure", return_false);
  12757. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  12758. if (!compressor.option("unsafe")) return;
  12759. const expr = this.expression;
  12760. let native_obj;
  12761. if (expr instanceof AST_Array) {
  12762. native_obj = "Array";
  12763. } else if (expr.is_boolean()) {
  12764. native_obj = "Boolean";
  12765. } else if (expr.is_number(compressor)) {
  12766. native_obj = "Number";
  12767. } else if (expr instanceof AST_RegExp) {
  12768. native_obj = "RegExp";
  12769. } else if (expr.is_string(compressor)) {
  12770. native_obj = "String";
  12771. } else if (!this.may_throw_on_access(compressor)) {
  12772. native_obj = "Object";
  12773. }
  12774. return native_obj != null && is_pure_native_method(native_obj, this.property);
  12775. });
  12776. // tell me if a statement aborts
  12777. const aborts = (thing) => thing && thing.aborts();
  12778. (function(def_aborts) {
  12779. def_aborts(AST_Statement, return_null);
  12780. def_aborts(AST_Jump, return_this);
  12781. function block_aborts() {
  12782. for (var i = 0; i < this.body.length; i++) {
  12783. if (aborts(this.body[i])) {
  12784. return this.body[i];
  12785. }
  12786. }
  12787. return null;
  12788. }
  12789. def_aborts(AST_Import, return_null);
  12790. def_aborts(AST_BlockStatement, block_aborts);
  12791. def_aborts(AST_SwitchBranch, block_aborts);
  12792. def_aborts(AST_DefClass, function () {
  12793. for (const prop of this.properties) {
  12794. if (prop instanceof AST_ClassStaticBlock) {
  12795. if (prop.aborts()) return prop;
  12796. }
  12797. }
  12798. return null;
  12799. });
  12800. def_aborts(AST_ClassStaticBlock, block_aborts);
  12801. def_aborts(AST_If, function() {
  12802. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  12803. });
  12804. })(function(node, func) {
  12805. node.DEFMETHOD("aborts", func);
  12806. });
  12807. AST_Node.DEFMETHOD("contains_this", function() {
  12808. return walk(this, node => {
  12809. if (node instanceof AST_This) return walk_abort;
  12810. if (
  12811. node !== this
  12812. && node instanceof AST_Scope
  12813. && !(node instanceof AST_Arrow)
  12814. ) {
  12815. return true;
  12816. }
  12817. });
  12818. });
  12819. function is_modified(compressor, tw, node, value, level, immutable) {
  12820. var parent = tw.parent(level);
  12821. var lhs = is_lhs(node, parent);
  12822. if (lhs) return lhs;
  12823. if (!immutable
  12824. && parent instanceof AST_Call
  12825. && parent.expression === node
  12826. && !(value instanceof AST_Arrow)
  12827. && !(value instanceof AST_Class)
  12828. && !parent.is_callee_pure(compressor)
  12829. && (!(value instanceof AST_Function)
  12830. || !(parent instanceof AST_New) && value.contains_this())) {
  12831. return true;
  12832. }
  12833. if (parent instanceof AST_Array) {
  12834. return is_modified(compressor, tw, parent, parent, level + 1);
  12835. }
  12836. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  12837. var obj = tw.parent(level + 1);
  12838. return is_modified(compressor, tw, obj, obj, level + 2);
  12839. }
  12840. if (parent instanceof AST_PropAccess && parent.expression === node) {
  12841. var prop = read_property(value, parent.property);
  12842. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  12843. }
  12844. }
  12845. /***********************************************************************
  12846. A JavaScript tokenizer / parser / beautifier / compressor.
  12847. https://github.com/mishoo/UglifyJS2
  12848. -------------------------------- (C) ---------------------------------
  12849. Author: Mihai Bazon
  12850. <mihai.bazon@gmail.com>
  12851. http://mihai.bazon.net/blog
  12852. Distributed under the BSD license:
  12853. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12854. Redistribution and use in source and binary forms, with or without
  12855. modification, are permitted provided that the following conditions
  12856. are met:
  12857. * Redistributions of source code must retain the above
  12858. copyright notice, this list of conditions and the following
  12859. disclaimer.
  12860. * Redistributions in binary form must reproduce the above
  12861. copyright notice, this list of conditions and the following
  12862. disclaimer in the documentation and/or other materials
  12863. provided with the distribution.
  12864. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12865. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12866. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12867. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12868. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12869. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12870. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12871. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12872. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12873. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12874. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12875. SUCH DAMAGE.
  12876. ***********************************************************************/
  12877. // methods to evaluate a constant expression
  12878. function def_eval(node, func) {
  12879. node.DEFMETHOD("_eval", func);
  12880. }
  12881. // Used to propagate a nullish short-circuit signal upwards through the chain.
  12882. const nullish = Symbol("This AST_Chain is nullish");
  12883. // If the node has been successfully reduced to a constant,
  12884. // then its value is returned; otherwise the element itself
  12885. // is returned.
  12886. // They can be distinguished as constant value is never a
  12887. // descendant of AST_Node.
  12888. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  12889. if (!compressor.option("evaluate"))
  12890. return this;
  12891. var val = this._eval(compressor, 1);
  12892. if (!val || val instanceof RegExp)
  12893. return val;
  12894. if (typeof val == "function" || typeof val == "object" || val == nullish)
  12895. return this;
  12896. // Evaluated strings can be larger than the original expression
  12897. if (typeof val === "string") {
  12898. const unevaluated_size = this.size(compressor);
  12899. if (val.length + 2 > unevaluated_size) return this;
  12900. }
  12901. return val;
  12902. });
  12903. var unaryPrefix = makePredicate("! ~ - + void");
  12904. AST_Node.DEFMETHOD("is_constant", function () {
  12905. // Accomodate when compress option evaluate=false
  12906. // as well as the common constant expressions !0 and -1
  12907. if (this instanceof AST_Constant) {
  12908. return !(this instanceof AST_RegExp);
  12909. } else {
  12910. return this instanceof AST_UnaryPrefix
  12911. && this.expression instanceof AST_Constant
  12912. && unaryPrefix.has(this.operator);
  12913. }
  12914. });
  12915. def_eval(AST_Statement, function () {
  12916. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  12917. });
  12918. def_eval(AST_Lambda, return_this);
  12919. def_eval(AST_Class, return_this);
  12920. def_eval(AST_Node, return_this);
  12921. def_eval(AST_Constant, function () {
  12922. return this.getValue();
  12923. });
  12924. def_eval(AST_BigInt, return_this);
  12925. def_eval(AST_RegExp, function (compressor) {
  12926. let evaluated = compressor.evaluated_regexps.get(this.value);
  12927. if (evaluated === undefined && regexp_is_safe(this.value.source)) {
  12928. try {
  12929. const { source, flags } = this.value;
  12930. evaluated = new RegExp(source, flags);
  12931. } catch (e) {
  12932. evaluated = null;
  12933. }
  12934. compressor.evaluated_regexps.set(this.value, evaluated);
  12935. }
  12936. return evaluated || this;
  12937. });
  12938. def_eval(AST_TemplateString, function () {
  12939. if (this.segments.length !== 1) return this;
  12940. return this.segments[0].value;
  12941. });
  12942. def_eval(AST_Function, function (compressor) {
  12943. if (compressor.option("unsafe")) {
  12944. var fn = function () { };
  12945. fn.node = this;
  12946. fn.toString = () => this.print_to_string();
  12947. return fn;
  12948. }
  12949. return this;
  12950. });
  12951. def_eval(AST_Array, function (compressor, depth) {
  12952. if (compressor.option("unsafe")) {
  12953. var elements = [];
  12954. for (var i = 0, len = this.elements.length; i < len; i++) {
  12955. var element = this.elements[i];
  12956. var value = element._eval(compressor, depth);
  12957. if (element === value)
  12958. return this;
  12959. elements.push(value);
  12960. }
  12961. return elements;
  12962. }
  12963. return this;
  12964. });
  12965. def_eval(AST_Object, function (compressor, depth) {
  12966. if (compressor.option("unsafe")) {
  12967. var val = {};
  12968. for (var i = 0, len = this.properties.length; i < len; i++) {
  12969. var prop = this.properties[i];
  12970. if (prop instanceof AST_Expansion)
  12971. return this;
  12972. var key = prop.key;
  12973. if (key instanceof AST_Symbol) {
  12974. key = key.name;
  12975. } else if (key instanceof AST_Node) {
  12976. key = key._eval(compressor, depth);
  12977. if (key === prop.key)
  12978. return this;
  12979. }
  12980. if (typeof Object.prototype[key] === "function") {
  12981. return this;
  12982. }
  12983. if (prop.value instanceof AST_Function)
  12984. continue;
  12985. val[key] = prop.value._eval(compressor, depth);
  12986. if (val[key] === prop.value)
  12987. return this;
  12988. }
  12989. return val;
  12990. }
  12991. return this;
  12992. });
  12993. var non_converting_unary = makePredicate("! typeof void");
  12994. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  12995. var e = this.expression;
  12996. // Function would be evaluated to an array and so typeof would
  12997. // incorrectly return 'object'. Hence making is a special case.
  12998. if (compressor.option("typeofs")
  12999. && this.operator == "typeof"
  13000. && (e instanceof AST_Lambda
  13001. || e instanceof AST_SymbolRef
  13002. && e.fixed_value() instanceof AST_Lambda)) {
  13003. return typeof function () { };
  13004. }
  13005. if (!non_converting_unary.has(this.operator))
  13006. depth++;
  13007. e = e._eval(compressor, depth);
  13008. if (e === this.expression)
  13009. return this;
  13010. switch (this.operator) {
  13011. case "!": return !e;
  13012. case "typeof":
  13013. // typeof <RegExp> returns "object" or "function" on different platforms
  13014. // so cannot evaluate reliably
  13015. if (e instanceof RegExp)
  13016. return this;
  13017. return typeof e;
  13018. case "void": return void e;
  13019. case "~": return ~e;
  13020. case "-": return -e;
  13021. case "+": return +e;
  13022. }
  13023. return this;
  13024. });
  13025. var non_converting_binary = makePredicate("&& || ?? === !==");
  13026. const identity_comparison = makePredicate("== != === !==");
  13027. const has_identity = value => typeof value === "object"
  13028. || typeof value === "function"
  13029. || typeof value === "symbol";
  13030. def_eval(AST_Binary, function (compressor, depth) {
  13031. if (!non_converting_binary.has(this.operator))
  13032. depth++;
  13033. var left = this.left._eval(compressor, depth);
  13034. if (left === this.left)
  13035. return this;
  13036. var right = this.right._eval(compressor, depth);
  13037. if (right === this.right)
  13038. return this;
  13039. var result;
  13040. if (left != null
  13041. && right != null
  13042. && identity_comparison.has(this.operator)
  13043. && has_identity(left)
  13044. && has_identity(right)
  13045. && typeof left === typeof right) {
  13046. // Do not compare by reference
  13047. return this;
  13048. }
  13049. switch (this.operator) {
  13050. case "&&": result = left && right; break;
  13051. case "||": result = left || right; break;
  13052. case "??": result = left != null ? left : right; break;
  13053. case "|": result = left | right; break;
  13054. case "&": result = left & right; break;
  13055. case "^": result = left ^ right; break;
  13056. case "+": result = left + right; break;
  13057. case "*": result = left * right; break;
  13058. case "**": result = Math.pow(left, right); break;
  13059. case "/": result = left / right; break;
  13060. case "%": result = left % right; break;
  13061. case "-": result = left - right; break;
  13062. case "<<": result = left << right; break;
  13063. case ">>": result = left >> right; break;
  13064. case ">>>": result = left >>> right; break;
  13065. case "==": result = left == right; break;
  13066. case "===": result = left === right; break;
  13067. case "!=": result = left != right; break;
  13068. case "!==": result = left !== right; break;
  13069. case "<": result = left < right; break;
  13070. case "<=": result = left <= right; break;
  13071. case ">": result = left > right; break;
  13072. case ">=": result = left >= right; break;
  13073. default:
  13074. return this;
  13075. }
  13076. if (isNaN(result) && compressor.find_parent(AST_With)) {
  13077. // leave original expression as is
  13078. return this;
  13079. }
  13080. return result;
  13081. });
  13082. def_eval(AST_Conditional, function (compressor, depth) {
  13083. var condition = this.condition._eval(compressor, depth);
  13084. if (condition === this.condition)
  13085. return this;
  13086. var node = condition ? this.consequent : this.alternative;
  13087. var value = node._eval(compressor, depth);
  13088. return value === node ? this : value;
  13089. });
  13090. // Set of AST_SymbolRef which are currently being evaluated.
  13091. // Avoids infinite recursion of ._eval()
  13092. const reentrant_ref_eval = new Set();
  13093. def_eval(AST_SymbolRef, function (compressor, depth) {
  13094. if (reentrant_ref_eval.has(this))
  13095. return this;
  13096. var fixed = this.fixed_value();
  13097. if (!fixed)
  13098. return this;
  13099. reentrant_ref_eval.add(this);
  13100. const value = fixed._eval(compressor, depth);
  13101. reentrant_ref_eval.delete(this);
  13102. if (value === fixed)
  13103. return this;
  13104. if (value && typeof value == "object") {
  13105. var escaped = this.definition().escaped;
  13106. if (escaped && depth > escaped)
  13107. return this;
  13108. }
  13109. return value;
  13110. });
  13111. const global_objs = { Array, Math, Number, Object, String };
  13112. const regexp_flags = new Set([
  13113. "dotAll",
  13114. "global",
  13115. "ignoreCase",
  13116. "multiline",
  13117. "sticky",
  13118. "unicode",
  13119. ]);
  13120. def_eval(AST_PropAccess, function (compressor, depth) {
  13121. let obj = this.expression._eval(compressor, depth + 1);
  13122. if (obj === nullish || (this.optional && obj == null)) return nullish;
  13123. // `.length` of strings and arrays is always safe
  13124. if (this.property === "length") {
  13125. if (typeof obj === "string") {
  13126. return obj.length;
  13127. }
  13128. const is_spreadless_array =
  13129. obj instanceof AST_Array
  13130. && obj.elements.every(el => !(el instanceof AST_Expansion));
  13131. if (
  13132. is_spreadless_array
  13133. && obj.elements.every(el => !el.has_side_effects(compressor))
  13134. ) {
  13135. return obj.elements.length;
  13136. }
  13137. }
  13138. if (compressor.option("unsafe")) {
  13139. var key = this.property;
  13140. if (key instanceof AST_Node) {
  13141. key = key._eval(compressor, depth);
  13142. if (key === this.property)
  13143. return this;
  13144. }
  13145. var exp = this.expression;
  13146. if (is_undeclared_ref(exp)) {
  13147. var aa;
  13148. var first_arg = exp.name === "hasOwnProperty"
  13149. && key === "call"
  13150. && (aa = compressor.parent() && compressor.parent().args)
  13151. && (aa && aa[0]
  13152. && aa[0].evaluate(compressor));
  13153. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13154. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  13155. return this.clone();
  13156. }
  13157. if (!is_pure_native_value(exp.name, key))
  13158. return this;
  13159. obj = global_objs[exp.name];
  13160. } else {
  13161. if (obj instanceof RegExp) {
  13162. if (key == "source") {
  13163. return regexp_source_fix(obj.source);
  13164. } else if (key == "flags" || regexp_flags.has(key)) {
  13165. return obj[key];
  13166. }
  13167. }
  13168. if (!obj || obj === exp || !HOP(obj, key))
  13169. return this;
  13170. if (typeof obj == "function")
  13171. switch (key) {
  13172. case "name":
  13173. return obj.node.name ? obj.node.name.name : "";
  13174. case "length":
  13175. return obj.node.length_property();
  13176. default:
  13177. return this;
  13178. }
  13179. }
  13180. return obj[key];
  13181. }
  13182. return this;
  13183. });
  13184. def_eval(AST_Chain, function (compressor, depth) {
  13185. const evaluated = this.expression._eval(compressor, depth);
  13186. return evaluated === nullish
  13187. ? undefined
  13188. : evaluated === this.expression
  13189. ? this
  13190. : evaluated;
  13191. });
  13192. def_eval(AST_Call, function (compressor, depth) {
  13193. var exp = this.expression;
  13194. const callee = exp._eval(compressor, depth);
  13195. if (callee === nullish || (this.optional && callee == null)) return nullish;
  13196. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  13197. var key = exp.property;
  13198. if (key instanceof AST_Node) {
  13199. key = key._eval(compressor, depth);
  13200. if (key === exp.property)
  13201. return this;
  13202. }
  13203. var val;
  13204. var e = exp.expression;
  13205. if (is_undeclared_ref(e)) {
  13206. var first_arg = e.name === "hasOwnProperty" &&
  13207. key === "call" &&
  13208. (this.args[0] && this.args[0].evaluate(compressor));
  13209. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  13210. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  13211. return this.clone();
  13212. }
  13213. if (!is_pure_native_fn(e.name, key)) return this;
  13214. val = global_objs[e.name];
  13215. } else {
  13216. val = e._eval(compressor, depth + 1);
  13217. if (val === e || !val)
  13218. return this;
  13219. if (!is_pure_native_method(val.constructor.name, key))
  13220. return this;
  13221. }
  13222. var args = [];
  13223. for (var i = 0, len = this.args.length; i < len; i++) {
  13224. var arg = this.args[i];
  13225. var value = arg._eval(compressor, depth);
  13226. if (arg === value)
  13227. return this;
  13228. if (arg instanceof AST_Lambda)
  13229. return this;
  13230. args.push(value);
  13231. }
  13232. try {
  13233. return val[key].apply(val, args);
  13234. } catch (ex) {
  13235. // We don't really care
  13236. }
  13237. }
  13238. return this;
  13239. });
  13240. // Also a subclass of AST_Call
  13241. def_eval(AST_New, return_this);
  13242. /***********************************************************************
  13243. A JavaScript tokenizer / parser / beautifier / compressor.
  13244. https://github.com/mishoo/UglifyJS2
  13245. -------------------------------- (C) ---------------------------------
  13246. Author: Mihai Bazon
  13247. <mihai.bazon@gmail.com>
  13248. http://mihai.bazon.net/blog
  13249. Distributed under the BSD license:
  13250. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13251. Redistribution and use in source and binary forms, with or without
  13252. modification, are permitted provided that the following conditions
  13253. are met:
  13254. * Redistributions of source code must retain the above
  13255. copyright notice, this list of conditions and the following
  13256. disclaimer.
  13257. * Redistributions in binary form must reproduce the above
  13258. copyright notice, this list of conditions and the following
  13259. disclaimer in the documentation and/or other materials
  13260. provided with the distribution.
  13261. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13262. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13263. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13264. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13265. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13266. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13267. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13268. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13269. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13270. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13271. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13272. SUCH DAMAGE.
  13273. ***********************************************************************/
  13274. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  13275. // only about side effects. We'll be defining this method for each node type in this module
  13276. //
  13277. // Examples:
  13278. // foo++ -> foo++
  13279. // 1 + func() -> func()
  13280. // 10 -> (nothing)
  13281. // knownPureFunc(foo++) -> foo++
  13282. function def_drop_side_effect_free(node, func) {
  13283. node.DEFMETHOD("drop_side_effect_free", func);
  13284. }
  13285. // Drop side-effect-free elements from an array of expressions.
  13286. // Returns an array of expressions with side-effects or null
  13287. // if all elements were dropped. Note: original array may be
  13288. // returned if nothing changed.
  13289. function trim(nodes, compressor, first_in_statement) {
  13290. var len = nodes.length;
  13291. if (!len) return null;
  13292. var ret = [], changed = false;
  13293. for (var i = 0; i < len; i++) {
  13294. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  13295. changed |= node !== nodes[i];
  13296. if (node) {
  13297. ret.push(node);
  13298. first_in_statement = false;
  13299. }
  13300. }
  13301. return changed ? ret.length ? ret : null : nodes;
  13302. }
  13303. def_drop_side_effect_free(AST_Node, return_this);
  13304. def_drop_side_effect_free(AST_Constant, return_null);
  13305. def_drop_side_effect_free(AST_This, return_null);
  13306. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  13307. if (is_nullish_shortcircuited(this, compressor)) {
  13308. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13309. }
  13310. if (!this.is_callee_pure(compressor)) {
  13311. if (this.expression.is_call_pure(compressor)) {
  13312. var exprs = this.args.slice();
  13313. exprs.unshift(this.expression.expression);
  13314. exprs = trim(exprs, compressor, first_in_statement);
  13315. return exprs && make_sequence(this, exprs);
  13316. }
  13317. if (is_func_expr(this.expression)
  13318. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  13319. var node = this.clone();
  13320. node.expression.process_expression(false, compressor);
  13321. return node;
  13322. }
  13323. return this;
  13324. }
  13325. var args = trim(this.args, compressor, first_in_statement);
  13326. return args && make_sequence(this, args);
  13327. });
  13328. def_drop_side_effect_free(AST_Accessor, return_null);
  13329. def_drop_side_effect_free(AST_Function, return_null);
  13330. def_drop_side_effect_free(AST_Arrow, return_null);
  13331. def_drop_side_effect_free(AST_Class, function (compressor) {
  13332. const with_effects = [];
  13333. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  13334. if (trimmed_extends)
  13335. with_effects.push(trimmed_extends);
  13336. for (const prop of this.properties) {
  13337. if (prop instanceof AST_ClassStaticBlock) {
  13338. if (prop.has_side_effects(compressor)) {
  13339. return this; // Be cautious about these
  13340. }
  13341. } else {
  13342. const trimmed_prop = prop.drop_side_effect_free(compressor);
  13343. if (trimmed_prop) {
  13344. if (trimmed_prop.contains_this()) return this;
  13345. with_effects.push(trimmed_prop);
  13346. }
  13347. }
  13348. }
  13349. if (!with_effects.length)
  13350. return null;
  13351. const exprs = make_sequence(this, with_effects);
  13352. if (this instanceof AST_DefClass) {
  13353. // We want a statement
  13354. return make_node(AST_SimpleStatement, this, { body: exprs });
  13355. } else {
  13356. return exprs;
  13357. }
  13358. });
  13359. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  13360. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  13361. const value = this.static && this.value
  13362. && this.value.drop_side_effect_free(compressor);
  13363. if (key && value)
  13364. return make_sequence(this, [key, value]);
  13365. return key || value || null;
  13366. });
  13367. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  13368. var right = this.right.drop_side_effect_free(compressor);
  13369. if (!right)
  13370. return this.left.drop_side_effect_free(compressor, first_in_statement);
  13371. if (lazy_op.has(this.operator)) {
  13372. if (right === this.right)
  13373. return this;
  13374. var node = this.clone();
  13375. node.right = right;
  13376. return node;
  13377. } else {
  13378. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  13379. if (!left)
  13380. return this.right.drop_side_effect_free(compressor, first_in_statement);
  13381. return make_sequence(this, [left, right]);
  13382. }
  13383. });
  13384. def_drop_side_effect_free(AST_Assign, function (compressor) {
  13385. if (this.logical)
  13386. return this;
  13387. var left = this.left;
  13388. if (left.has_side_effects(compressor)
  13389. || compressor.has_directive("use strict")
  13390. && left instanceof AST_PropAccess
  13391. && left.expression.is_constant()) {
  13392. return this;
  13393. }
  13394. set_flag(this, WRITE_ONLY);
  13395. while (left instanceof AST_PropAccess) {
  13396. left = left.expression;
  13397. }
  13398. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  13399. return this.right.drop_side_effect_free(compressor);
  13400. }
  13401. return this;
  13402. });
  13403. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  13404. var consequent = this.consequent.drop_side_effect_free(compressor);
  13405. var alternative = this.alternative.drop_side_effect_free(compressor);
  13406. if (consequent === this.consequent && alternative === this.alternative)
  13407. return this;
  13408. if (!consequent)
  13409. return alternative ? make_node(AST_Binary, this, {
  13410. operator: "||",
  13411. left: this.condition,
  13412. right: alternative
  13413. }) : this.condition.drop_side_effect_free(compressor);
  13414. if (!alternative)
  13415. return make_node(AST_Binary, this, {
  13416. operator: "&&",
  13417. left: this.condition,
  13418. right: consequent
  13419. });
  13420. var node = this.clone();
  13421. node.consequent = consequent;
  13422. node.alternative = alternative;
  13423. return node;
  13424. });
  13425. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  13426. if (unary_side_effects.has(this.operator)) {
  13427. if (!this.expression.has_side_effects(compressor)) {
  13428. set_flag(this, WRITE_ONLY);
  13429. } else {
  13430. clear_flag(this, WRITE_ONLY);
  13431. }
  13432. return this;
  13433. }
  13434. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  13435. return null;
  13436. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13437. if (first_in_statement && expression && is_iife_call(expression)) {
  13438. if (expression === this.expression && this.operator == "!")
  13439. return this;
  13440. return expression.negate(compressor, first_in_statement);
  13441. }
  13442. return expression;
  13443. });
  13444. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  13445. const safe_access = this.is_declared(compressor)
  13446. || pure_prop_access_globals.has(this.name);
  13447. return safe_access ? null : this;
  13448. });
  13449. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  13450. var values = trim(this.properties, compressor, first_in_statement);
  13451. return values && make_sequence(this, values);
  13452. });
  13453. def_drop_side_effect_free(AST_ObjectProperty, function (compressor, first_in_statement) {
  13454. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  13455. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  13456. const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
  13457. if (key && value) {
  13458. return make_sequence(this, [key, value]);
  13459. }
  13460. return key || value;
  13461. });
  13462. def_drop_side_effect_free(AST_ConciseMethod, function () {
  13463. return this.computed_key() ? this.key : null;
  13464. });
  13465. def_drop_side_effect_free(AST_ObjectGetter, function () {
  13466. return this.computed_key() ? this.key : null;
  13467. });
  13468. def_drop_side_effect_free(AST_ObjectSetter, function () {
  13469. return this.computed_key() ? this.key : null;
  13470. });
  13471. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  13472. var values = trim(this.elements, compressor, first_in_statement);
  13473. return values && make_sequence(this, values);
  13474. });
  13475. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  13476. if (is_nullish_shortcircuited(this, compressor)) {
  13477. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13478. }
  13479. if (this.expression.may_throw_on_access(compressor)) return this;
  13480. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13481. });
  13482. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  13483. if (is_nullish_shortcircuited(this, compressor)) {
  13484. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13485. }
  13486. if (this.expression.may_throw_on_access(compressor)) return this;
  13487. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  13488. if (!expression)
  13489. return this.property.drop_side_effect_free(compressor, first_in_statement);
  13490. var property = this.property.drop_side_effect_free(compressor);
  13491. if (!property)
  13492. return expression;
  13493. return make_sequence(this, [expression, property]);
  13494. });
  13495. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  13496. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13497. });
  13498. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  13499. var last = this.tail_node();
  13500. var expr = last.drop_side_effect_free(compressor);
  13501. if (expr === last)
  13502. return this;
  13503. var expressions = this.expressions.slice(0, -1);
  13504. if (expr)
  13505. expressions.push(expr);
  13506. if (!expressions.length) {
  13507. return make_node(AST_Number, this, { value: 0 });
  13508. }
  13509. return make_sequence(this, expressions);
  13510. });
  13511. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  13512. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  13513. });
  13514. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  13515. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  13516. var values = trim(this.segments, compressor, first_in_statement);
  13517. return values && make_sequence(this, values);
  13518. });
  13519. /***********************************************************************
  13520. A JavaScript tokenizer / parser / beautifier / compressor.
  13521. https://github.com/mishoo/UglifyJS2
  13522. -------------------------------- (C) ---------------------------------
  13523. Author: Mihai Bazon
  13524. <mihai.bazon@gmail.com>
  13525. http://mihai.bazon.net/blog
  13526. Distributed under the BSD license:
  13527. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13528. Redistribution and use in source and binary forms, with or without
  13529. modification, are permitted provided that the following conditions
  13530. are met:
  13531. * Redistributions of source code must retain the above
  13532. copyright notice, this list of conditions and the following
  13533. disclaimer.
  13534. * Redistributions in binary form must reproduce the above
  13535. copyright notice, this list of conditions and the following
  13536. disclaimer in the documentation and/or other materials
  13537. provided with the distribution.
  13538. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13539. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13540. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13541. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13542. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13543. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13544. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13545. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13546. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13547. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13548. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13549. SUCH DAMAGE.
  13550. ***********************************************************************/
  13551. const r_keep_assign = /keep_assign/;
  13552. /** Drop unused variables from this scope */
  13553. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  13554. if (!compressor.option("unused")) return;
  13555. if (compressor.has_directive("use asm")) return;
  13556. var self = this;
  13557. if (self.pinned()) return;
  13558. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  13559. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  13560. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  13561. if (node instanceof AST_Assign
  13562. && !node.logical
  13563. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  13564. ) {
  13565. return node.left;
  13566. }
  13567. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  13568. return node.expression;
  13569. }
  13570. };
  13571. var in_use_ids = new Map();
  13572. var fixed_ids = new Map();
  13573. if (self instanceof AST_Toplevel && compressor.top_retain) {
  13574. self.variables.forEach(function(def) {
  13575. if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
  13576. in_use_ids.set(def.id, def);
  13577. }
  13578. });
  13579. }
  13580. var var_defs_by_id = new Map();
  13581. var initializations = new Map();
  13582. // pass 1: find out which symbols are directly used in
  13583. // this scope (not in nested scopes).
  13584. var scope = this;
  13585. var tw = new TreeWalker(function(node, descend) {
  13586. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  13587. node.argnames.forEach(function(argname) {
  13588. if (!(argname instanceof AST_SymbolDeclaration)) return;
  13589. var def = argname.definition();
  13590. if (!in_use_ids.has(def.id)) {
  13591. in_use_ids.set(def.id, def);
  13592. }
  13593. });
  13594. }
  13595. if (node === self) return;
  13596. if (node instanceof AST_Class) {
  13597. if (node.has_side_effects(compressor)) {
  13598. node.visit_nondeferred_class_parts(tw);
  13599. }
  13600. }
  13601. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  13602. var node_def = node.name.definition();
  13603. const in_export = tw.parent() instanceof AST_Export;
  13604. if (in_export || !drop_funcs && scope === self) {
  13605. if (node_def.global && !in_use_ids.has(node_def.id)) {
  13606. in_use_ids.set(node_def.id, node_def);
  13607. }
  13608. }
  13609. map_add(initializations, node_def.id, node);
  13610. return true; // don't go in nested scopes
  13611. }
  13612. if (node instanceof AST_SymbolFunarg && scope === self) {
  13613. map_add(var_defs_by_id, node.definition().id, node);
  13614. }
  13615. if (node instanceof AST_Definitions && scope === self) {
  13616. const in_export = tw.parent() instanceof AST_Export;
  13617. node.definitions.forEach(function(def) {
  13618. if (def.name instanceof AST_SymbolVar) {
  13619. map_add(var_defs_by_id, def.name.definition().id, def);
  13620. }
  13621. if (in_export || !drop_vars) {
  13622. walk(def.name, node => {
  13623. if (node instanceof AST_SymbolDeclaration) {
  13624. const def = node.definition();
  13625. if (def.global && !in_use_ids.has(def.id)) {
  13626. in_use_ids.set(def.id, def);
  13627. }
  13628. }
  13629. });
  13630. }
  13631. if (def.name instanceof AST_Destructuring) {
  13632. def.walk(tw);
  13633. }
  13634. if (def.name instanceof AST_SymbolDeclaration && def.value) {
  13635. var node_def = def.name.definition();
  13636. map_add(initializations, node_def.id, def.value);
  13637. if (!node_def.chained && def.name.fixed_value() === def.value) {
  13638. fixed_ids.set(node_def.id, def);
  13639. }
  13640. if (def.value.has_side_effects(compressor)) {
  13641. def.value.walk(tw);
  13642. }
  13643. }
  13644. });
  13645. return true;
  13646. }
  13647. return scan_ref_scoped(node, descend);
  13648. });
  13649. self.walk(tw);
  13650. // pass 2: for every used symbol we need to walk its
  13651. // initialization code to figure out if it uses other
  13652. // symbols (that may not be in_use).
  13653. tw = new TreeWalker(scan_ref_scoped);
  13654. in_use_ids.forEach(function (def) {
  13655. var init = initializations.get(def.id);
  13656. if (init) init.forEach(function(init) {
  13657. init.walk(tw);
  13658. });
  13659. });
  13660. // pass 3: we should drop declarations not in_use
  13661. var tt = new TreeTransformer(
  13662. function before(node, descend, in_list) {
  13663. var parent = tt.parent();
  13664. if (drop_vars) {
  13665. const sym = assign_as_unused(node);
  13666. if (sym instanceof AST_SymbolRef) {
  13667. var def = sym.definition();
  13668. var in_use = in_use_ids.has(def.id);
  13669. if (node instanceof AST_Assign) {
  13670. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  13671. return maintain_this_binding(parent, node, node.right.transform(tt));
  13672. }
  13673. } else if (!in_use) {
  13674. return in_list ? MAP.skip : make_node(AST_Number, node, { value: 0 });
  13675. }
  13676. }
  13677. }
  13678. if (scope !== self) return;
  13679. var def;
  13680. if (node.name
  13681. && (node instanceof AST_ClassExpression
  13682. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  13683. || node instanceof AST_Function
  13684. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  13685. // any declarations with same name will overshadow
  13686. // name of this anonymous function and can therefore
  13687. // never be used anywhere
  13688. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  13689. }
  13690. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  13691. var trim = !compressor.option("keep_fargs");
  13692. for (var a = node.argnames, i = a.length; --i >= 0;) {
  13693. var sym = a[i];
  13694. if (sym instanceof AST_Expansion) {
  13695. sym = sym.expression;
  13696. }
  13697. if (sym instanceof AST_DefaultAssign) {
  13698. sym = sym.left;
  13699. }
  13700. // Do not drop destructuring arguments.
  13701. // They constitute a type assertion of sorts
  13702. if (
  13703. !(sym instanceof AST_Destructuring)
  13704. && !in_use_ids.has(sym.definition().id)
  13705. ) {
  13706. set_flag(sym, UNUSED);
  13707. if (trim) {
  13708. a.pop();
  13709. }
  13710. } else {
  13711. trim = false;
  13712. }
  13713. }
  13714. }
  13715. if (node instanceof AST_DefClass && node !== self) {
  13716. const def = node.name.definition();
  13717. descend(node, this);
  13718. const keep_class = def.global && !drop_funcs || in_use_ids.has(def.id);
  13719. if (!keep_class) {
  13720. const kept = node.drop_side_effect_free(compressor);
  13721. if (kept == null) {
  13722. def.eliminated++;
  13723. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  13724. }
  13725. return kept;
  13726. }
  13727. return node;
  13728. }
  13729. if (node instanceof AST_Defun && node !== self) {
  13730. const def = node.name.definition();
  13731. const keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  13732. if (!keep) {
  13733. def.eliminated++;
  13734. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  13735. }
  13736. }
  13737. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  13738. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  13739. // place uninitialized names at the start
  13740. var body = [], head = [], tail = [];
  13741. // for unused names whose initialization has
  13742. // side effects, we can cascade the init. code
  13743. // into the next one, or next statement.
  13744. var side_effects = [];
  13745. node.definitions.forEach(function(def) {
  13746. if (def.value) def.value = def.value.transform(tt);
  13747. var is_destructure = def.name instanceof AST_Destructuring;
  13748. var sym = is_destructure
  13749. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  13750. : def.name.definition();
  13751. if (drop_block && sym.global) return tail.push(def);
  13752. if (!(drop_vars || drop_block)
  13753. || is_destructure
  13754. && (def.name.names.length
  13755. || def.name.is_array
  13756. || compressor.option("pure_getters") != true)
  13757. || in_use_ids.has(sym.id)
  13758. ) {
  13759. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  13760. def.value = def.value.drop_side_effect_free(compressor);
  13761. }
  13762. if (def.name instanceof AST_SymbolVar) {
  13763. var var_defs = var_defs_by_id.get(sym.id);
  13764. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  13765. if (def.value) {
  13766. var ref = make_node(AST_SymbolRef, def.name, def.name);
  13767. sym.references.push(ref);
  13768. var assign = make_node(AST_Assign, def, {
  13769. operator: "=",
  13770. logical: false,
  13771. left: ref,
  13772. right: def.value
  13773. });
  13774. if (fixed_ids.get(sym.id) === def) {
  13775. fixed_ids.set(sym.id, assign);
  13776. }
  13777. side_effects.push(assign.transform(tt));
  13778. }
  13779. remove(var_defs, def);
  13780. sym.eliminated++;
  13781. return;
  13782. }
  13783. }
  13784. if (def.value) {
  13785. if (side_effects.length > 0) {
  13786. if (tail.length > 0) {
  13787. side_effects.push(def.value);
  13788. def.value = make_sequence(def.value, side_effects);
  13789. } else {
  13790. body.push(make_node(AST_SimpleStatement, node, {
  13791. body: make_sequence(node, side_effects)
  13792. }));
  13793. }
  13794. side_effects = [];
  13795. }
  13796. tail.push(def);
  13797. } else {
  13798. head.push(def);
  13799. }
  13800. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  13801. var value = def.value && def.value.drop_side_effect_free(compressor);
  13802. if (value) side_effects.push(value);
  13803. def.value = null;
  13804. head.push(def);
  13805. } else {
  13806. var value = def.value && def.value.drop_side_effect_free(compressor);
  13807. if (value) {
  13808. side_effects.push(value);
  13809. }
  13810. sym.eliminated++;
  13811. }
  13812. });
  13813. if (head.length > 0 || tail.length > 0) {
  13814. node.definitions = head.concat(tail);
  13815. body.push(node);
  13816. }
  13817. if (side_effects.length > 0) {
  13818. body.push(make_node(AST_SimpleStatement, node, {
  13819. body: make_sequence(node, side_effects)
  13820. }));
  13821. }
  13822. switch (body.length) {
  13823. case 0:
  13824. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  13825. case 1:
  13826. return body[0];
  13827. default:
  13828. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, { body });
  13829. }
  13830. }
  13831. // certain combination of unused name + side effect leads to:
  13832. // https://github.com/mishoo/UglifyJS2/issues/44
  13833. // https://github.com/mishoo/UglifyJS2/issues/1830
  13834. // https://github.com/mishoo/UglifyJS2/issues/1838
  13835. // that's an invalid AST.
  13836. // We fix it at this stage by moving the `var` outside the `for`.
  13837. if (node instanceof AST_For) {
  13838. descend(node, this);
  13839. var block;
  13840. if (node.init instanceof AST_BlockStatement) {
  13841. block = node.init;
  13842. node.init = block.body.pop();
  13843. block.body.push(node);
  13844. }
  13845. if (node.init instanceof AST_SimpleStatement) {
  13846. node.init = node.init.body;
  13847. } else if (is_empty(node.init)) {
  13848. node.init = null;
  13849. }
  13850. return !block ? node : in_list ? MAP.splice(block.body) : block;
  13851. }
  13852. if (node instanceof AST_LabeledStatement
  13853. && node.body instanceof AST_For
  13854. ) {
  13855. descend(node, this);
  13856. if (node.body instanceof AST_BlockStatement) {
  13857. var block = node.body;
  13858. node.body = block.body.pop();
  13859. block.body.push(node);
  13860. return in_list ? MAP.splice(block.body) : block;
  13861. }
  13862. return node;
  13863. }
  13864. if (node instanceof AST_BlockStatement) {
  13865. descend(node, this);
  13866. if (in_list && node.body.every(can_be_evicted_from_block)) {
  13867. return MAP.splice(node.body);
  13868. }
  13869. return node;
  13870. }
  13871. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  13872. const save_scope = scope;
  13873. scope = node;
  13874. descend(node, this);
  13875. scope = save_scope;
  13876. return node;
  13877. }
  13878. }
  13879. );
  13880. self.transform(tt);
  13881. function scan_ref_scoped(node, descend) {
  13882. var node_def;
  13883. const sym = assign_as_unused(node);
  13884. if (sym instanceof AST_SymbolRef
  13885. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  13886. && self.variables.get(sym.name) === (node_def = sym.definition())
  13887. ) {
  13888. if (node instanceof AST_Assign) {
  13889. node.right.walk(tw);
  13890. if (!node_def.chained && node.left.fixed_value() === node.right) {
  13891. fixed_ids.set(node_def.id, node);
  13892. }
  13893. }
  13894. return true;
  13895. }
  13896. if (node instanceof AST_SymbolRef) {
  13897. node_def = node.definition();
  13898. if (!in_use_ids.has(node_def.id)) {
  13899. in_use_ids.set(node_def.id, node_def);
  13900. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  13901. const redef = node_def.scope.is_block_scope()
  13902. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  13903. if (redef) in_use_ids.set(redef.id, redef);
  13904. }
  13905. }
  13906. return true;
  13907. }
  13908. if (node instanceof AST_Class) {
  13909. descend();
  13910. return true;
  13911. }
  13912. if (node instanceof AST_Scope && !(node instanceof AST_ClassStaticBlock)) {
  13913. var save_scope = scope;
  13914. scope = node;
  13915. descend();
  13916. scope = save_scope;
  13917. return true;
  13918. }
  13919. }
  13920. });
  13921. /***********************************************************************
  13922. A JavaScript tokenizer / parser / beautifier / compressor.
  13923. https://github.com/mishoo/UglifyJS2
  13924. -------------------------------- (C) ---------------------------------
  13925. Author: Mihai Bazon
  13926. <mihai.bazon@gmail.com>
  13927. http://mihai.bazon.net/blog
  13928. Distributed under the BSD license:
  13929. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13930. Redistribution and use in source and binary forms, with or without
  13931. modification, are permitted provided that the following conditions
  13932. are met:
  13933. * Redistributions of source code must retain the above
  13934. copyright notice, this list of conditions and the following
  13935. disclaimer.
  13936. * Redistributions in binary form must reproduce the above
  13937. copyright notice, this list of conditions and the following
  13938. disclaimer in the documentation and/or other materials
  13939. provided with the distribution.
  13940. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13941. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13942. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13943. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13944. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13945. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13946. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13947. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13948. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13949. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13950. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13951. SUCH DAMAGE.
  13952. ***********************************************************************/
  13953. /**
  13954. * Define the method AST_Node#reduce_vars, which goes through the AST in
  13955. * execution order to perform basic flow analysis
  13956. */
  13957. function def_reduce_vars(node, func) {
  13958. node.DEFMETHOD("reduce_vars", func);
  13959. }
  13960. def_reduce_vars(AST_Node, noop);
  13961. /** Clear definition properties */
  13962. function reset_def(compressor, def) {
  13963. def.assignments = 0;
  13964. def.chained = false;
  13965. def.direct_access = false;
  13966. def.escaped = 0;
  13967. def.recursive_refs = 0;
  13968. def.references = [];
  13969. def.single_use = undefined;
  13970. if (
  13971. def.scope.pinned()
  13972. || (def.orig[0] instanceof AST_SymbolFunarg && def.scope.uses_arguments)
  13973. ) {
  13974. def.fixed = false;
  13975. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  13976. def.fixed = def.init;
  13977. } else {
  13978. def.fixed = false;
  13979. }
  13980. }
  13981. function reset_variables(tw, compressor, node) {
  13982. node.variables.forEach(function(def) {
  13983. reset_def(compressor, def);
  13984. if (def.fixed === null) {
  13985. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  13986. mark(tw, def, true);
  13987. } else if (def.fixed) {
  13988. tw.loop_ids.set(def.id, tw.in_loop);
  13989. mark(tw, def, true);
  13990. }
  13991. });
  13992. }
  13993. function reset_block_variables(compressor, node) {
  13994. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  13995. reset_def(compressor, def);
  13996. });
  13997. }
  13998. function push(tw) {
  13999. tw.safe_ids = Object.create(tw.safe_ids);
  14000. }
  14001. function pop(tw) {
  14002. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  14003. }
  14004. function mark(tw, def, safe) {
  14005. tw.safe_ids[def.id] = safe;
  14006. }
  14007. function safe_to_read(tw, def) {
  14008. if (def.single_use == "m") return false;
  14009. if (tw.safe_ids[def.id]) {
  14010. if (def.fixed == null) {
  14011. var orig = def.orig[0];
  14012. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  14013. def.fixed = make_node(AST_Undefined, orig);
  14014. }
  14015. return true;
  14016. }
  14017. return def.fixed instanceof AST_Defun;
  14018. }
  14019. function safe_to_assign(tw, def, scope, value) {
  14020. if (def.fixed === undefined) return true;
  14021. let def_safe_ids;
  14022. if (def.fixed === null
  14023. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  14024. ) {
  14025. def_safe_ids[def.id] = false;
  14026. tw.defs_to_safe_ids.delete(def.id);
  14027. return true;
  14028. }
  14029. if (!HOP(tw.safe_ids, def.id)) return false;
  14030. if (!safe_to_read(tw, def)) return false;
  14031. if (def.fixed === false) return false;
  14032. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  14033. if (def.fixed instanceof AST_Defun) {
  14034. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  14035. }
  14036. return def.orig.every((sym) => {
  14037. return !(sym instanceof AST_SymbolConst
  14038. || sym instanceof AST_SymbolDefun
  14039. || sym instanceof AST_SymbolLambda);
  14040. });
  14041. }
  14042. function ref_once(tw, compressor, def) {
  14043. return compressor.option("unused")
  14044. && !def.scope.pinned()
  14045. && def.references.length - def.recursive_refs == 1
  14046. && tw.loop_ids.get(def.id) === tw.in_loop;
  14047. }
  14048. function is_immutable(value) {
  14049. if (!value) return false;
  14050. return value.is_constant()
  14051. || value instanceof AST_Lambda
  14052. || value instanceof AST_This;
  14053. }
  14054. // A definition "escapes" when its value can leave the point of use.
  14055. // Example: `a = b || c`
  14056. // In this example, "b" and "c" are escaping, because they're going into "a"
  14057. //
  14058. // def.escaped is != 0 when it escapes.
  14059. //
  14060. // When greater than 1, it means that N chained properties will be read off
  14061. // of that def before an escape occurs. This is useful for evaluating
  14062. // property accesses, where you need to know when to stop.
  14063. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  14064. var parent = tw.parent(level);
  14065. if (value) {
  14066. if (value.is_constant()) return;
  14067. if (value instanceof AST_ClassExpression) return;
  14068. }
  14069. if (
  14070. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  14071. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  14072. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  14073. || parent instanceof AST_VarDef && node === parent.value
  14074. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  14075. ) {
  14076. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  14077. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  14078. return;
  14079. } else if (
  14080. parent instanceof AST_Array
  14081. || parent instanceof AST_Await
  14082. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  14083. || parent instanceof AST_Conditional && node !== parent.condition
  14084. || parent instanceof AST_Expansion
  14085. || parent instanceof AST_Sequence && node === parent.tail_node()
  14086. ) {
  14087. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  14088. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  14089. var obj = tw.parent(level + 1);
  14090. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  14091. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  14092. value = read_property(value, parent.property);
  14093. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  14094. if (value) return;
  14095. }
  14096. if (level > 0) return;
  14097. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  14098. if (parent instanceof AST_SimpleStatement) return;
  14099. d.direct_access = true;
  14100. }
  14101. const suppress = node => walk(node, node => {
  14102. if (!(node instanceof AST_Symbol)) return;
  14103. var d = node.definition();
  14104. if (!d) return;
  14105. if (node instanceof AST_SymbolRef) d.references.push(node);
  14106. d.fixed = false;
  14107. });
  14108. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  14109. push(tw);
  14110. reset_variables(tw, compressor, this);
  14111. descend();
  14112. pop(tw);
  14113. return true;
  14114. });
  14115. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  14116. var node = this;
  14117. if (node.left instanceof AST_Destructuring) {
  14118. suppress(node.left);
  14119. return;
  14120. }
  14121. const finish_walk = () => {
  14122. if (node.logical) {
  14123. node.left.walk(tw);
  14124. push(tw);
  14125. node.right.walk(tw);
  14126. pop(tw);
  14127. return true;
  14128. }
  14129. };
  14130. var sym = node.left;
  14131. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  14132. var def = sym.definition();
  14133. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  14134. def.assignments++;
  14135. if (!safe) return finish_walk();
  14136. var fixed = def.fixed;
  14137. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  14138. var eq = node.operator == "=";
  14139. var value = eq ? node.right : node;
  14140. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  14141. def.references.push(sym);
  14142. if (!node.logical) {
  14143. if (!eq) def.chained = true;
  14144. def.fixed = eq ? function() {
  14145. return node.right;
  14146. } : function() {
  14147. return make_node(AST_Binary, node, {
  14148. operator: node.operator.slice(0, -1),
  14149. left: fixed instanceof AST_Node ? fixed : fixed(),
  14150. right: node.right
  14151. });
  14152. };
  14153. }
  14154. if (node.logical) {
  14155. mark(tw, def, false);
  14156. push(tw);
  14157. node.right.walk(tw);
  14158. pop(tw);
  14159. return true;
  14160. }
  14161. mark(tw, def, false);
  14162. node.right.walk(tw);
  14163. mark(tw, def, true);
  14164. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  14165. return true;
  14166. });
  14167. def_reduce_vars(AST_Binary, function(tw) {
  14168. if (!lazy_op.has(this.operator)) return;
  14169. this.left.walk(tw);
  14170. push(tw);
  14171. this.right.walk(tw);
  14172. pop(tw);
  14173. return true;
  14174. });
  14175. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  14176. reset_block_variables(compressor, this);
  14177. });
  14178. def_reduce_vars(AST_Case, function(tw) {
  14179. push(tw);
  14180. this.expression.walk(tw);
  14181. pop(tw);
  14182. push(tw);
  14183. walk_body(this, tw);
  14184. pop(tw);
  14185. return true;
  14186. });
  14187. def_reduce_vars(AST_Class, function(tw, descend) {
  14188. clear_flag(this, INLINED);
  14189. push(tw);
  14190. descend();
  14191. pop(tw);
  14192. return true;
  14193. });
  14194. def_reduce_vars(AST_ClassStaticBlock, function(tw, descend, compressor) {
  14195. reset_block_variables(compressor, this);
  14196. });
  14197. def_reduce_vars(AST_Conditional, function(tw) {
  14198. this.condition.walk(tw);
  14199. push(tw);
  14200. this.consequent.walk(tw);
  14201. pop(tw);
  14202. push(tw);
  14203. this.alternative.walk(tw);
  14204. pop(tw);
  14205. return true;
  14206. });
  14207. def_reduce_vars(AST_Chain, function(tw, descend) {
  14208. // Chains' conditions apply left-to-right, cumulatively.
  14209. // If we walk normally we don't go in that order because we would pop before pushing again
  14210. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  14211. // Then we pop everything when they are done being walked.
  14212. const safe_ids = tw.safe_ids;
  14213. descend();
  14214. // Unroll back to start
  14215. tw.safe_ids = safe_ids;
  14216. return true;
  14217. });
  14218. def_reduce_vars(AST_Call, function (tw) {
  14219. this.expression.walk(tw);
  14220. if (this.optional) {
  14221. // Never pop -- it's popped at AST_Chain above
  14222. push(tw);
  14223. }
  14224. for (const arg of this.args) arg.walk(tw);
  14225. return true;
  14226. });
  14227. def_reduce_vars(AST_PropAccess, function (tw) {
  14228. if (!this.optional) return;
  14229. this.expression.walk(tw);
  14230. // Never pop -- it's popped at AST_Chain above
  14231. push(tw);
  14232. if (this.property instanceof AST_Node) this.property.walk(tw);
  14233. return true;
  14234. });
  14235. def_reduce_vars(AST_Default, function(tw, descend) {
  14236. push(tw);
  14237. descend();
  14238. pop(tw);
  14239. return true;
  14240. });
  14241. function mark_lambda(tw, descend, compressor) {
  14242. clear_flag(this, INLINED);
  14243. push(tw);
  14244. reset_variables(tw, compressor, this);
  14245. var iife;
  14246. if (!this.name
  14247. && !this.uses_arguments
  14248. && !this.pinned()
  14249. && (iife = tw.parent()) instanceof AST_Call
  14250. && iife.expression === this
  14251. && !iife.args.some(arg => arg instanceof AST_Expansion)
  14252. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  14253. ) {
  14254. // Virtually turn IIFE parameters into variable definitions:
  14255. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  14256. // So existing transformation rules can work on them.
  14257. this.argnames.forEach((arg, i) => {
  14258. if (!arg.definition) return;
  14259. var d = arg.definition();
  14260. // Avoid setting fixed when there's more than one origin for a variable value
  14261. if (d.orig.length > 1) return;
  14262. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  14263. d.fixed = function() {
  14264. return iife.args[i] || make_node(AST_Undefined, iife);
  14265. };
  14266. tw.loop_ids.set(d.id, tw.in_loop);
  14267. mark(tw, d, true);
  14268. } else {
  14269. d.fixed = false;
  14270. }
  14271. });
  14272. }
  14273. descend();
  14274. pop(tw);
  14275. handle_defined_after_hoist(this);
  14276. return true;
  14277. }
  14278. /**
  14279. * It's possible for a hoisted function to use something that's not defined yet. Example:
  14280. *
  14281. * hoisted();
  14282. * var defined_after = true;
  14283. * function hoisted() {
  14284. * // use defined_after
  14285. * }
  14286. *
  14287. * This function is called on the parent to handle this issue.
  14288. */
  14289. function handle_defined_after_hoist(parent) {
  14290. const defuns = [];
  14291. walk(parent, node => {
  14292. if (node === parent) return;
  14293. if (node instanceof AST_Defun) defuns.push(node);
  14294. if (
  14295. node instanceof AST_Scope
  14296. || node instanceof AST_SimpleStatement
  14297. ) return true;
  14298. });
  14299. const symbols_of_interest = new Set();
  14300. const defuns_of_interest = new Set();
  14301. const potential_conflicts = [];
  14302. for (const defun of defuns) {
  14303. const fname_def = defun.name.definition();
  14304. const found_self_ref_in_other_defuns = defuns.some(
  14305. d => d !== defun && d.enclosed.indexOf(fname_def) !== -1
  14306. );
  14307. for (const def of defun.enclosed) {
  14308. if (
  14309. def.fixed === false
  14310. || def === fname_def
  14311. || def.scope.get_defun_scope() !== parent
  14312. ) {
  14313. continue;
  14314. }
  14315. // defun is hoisted, so always safe
  14316. if (
  14317. def.assignments === 0
  14318. && def.orig.length === 1
  14319. && def.orig[0] instanceof AST_SymbolDefun
  14320. ) {
  14321. continue;
  14322. }
  14323. if (found_self_ref_in_other_defuns) {
  14324. def.fixed = false;
  14325. continue;
  14326. }
  14327. // for the slower checks below this loop
  14328. potential_conflicts.push({ defun, def, fname_def });
  14329. symbols_of_interest.add(def.id);
  14330. symbols_of_interest.add(fname_def.id);
  14331. defuns_of_interest.add(defun);
  14332. }
  14333. }
  14334. // linearize all symbols, and locate defs that are read after the defun
  14335. if (potential_conflicts.length) {
  14336. // All "symbols of interest", that is, defuns or defs, that we found.
  14337. // These are placed in order so we can check which is after which.
  14338. const found_symbols = [];
  14339. // Indices of `found_symbols` which are writes
  14340. const found_symbol_writes = new Set();
  14341. // Defun ranges are recorded because we don't care if a function uses the def internally
  14342. const defun_ranges = new Map();
  14343. let tw;
  14344. parent.walk((tw = new TreeWalker((node, descend) => {
  14345. if (node instanceof AST_Defun && defuns_of_interest.has(node)) {
  14346. const start = found_symbols.length;
  14347. descend();
  14348. const end = found_symbols.length;
  14349. defun_ranges.set(node, { start, end });
  14350. return true;
  14351. }
  14352. // if we found a defun on the list, mark IN_DEFUN=id and descend
  14353. if (node instanceof AST_Symbol && node.thedef) {
  14354. const id = node.definition().id;
  14355. if (symbols_of_interest.has(id)) {
  14356. if (node instanceof AST_SymbolDeclaration || is_lhs(node, tw)) {
  14357. found_symbol_writes.add(found_symbols.length);
  14358. }
  14359. found_symbols.push(id);
  14360. }
  14361. }
  14362. })));
  14363. for (const { def, defun, fname_def } of potential_conflicts) {
  14364. const defun_range = defun_ranges.get(defun);
  14365. // find the index in `found_symbols`, with some special rules:
  14366. const find = (sym_id, starting_at = 0, must_be_write = false) => {
  14367. let index = starting_at;
  14368. for (;;) {
  14369. index = found_symbols.indexOf(sym_id, index);
  14370. if (index === -1) {
  14371. break;
  14372. } else if (index >= defun_range.start && index < defun_range.end) {
  14373. index = defun_range.end;
  14374. continue;
  14375. } else if (must_be_write && !found_symbol_writes.has(index)) {
  14376. index++;
  14377. continue;
  14378. } else {
  14379. break;
  14380. }
  14381. }
  14382. return index;
  14383. };
  14384. const read_defun_at = find(fname_def.id);
  14385. const wrote_def_at = find(def.id, read_defun_at + 1, true);
  14386. const wrote_def_after_reading_defun = read_defun_at != -1 && wrote_def_at != -1 && wrote_def_at > read_defun_at;
  14387. if (wrote_def_after_reading_defun) {
  14388. def.fixed = false;
  14389. }
  14390. }
  14391. }
  14392. }
  14393. def_reduce_vars(AST_Lambda, mark_lambda);
  14394. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  14395. reset_block_variables(compressor, this);
  14396. const saved_loop = tw.in_loop;
  14397. tw.in_loop = this;
  14398. push(tw);
  14399. this.body.walk(tw);
  14400. if (has_break_or_continue(this)) {
  14401. pop(tw);
  14402. push(tw);
  14403. }
  14404. this.condition.walk(tw);
  14405. pop(tw);
  14406. tw.in_loop = saved_loop;
  14407. return true;
  14408. });
  14409. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  14410. reset_block_variables(compressor, this);
  14411. if (this.init) this.init.walk(tw);
  14412. const saved_loop = tw.in_loop;
  14413. tw.in_loop = this;
  14414. push(tw);
  14415. if (this.condition) this.condition.walk(tw);
  14416. this.body.walk(tw);
  14417. if (this.step) {
  14418. if (has_break_or_continue(this)) {
  14419. pop(tw);
  14420. push(tw);
  14421. }
  14422. this.step.walk(tw);
  14423. }
  14424. pop(tw);
  14425. tw.in_loop = saved_loop;
  14426. return true;
  14427. });
  14428. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  14429. reset_block_variables(compressor, this);
  14430. suppress(this.init);
  14431. this.object.walk(tw);
  14432. const saved_loop = tw.in_loop;
  14433. tw.in_loop = this;
  14434. push(tw);
  14435. this.body.walk(tw);
  14436. pop(tw);
  14437. tw.in_loop = saved_loop;
  14438. return true;
  14439. });
  14440. def_reduce_vars(AST_If, function(tw) {
  14441. this.condition.walk(tw);
  14442. push(tw);
  14443. this.body.walk(tw);
  14444. pop(tw);
  14445. if (this.alternative) {
  14446. push(tw);
  14447. this.alternative.walk(tw);
  14448. pop(tw);
  14449. }
  14450. return true;
  14451. });
  14452. def_reduce_vars(AST_LabeledStatement, function(tw) {
  14453. push(tw);
  14454. this.body.walk(tw);
  14455. pop(tw);
  14456. return true;
  14457. });
  14458. def_reduce_vars(AST_SymbolCatch, function() {
  14459. this.definition().fixed = false;
  14460. });
  14461. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  14462. var d = this.definition();
  14463. d.references.push(this);
  14464. if (d.references.length == 1
  14465. && !d.fixed
  14466. && d.orig[0] instanceof AST_SymbolDefun) {
  14467. tw.loop_ids.set(d.id, tw.in_loop);
  14468. }
  14469. var fixed_value;
  14470. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  14471. d.fixed = false;
  14472. } else if (d.fixed) {
  14473. fixed_value = this.fixed_value();
  14474. if (
  14475. fixed_value instanceof AST_Lambda
  14476. && is_recursive_ref(tw, d)
  14477. ) {
  14478. d.recursive_refs++;
  14479. } else if (fixed_value
  14480. && !compressor.exposed(d)
  14481. && ref_once(tw, compressor, d)
  14482. ) {
  14483. d.single_use =
  14484. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  14485. || fixed_value instanceof AST_Class
  14486. || d.scope === this.scope && fixed_value.is_constant_expression();
  14487. } else {
  14488. d.single_use = false;
  14489. }
  14490. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  14491. if (d.single_use) {
  14492. d.single_use = "m";
  14493. } else {
  14494. d.fixed = false;
  14495. }
  14496. }
  14497. }
  14498. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  14499. });
  14500. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  14501. this.globals.forEach(function(def) {
  14502. reset_def(compressor, def);
  14503. });
  14504. reset_variables(tw, compressor, this);
  14505. descend();
  14506. handle_defined_after_hoist(this);
  14507. return true;
  14508. });
  14509. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  14510. reset_block_variables(compressor, this);
  14511. push(tw);
  14512. this.body.walk(tw);
  14513. pop(tw);
  14514. if (this.bcatch) {
  14515. push(tw);
  14516. this.bcatch.walk(tw);
  14517. pop(tw);
  14518. }
  14519. if (this.bfinally) this.bfinally.walk(tw);
  14520. return true;
  14521. });
  14522. def_reduce_vars(AST_Unary, function(tw) {
  14523. var node = this;
  14524. if (node.operator !== "++" && node.operator !== "--") return;
  14525. var exp = node.expression;
  14526. if (!(exp instanceof AST_SymbolRef)) return;
  14527. var def = exp.definition();
  14528. var safe = safe_to_assign(tw, def, exp.scope, true);
  14529. def.assignments++;
  14530. if (!safe) return;
  14531. var fixed = def.fixed;
  14532. if (!fixed) return;
  14533. def.references.push(exp);
  14534. def.chained = true;
  14535. def.fixed = function() {
  14536. return make_node(AST_Binary, node, {
  14537. operator: node.operator.slice(0, -1),
  14538. left: make_node(AST_UnaryPrefix, node, {
  14539. operator: "+",
  14540. expression: fixed instanceof AST_Node ? fixed : fixed()
  14541. }),
  14542. right: make_node(AST_Number, node, {
  14543. value: 1
  14544. })
  14545. });
  14546. };
  14547. mark(tw, def, true);
  14548. return true;
  14549. });
  14550. def_reduce_vars(AST_VarDef, function(tw, descend) {
  14551. var node = this;
  14552. if (node.name instanceof AST_Destructuring) {
  14553. suppress(node.name);
  14554. return;
  14555. }
  14556. var d = node.name.definition();
  14557. if (node.value) {
  14558. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  14559. d.fixed = function() {
  14560. return node.value;
  14561. };
  14562. tw.loop_ids.set(d.id, tw.in_loop);
  14563. mark(tw, d, false);
  14564. descend();
  14565. mark(tw, d, true);
  14566. return true;
  14567. } else {
  14568. d.fixed = false;
  14569. }
  14570. }
  14571. });
  14572. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  14573. reset_block_variables(compressor, this);
  14574. const saved_loop = tw.in_loop;
  14575. tw.in_loop = this;
  14576. push(tw);
  14577. descend();
  14578. pop(tw);
  14579. tw.in_loop = saved_loop;
  14580. return true;
  14581. });
  14582. /***********************************************************************
  14583. A JavaScript tokenizer / parser / beautifier / compressor.
  14584. https://github.com/mishoo/UglifyJS2
  14585. -------------------------------- (C) ---------------------------------
  14586. Author: Mihai Bazon
  14587. <mihai.bazon@gmail.com>
  14588. http://mihai.bazon.net/blog
  14589. Distributed under the BSD license:
  14590. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14591. Redistribution and use in source and binary forms, with or without
  14592. modification, are permitted provided that the following conditions
  14593. are met:
  14594. * Redistributions of source code must retain the above
  14595. copyright notice, this list of conditions and the following
  14596. disclaimer.
  14597. * Redistributions in binary form must reproduce the above
  14598. copyright notice, this list of conditions and the following
  14599. disclaimer in the documentation and/or other materials
  14600. provided with the distribution.
  14601. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14602. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14603. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14604. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14605. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14606. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14607. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14608. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14609. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14610. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14611. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14612. SUCH DAMAGE.
  14613. ***********************************************************************/
  14614. function loop_body(x) {
  14615. if (x instanceof AST_IterationStatement) {
  14616. return x.body instanceof AST_BlockStatement ? x.body : x;
  14617. }
  14618. return x;
  14619. }
  14620. function is_lhs_read_only(lhs) {
  14621. if (lhs instanceof AST_This) return true;
  14622. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  14623. if (lhs instanceof AST_PropAccess) {
  14624. lhs = lhs.expression;
  14625. if (lhs instanceof AST_SymbolRef) {
  14626. if (lhs.is_immutable()) return false;
  14627. lhs = lhs.fixed_value();
  14628. }
  14629. if (!lhs) return true;
  14630. if (lhs instanceof AST_RegExp) return false;
  14631. if (lhs instanceof AST_Constant) return true;
  14632. return is_lhs_read_only(lhs);
  14633. }
  14634. return false;
  14635. }
  14636. /** var a = 1 --> var a*/
  14637. function remove_initializers(var_statement) {
  14638. var decls = [];
  14639. var_statement.definitions.forEach(function(def) {
  14640. if (def.name instanceof AST_SymbolDeclaration) {
  14641. def.value = null;
  14642. decls.push(def);
  14643. } else {
  14644. def.declarations_as_names().forEach(name => {
  14645. decls.push(make_node(AST_VarDef, def, {
  14646. name,
  14647. value: null
  14648. }));
  14649. });
  14650. }
  14651. });
  14652. return decls.length ? make_node(AST_Var, var_statement, { definitions: decls }) : null;
  14653. }
  14654. /** Called on code which we know is unreachable, to keep elements that affect outside of it. */
  14655. function trim_unreachable_code(compressor, stat, target) {
  14656. walk(stat, node => {
  14657. if (node instanceof AST_Var) {
  14658. const no_initializers = remove_initializers(node);
  14659. if (no_initializers) target.push(no_initializers);
  14660. return true;
  14661. }
  14662. if (
  14663. node instanceof AST_Defun
  14664. && (node === stat || !compressor.has_directive("use strict"))
  14665. ) {
  14666. target.push(node === stat ? node : make_node(AST_Var, node, {
  14667. definitions: [
  14668. make_node(AST_VarDef, node, {
  14669. name: make_node(AST_SymbolVar, node.name, node.name),
  14670. value: null
  14671. })
  14672. ]
  14673. }));
  14674. return true;
  14675. }
  14676. if (node instanceof AST_Export || node instanceof AST_Import) {
  14677. target.push(node);
  14678. return true;
  14679. }
  14680. if (node instanceof AST_Scope) {
  14681. return true;
  14682. }
  14683. });
  14684. }
  14685. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  14686. function tighten_body(statements, compressor) {
  14687. const nearest_scope = compressor.find_scope();
  14688. const defun_scope = nearest_scope.get_defun_scope();
  14689. const { in_loop, in_try } = find_loop_scope_try();
  14690. var CHANGED, max_iter = 10;
  14691. do {
  14692. CHANGED = false;
  14693. eliminate_spurious_blocks(statements);
  14694. if (compressor.option("dead_code")) {
  14695. eliminate_dead_code(statements, compressor);
  14696. }
  14697. if (compressor.option("if_return")) {
  14698. handle_if_return(statements, compressor);
  14699. }
  14700. if (compressor.sequences_limit > 0) {
  14701. sequencesize(statements, compressor);
  14702. sequencesize_2(statements, compressor);
  14703. }
  14704. if (compressor.option("join_vars")) {
  14705. join_consecutive_vars(statements);
  14706. }
  14707. if (compressor.option("collapse_vars")) {
  14708. collapse(statements, compressor);
  14709. }
  14710. } while (CHANGED && max_iter-- > 0);
  14711. function find_loop_scope_try() {
  14712. var node = compressor.self(), level = 0, in_loop = false, in_try = false;
  14713. do {
  14714. if (node instanceof AST_IterationStatement) {
  14715. in_loop = true;
  14716. } else if (node instanceof AST_Scope) {
  14717. break;
  14718. } else if (node instanceof AST_TryBlock) {
  14719. in_try = true;
  14720. }
  14721. } while (node = compressor.parent(level++));
  14722. return { in_loop, in_try };
  14723. }
  14724. // Search from right to left for assignment-like expressions:
  14725. // - `var a = x;`
  14726. // - `a = x;`
  14727. // - `++a`
  14728. // For each candidate, scan from left to right for first usage, then try
  14729. // to fold assignment into the site for compression.
  14730. // Will not attempt to collapse assignments into or past code blocks
  14731. // which are not sequentially executed, e.g. loops and conditionals.
  14732. function collapse(statements, compressor) {
  14733. if (nearest_scope.pinned() || defun_scope.pinned())
  14734. return statements;
  14735. var args;
  14736. var candidates = [];
  14737. var stat_index = statements.length;
  14738. var scanner = new TreeTransformer(function (node) {
  14739. if (abort)
  14740. return node;
  14741. // Skip nodes before `candidate` as quickly as possible
  14742. if (!hit) {
  14743. if (node !== hit_stack[hit_index])
  14744. return node;
  14745. hit_index++;
  14746. if (hit_index < hit_stack.length)
  14747. return handle_custom_scan_order(node);
  14748. hit = true;
  14749. stop_after = find_stop(node, 0);
  14750. if (stop_after === node)
  14751. abort = true;
  14752. return node;
  14753. }
  14754. // Stop immediately if these node types are encountered
  14755. var parent = scanner.parent();
  14756. if (node instanceof AST_Assign
  14757. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  14758. || node instanceof AST_Await
  14759. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  14760. ||
  14761. (node instanceof AST_Call || node instanceof AST_PropAccess)
  14762. && node.optional
  14763. || node instanceof AST_Debugger
  14764. || node instanceof AST_Destructuring
  14765. || node instanceof AST_Expansion
  14766. && node.expression instanceof AST_Symbol
  14767. && (
  14768. node.expression instanceof AST_This
  14769. || node.expression.definition().references.length > 1
  14770. )
  14771. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  14772. || node instanceof AST_LoopControl
  14773. || node instanceof AST_Try
  14774. || node instanceof AST_With
  14775. || node instanceof AST_Yield
  14776. || node instanceof AST_Export
  14777. || node instanceof AST_Class
  14778. || parent instanceof AST_For && node !== parent.init
  14779. || !replace_all
  14780. && (
  14781. node instanceof AST_SymbolRef
  14782. && !node.is_declared(compressor)
  14783. && !pure_prop_access_globals.has(node)
  14784. )
  14785. || node instanceof AST_SymbolRef
  14786. && parent instanceof AST_Call
  14787. && has_annotation(parent, _NOINLINE)
  14788. ) {
  14789. abort = true;
  14790. return node;
  14791. }
  14792. // Stop only if candidate is found within conditional branches
  14793. if (!stop_if_hit && (!lhs_local || !replace_all)
  14794. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  14795. || parent instanceof AST_Conditional && parent.condition !== node
  14796. || parent instanceof AST_If && parent.condition !== node)) {
  14797. stop_if_hit = parent;
  14798. }
  14799. // Replace variable with assignment when found
  14800. if (
  14801. can_replace
  14802. && !(node instanceof AST_SymbolDeclaration)
  14803. && lhs.equivalent_to(node)
  14804. && !shadows(scanner.find_scope() || nearest_scope, lvalues)
  14805. ) {
  14806. if (stop_if_hit) {
  14807. abort = true;
  14808. return node;
  14809. }
  14810. if (is_lhs(node, parent)) {
  14811. if (value_def)
  14812. replaced++;
  14813. return node;
  14814. } else {
  14815. replaced++;
  14816. if (value_def && candidate instanceof AST_VarDef)
  14817. return node;
  14818. }
  14819. CHANGED = abort = true;
  14820. if (candidate instanceof AST_UnaryPostfix) {
  14821. return make_node(AST_UnaryPrefix, candidate, candidate);
  14822. }
  14823. if (candidate instanceof AST_VarDef) {
  14824. var def = candidate.name.definition();
  14825. var value = candidate.value;
  14826. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  14827. def.replaced++;
  14828. if (funarg && is_identifier_atom(value)) {
  14829. return value.transform(compressor);
  14830. } else {
  14831. return maintain_this_binding(parent, node, value);
  14832. }
  14833. }
  14834. return make_node(AST_Assign, candidate, {
  14835. operator: "=",
  14836. logical: false,
  14837. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  14838. right: value
  14839. });
  14840. }
  14841. clear_flag(candidate, WRITE_ONLY);
  14842. return candidate;
  14843. }
  14844. // These node types have child nodes that execute sequentially,
  14845. // but are otherwise not safe to scan into or beyond them.
  14846. var sym;
  14847. if (node instanceof AST_Call
  14848. || node instanceof AST_Exit
  14849. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  14850. || node instanceof AST_PropAccess
  14851. && (side_effects || node.expression.may_throw_on_access(compressor))
  14852. || node instanceof AST_SymbolRef
  14853. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  14854. || node instanceof AST_VarDef && node.value
  14855. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  14856. || (sym = is_lhs(node.left, node))
  14857. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  14858. || may_throw
  14859. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  14860. stop_after = node;
  14861. if (node instanceof AST_Scope)
  14862. abort = true;
  14863. }
  14864. return handle_custom_scan_order(node);
  14865. }, function (node) {
  14866. if (abort)
  14867. return;
  14868. if (stop_after === node)
  14869. abort = true;
  14870. if (stop_if_hit === node)
  14871. stop_if_hit = null;
  14872. });
  14873. var multi_replacer = new TreeTransformer(function (node) {
  14874. if (abort)
  14875. return node;
  14876. // Skip nodes before `candidate` as quickly as possible
  14877. if (!hit) {
  14878. if (node !== hit_stack[hit_index])
  14879. return node;
  14880. hit_index++;
  14881. if (hit_index < hit_stack.length)
  14882. return;
  14883. hit = true;
  14884. return node;
  14885. }
  14886. // Replace variable when found
  14887. if (node instanceof AST_SymbolRef
  14888. && node.name == def.name) {
  14889. if (!--replaced)
  14890. abort = true;
  14891. if (is_lhs(node, multi_replacer.parent()))
  14892. return node;
  14893. def.replaced++;
  14894. value_def.replaced--;
  14895. return candidate.value;
  14896. }
  14897. // Skip (non-executed) functions and (leading) default case in switch statements
  14898. if (node instanceof AST_Default || node instanceof AST_Scope)
  14899. return node;
  14900. });
  14901. while (--stat_index >= 0) {
  14902. // Treat parameters as collapsible in IIFE, i.e.
  14903. // function(a, b){ ... }(x());
  14904. // would be translated into equivalent assignments:
  14905. // var a = x(), b = undefined;
  14906. if (stat_index == 0 && compressor.option("unused"))
  14907. extract_args();
  14908. // Find collapsible assignments
  14909. var hit_stack = [];
  14910. extract_candidates(statements[stat_index]);
  14911. while (candidates.length > 0) {
  14912. hit_stack = candidates.pop();
  14913. var hit_index = 0;
  14914. var candidate = hit_stack[hit_stack.length - 1];
  14915. var value_def = null;
  14916. var stop_after = null;
  14917. var stop_if_hit = null;
  14918. var lhs = get_lhs(candidate);
  14919. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  14920. continue;
  14921. // Locate symbols which may execute code outside of scanning range
  14922. var lvalues = get_lvalues(candidate);
  14923. var lhs_local = is_lhs_local(lhs);
  14924. if (lhs instanceof AST_SymbolRef) {
  14925. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  14926. }
  14927. var side_effects = value_has_side_effects(candidate);
  14928. var replace_all = replace_all_symbols();
  14929. var may_throw = candidate.may_throw(compressor);
  14930. var funarg = candidate.name instanceof AST_SymbolFunarg;
  14931. var hit = funarg;
  14932. var abort = false, replaced = 0, can_replace = !args || !hit;
  14933. if (!can_replace) {
  14934. for (
  14935. let j = compressor.self().argnames.lastIndexOf(candidate.name) + 1;
  14936. !abort && j < args.length;
  14937. j++
  14938. ) {
  14939. args[j].transform(scanner);
  14940. }
  14941. can_replace = true;
  14942. }
  14943. for (var i = stat_index; !abort && i < statements.length; i++) {
  14944. statements[i].transform(scanner);
  14945. }
  14946. if (value_def) {
  14947. var def = candidate.name.definition();
  14948. if (abort && def.references.length - def.replaced > replaced)
  14949. replaced = false;
  14950. else {
  14951. abort = false;
  14952. hit_index = 0;
  14953. hit = funarg;
  14954. for (var i = stat_index; !abort && i < statements.length; i++) {
  14955. statements[i].transform(multi_replacer);
  14956. }
  14957. value_def.single_use = false;
  14958. }
  14959. }
  14960. if (replaced && !remove_candidate(candidate))
  14961. statements.splice(stat_index, 1);
  14962. }
  14963. }
  14964. function handle_custom_scan_order(node) {
  14965. // Skip (non-executed) functions
  14966. if (node instanceof AST_Scope)
  14967. return node;
  14968. // Scan case expressions first in a switch statement
  14969. if (node instanceof AST_Switch) {
  14970. node.expression = node.expression.transform(scanner);
  14971. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  14972. var branch = node.body[i];
  14973. if (branch instanceof AST_Case) {
  14974. if (!hit) {
  14975. if (branch !== hit_stack[hit_index])
  14976. continue;
  14977. hit_index++;
  14978. }
  14979. branch.expression = branch.expression.transform(scanner);
  14980. if (!replace_all)
  14981. break;
  14982. }
  14983. }
  14984. abort = true;
  14985. return node;
  14986. }
  14987. }
  14988. function redefined_within_scope(def, scope) {
  14989. if (def.global)
  14990. return false;
  14991. let cur_scope = def.scope;
  14992. while (cur_scope && cur_scope !== scope) {
  14993. if (cur_scope.variables.has(def.name)) {
  14994. return true;
  14995. }
  14996. cur_scope = cur_scope.parent_scope;
  14997. }
  14998. return false;
  14999. }
  15000. function has_overlapping_symbol(fn, arg, fn_strict) {
  15001. var found = false, scan_this = !(fn instanceof AST_Arrow);
  15002. arg.walk(new TreeWalker(function (node, descend) {
  15003. if (found)
  15004. return true;
  15005. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  15006. var s = node.definition().scope;
  15007. if (s !== defun_scope)
  15008. while (s = s.parent_scope) {
  15009. if (s === defun_scope)
  15010. return true;
  15011. }
  15012. return found = true;
  15013. }
  15014. if ((fn_strict || scan_this) && node instanceof AST_This) {
  15015. return found = true;
  15016. }
  15017. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  15018. var prev = scan_this;
  15019. scan_this = false;
  15020. descend();
  15021. scan_this = prev;
  15022. return true;
  15023. }
  15024. }));
  15025. return found;
  15026. }
  15027. function extract_args() {
  15028. var iife, fn = compressor.self();
  15029. if (is_func_expr(fn)
  15030. && !fn.name
  15031. && !fn.uses_arguments
  15032. && !fn.pinned()
  15033. && (iife = compressor.parent()) instanceof AST_Call
  15034. && iife.expression === fn
  15035. && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
  15036. var fn_strict = compressor.has_directive("use strict");
  15037. if (fn_strict && !member(fn_strict, fn.body))
  15038. fn_strict = false;
  15039. var len = fn.argnames.length;
  15040. args = iife.args.slice(len);
  15041. var names = new Set();
  15042. for (var i = len; --i >= 0;) {
  15043. var sym = fn.argnames[i];
  15044. var arg = iife.args[i];
  15045. // The following two line fix is a duplicate of the fix at
  15046. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  15047. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  15048. // Might be doing the exact same thing.
  15049. const def = sym.definition && sym.definition();
  15050. const is_reassigned = def && def.orig.length > 1;
  15051. if (is_reassigned)
  15052. continue;
  15053. args.unshift(make_node(AST_VarDef, sym, {
  15054. name: sym,
  15055. value: arg
  15056. }));
  15057. if (names.has(sym.name))
  15058. continue;
  15059. names.add(sym.name);
  15060. if (sym instanceof AST_Expansion) {
  15061. var elements = iife.args.slice(i);
  15062. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  15063. )) {
  15064. candidates.unshift([make_node(AST_VarDef, sym, {
  15065. name: sym.expression,
  15066. value: make_node(AST_Array, iife, {
  15067. elements: elements
  15068. })
  15069. })]);
  15070. }
  15071. } else {
  15072. if (!arg) {
  15073. arg = make_node(AST_Undefined, sym).transform(compressor);
  15074. } else if (arg instanceof AST_Lambda && arg.pinned()
  15075. || has_overlapping_symbol(fn, arg, fn_strict)) {
  15076. arg = null;
  15077. }
  15078. if (arg)
  15079. candidates.unshift([make_node(AST_VarDef, sym, {
  15080. name: sym,
  15081. value: arg
  15082. })]);
  15083. }
  15084. }
  15085. }
  15086. }
  15087. function extract_candidates(expr) {
  15088. hit_stack.push(expr);
  15089. if (expr instanceof AST_Assign) {
  15090. if (!expr.left.has_side_effects(compressor)
  15091. && !(expr.right instanceof AST_Chain)) {
  15092. candidates.push(hit_stack.slice());
  15093. }
  15094. extract_candidates(expr.right);
  15095. } else if (expr instanceof AST_Binary) {
  15096. extract_candidates(expr.left);
  15097. extract_candidates(expr.right);
  15098. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  15099. extract_candidates(expr.expression);
  15100. expr.args.forEach(extract_candidates);
  15101. } else if (expr instanceof AST_Case) {
  15102. extract_candidates(expr.expression);
  15103. } else if (expr instanceof AST_Conditional) {
  15104. extract_candidates(expr.condition);
  15105. extract_candidates(expr.consequent);
  15106. extract_candidates(expr.alternative);
  15107. } else if (expr instanceof AST_Definitions) {
  15108. var len = expr.definitions.length;
  15109. // limit number of trailing variable definitions for consideration
  15110. var i = len - 200;
  15111. if (i < 0)
  15112. i = 0;
  15113. for (; i < len; i++) {
  15114. extract_candidates(expr.definitions[i]);
  15115. }
  15116. } else if (expr instanceof AST_DWLoop) {
  15117. extract_candidates(expr.condition);
  15118. if (!(expr.body instanceof AST_Block)) {
  15119. extract_candidates(expr.body);
  15120. }
  15121. } else if (expr instanceof AST_Exit) {
  15122. if (expr.value)
  15123. extract_candidates(expr.value);
  15124. } else if (expr instanceof AST_For) {
  15125. if (expr.init)
  15126. extract_candidates(expr.init);
  15127. if (expr.condition)
  15128. extract_candidates(expr.condition);
  15129. if (expr.step)
  15130. extract_candidates(expr.step);
  15131. if (!(expr.body instanceof AST_Block)) {
  15132. extract_candidates(expr.body);
  15133. }
  15134. } else if (expr instanceof AST_ForIn) {
  15135. extract_candidates(expr.object);
  15136. if (!(expr.body instanceof AST_Block)) {
  15137. extract_candidates(expr.body);
  15138. }
  15139. } else if (expr instanceof AST_If) {
  15140. extract_candidates(expr.condition);
  15141. if (!(expr.body instanceof AST_Block)) {
  15142. extract_candidates(expr.body);
  15143. }
  15144. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  15145. extract_candidates(expr.alternative);
  15146. }
  15147. } else if (expr instanceof AST_Sequence) {
  15148. expr.expressions.forEach(extract_candidates);
  15149. } else if (expr instanceof AST_SimpleStatement) {
  15150. extract_candidates(expr.body);
  15151. } else if (expr instanceof AST_Switch) {
  15152. extract_candidates(expr.expression);
  15153. expr.body.forEach(extract_candidates);
  15154. } else if (expr instanceof AST_Unary) {
  15155. if (expr.operator == "++" || expr.operator == "--") {
  15156. candidates.push(hit_stack.slice());
  15157. }
  15158. } else if (expr instanceof AST_VarDef) {
  15159. if (expr.value && !(expr.value instanceof AST_Chain)) {
  15160. candidates.push(hit_stack.slice());
  15161. extract_candidates(expr.value);
  15162. }
  15163. }
  15164. hit_stack.pop();
  15165. }
  15166. function find_stop(node, level, write_only) {
  15167. var parent = scanner.parent(level);
  15168. if (parent instanceof AST_Assign) {
  15169. if (write_only
  15170. && !parent.logical
  15171. && !(parent.left instanceof AST_PropAccess
  15172. || lvalues.has(parent.left.name))) {
  15173. return find_stop(parent, level + 1, write_only);
  15174. }
  15175. return node;
  15176. }
  15177. if (parent instanceof AST_Binary) {
  15178. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  15179. return find_stop(parent, level + 1, write_only);
  15180. }
  15181. return node;
  15182. }
  15183. if (parent instanceof AST_Call)
  15184. return node;
  15185. if (parent instanceof AST_Case)
  15186. return node;
  15187. if (parent instanceof AST_Conditional) {
  15188. if (write_only && parent.condition === node) {
  15189. return find_stop(parent, level + 1, write_only);
  15190. }
  15191. return node;
  15192. }
  15193. if (parent instanceof AST_Definitions) {
  15194. return find_stop(parent, level + 1, true);
  15195. }
  15196. if (parent instanceof AST_Exit) {
  15197. return write_only ? find_stop(parent, level + 1, write_only) : node;
  15198. }
  15199. if (parent instanceof AST_If) {
  15200. if (write_only && parent.condition === node) {
  15201. return find_stop(parent, level + 1, write_only);
  15202. }
  15203. return node;
  15204. }
  15205. if (parent instanceof AST_IterationStatement)
  15206. return node;
  15207. if (parent instanceof AST_Sequence) {
  15208. return find_stop(parent, level + 1, parent.tail_node() !== node);
  15209. }
  15210. if (parent instanceof AST_SimpleStatement) {
  15211. return find_stop(parent, level + 1, true);
  15212. }
  15213. if (parent instanceof AST_Switch)
  15214. return node;
  15215. if (parent instanceof AST_VarDef)
  15216. return node;
  15217. return null;
  15218. }
  15219. function mangleable_var(var_def) {
  15220. var value = var_def.value;
  15221. if (!(value instanceof AST_SymbolRef))
  15222. return;
  15223. if (value.name == "arguments")
  15224. return;
  15225. var def = value.definition();
  15226. if (def.undeclared)
  15227. return;
  15228. return value_def = def;
  15229. }
  15230. function get_lhs(expr) {
  15231. if (expr instanceof AST_Assign && expr.logical) {
  15232. return false;
  15233. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  15234. var def = expr.name.definition();
  15235. if (!member(expr.name, def.orig))
  15236. return;
  15237. var referenced = def.references.length - def.replaced;
  15238. if (!referenced)
  15239. return;
  15240. var declared = def.orig.length - def.eliminated;
  15241. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  15242. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  15243. return make_node(AST_SymbolRef, expr.name, expr.name);
  15244. }
  15245. } else {
  15246. const lhs = expr instanceof AST_Assign
  15247. ? expr.left
  15248. : expr.expression;
  15249. return !is_ref_of(lhs, AST_SymbolConst)
  15250. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  15251. }
  15252. }
  15253. function get_rvalue(expr) {
  15254. if (expr instanceof AST_Assign) {
  15255. return expr.right;
  15256. } else {
  15257. return expr.value;
  15258. }
  15259. }
  15260. function get_lvalues(expr) {
  15261. var lvalues = new Map();
  15262. if (expr instanceof AST_Unary)
  15263. return lvalues;
  15264. var tw = new TreeWalker(function (node) {
  15265. var sym = node;
  15266. while (sym instanceof AST_PropAccess)
  15267. sym = sym.expression;
  15268. if (sym instanceof AST_SymbolRef) {
  15269. const prev = lvalues.get(sym.name);
  15270. if (!prev || !prev.modified) {
  15271. lvalues.set(sym.name, {
  15272. def: sym.definition(),
  15273. modified: is_modified(compressor, tw, node, node, 0)
  15274. });
  15275. }
  15276. }
  15277. });
  15278. get_rvalue(expr).walk(tw);
  15279. return lvalues;
  15280. }
  15281. function remove_candidate(expr) {
  15282. if (expr.name instanceof AST_SymbolFunarg) {
  15283. var iife = compressor.parent(), argnames = compressor.self().argnames;
  15284. var index = argnames.indexOf(expr.name);
  15285. if (index < 0) {
  15286. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  15287. } else {
  15288. var args = iife.args;
  15289. if (args[index])
  15290. args[index] = make_node(AST_Number, args[index], {
  15291. value: 0
  15292. });
  15293. }
  15294. return true;
  15295. }
  15296. var found = false;
  15297. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  15298. if (found)
  15299. return node;
  15300. if (node === expr || node.body === expr) {
  15301. found = true;
  15302. if (node instanceof AST_VarDef) {
  15303. node.value = node.name instanceof AST_SymbolConst
  15304. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  15305. : null;
  15306. return node;
  15307. }
  15308. return in_list ? MAP.skip : null;
  15309. }
  15310. }, function (node) {
  15311. if (node instanceof AST_Sequence)
  15312. switch (node.expressions.length) {
  15313. case 0: return null;
  15314. case 1: return node.expressions[0];
  15315. }
  15316. }));
  15317. }
  15318. function is_lhs_local(lhs) {
  15319. while (lhs instanceof AST_PropAccess)
  15320. lhs = lhs.expression;
  15321. return lhs instanceof AST_SymbolRef
  15322. && lhs.definition().scope.get_defun_scope() === defun_scope
  15323. && !(in_loop
  15324. && (lvalues.has(lhs.name)
  15325. || candidate instanceof AST_Unary
  15326. || (candidate instanceof AST_Assign
  15327. && !candidate.logical
  15328. && candidate.operator != "=")));
  15329. }
  15330. function value_has_side_effects(expr) {
  15331. if (expr instanceof AST_Unary)
  15332. return unary_side_effects.has(expr.operator);
  15333. return get_rvalue(expr).has_side_effects(compressor);
  15334. }
  15335. function replace_all_symbols() {
  15336. if (side_effects)
  15337. return false;
  15338. if (value_def)
  15339. return true;
  15340. if (lhs instanceof AST_SymbolRef) {
  15341. var def = lhs.definition();
  15342. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  15343. return true;
  15344. }
  15345. }
  15346. return false;
  15347. }
  15348. function may_modify(sym) {
  15349. if (!sym.definition)
  15350. return true; // AST_Destructuring
  15351. var def = sym.definition();
  15352. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  15353. return false;
  15354. if (def.scope.get_defun_scope() !== defun_scope)
  15355. return true;
  15356. return def.references.some((ref) =>
  15357. ref.scope.get_defun_scope() !== defun_scope
  15358. );
  15359. }
  15360. function side_effects_external(node, lhs) {
  15361. if (node instanceof AST_Assign)
  15362. return side_effects_external(node.left, true);
  15363. if (node instanceof AST_Unary)
  15364. return side_effects_external(node.expression, true);
  15365. if (node instanceof AST_VarDef)
  15366. return node.value && side_effects_external(node.value);
  15367. if (lhs) {
  15368. if (node instanceof AST_Dot)
  15369. return side_effects_external(node.expression, true);
  15370. if (node instanceof AST_Sub)
  15371. return side_effects_external(node.expression, true);
  15372. if (node instanceof AST_SymbolRef)
  15373. return node.definition().scope.get_defun_scope() !== defun_scope;
  15374. }
  15375. return false;
  15376. }
  15377. /**
  15378. * Will any of the pulled-in lvalues shadow a variable in newScope or parents?
  15379. * similar to scope_encloses_variables_in_this_scope */
  15380. function shadows(my_scope, lvalues) {
  15381. for (const { def } of lvalues.values()) {
  15382. const looked_up = my_scope.find_variable(def.name);
  15383. if (looked_up) {
  15384. if (looked_up === def) continue;
  15385. return true;
  15386. }
  15387. }
  15388. return false;
  15389. }
  15390. }
  15391. function eliminate_spurious_blocks(statements) {
  15392. var seen_dirs = [];
  15393. for (var i = 0; i < statements.length;) {
  15394. var stat = statements[i];
  15395. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  15396. CHANGED = true;
  15397. eliminate_spurious_blocks(stat.body);
  15398. statements.splice(i, 1, ...stat.body);
  15399. i += stat.body.length;
  15400. } else if (stat instanceof AST_EmptyStatement) {
  15401. CHANGED = true;
  15402. statements.splice(i, 1);
  15403. } else if (stat instanceof AST_Directive) {
  15404. if (seen_dirs.indexOf(stat.value) < 0) {
  15405. i++;
  15406. seen_dirs.push(stat.value);
  15407. } else {
  15408. CHANGED = true;
  15409. statements.splice(i, 1);
  15410. }
  15411. } else
  15412. i++;
  15413. }
  15414. }
  15415. function handle_if_return(statements, compressor) {
  15416. var self = compressor.self();
  15417. var multiple_if_returns = has_multiple_if_returns(statements);
  15418. var in_lambda = self instanceof AST_Lambda;
  15419. for (var i = statements.length; --i >= 0;) {
  15420. var stat = statements[i];
  15421. var j = next_index(i);
  15422. var next = statements[j];
  15423. if (in_lambda && !next && stat instanceof AST_Return) {
  15424. if (!stat.value) {
  15425. CHANGED = true;
  15426. statements.splice(i, 1);
  15427. continue;
  15428. }
  15429. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  15430. CHANGED = true;
  15431. statements[i] = make_node(AST_SimpleStatement, stat, {
  15432. body: stat.value.expression
  15433. });
  15434. continue;
  15435. }
  15436. }
  15437. if (stat instanceof AST_If) {
  15438. let ab, new_else;
  15439. ab = aborts(stat.body);
  15440. if (
  15441. can_merge_flow(ab)
  15442. && (new_else = as_statement_array_with_return(stat.body, ab))
  15443. ) {
  15444. if (ab.label) {
  15445. remove(ab.label.thedef.references, ab);
  15446. }
  15447. CHANGED = true;
  15448. stat = stat.clone();
  15449. stat.condition = stat.condition.negate(compressor);
  15450. stat.body = make_node(AST_BlockStatement, stat, {
  15451. body: as_statement_array(stat.alternative).concat(extract_functions())
  15452. });
  15453. stat.alternative = make_node(AST_BlockStatement, stat, {
  15454. body: new_else
  15455. });
  15456. statements[i] = stat.transform(compressor);
  15457. continue;
  15458. }
  15459. ab = aborts(stat.alternative);
  15460. if (
  15461. can_merge_flow(ab)
  15462. && (new_else = as_statement_array_with_return(stat.alternative, ab))
  15463. ) {
  15464. if (ab.label) {
  15465. remove(ab.label.thedef.references, ab);
  15466. }
  15467. CHANGED = true;
  15468. stat = stat.clone();
  15469. stat.body = make_node(AST_BlockStatement, stat.body, {
  15470. body: as_statement_array(stat.body).concat(extract_functions())
  15471. });
  15472. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  15473. body: new_else
  15474. });
  15475. statements[i] = stat.transform(compressor);
  15476. continue;
  15477. }
  15478. }
  15479. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  15480. var value = stat.body.value;
  15481. //---
  15482. // pretty silly case, but:
  15483. // if (foo()) return; return; ==> foo(); return;
  15484. if (!value && !stat.alternative
  15485. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  15486. CHANGED = true;
  15487. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  15488. body: stat.condition
  15489. });
  15490. continue;
  15491. }
  15492. //---
  15493. // if (foo()) return x; return y; ==> return foo() ? x : y;
  15494. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  15495. CHANGED = true;
  15496. stat = stat.clone();
  15497. stat.alternative = next;
  15498. statements[i] = stat.transform(compressor);
  15499. statements.splice(j, 1);
  15500. continue;
  15501. }
  15502. //---
  15503. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  15504. if (value && !stat.alternative
  15505. && (!next && in_lambda && multiple_if_returns
  15506. || next instanceof AST_Return)) {
  15507. CHANGED = true;
  15508. stat = stat.clone();
  15509. stat.alternative = next || make_node(AST_Return, stat, {
  15510. value: null
  15511. });
  15512. statements[i] = stat.transform(compressor);
  15513. if (next)
  15514. statements.splice(j, 1);
  15515. continue;
  15516. }
  15517. //---
  15518. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  15519. //
  15520. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  15521. // however, with sequences on this helps producing slightly better output for
  15522. // the example code.
  15523. var prev = statements[prev_index(i)];
  15524. if (compressor.option("sequences") && in_lambda && !stat.alternative
  15525. && prev instanceof AST_If && prev.body instanceof AST_Return
  15526. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  15527. CHANGED = true;
  15528. stat = stat.clone();
  15529. stat.alternative = make_node(AST_BlockStatement, next, {
  15530. body: [
  15531. next,
  15532. make_node(AST_Return, next, {
  15533. value: null
  15534. })
  15535. ]
  15536. });
  15537. statements[i] = stat.transform(compressor);
  15538. statements.splice(j, 1);
  15539. continue;
  15540. }
  15541. }
  15542. }
  15543. function has_multiple_if_returns(statements) {
  15544. var n = 0;
  15545. for (var i = statements.length; --i >= 0;) {
  15546. var stat = statements[i];
  15547. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  15548. if (++n > 1)
  15549. return true;
  15550. }
  15551. }
  15552. return false;
  15553. }
  15554. function is_return_void(value) {
  15555. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  15556. }
  15557. function can_merge_flow(ab) {
  15558. if (!ab)
  15559. return false;
  15560. for (var j = i + 1, len = statements.length; j < len; j++) {
  15561. var stat = statements[j];
  15562. if (stat instanceof AST_Const || stat instanceof AST_Let)
  15563. return false;
  15564. }
  15565. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  15566. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  15567. || ab instanceof AST_Continue && self === loop_body(lct)
  15568. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  15569. }
  15570. function extract_functions() {
  15571. var tail = statements.slice(i + 1);
  15572. statements.length = i + 1;
  15573. return tail.filter(function (stat) {
  15574. if (stat instanceof AST_Defun) {
  15575. statements.push(stat);
  15576. return false;
  15577. }
  15578. return true;
  15579. });
  15580. }
  15581. function as_statement_array_with_return(node, ab) {
  15582. var body = as_statement_array(node);
  15583. if (ab !== body[body.length - 1]) {
  15584. return undefined;
  15585. }
  15586. body = body.slice(0, -1);
  15587. if (ab.value) {
  15588. body.push(make_node(AST_SimpleStatement, ab.value, {
  15589. body: ab.value.expression
  15590. }));
  15591. }
  15592. return body;
  15593. }
  15594. function next_index(i) {
  15595. for (var j = i + 1, len = statements.length; j < len; j++) {
  15596. var stat = statements[j];
  15597. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  15598. break;
  15599. }
  15600. }
  15601. return j;
  15602. }
  15603. function prev_index(i) {
  15604. for (var j = i; --j >= 0;) {
  15605. var stat = statements[j];
  15606. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  15607. break;
  15608. }
  15609. }
  15610. return j;
  15611. }
  15612. }
  15613. function eliminate_dead_code(statements, compressor) {
  15614. var has_quit;
  15615. var self = compressor.self();
  15616. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  15617. var stat = statements[i];
  15618. if (stat instanceof AST_LoopControl) {
  15619. var lct = compressor.loopcontrol_target(stat);
  15620. if (stat instanceof AST_Break
  15621. && !(lct instanceof AST_IterationStatement)
  15622. && loop_body(lct) === self
  15623. || stat instanceof AST_Continue
  15624. && loop_body(lct) === self) {
  15625. if (stat.label) {
  15626. remove(stat.label.thedef.references, stat);
  15627. }
  15628. } else {
  15629. statements[n++] = stat;
  15630. }
  15631. } else {
  15632. statements[n++] = stat;
  15633. }
  15634. if (aborts(stat)) {
  15635. has_quit = statements.slice(i + 1);
  15636. break;
  15637. }
  15638. }
  15639. statements.length = n;
  15640. CHANGED = n != len;
  15641. if (has_quit)
  15642. has_quit.forEach(function (stat) {
  15643. trim_unreachable_code(compressor, stat, statements);
  15644. });
  15645. }
  15646. function declarations_only(node) {
  15647. return node.definitions.every((var_def) => !var_def.value);
  15648. }
  15649. function sequencesize(statements, compressor) {
  15650. if (statements.length < 2)
  15651. return;
  15652. var seq = [], n = 0;
  15653. function push_seq() {
  15654. if (!seq.length)
  15655. return;
  15656. var body = make_sequence(seq[0], seq);
  15657. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  15658. seq = [];
  15659. }
  15660. for (var i = 0, len = statements.length; i < len; i++) {
  15661. var stat = statements[i];
  15662. if (stat instanceof AST_SimpleStatement) {
  15663. if (seq.length >= compressor.sequences_limit)
  15664. push_seq();
  15665. var body = stat.body;
  15666. if (seq.length > 0)
  15667. body = body.drop_side_effect_free(compressor);
  15668. if (body)
  15669. merge_sequence(seq, body);
  15670. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  15671. || stat instanceof AST_Defun) {
  15672. statements[n++] = stat;
  15673. } else {
  15674. push_seq();
  15675. statements[n++] = stat;
  15676. }
  15677. }
  15678. push_seq();
  15679. statements.length = n;
  15680. if (n != len)
  15681. CHANGED = true;
  15682. }
  15683. function to_simple_statement(block, decls) {
  15684. if (!(block instanceof AST_BlockStatement))
  15685. return block;
  15686. var stat = null;
  15687. for (var i = 0, len = block.body.length; i < len; i++) {
  15688. var line = block.body[i];
  15689. if (line instanceof AST_Var && declarations_only(line)) {
  15690. decls.push(line);
  15691. } else if (stat || line instanceof AST_Const || line instanceof AST_Let) {
  15692. return false;
  15693. } else {
  15694. stat = line;
  15695. }
  15696. }
  15697. return stat;
  15698. }
  15699. function sequencesize_2(statements, compressor) {
  15700. function cons_seq(right) {
  15701. n--;
  15702. CHANGED = true;
  15703. var left = prev.body;
  15704. return make_sequence(left, [left, right]).transform(compressor);
  15705. }
  15706. var n = 0, prev;
  15707. for (var i = 0; i < statements.length; i++) {
  15708. var stat = statements[i];
  15709. if (prev) {
  15710. if (stat instanceof AST_Exit) {
  15711. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  15712. } else if (stat instanceof AST_For) {
  15713. if (!(stat.init instanceof AST_Definitions)) {
  15714. const abort = walk(prev.body, node => {
  15715. if (node instanceof AST_Scope)
  15716. return true;
  15717. if (node instanceof AST_Binary
  15718. && node.operator === "in") {
  15719. return walk_abort;
  15720. }
  15721. });
  15722. if (!abort) {
  15723. if (stat.init)
  15724. stat.init = cons_seq(stat.init);
  15725. else {
  15726. stat.init = prev.body;
  15727. n--;
  15728. CHANGED = true;
  15729. }
  15730. }
  15731. }
  15732. } else if (stat instanceof AST_ForIn) {
  15733. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  15734. stat.object = cons_seq(stat.object);
  15735. }
  15736. } else if (stat instanceof AST_If) {
  15737. stat.condition = cons_seq(stat.condition);
  15738. } else if (stat instanceof AST_Switch) {
  15739. stat.expression = cons_seq(stat.expression);
  15740. } else if (stat instanceof AST_With) {
  15741. stat.expression = cons_seq(stat.expression);
  15742. }
  15743. }
  15744. if (compressor.option("conditionals") && stat instanceof AST_If) {
  15745. var decls = [];
  15746. var body = to_simple_statement(stat.body, decls);
  15747. var alt = to_simple_statement(stat.alternative, decls);
  15748. if (body !== false && alt !== false && decls.length > 0) {
  15749. var len = decls.length;
  15750. decls.push(make_node(AST_If, stat, {
  15751. condition: stat.condition,
  15752. body: body || make_node(AST_EmptyStatement, stat.body),
  15753. alternative: alt
  15754. }));
  15755. decls.unshift(n, 1);
  15756. [].splice.apply(statements, decls);
  15757. i += len;
  15758. n += len + 1;
  15759. prev = null;
  15760. CHANGED = true;
  15761. continue;
  15762. }
  15763. }
  15764. statements[n++] = stat;
  15765. prev = stat instanceof AST_SimpleStatement ? stat : null;
  15766. }
  15767. statements.length = n;
  15768. }
  15769. function join_object_assignments(defn, body) {
  15770. if (!(defn instanceof AST_Definitions))
  15771. return;
  15772. var def = defn.definitions[defn.definitions.length - 1];
  15773. if (!(def.value instanceof AST_Object))
  15774. return;
  15775. var exprs;
  15776. if (body instanceof AST_Assign && !body.logical) {
  15777. exprs = [body];
  15778. } else if (body instanceof AST_Sequence) {
  15779. exprs = body.expressions.slice();
  15780. }
  15781. if (!exprs)
  15782. return;
  15783. var trimmed = false;
  15784. do {
  15785. var node = exprs[0];
  15786. if (!(node instanceof AST_Assign))
  15787. break;
  15788. if (node.operator != "=")
  15789. break;
  15790. if (!(node.left instanceof AST_PropAccess))
  15791. break;
  15792. var sym = node.left.expression;
  15793. if (!(sym instanceof AST_SymbolRef))
  15794. break;
  15795. if (def.name.name != sym.name)
  15796. break;
  15797. if (!node.right.is_constant_expression(nearest_scope))
  15798. break;
  15799. var prop = node.left.property;
  15800. if (prop instanceof AST_Node) {
  15801. prop = prop.evaluate(compressor);
  15802. }
  15803. if (prop instanceof AST_Node)
  15804. break;
  15805. prop = "" + prop;
  15806. var diff = compressor.option("ecma") < 2015
  15807. && compressor.has_directive("use strict") ? function (node) {
  15808. return node.key != prop && (node.key && node.key.name != prop);
  15809. } : function (node) {
  15810. return node.key && node.key.name != prop;
  15811. };
  15812. if (!def.value.properties.every(diff))
  15813. break;
  15814. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  15815. if (!p) {
  15816. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  15817. key: prop,
  15818. value: node.right
  15819. }));
  15820. } else {
  15821. p.value = new AST_Sequence({
  15822. start: p.start,
  15823. expressions: [p.value.clone(), node.right.clone()],
  15824. end: p.end
  15825. });
  15826. }
  15827. exprs.shift();
  15828. trimmed = true;
  15829. } while (exprs.length);
  15830. return trimmed && exprs;
  15831. }
  15832. function join_consecutive_vars(statements) {
  15833. var defs;
  15834. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  15835. var stat = statements[i];
  15836. var prev = statements[j];
  15837. if (stat instanceof AST_Definitions) {
  15838. if (prev && prev.TYPE == stat.TYPE) {
  15839. prev.definitions = prev.definitions.concat(stat.definitions);
  15840. CHANGED = true;
  15841. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  15842. defs.definitions = defs.definitions.concat(stat.definitions);
  15843. CHANGED = true;
  15844. } else {
  15845. statements[++j] = stat;
  15846. defs = stat;
  15847. }
  15848. } else if (stat instanceof AST_Exit) {
  15849. stat.value = extract_object_assignments(stat.value);
  15850. } else if (stat instanceof AST_For) {
  15851. var exprs = join_object_assignments(prev, stat.init);
  15852. if (exprs) {
  15853. CHANGED = true;
  15854. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  15855. statements[++j] = stat;
  15856. } else if (
  15857. prev instanceof AST_Var
  15858. && (!stat.init || stat.init.TYPE == prev.TYPE)
  15859. ) {
  15860. if (stat.init) {
  15861. prev.definitions = prev.definitions.concat(stat.init.definitions);
  15862. }
  15863. stat.init = prev;
  15864. statements[j] = stat;
  15865. CHANGED = true;
  15866. } else if (
  15867. defs instanceof AST_Var
  15868. && stat.init instanceof AST_Var
  15869. && declarations_only(stat.init)
  15870. ) {
  15871. defs.definitions = defs.definitions.concat(stat.init.definitions);
  15872. stat.init = null;
  15873. statements[++j] = stat;
  15874. CHANGED = true;
  15875. } else {
  15876. statements[++j] = stat;
  15877. }
  15878. } else if (stat instanceof AST_ForIn) {
  15879. stat.object = extract_object_assignments(stat.object);
  15880. } else if (stat instanceof AST_If) {
  15881. stat.condition = extract_object_assignments(stat.condition);
  15882. } else if (stat instanceof AST_SimpleStatement) {
  15883. var exprs = join_object_assignments(prev, stat.body);
  15884. if (exprs) {
  15885. CHANGED = true;
  15886. if (!exprs.length)
  15887. continue;
  15888. stat.body = make_sequence(stat.body, exprs);
  15889. }
  15890. statements[++j] = stat;
  15891. } else if (stat instanceof AST_Switch) {
  15892. stat.expression = extract_object_assignments(stat.expression);
  15893. } else if (stat instanceof AST_With) {
  15894. stat.expression = extract_object_assignments(stat.expression);
  15895. } else {
  15896. statements[++j] = stat;
  15897. }
  15898. }
  15899. statements.length = j + 1;
  15900. function extract_object_assignments(value) {
  15901. statements[++j] = stat;
  15902. var exprs = join_object_assignments(prev, value);
  15903. if (exprs) {
  15904. CHANGED = true;
  15905. if (exprs.length) {
  15906. return make_sequence(value, exprs);
  15907. } else if (value instanceof AST_Sequence) {
  15908. return value.tail_node().left;
  15909. } else {
  15910. return value.left;
  15911. }
  15912. }
  15913. return value;
  15914. }
  15915. }
  15916. }
  15917. /***********************************************************************
  15918. A JavaScript tokenizer / parser / beautifier / compressor.
  15919. https://github.com/mishoo/UglifyJS2
  15920. -------------------------------- (C) ---------------------------------
  15921. Author: Mihai Bazon
  15922. <mihai.bazon@gmail.com>
  15923. http://mihai.bazon.net/blog
  15924. Distributed under the BSD license:
  15925. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15926. Redistribution and use in source and binary forms, with or without
  15927. modification, are permitted provided that the following conditions
  15928. are met:
  15929. * Redistributions of source code must retain the above
  15930. copyright notice, this list of conditions and the following
  15931. disclaimer.
  15932. * Redistributions in binary form must reproduce the above
  15933. copyright notice, this list of conditions and the following
  15934. disclaimer in the documentation and/or other materials
  15935. provided with the distribution.
  15936. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15937. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15938. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15939. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15940. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15941. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15942. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15943. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15944. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15945. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15946. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15947. SUCH DAMAGE.
  15948. ***********************************************************************/
  15949. /**
  15950. * Module that contains the inlining logic.
  15951. *
  15952. * @module
  15953. *
  15954. * The stars of the show are `inline_into_symbolref` and `inline_into_call`.
  15955. */
  15956. function within_array_or_object_literal(compressor) {
  15957. var node, level = 0;
  15958. while (node = compressor.parent(level++)) {
  15959. if (node instanceof AST_Statement) return false;
  15960. if (node instanceof AST_Array
  15961. || node instanceof AST_ObjectKeyVal
  15962. || node instanceof AST_Object) {
  15963. return true;
  15964. }
  15965. }
  15966. return false;
  15967. }
  15968. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  15969. for (const enclosed of pulled_scope.enclosed) {
  15970. if (pulled_scope.variables.has(enclosed.name)) {
  15971. continue;
  15972. }
  15973. const looked_up = scope.find_variable(enclosed.name);
  15974. if (looked_up) {
  15975. if (looked_up === enclosed) continue;
  15976. return true;
  15977. }
  15978. }
  15979. return false;
  15980. }
  15981. function inline_into_symbolref(self, compressor) {
  15982. const parent = compressor.parent();
  15983. const def = self.definition();
  15984. const nearest_scope = compressor.find_scope();
  15985. if (compressor.top_retain && def.global && compressor.top_retain(def)) {
  15986. def.fixed = false;
  15987. def.single_use = false;
  15988. return self;
  15989. }
  15990. let fixed = self.fixed_value();
  15991. let single_use = def.single_use
  15992. && !(parent instanceof AST_Call
  15993. && (parent.is_callee_pure(compressor))
  15994. || has_annotation(parent, _NOINLINE))
  15995. && !(parent instanceof AST_Export
  15996. && fixed instanceof AST_Lambda
  15997. && fixed.name);
  15998. if (single_use && fixed instanceof AST_Node) {
  15999. single_use =
  16000. !fixed.has_side_effects(compressor)
  16001. && !fixed.may_throw(compressor);
  16002. }
  16003. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16004. if (retain_top_func(fixed, compressor)) {
  16005. single_use = false;
  16006. } else if (def.scope !== self.scope
  16007. && (def.escaped == 1
  16008. || has_flag(fixed, INLINED)
  16009. || within_array_or_object_literal(compressor)
  16010. || !compressor.option("reduce_funcs"))) {
  16011. single_use = false;
  16012. } else if (is_recursive_ref(compressor, def)) {
  16013. single_use = false;
  16014. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  16015. single_use = fixed.is_constant_expression(self.scope);
  16016. if (single_use == "f") {
  16017. var scope = self.scope;
  16018. do {
  16019. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  16020. set_flag(scope, INLINED);
  16021. }
  16022. } while (scope = scope.parent_scope);
  16023. }
  16024. }
  16025. }
  16026. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16027. single_use =
  16028. def.scope === self.scope
  16029. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16030. || parent instanceof AST_Call
  16031. && parent.expression === self
  16032. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16033. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  16034. }
  16035. if (single_use && fixed) {
  16036. if (fixed instanceof AST_DefClass) {
  16037. set_flag(fixed, SQUEEZED);
  16038. fixed = make_node(AST_ClassExpression, fixed, fixed);
  16039. }
  16040. if (fixed instanceof AST_Defun) {
  16041. set_flag(fixed, SQUEEZED);
  16042. fixed = make_node(AST_Function, fixed, fixed);
  16043. }
  16044. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  16045. const defun_def = fixed.name.definition();
  16046. let lambda_def = fixed.variables.get(fixed.name.name);
  16047. let name = lambda_def && lambda_def.orig[0];
  16048. if (!(name instanceof AST_SymbolLambda)) {
  16049. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  16050. name.scope = fixed;
  16051. fixed.name = name;
  16052. lambda_def = fixed.def_function(name);
  16053. }
  16054. walk(fixed, node => {
  16055. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  16056. node.thedef = lambda_def;
  16057. lambda_def.references.push(node);
  16058. }
  16059. });
  16060. }
  16061. if (
  16062. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  16063. && fixed.parent_scope !== nearest_scope
  16064. ) {
  16065. fixed = fixed.clone(true, compressor.get_toplevel());
  16066. nearest_scope.add_child_scope(fixed);
  16067. }
  16068. return fixed.optimize(compressor);
  16069. }
  16070. // multiple uses
  16071. if (fixed) {
  16072. let replace;
  16073. if (fixed instanceof AST_This) {
  16074. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  16075. && def.references.every((ref) =>
  16076. def.scope === ref.scope
  16077. )) {
  16078. replace = fixed;
  16079. }
  16080. } else {
  16081. var ev = fixed.evaluate(compressor);
  16082. if (
  16083. ev !== fixed
  16084. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  16085. ) {
  16086. replace = make_node_from_constant(ev, fixed);
  16087. }
  16088. }
  16089. if (replace) {
  16090. const name_length = self.size(compressor);
  16091. const replace_size = replace.size(compressor);
  16092. let overhead = 0;
  16093. if (compressor.option("unused") && !compressor.exposed(def)) {
  16094. overhead =
  16095. (name_length + 2 + replace_size) /
  16096. (def.references.length - def.assignments);
  16097. }
  16098. if (replace_size <= name_length + overhead) {
  16099. return replace;
  16100. }
  16101. }
  16102. }
  16103. return self;
  16104. }
  16105. function inline_into_call(self, fn, compressor) {
  16106. var exp = self.expression;
  16107. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  16108. if (compressor.option("reduce_vars")
  16109. && fn instanceof AST_SymbolRef
  16110. && !has_annotation(self, _NOINLINE)
  16111. ) {
  16112. const fixed = fn.fixed_value();
  16113. if (!retain_top_func(fixed, compressor)) {
  16114. fn = fixed;
  16115. }
  16116. }
  16117. var is_func = fn instanceof AST_Lambda;
  16118. var stat = is_func && fn.body[0];
  16119. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  16120. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  16121. if (can_inline && stat instanceof AST_Return) {
  16122. let returned = stat.value;
  16123. if (!returned || returned.is_constant_expression()) {
  16124. if (returned) {
  16125. returned = returned.clone(true);
  16126. } else {
  16127. returned = make_node(AST_Undefined, self);
  16128. }
  16129. const args = self.args.concat(returned);
  16130. return make_sequence(self, args).optimize(compressor);
  16131. }
  16132. // optimize identity function
  16133. if (
  16134. fn.argnames.length === 1
  16135. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  16136. && self.args.length < 2
  16137. && !(self.args[0] instanceof AST_Expansion)
  16138. && returned instanceof AST_SymbolRef
  16139. && returned.name === fn.argnames[0].name
  16140. ) {
  16141. const replacement =
  16142. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  16143. let parent;
  16144. if (
  16145. replacement instanceof AST_PropAccess
  16146. && (parent = compressor.parent()) instanceof AST_Call
  16147. && parent.expression === self
  16148. ) {
  16149. // identity function was being used to remove `this`, like in
  16150. //
  16151. // id(bag.no_this)(...)
  16152. //
  16153. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  16154. return make_sequence(self, [
  16155. make_node(AST_Number, self, { value: 0 }),
  16156. replacement
  16157. ]);
  16158. }
  16159. // replace call with first argument or undefined if none passed
  16160. return replacement;
  16161. }
  16162. }
  16163. if (can_inline) {
  16164. var scope, in_loop, level = -1;
  16165. let def;
  16166. let returned_value;
  16167. let nearest_scope;
  16168. if (simple_args
  16169. && !fn.uses_arguments
  16170. && !(compressor.parent() instanceof AST_Class)
  16171. && !(fn.name && fn instanceof AST_Function)
  16172. && (returned_value = can_flatten_body(stat))
  16173. && (exp === fn
  16174. || has_annotation(self, _INLINE)
  16175. || compressor.option("unused")
  16176. && (def = exp.definition()).references.length == 1
  16177. && !is_recursive_ref(compressor, def)
  16178. && fn.is_constant_expression(exp.scope))
  16179. && !has_annotation(self, _PURE | _NOINLINE)
  16180. && !fn.contains_this()
  16181. && can_inject_symbols()
  16182. && (nearest_scope = compressor.find_scope())
  16183. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  16184. && !(function in_default_assign() {
  16185. // Due to the fact function parameters have their own scope
  16186. // which can't use `var something` in the function body within,
  16187. // we simply don't inline into DefaultAssign.
  16188. let i = 0;
  16189. let p;
  16190. while ((p = compressor.parent(i++))) {
  16191. if (p instanceof AST_DefaultAssign) return true;
  16192. if (p instanceof AST_Block) break;
  16193. }
  16194. return false;
  16195. })()
  16196. && !(scope instanceof AST_Class)
  16197. ) {
  16198. set_flag(fn, SQUEEZED);
  16199. nearest_scope.add_child_scope(fn);
  16200. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  16201. }
  16202. }
  16203. if (can_inline && has_annotation(self, _INLINE)) {
  16204. set_flag(fn, SQUEEZED);
  16205. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  16206. fn = fn.clone(true);
  16207. fn.figure_out_scope({}, {
  16208. parent_scope: compressor.find_scope(),
  16209. toplevel: compressor.get_toplevel()
  16210. });
  16211. return make_node(AST_Call, self, {
  16212. expression: fn,
  16213. args: self.args,
  16214. }).optimize(compressor);
  16215. }
  16216. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  16217. if (can_drop_this_call) {
  16218. var args = self.args.concat(make_node(AST_Undefined, self));
  16219. return make_sequence(self, args).optimize(compressor);
  16220. }
  16221. if (compressor.option("negate_iife")
  16222. && compressor.parent() instanceof AST_SimpleStatement
  16223. && is_iife_call(self)) {
  16224. return self.negate(compressor, true);
  16225. }
  16226. var ev = self.evaluate(compressor);
  16227. if (ev !== self) {
  16228. ev = make_node_from_constant(ev, self).optimize(compressor);
  16229. return best_of(compressor, ev, self);
  16230. }
  16231. return self;
  16232. function return_value(stat) {
  16233. if (!stat) return make_node(AST_Undefined, self);
  16234. if (stat instanceof AST_Return) {
  16235. if (!stat.value) return make_node(AST_Undefined, self);
  16236. return stat.value.clone(true);
  16237. }
  16238. if (stat instanceof AST_SimpleStatement) {
  16239. return make_node(AST_UnaryPrefix, stat, {
  16240. operator: "void",
  16241. expression: stat.body.clone(true)
  16242. });
  16243. }
  16244. }
  16245. function can_flatten_body(stat) {
  16246. var body = fn.body;
  16247. var len = body.length;
  16248. if (compressor.option("inline") < 3) {
  16249. return len == 1 && return_value(stat);
  16250. }
  16251. stat = null;
  16252. for (var i = 0; i < len; i++) {
  16253. var line = body[i];
  16254. if (line instanceof AST_Var) {
  16255. if (stat && !line.definitions.every((var_def) =>
  16256. !var_def.value
  16257. )) {
  16258. return false;
  16259. }
  16260. } else if (stat) {
  16261. return false;
  16262. } else if (!(line instanceof AST_EmptyStatement)) {
  16263. stat = line;
  16264. }
  16265. }
  16266. return return_value(stat);
  16267. }
  16268. function can_inject_args(block_scoped, safe_to_inject) {
  16269. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  16270. var arg = fn.argnames[i];
  16271. if (arg instanceof AST_DefaultAssign) {
  16272. if (has_flag(arg.left, UNUSED)) continue;
  16273. return false;
  16274. }
  16275. if (arg instanceof AST_Destructuring) return false;
  16276. if (arg instanceof AST_Expansion) {
  16277. if (has_flag(arg.expression, UNUSED)) continue;
  16278. return false;
  16279. }
  16280. if (has_flag(arg, UNUSED)) continue;
  16281. if (!safe_to_inject
  16282. || block_scoped.has(arg.name)
  16283. || identifier_atom.has(arg.name)
  16284. || scope.conflicting_def(arg.name)) {
  16285. return false;
  16286. }
  16287. if (in_loop) in_loop.push(arg.definition());
  16288. }
  16289. return true;
  16290. }
  16291. function can_inject_vars(block_scoped, safe_to_inject) {
  16292. var len = fn.body.length;
  16293. for (var i = 0; i < len; i++) {
  16294. var stat = fn.body[i];
  16295. if (!(stat instanceof AST_Var)) continue;
  16296. if (!safe_to_inject) return false;
  16297. for (var j = stat.definitions.length; --j >= 0;) {
  16298. var name = stat.definitions[j].name;
  16299. if (name instanceof AST_Destructuring
  16300. || block_scoped.has(name.name)
  16301. || identifier_atom.has(name.name)
  16302. || scope.conflicting_def(name.name)) {
  16303. return false;
  16304. }
  16305. if (in_loop) in_loop.push(name.definition());
  16306. }
  16307. }
  16308. return true;
  16309. }
  16310. function can_inject_symbols() {
  16311. var block_scoped = new Set();
  16312. do {
  16313. scope = compressor.parent(++level);
  16314. if (scope.is_block_scope() && scope.block_scope) {
  16315. // TODO this is sometimes undefined during compression.
  16316. // But it should always have a value!
  16317. scope.block_scope.variables.forEach(function (variable) {
  16318. block_scoped.add(variable.name);
  16319. });
  16320. }
  16321. if (scope instanceof AST_Catch) {
  16322. // TODO can we delete? AST_Catch is a block scope.
  16323. if (scope.argname) {
  16324. block_scoped.add(scope.argname.name);
  16325. }
  16326. } else if (scope instanceof AST_IterationStatement) {
  16327. in_loop = [];
  16328. } else if (scope instanceof AST_SymbolRef) {
  16329. if (scope.fixed_value() instanceof AST_Scope) return false;
  16330. }
  16331. } while (!(scope instanceof AST_Scope));
  16332. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  16333. var inline = compressor.option("inline");
  16334. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  16335. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  16336. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  16337. }
  16338. function append_var(decls, expressions, name, value) {
  16339. var def = name.definition();
  16340. // Name already exists, only when a function argument had the same name
  16341. const already_appended = scope.variables.has(name.name);
  16342. if (!already_appended) {
  16343. scope.variables.set(name.name, def);
  16344. scope.enclosed.push(def);
  16345. decls.push(make_node(AST_VarDef, name, {
  16346. name: name,
  16347. value: null
  16348. }));
  16349. }
  16350. var sym = make_node(AST_SymbolRef, name, name);
  16351. def.references.push(sym);
  16352. if (value) expressions.push(make_node(AST_Assign, self, {
  16353. operator: "=",
  16354. logical: false,
  16355. left: sym,
  16356. right: value.clone()
  16357. }));
  16358. }
  16359. function flatten_args(decls, expressions) {
  16360. var len = fn.argnames.length;
  16361. for (var i = self.args.length; --i >= len;) {
  16362. expressions.push(self.args[i]);
  16363. }
  16364. for (i = len; --i >= 0;) {
  16365. var name = fn.argnames[i];
  16366. var value = self.args[i];
  16367. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  16368. if (value) expressions.push(value);
  16369. } else {
  16370. var symbol = make_node(AST_SymbolVar, name, name);
  16371. name.definition().orig.push(symbol);
  16372. if (!value && in_loop) value = make_node(AST_Undefined, self);
  16373. append_var(decls, expressions, symbol, value);
  16374. }
  16375. }
  16376. decls.reverse();
  16377. expressions.reverse();
  16378. }
  16379. function flatten_vars(decls, expressions) {
  16380. var pos = expressions.length;
  16381. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  16382. var stat = fn.body[i];
  16383. if (!(stat instanceof AST_Var)) continue;
  16384. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  16385. var var_def = stat.definitions[j];
  16386. var name = var_def.name;
  16387. append_var(decls, expressions, name, var_def.value);
  16388. if (in_loop && fn.argnames.every((argname) =>
  16389. argname.name != name.name
  16390. )) {
  16391. var def = fn.variables.get(name.name);
  16392. var sym = make_node(AST_SymbolRef, name, name);
  16393. def.references.push(sym);
  16394. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  16395. operator: "=",
  16396. logical: false,
  16397. left: sym,
  16398. right: make_node(AST_Undefined, name)
  16399. }));
  16400. }
  16401. }
  16402. }
  16403. }
  16404. function flatten_fn(returned_value) {
  16405. var decls = [];
  16406. var expressions = [];
  16407. flatten_args(decls, expressions);
  16408. flatten_vars(decls, expressions);
  16409. expressions.push(returned_value);
  16410. if (decls.length) {
  16411. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  16412. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  16413. definitions: decls
  16414. }));
  16415. }
  16416. return expressions.map(exp => exp.clone(true));
  16417. }
  16418. }
  16419. /***********************************************************************
  16420. A JavaScript tokenizer / parser / beautifier / compressor.
  16421. https://github.com/mishoo/UglifyJS2
  16422. -------------------------------- (C) ---------------------------------
  16423. Author: Mihai Bazon
  16424. <mihai.bazon@gmail.com>
  16425. http://mihai.bazon.net/blog
  16426. Distributed under the BSD license:
  16427. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  16428. Redistribution and use in source and binary forms, with or without
  16429. modification, are permitted provided that the following conditions
  16430. are met:
  16431. * Redistributions of source code must retain the above
  16432. copyright notice, this list of conditions and the following
  16433. disclaimer.
  16434. * Redistributions in binary form must reproduce the above
  16435. copyright notice, this list of conditions and the following
  16436. disclaimer in the documentation and/or other materials
  16437. provided with the distribution.
  16438. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  16439. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16440. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16441. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  16442. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  16443. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  16444. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  16445. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  16446. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  16447. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  16448. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  16449. SUCH DAMAGE.
  16450. ***********************************************************************/
  16451. class Compressor extends TreeWalker {
  16452. constructor(options, { false_by_default = false, mangle_options = false }) {
  16453. super();
  16454. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  16455. this.options = defaults(options, {
  16456. arguments : false,
  16457. arrows : !false_by_default,
  16458. booleans : !false_by_default,
  16459. booleans_as_integers : false,
  16460. collapse_vars : !false_by_default,
  16461. comparisons : !false_by_default,
  16462. computed_props: !false_by_default,
  16463. conditionals : !false_by_default,
  16464. dead_code : !false_by_default,
  16465. defaults : true,
  16466. directives : !false_by_default,
  16467. drop_console : false,
  16468. drop_debugger : !false_by_default,
  16469. ecma : 5,
  16470. evaluate : !false_by_default,
  16471. expression : false,
  16472. global_defs : false,
  16473. hoist_funs : false,
  16474. hoist_props : !false_by_default,
  16475. hoist_vars : false,
  16476. ie8 : false,
  16477. if_return : !false_by_default,
  16478. inline : !false_by_default,
  16479. join_vars : !false_by_default,
  16480. keep_classnames: false,
  16481. keep_fargs : true,
  16482. keep_fnames : false,
  16483. keep_infinity : false,
  16484. lhs_constants : !false_by_default,
  16485. loops : !false_by_default,
  16486. module : false,
  16487. negate_iife : !false_by_default,
  16488. passes : 1,
  16489. properties : !false_by_default,
  16490. pure_getters : !false_by_default && "strict",
  16491. pure_funcs : null,
  16492. reduce_funcs : !false_by_default,
  16493. reduce_vars : !false_by_default,
  16494. sequences : !false_by_default,
  16495. side_effects : !false_by_default,
  16496. switches : !false_by_default,
  16497. top_retain : null,
  16498. toplevel : !!(options && options["top_retain"]),
  16499. typeofs : !false_by_default,
  16500. unsafe : false,
  16501. unsafe_arrows : false,
  16502. unsafe_comps : false,
  16503. unsafe_Function: false,
  16504. unsafe_math : false,
  16505. unsafe_symbols: false,
  16506. unsafe_methods: false,
  16507. unsafe_proto : false,
  16508. unsafe_regexp : false,
  16509. unsafe_undefined: false,
  16510. unused : !false_by_default,
  16511. warnings : false // legacy
  16512. }, true);
  16513. var global_defs = this.options["global_defs"];
  16514. if (typeof global_defs == "object") for (var key in global_defs) {
  16515. if (key[0] === "@" && HOP(global_defs, key)) {
  16516. global_defs[key.slice(1)] = parse(global_defs[key], {
  16517. expression: true
  16518. });
  16519. }
  16520. }
  16521. if (this.options["inline"] === true) this.options["inline"] = 3;
  16522. var pure_funcs = this.options["pure_funcs"];
  16523. if (typeof pure_funcs == "function") {
  16524. this.pure_funcs = pure_funcs;
  16525. } else {
  16526. this.pure_funcs = pure_funcs ? function(node) {
  16527. return !pure_funcs.includes(node.expression.print_to_string());
  16528. } : return_true;
  16529. }
  16530. var top_retain = this.options["top_retain"];
  16531. if (top_retain instanceof RegExp) {
  16532. this.top_retain = function(def) {
  16533. return top_retain.test(def.name);
  16534. };
  16535. } else if (typeof top_retain == "function") {
  16536. this.top_retain = top_retain;
  16537. } else if (top_retain) {
  16538. if (typeof top_retain == "string") {
  16539. top_retain = top_retain.split(/,/);
  16540. }
  16541. this.top_retain = function(def) {
  16542. return top_retain.includes(def.name);
  16543. };
  16544. }
  16545. if (this.options["module"]) {
  16546. this.directives["use strict"] = true;
  16547. this.options["toplevel"] = true;
  16548. }
  16549. var toplevel = this.options["toplevel"];
  16550. this.toplevel = typeof toplevel == "string" ? {
  16551. funcs: /funcs/.test(toplevel),
  16552. vars: /vars/.test(toplevel)
  16553. } : {
  16554. funcs: toplevel,
  16555. vars: toplevel
  16556. };
  16557. var sequences = this.options["sequences"];
  16558. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  16559. this.evaluated_regexps = new Map();
  16560. this._toplevel = undefined;
  16561. this.mangle_options = mangle_options
  16562. ? format_mangler_options(mangle_options)
  16563. : mangle_options;
  16564. }
  16565. option(key) {
  16566. return this.options[key];
  16567. }
  16568. exposed(def) {
  16569. if (def.export) return true;
  16570. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  16571. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  16572. return true;
  16573. return false;
  16574. }
  16575. in_boolean_context() {
  16576. if (!this.option("booleans")) return false;
  16577. var self = this.self();
  16578. for (var i = 0, p; p = this.parent(i); i++) {
  16579. if (p instanceof AST_SimpleStatement
  16580. || p instanceof AST_Conditional && p.condition === self
  16581. || p instanceof AST_DWLoop && p.condition === self
  16582. || p instanceof AST_For && p.condition === self
  16583. || p instanceof AST_If && p.condition === self
  16584. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  16585. return true;
  16586. }
  16587. if (
  16588. p instanceof AST_Binary
  16589. && (
  16590. p.operator == "&&"
  16591. || p.operator == "||"
  16592. || p.operator == "??"
  16593. )
  16594. || p instanceof AST_Conditional
  16595. || p.tail_node() === self
  16596. ) {
  16597. self = p;
  16598. } else {
  16599. return false;
  16600. }
  16601. }
  16602. }
  16603. get_toplevel() {
  16604. return this._toplevel;
  16605. }
  16606. compress(toplevel) {
  16607. toplevel = toplevel.resolve_defines(this);
  16608. this._toplevel = toplevel;
  16609. if (this.option("expression")) {
  16610. this._toplevel.process_expression(true);
  16611. }
  16612. var passes = +this.options.passes || 1;
  16613. var min_count = 1 / 0;
  16614. var stopping = false;
  16615. var nth_identifier = this.mangle_options && this.mangle_options.nth_identifier || base54;
  16616. var mangle = { ie8: this.option("ie8"), nth_identifier: nth_identifier };
  16617. for (var pass = 0; pass < passes; pass++) {
  16618. this._toplevel.figure_out_scope(mangle);
  16619. if (pass === 0 && this.option("drop_console")) {
  16620. // must be run before reduce_vars and compress pass
  16621. this._toplevel = this._toplevel.drop_console();
  16622. }
  16623. if (pass > 0 || this.option("reduce_vars")) {
  16624. this._toplevel.reset_opt_flags(this);
  16625. }
  16626. this._toplevel = this._toplevel.transform(this);
  16627. if (passes > 1) {
  16628. let count = 0;
  16629. walk(this._toplevel, () => { count++; });
  16630. if (count < min_count) {
  16631. min_count = count;
  16632. stopping = false;
  16633. } else if (stopping) {
  16634. break;
  16635. } else {
  16636. stopping = true;
  16637. }
  16638. }
  16639. }
  16640. if (this.option("expression")) {
  16641. this._toplevel.process_expression(false);
  16642. }
  16643. toplevel = this._toplevel;
  16644. this._toplevel = undefined;
  16645. return toplevel;
  16646. }
  16647. before(node, descend) {
  16648. if (has_flag(node, SQUEEZED)) return node;
  16649. var was_scope = false;
  16650. if (node instanceof AST_Scope) {
  16651. node = node.hoist_properties(this);
  16652. node = node.hoist_declarations(this);
  16653. was_scope = true;
  16654. }
  16655. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  16656. // would call AST_Node.transform() if a different instance of AST_Node is
  16657. // produced after def_optimize().
  16658. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  16659. // Migrate and defer all children's AST_Node.transform() to below, which
  16660. // will now happen after this parent AST_Node has been properly substituted
  16661. // thus gives a consistent AST snapshot.
  16662. descend(node, this);
  16663. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  16664. // following replacement call would result in degraded efficiency of both
  16665. // output and performance.
  16666. descend(node, this);
  16667. var opt = node.optimize(this);
  16668. if (was_scope && opt instanceof AST_Scope) {
  16669. opt.drop_unused(this);
  16670. descend(opt, this);
  16671. }
  16672. if (opt === node) set_flag(opt, SQUEEZED);
  16673. return opt;
  16674. }
  16675. /** Alternative to plain is_lhs() which doesn't work within .optimize() */
  16676. is_lhs() {
  16677. const self = this.stack[this.stack.length - 1];
  16678. const parent = this.stack[this.stack.length - 2];
  16679. return is_lhs(self, parent);
  16680. }
  16681. }
  16682. function def_optimize(node, optimizer) {
  16683. node.DEFMETHOD("optimize", function(compressor) {
  16684. var self = this;
  16685. if (has_flag(self, OPTIMIZED)) return self;
  16686. if (compressor.has_directive("use asm")) return self;
  16687. var opt = optimizer(self, compressor);
  16688. set_flag(opt, OPTIMIZED);
  16689. return opt;
  16690. });
  16691. }
  16692. def_optimize(AST_Node, function(self) {
  16693. return self;
  16694. });
  16695. AST_Toplevel.DEFMETHOD("drop_console", function() {
  16696. return this.transform(new TreeTransformer(function(self) {
  16697. if (self.TYPE == "Call") {
  16698. var exp = self.expression;
  16699. if (exp instanceof AST_PropAccess) {
  16700. var name = exp.expression;
  16701. while (name.expression) {
  16702. name = name.expression;
  16703. }
  16704. if (is_undeclared_ref(name) && name.name == "console") {
  16705. return make_node(AST_Undefined, self);
  16706. }
  16707. }
  16708. }
  16709. }));
  16710. });
  16711. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  16712. return equivalent_to(this, node);
  16713. });
  16714. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  16715. var self = this;
  16716. var tt = new TreeTransformer(function(node) {
  16717. if (insert && node instanceof AST_SimpleStatement) {
  16718. return make_node(AST_Return, node, {
  16719. value: node.body
  16720. });
  16721. }
  16722. if (!insert && node instanceof AST_Return) {
  16723. if (compressor) {
  16724. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  16725. return value
  16726. ? make_node(AST_SimpleStatement, node, { body: value })
  16727. : make_node(AST_EmptyStatement, node);
  16728. }
  16729. return make_node(AST_SimpleStatement, node, {
  16730. body: node.value || make_node(AST_UnaryPrefix, node, {
  16731. operator: "void",
  16732. expression: make_node(AST_Number, node, {
  16733. value: 0
  16734. })
  16735. })
  16736. });
  16737. }
  16738. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  16739. return node;
  16740. }
  16741. if (node instanceof AST_Block) {
  16742. var index = node.body.length - 1;
  16743. if (index >= 0) {
  16744. node.body[index] = node.body[index].transform(tt);
  16745. }
  16746. } else if (node instanceof AST_If) {
  16747. node.body = node.body.transform(tt);
  16748. if (node.alternative) {
  16749. node.alternative = node.alternative.transform(tt);
  16750. }
  16751. } else if (node instanceof AST_With) {
  16752. node.body = node.body.transform(tt);
  16753. }
  16754. return node;
  16755. });
  16756. self.transform(tt);
  16757. });
  16758. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  16759. const self = this;
  16760. const reduce_vars = compressor.option("reduce_vars");
  16761. const preparation = new TreeWalker(function(node, descend) {
  16762. clear_flag(node, CLEAR_BETWEEN_PASSES);
  16763. if (reduce_vars) {
  16764. if (compressor.top_retain
  16765. && node instanceof AST_Defun // Only functions are retained
  16766. && preparation.parent() === self
  16767. ) {
  16768. set_flag(node, TOP);
  16769. }
  16770. return node.reduce_vars(preparation, descend, compressor);
  16771. }
  16772. });
  16773. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  16774. // properly assigned before use:
  16775. // - `push()` & `pop()` when visiting conditional branches
  16776. preparation.safe_ids = Object.create(null);
  16777. preparation.in_loop = null;
  16778. preparation.loop_ids = new Map();
  16779. preparation.defs_to_safe_ids = new Map();
  16780. self.walk(preparation);
  16781. });
  16782. AST_Symbol.DEFMETHOD("fixed_value", function() {
  16783. var fixed = this.thedef.fixed;
  16784. if (!fixed || fixed instanceof AST_Node) return fixed;
  16785. return fixed();
  16786. });
  16787. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  16788. var orig = this.definition().orig;
  16789. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  16790. });
  16791. function find_variable(compressor, name) {
  16792. var scope, i = 0;
  16793. while (scope = compressor.parent(i++)) {
  16794. if (scope instanceof AST_Scope) break;
  16795. if (scope instanceof AST_Catch && scope.argname) {
  16796. scope = scope.argname.definition().scope;
  16797. break;
  16798. }
  16799. }
  16800. return scope.find_variable(name);
  16801. }
  16802. 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");
  16803. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  16804. return !this.definition().undeclared
  16805. || compressor.option("unsafe") && global_names.has(this.name);
  16806. });
  16807. /* -----[ optimizers ]----- */
  16808. var directives = new Set(["use asm", "use strict"]);
  16809. def_optimize(AST_Directive, function(self, compressor) {
  16810. if (compressor.option("directives")
  16811. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  16812. return make_node(AST_EmptyStatement, self);
  16813. }
  16814. return self;
  16815. });
  16816. def_optimize(AST_Debugger, function(self, compressor) {
  16817. if (compressor.option("drop_debugger"))
  16818. return make_node(AST_EmptyStatement, self);
  16819. return self;
  16820. });
  16821. def_optimize(AST_LabeledStatement, function(self, compressor) {
  16822. if (self.body instanceof AST_Break
  16823. && compressor.loopcontrol_target(self.body) === self.body) {
  16824. return make_node(AST_EmptyStatement, self);
  16825. }
  16826. return self.label.references.length == 0 ? self.body : self;
  16827. });
  16828. def_optimize(AST_Block, function(self, compressor) {
  16829. tighten_body(self.body, compressor);
  16830. return self;
  16831. });
  16832. function can_be_extracted_from_if_block(node) {
  16833. return !(
  16834. node instanceof AST_Const
  16835. || node instanceof AST_Let
  16836. || node instanceof AST_Class
  16837. );
  16838. }
  16839. def_optimize(AST_BlockStatement, function(self, compressor) {
  16840. tighten_body(self.body, compressor);
  16841. switch (self.body.length) {
  16842. case 1:
  16843. if (!compressor.has_directive("use strict")
  16844. && compressor.parent() instanceof AST_If
  16845. && can_be_extracted_from_if_block(self.body[0])
  16846. || can_be_evicted_from_block(self.body[0])) {
  16847. return self.body[0];
  16848. }
  16849. break;
  16850. case 0: return make_node(AST_EmptyStatement, self);
  16851. }
  16852. return self;
  16853. });
  16854. function opt_AST_Lambda(self, compressor) {
  16855. tighten_body(self.body, compressor);
  16856. if (compressor.option("side_effects")
  16857. && self.body.length == 1
  16858. && self.body[0] === compressor.has_directive("use strict")) {
  16859. self.body.length = 0;
  16860. }
  16861. return self;
  16862. }
  16863. def_optimize(AST_Lambda, opt_AST_Lambda);
  16864. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  16865. var self = this;
  16866. if (compressor.has_directive("use asm")) return self;
  16867. var hoist_funs = compressor.option("hoist_funs");
  16868. var hoist_vars = compressor.option("hoist_vars");
  16869. if (hoist_funs || hoist_vars) {
  16870. var dirs = [];
  16871. var hoisted = [];
  16872. var vars = new Map(), vars_found = 0, var_decl = 0;
  16873. // let's count var_decl first, we seem to waste a lot of
  16874. // space if we hoist `var` when there's only one.
  16875. walk(self, node => {
  16876. if (node instanceof AST_Scope && node !== self)
  16877. return true;
  16878. if (node instanceof AST_Var) {
  16879. ++var_decl;
  16880. return true;
  16881. }
  16882. });
  16883. hoist_vars = hoist_vars && var_decl > 1;
  16884. var tt = new TreeTransformer(
  16885. function before(node) {
  16886. if (node !== self) {
  16887. if (node instanceof AST_Directive) {
  16888. dirs.push(node);
  16889. return make_node(AST_EmptyStatement, node);
  16890. }
  16891. if (hoist_funs && node instanceof AST_Defun
  16892. && !(tt.parent() instanceof AST_Export)
  16893. && tt.parent() === self) {
  16894. hoisted.push(node);
  16895. return make_node(AST_EmptyStatement, node);
  16896. }
  16897. if (
  16898. hoist_vars
  16899. && node instanceof AST_Var
  16900. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  16901. ) {
  16902. node.definitions.forEach(function(def) {
  16903. vars.set(def.name.name, def);
  16904. ++vars_found;
  16905. });
  16906. var seq = node.to_assignments(compressor);
  16907. var p = tt.parent();
  16908. if (p instanceof AST_ForIn && p.init === node) {
  16909. if (seq == null) {
  16910. var def = node.definitions[0].name;
  16911. return make_node(AST_SymbolRef, def, def);
  16912. }
  16913. return seq;
  16914. }
  16915. if (p instanceof AST_For && p.init === node) {
  16916. return seq;
  16917. }
  16918. if (!seq) return make_node(AST_EmptyStatement, node);
  16919. return make_node(AST_SimpleStatement, node, {
  16920. body: seq
  16921. });
  16922. }
  16923. if (node instanceof AST_Scope)
  16924. return node; // to avoid descending in nested scopes
  16925. }
  16926. }
  16927. );
  16928. self = self.transform(tt);
  16929. if (vars_found > 0) {
  16930. // collect only vars which don't show up in self's arguments list
  16931. var defs = [];
  16932. const is_lambda = self instanceof AST_Lambda;
  16933. const args_as_names = is_lambda ? self.args_as_names() : null;
  16934. vars.forEach((def, name) => {
  16935. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  16936. vars.delete(name);
  16937. } else {
  16938. def = def.clone();
  16939. def.value = null;
  16940. defs.push(def);
  16941. vars.set(name, def);
  16942. }
  16943. });
  16944. if (defs.length > 0) {
  16945. // try to merge in assignments
  16946. for (var i = 0; i < self.body.length;) {
  16947. if (self.body[i] instanceof AST_SimpleStatement) {
  16948. var expr = self.body[i].body, sym, assign;
  16949. if (expr instanceof AST_Assign
  16950. && expr.operator == "="
  16951. && (sym = expr.left) instanceof AST_Symbol
  16952. && vars.has(sym.name)
  16953. ) {
  16954. var def = vars.get(sym.name);
  16955. if (def.value) break;
  16956. def.value = expr.right;
  16957. remove(defs, def);
  16958. defs.push(def);
  16959. self.body.splice(i, 1);
  16960. continue;
  16961. }
  16962. if (expr instanceof AST_Sequence
  16963. && (assign = expr.expressions[0]) instanceof AST_Assign
  16964. && assign.operator == "="
  16965. && (sym = assign.left) instanceof AST_Symbol
  16966. && vars.has(sym.name)
  16967. ) {
  16968. var def = vars.get(sym.name);
  16969. if (def.value) break;
  16970. def.value = assign.right;
  16971. remove(defs, def);
  16972. defs.push(def);
  16973. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  16974. continue;
  16975. }
  16976. }
  16977. if (self.body[i] instanceof AST_EmptyStatement) {
  16978. self.body.splice(i, 1);
  16979. continue;
  16980. }
  16981. if (self.body[i] instanceof AST_BlockStatement) {
  16982. self.body.splice(i, 1, ...self.body[i].body);
  16983. continue;
  16984. }
  16985. break;
  16986. }
  16987. defs = make_node(AST_Var, self, {
  16988. definitions: defs
  16989. });
  16990. hoisted.push(defs);
  16991. }
  16992. }
  16993. self.body = dirs.concat(hoisted, self.body);
  16994. }
  16995. return self;
  16996. });
  16997. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  16998. var self = this;
  16999. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  17000. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  17001. var defs_by_id = new Map();
  17002. var hoister = new TreeTransformer(function(node, descend) {
  17003. if (node instanceof AST_VarDef) {
  17004. const sym = node.name;
  17005. let def;
  17006. let value;
  17007. if (sym.scope === self
  17008. && (def = sym.definition()).escaped != 1
  17009. && !def.assignments
  17010. && !def.direct_access
  17011. && !def.single_use
  17012. && !compressor.exposed(def)
  17013. && !top_retain(def)
  17014. && (value = sym.fixed_value()) === node.value
  17015. && value instanceof AST_Object
  17016. && !value.properties.some(prop =>
  17017. prop instanceof AST_Expansion || prop.computed_key()
  17018. )
  17019. ) {
  17020. descend(node, this);
  17021. const defs = new Map();
  17022. const assignments = [];
  17023. value.properties.forEach(({ key, value }) => {
  17024. const scope = hoister.find_scope();
  17025. const symbol = self.create_symbol(sym.CTOR, {
  17026. source: sym,
  17027. scope,
  17028. conflict_scopes: new Set([
  17029. scope,
  17030. ...sym.definition().references.map(ref => ref.scope)
  17031. ]),
  17032. tentative_name: sym.name + "_" + key
  17033. });
  17034. defs.set(String(key), symbol.definition());
  17035. assignments.push(make_node(AST_VarDef, node, {
  17036. name: symbol,
  17037. value
  17038. }));
  17039. });
  17040. defs_by_id.set(def.id, defs);
  17041. return MAP.splice(assignments);
  17042. }
  17043. } else if (node instanceof AST_PropAccess
  17044. && node.expression instanceof AST_SymbolRef
  17045. ) {
  17046. const defs = defs_by_id.get(node.expression.definition().id);
  17047. if (defs) {
  17048. const def = defs.get(String(get_simple_key(node.property)));
  17049. const sym = make_node(AST_SymbolRef, node, {
  17050. name: def.name,
  17051. scope: node.expression.scope,
  17052. thedef: def
  17053. });
  17054. sym.reference({});
  17055. return sym;
  17056. }
  17057. }
  17058. });
  17059. return self.transform(hoister);
  17060. });
  17061. def_optimize(AST_SimpleStatement, function(self, compressor) {
  17062. if (compressor.option("side_effects")) {
  17063. var body = self.body;
  17064. var node = body.drop_side_effect_free(compressor, true);
  17065. if (!node) {
  17066. return make_node(AST_EmptyStatement, self);
  17067. }
  17068. if (node !== body) {
  17069. return make_node(AST_SimpleStatement, self, { body: node });
  17070. }
  17071. }
  17072. return self;
  17073. });
  17074. def_optimize(AST_While, function(self, compressor) {
  17075. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  17076. });
  17077. def_optimize(AST_Do, function(self, compressor) {
  17078. if (!compressor.option("loops")) return self;
  17079. var cond = self.condition.tail_node().evaluate(compressor);
  17080. if (!(cond instanceof AST_Node)) {
  17081. if (cond) return make_node(AST_For, self, {
  17082. body: make_node(AST_BlockStatement, self.body, {
  17083. body: [
  17084. self.body,
  17085. make_node(AST_SimpleStatement, self.condition, {
  17086. body: self.condition
  17087. })
  17088. ]
  17089. })
  17090. }).optimize(compressor);
  17091. if (!has_break_or_continue(self, compressor.parent())) {
  17092. return make_node(AST_BlockStatement, self.body, {
  17093. body: [
  17094. self.body,
  17095. make_node(AST_SimpleStatement, self.condition, {
  17096. body: self.condition
  17097. })
  17098. ]
  17099. }).optimize(compressor);
  17100. }
  17101. }
  17102. return self;
  17103. });
  17104. function if_break_in_loop(self, compressor) {
  17105. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  17106. if (compressor.option("dead_code") && is_break(first)) {
  17107. var body = [];
  17108. if (self.init instanceof AST_Statement) {
  17109. body.push(self.init);
  17110. } else if (self.init) {
  17111. body.push(make_node(AST_SimpleStatement, self.init, {
  17112. body: self.init
  17113. }));
  17114. }
  17115. if (self.condition) {
  17116. body.push(make_node(AST_SimpleStatement, self.condition, {
  17117. body: self.condition
  17118. }));
  17119. }
  17120. trim_unreachable_code(compressor, self.body, body);
  17121. return make_node(AST_BlockStatement, self, {
  17122. body: body
  17123. });
  17124. }
  17125. if (first instanceof AST_If) {
  17126. if (is_break(first.body)) {
  17127. if (self.condition) {
  17128. self.condition = make_node(AST_Binary, self.condition, {
  17129. left: self.condition,
  17130. operator: "&&",
  17131. right: first.condition.negate(compressor),
  17132. });
  17133. } else {
  17134. self.condition = first.condition.negate(compressor);
  17135. }
  17136. drop_it(first.alternative);
  17137. } else if (is_break(first.alternative)) {
  17138. if (self.condition) {
  17139. self.condition = make_node(AST_Binary, self.condition, {
  17140. left: self.condition,
  17141. operator: "&&",
  17142. right: first.condition,
  17143. });
  17144. } else {
  17145. self.condition = first.condition;
  17146. }
  17147. drop_it(first.body);
  17148. }
  17149. }
  17150. return self;
  17151. function is_break(node) {
  17152. return node instanceof AST_Break
  17153. && compressor.loopcontrol_target(node) === compressor.self();
  17154. }
  17155. function drop_it(rest) {
  17156. rest = as_statement_array(rest);
  17157. if (self.body instanceof AST_BlockStatement) {
  17158. self.body = self.body.clone();
  17159. self.body.body = rest.concat(self.body.body.slice(1));
  17160. self.body = self.body.transform(compressor);
  17161. } else {
  17162. self.body = make_node(AST_BlockStatement, self.body, {
  17163. body: rest
  17164. }).transform(compressor);
  17165. }
  17166. self = if_break_in_loop(self, compressor);
  17167. }
  17168. }
  17169. def_optimize(AST_For, function(self, compressor) {
  17170. if (!compressor.option("loops")) return self;
  17171. if (compressor.option("side_effects") && self.init) {
  17172. self.init = self.init.drop_side_effect_free(compressor);
  17173. }
  17174. if (self.condition) {
  17175. var cond = self.condition.evaluate(compressor);
  17176. if (!(cond instanceof AST_Node)) {
  17177. if (cond) self.condition = null;
  17178. else if (!compressor.option("dead_code")) {
  17179. var orig = self.condition;
  17180. self.condition = make_node_from_constant(cond, self.condition);
  17181. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17182. }
  17183. }
  17184. if (compressor.option("dead_code")) {
  17185. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17186. if (!cond) {
  17187. var body = [];
  17188. trim_unreachable_code(compressor, self.body, body);
  17189. if (self.init instanceof AST_Statement) {
  17190. body.push(self.init);
  17191. } else if (self.init) {
  17192. body.push(make_node(AST_SimpleStatement, self.init, {
  17193. body: self.init
  17194. }));
  17195. }
  17196. body.push(make_node(AST_SimpleStatement, self.condition, {
  17197. body: self.condition
  17198. }));
  17199. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17200. }
  17201. }
  17202. }
  17203. return if_break_in_loop(self, compressor);
  17204. });
  17205. def_optimize(AST_If, function(self, compressor) {
  17206. if (is_empty(self.alternative)) self.alternative = null;
  17207. if (!compressor.option("conditionals")) return self;
  17208. // if condition can be statically determined, drop
  17209. // one of the blocks. note, statically determined implies
  17210. // “has no side effects”; also it doesn't work for cases like
  17211. // `x && true`, though it probably should.
  17212. var cond = self.condition.evaluate(compressor);
  17213. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  17214. var orig = self.condition;
  17215. self.condition = make_node_from_constant(cond, orig);
  17216. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  17217. }
  17218. if (compressor.option("dead_code")) {
  17219. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  17220. if (!cond) {
  17221. var body = [];
  17222. trim_unreachable_code(compressor, self.body, body);
  17223. body.push(make_node(AST_SimpleStatement, self.condition, {
  17224. body: self.condition
  17225. }));
  17226. if (self.alternative) body.push(self.alternative);
  17227. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17228. } else if (!(cond instanceof AST_Node)) {
  17229. var body = [];
  17230. body.push(make_node(AST_SimpleStatement, self.condition, {
  17231. body: self.condition
  17232. }));
  17233. body.push(self.body);
  17234. if (self.alternative) {
  17235. trim_unreachable_code(compressor, self.alternative, body);
  17236. }
  17237. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  17238. }
  17239. }
  17240. var negated = self.condition.negate(compressor);
  17241. var self_condition_length = self.condition.size();
  17242. var negated_length = negated.size();
  17243. var negated_is_best = negated_length < self_condition_length;
  17244. if (self.alternative && negated_is_best) {
  17245. negated_is_best = false; // because we already do the switch here.
  17246. // no need to swap values of self_condition_length and negated_length
  17247. // here because they are only used in an equality comparison later on.
  17248. self.condition = negated;
  17249. var tmp = self.body;
  17250. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  17251. self.alternative = tmp;
  17252. }
  17253. if (is_empty(self.body) && is_empty(self.alternative)) {
  17254. return make_node(AST_SimpleStatement, self.condition, {
  17255. body: self.condition.clone()
  17256. }).optimize(compressor);
  17257. }
  17258. if (self.body instanceof AST_SimpleStatement
  17259. && self.alternative instanceof AST_SimpleStatement) {
  17260. return make_node(AST_SimpleStatement, self, {
  17261. body: make_node(AST_Conditional, self, {
  17262. condition : self.condition,
  17263. consequent : self.body.body,
  17264. alternative : self.alternative.body
  17265. })
  17266. }).optimize(compressor);
  17267. }
  17268. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  17269. if (self_condition_length === negated_length && !negated_is_best
  17270. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  17271. // although the code length of self.condition and negated are the same,
  17272. // negated does not require additional surrounding parentheses.
  17273. // see https://github.com/mishoo/UglifyJS2/issues/979
  17274. negated_is_best = true;
  17275. }
  17276. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  17277. body: make_node(AST_Binary, self, {
  17278. operator : "||",
  17279. left : negated,
  17280. right : self.body.body
  17281. })
  17282. }).optimize(compressor);
  17283. return make_node(AST_SimpleStatement, self, {
  17284. body: make_node(AST_Binary, self, {
  17285. operator : "&&",
  17286. left : self.condition,
  17287. right : self.body.body
  17288. })
  17289. }).optimize(compressor);
  17290. }
  17291. if (self.body instanceof AST_EmptyStatement
  17292. && self.alternative instanceof AST_SimpleStatement) {
  17293. return make_node(AST_SimpleStatement, self, {
  17294. body: make_node(AST_Binary, self, {
  17295. operator : "||",
  17296. left : self.condition,
  17297. right : self.alternative.body
  17298. })
  17299. }).optimize(compressor);
  17300. }
  17301. if (self.body instanceof AST_Exit
  17302. && self.alternative instanceof AST_Exit
  17303. && self.body.TYPE == self.alternative.TYPE) {
  17304. return make_node(self.body.CTOR, self, {
  17305. value: make_node(AST_Conditional, self, {
  17306. condition : self.condition,
  17307. consequent : self.body.value || make_node(AST_Undefined, self.body),
  17308. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  17309. }).transform(compressor)
  17310. }).optimize(compressor);
  17311. }
  17312. if (self.body instanceof AST_If
  17313. && !self.body.alternative
  17314. && !self.alternative) {
  17315. self = make_node(AST_If, self, {
  17316. condition: make_node(AST_Binary, self.condition, {
  17317. operator: "&&",
  17318. left: self.condition,
  17319. right: self.body.condition
  17320. }),
  17321. body: self.body.body,
  17322. alternative: null
  17323. });
  17324. }
  17325. if (aborts(self.body)) {
  17326. if (self.alternative) {
  17327. var alt = self.alternative;
  17328. self.alternative = null;
  17329. return make_node(AST_BlockStatement, self, {
  17330. body: [ self, alt ]
  17331. }).optimize(compressor);
  17332. }
  17333. }
  17334. if (aborts(self.alternative)) {
  17335. var body = self.body;
  17336. self.body = self.alternative;
  17337. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  17338. self.alternative = null;
  17339. return make_node(AST_BlockStatement, self, {
  17340. body: [ self, body ]
  17341. }).optimize(compressor);
  17342. }
  17343. return self;
  17344. });
  17345. def_optimize(AST_Switch, function(self, compressor) {
  17346. if (!compressor.option("switches")) return self;
  17347. var branch;
  17348. var value = self.expression.evaluate(compressor);
  17349. if (!(value instanceof AST_Node)) {
  17350. var orig = self.expression;
  17351. self.expression = make_node_from_constant(value, orig);
  17352. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  17353. }
  17354. if (!compressor.option("dead_code")) return self;
  17355. if (value instanceof AST_Node) {
  17356. value = self.expression.tail_node().evaluate(compressor);
  17357. }
  17358. var decl = [];
  17359. var body = [];
  17360. var default_branch;
  17361. var exact_match;
  17362. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  17363. branch = self.body[i];
  17364. if (branch instanceof AST_Default) {
  17365. if (!default_branch) {
  17366. default_branch = branch;
  17367. } else {
  17368. eliminate_branch(branch, body[body.length - 1]);
  17369. }
  17370. } else if (!(value instanceof AST_Node)) {
  17371. var exp = branch.expression.evaluate(compressor);
  17372. if (!(exp instanceof AST_Node) && exp !== value) {
  17373. eliminate_branch(branch, body[body.length - 1]);
  17374. continue;
  17375. }
  17376. if (exp instanceof AST_Node) exp = branch.expression.tail_node().evaluate(compressor);
  17377. if (exp === value) {
  17378. exact_match = branch;
  17379. if (default_branch) {
  17380. var default_index = body.indexOf(default_branch);
  17381. body.splice(default_index, 1);
  17382. eliminate_branch(default_branch, body[default_index - 1]);
  17383. default_branch = null;
  17384. }
  17385. }
  17386. }
  17387. body.push(branch);
  17388. }
  17389. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  17390. self.body = body;
  17391. let default_or_exact = default_branch || exact_match;
  17392. default_branch = null;
  17393. exact_match = null;
  17394. // group equivalent branches so they will be located next to each other,
  17395. // that way the next micro-optimization will merge them.
  17396. // ** bail micro-optimization if not a simple switch case with breaks
  17397. if (body.every((branch, i) =>
  17398. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  17399. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  17400. ) {
  17401. for (let i = 0; i < body.length; i++) {
  17402. const branch = body[i];
  17403. for (let j = i + 1; j < body.length; j++) {
  17404. const next = body[j];
  17405. if (next.body.length === 0) continue;
  17406. const last_branch = j === (body.length - 1);
  17407. const equivalentBranch = branches_equivalent(next, branch, false);
  17408. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  17409. if (!equivalentBranch && last_branch) {
  17410. next.body.push(make_node(AST_Break));
  17411. }
  17412. // let's find previous siblings with inert fallthrough...
  17413. let x = j - 1;
  17414. let fallthroughDepth = 0;
  17415. while (x > i) {
  17416. if (is_inert_body(body[x--])) {
  17417. fallthroughDepth++;
  17418. } else {
  17419. break;
  17420. }
  17421. }
  17422. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  17423. body.splice(i + 1, 0, ...plucked);
  17424. i += plucked.length;
  17425. }
  17426. }
  17427. }
  17428. }
  17429. // merge equivalent branches in a row
  17430. for (let i = 0; i < body.length; i++) {
  17431. let branch = body[i];
  17432. if (branch.body.length === 0) continue;
  17433. if (!aborts(branch)) continue;
  17434. for (let j = i + 1; j < body.length; i++, j++) {
  17435. let next = body[j];
  17436. if (next.body.length === 0) continue;
  17437. if (
  17438. branches_equivalent(next, branch, false)
  17439. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  17440. ) {
  17441. branch.body = [];
  17442. branch = next;
  17443. continue;
  17444. }
  17445. break;
  17446. }
  17447. }
  17448. // Prune any empty branches at the end of the switch statement.
  17449. {
  17450. let i = body.length - 1;
  17451. for (; i >= 0; i--) {
  17452. let bbody = body[i].body;
  17453. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  17454. if (!is_inert_body(body[i])) break;
  17455. }
  17456. // i now points to the index of a branch that contains a body. By incrementing, it's
  17457. // pointing to the first branch that's empty.
  17458. i++;
  17459. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  17460. // The default behavior is to do nothing. We can take advantage of that to
  17461. // remove all case expressions that are side-effect free that also do
  17462. // nothing, since they'll default to doing nothing. But we can't remove any
  17463. // case expressions before one that would side-effect, since they may cause
  17464. // the side-effect to be skipped.
  17465. for (let j = body.length - 1; j >= i; j--) {
  17466. let branch = body[j];
  17467. if (branch === default_or_exact) {
  17468. default_or_exact = null;
  17469. body.pop();
  17470. } else if (!branch.expression.has_side_effects(compressor)) {
  17471. body.pop();
  17472. } else {
  17473. break;
  17474. }
  17475. }
  17476. }
  17477. }
  17478. // Prune side-effect free branches that fall into default.
  17479. DEFAULT: if (default_or_exact) {
  17480. let default_index = body.indexOf(default_or_exact);
  17481. let default_body_index = default_index;
  17482. for (; default_body_index < body.length - 1; default_body_index++) {
  17483. if (!is_inert_body(body[default_body_index])) break;
  17484. }
  17485. if (default_body_index < body.length - 1) {
  17486. break DEFAULT;
  17487. }
  17488. let side_effect_index = body.length - 1;
  17489. for (; side_effect_index >= 0; side_effect_index--) {
  17490. let branch = body[side_effect_index];
  17491. if (branch === default_or_exact) continue;
  17492. if (branch.expression.has_side_effects(compressor)) break;
  17493. }
  17494. // If the default behavior comes after any side-effect case expressions,
  17495. // then we can fold all side-effect free cases into the default branch.
  17496. // If the side-effect case is after the default, then any side-effect
  17497. // free cases could prevent the side-effect from occurring.
  17498. if (default_body_index > side_effect_index) {
  17499. let prev_body_index = default_index - 1;
  17500. for (; prev_body_index >= 0; prev_body_index--) {
  17501. if (!is_inert_body(body[prev_body_index])) break;
  17502. }
  17503. let before = Math.max(side_effect_index, prev_body_index) + 1;
  17504. let after = default_index;
  17505. if (side_effect_index > default_index) {
  17506. // If the default falls into the same body as a side-effect
  17507. // case, then we need preserve that case and only prune the
  17508. // cases after it.
  17509. after = side_effect_index;
  17510. body[side_effect_index].body = body[default_body_index].body;
  17511. } else {
  17512. // The default will be the last branch.
  17513. default_or_exact.body = body[default_body_index].body;
  17514. }
  17515. // Prune everything after the default (or last side-effect case)
  17516. // until the next case with a body.
  17517. body.splice(after + 1, default_body_index - after);
  17518. // Prune everything before the default that falls into it.
  17519. body.splice(before, default_index - before);
  17520. }
  17521. }
  17522. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  17523. DEFAULT: if (default_or_exact) {
  17524. let i = body.findIndex(branch => !is_inert_body(branch));
  17525. let caseBody;
  17526. // `i` is equal to one of the following:
  17527. // - `-1`, there is no body in the switch statement.
  17528. // - `body.length - 1`, all cases fall into the same body.
  17529. // - anything else, there are multiple bodies in the switch.
  17530. if (i === body.length - 1) {
  17531. // All cases fall into the case body.
  17532. let branch = body[i];
  17533. if (has_nested_break(self)) break DEFAULT;
  17534. // This is the last case body, and we've already pruned any breaks, so it's
  17535. // safe to hoist.
  17536. caseBody = make_node(AST_BlockStatement, branch, {
  17537. body: branch.body
  17538. });
  17539. branch.body = [];
  17540. } else if (i !== -1) {
  17541. // If there are multiple bodies, then we cannot optimize anything.
  17542. break DEFAULT;
  17543. }
  17544. let sideEffect = body.find(branch => {
  17545. return (
  17546. branch !== default_or_exact
  17547. && branch.expression.has_side_effects(compressor)
  17548. );
  17549. });
  17550. // If no cases cause a side-effect, we can eliminate the switch entirely.
  17551. if (!sideEffect) {
  17552. return make_node(AST_BlockStatement, self, {
  17553. body: decl.concat(
  17554. statement(self.expression),
  17555. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  17556. caseBody || []
  17557. )
  17558. }).optimize(compressor);
  17559. }
  17560. // If we're this far, either there was no body or all cases fell into the same body.
  17561. // If there was no body, then we don't need a default branch (because the default is
  17562. // do nothing). If there was a body, we'll extract it to after the switch, so the
  17563. // switch's new default is to do nothing and we can still prune it.
  17564. const default_index = body.indexOf(default_or_exact);
  17565. body.splice(default_index, 1);
  17566. default_or_exact = null;
  17567. if (caseBody) {
  17568. // Recurse into switch statement one more time so that we can append the case body
  17569. // outside of the switch. This recursion will only happen once since we've pruned
  17570. // the default case.
  17571. return make_node(AST_BlockStatement, self, {
  17572. body: decl.concat(self, caseBody)
  17573. }).optimize(compressor);
  17574. }
  17575. // If we fall here, there is a default branch somewhere, there are no case bodies,
  17576. // and there's a side-effect somewhere. Just let the below paths take care of it.
  17577. }
  17578. if (body.length > 0) {
  17579. body[0].body = decl.concat(body[0].body);
  17580. }
  17581. if (body.length == 0) {
  17582. return make_node(AST_BlockStatement, self, {
  17583. body: decl.concat(statement(self.expression))
  17584. }).optimize(compressor);
  17585. }
  17586. if (body.length == 1 && !has_nested_break(self)) {
  17587. // This is the last case body, and we've already pruned any breaks, so it's
  17588. // safe to hoist.
  17589. let branch = body[0];
  17590. return make_node(AST_If, self, {
  17591. condition: make_node(AST_Binary, self, {
  17592. operator: "===",
  17593. left: self.expression,
  17594. right: branch.expression,
  17595. }),
  17596. body: make_node(AST_BlockStatement, branch, {
  17597. body: branch.body
  17598. }),
  17599. alternative: null
  17600. }).optimize(compressor);
  17601. }
  17602. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  17603. let branch = body[0] === default_or_exact ? body[1] : body[0];
  17604. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  17605. if (aborts(body[0])) {
  17606. // Only the first branch body could have a break (at the last statement)
  17607. let first = body[0];
  17608. if (is_break(first.body[first.body.length - 1], compressor)) {
  17609. first.body.pop();
  17610. }
  17611. return make_node(AST_If, self, {
  17612. condition: make_node(AST_Binary, self, {
  17613. operator: "===",
  17614. left: self.expression,
  17615. right: branch.expression,
  17616. }),
  17617. body: make_node(AST_BlockStatement, branch, {
  17618. body: branch.body
  17619. }),
  17620. alternative: make_node(AST_BlockStatement, default_or_exact, {
  17621. body: [].concat(
  17622. exact_exp || [],
  17623. default_or_exact.body
  17624. )
  17625. })
  17626. }).optimize(compressor);
  17627. }
  17628. let operator = "===";
  17629. let consequent = make_node(AST_BlockStatement, branch, {
  17630. body: branch.body,
  17631. });
  17632. let always = make_node(AST_BlockStatement, default_or_exact, {
  17633. body: [].concat(
  17634. exact_exp || [],
  17635. default_or_exact.body
  17636. )
  17637. });
  17638. if (body[0] === default_or_exact) {
  17639. operator = "!==";
  17640. let tmp = always;
  17641. always = consequent;
  17642. consequent = tmp;
  17643. }
  17644. return make_node(AST_BlockStatement, self, {
  17645. body: [
  17646. make_node(AST_If, self, {
  17647. condition: make_node(AST_Binary, self, {
  17648. operator: operator,
  17649. left: self.expression,
  17650. right: branch.expression,
  17651. }),
  17652. body: consequent,
  17653. alternative: null
  17654. })
  17655. ].concat(always)
  17656. }).optimize(compressor);
  17657. }
  17658. return self;
  17659. function eliminate_branch(branch, prev) {
  17660. if (prev && !aborts(prev)) {
  17661. prev.body = prev.body.concat(branch.body);
  17662. } else {
  17663. trim_unreachable_code(compressor, branch, decl);
  17664. }
  17665. }
  17666. function branches_equivalent(branch, prev, insertBreak) {
  17667. let bbody = branch.body;
  17668. let pbody = prev.body;
  17669. if (insertBreak) {
  17670. bbody = bbody.concat(make_node(AST_Break));
  17671. }
  17672. if (bbody.length !== pbody.length) return false;
  17673. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  17674. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  17675. return bblock.equivalent_to(pblock);
  17676. }
  17677. function statement(expression) {
  17678. return make_node(AST_SimpleStatement, expression, {
  17679. body: expression
  17680. });
  17681. }
  17682. function has_nested_break(root) {
  17683. let has_break = false;
  17684. let tw = new TreeWalker(node => {
  17685. if (has_break) return true;
  17686. if (node instanceof AST_Lambda) return true;
  17687. if (node instanceof AST_SimpleStatement) return true;
  17688. if (!is_break(node, tw)) return;
  17689. let parent = tw.parent();
  17690. if (
  17691. parent instanceof AST_SwitchBranch
  17692. && parent.body[parent.body.length - 1] === node
  17693. ) {
  17694. return;
  17695. }
  17696. has_break = true;
  17697. });
  17698. root.walk(tw);
  17699. return has_break;
  17700. }
  17701. function is_break(node, stack) {
  17702. return node instanceof AST_Break
  17703. && stack.loopcontrol_target(node) === self;
  17704. }
  17705. function is_inert_body(branch) {
  17706. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  17707. body: branch.body
  17708. }).has_side_effects(compressor);
  17709. }
  17710. });
  17711. def_optimize(AST_Try, function(self, compressor) {
  17712. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  17713. if (compressor.option("dead_code") && self.body.body.every(is_empty)) {
  17714. var body = [];
  17715. if (self.bcatch) {
  17716. trim_unreachable_code(compressor, self.bcatch, body);
  17717. }
  17718. if (self.bfinally) body.push(...self.bfinally.body);
  17719. return make_node(AST_BlockStatement, self, {
  17720. body: body
  17721. }).optimize(compressor);
  17722. }
  17723. return self;
  17724. });
  17725. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  17726. var reduce_vars = compressor.option("reduce_vars");
  17727. var assignments = [];
  17728. for (const def of this.definitions) {
  17729. if (def.value) {
  17730. var name = make_node(AST_SymbolRef, def.name, def.name);
  17731. assignments.push(make_node(AST_Assign, def, {
  17732. operator : "=",
  17733. logical: false,
  17734. left : name,
  17735. right : def.value
  17736. }));
  17737. if (reduce_vars) name.definition().fixed = false;
  17738. }
  17739. const thedef = def.name.definition();
  17740. thedef.eliminated++;
  17741. thedef.replaced--;
  17742. }
  17743. if (assignments.length == 0) return null;
  17744. return make_sequence(this, assignments);
  17745. });
  17746. def_optimize(AST_Definitions, function(self) {
  17747. if (self.definitions.length == 0) {
  17748. return make_node(AST_EmptyStatement, self);
  17749. }
  17750. return self;
  17751. });
  17752. def_optimize(AST_VarDef, function(self, compressor) {
  17753. if (
  17754. self.name instanceof AST_SymbolLet
  17755. && self.value != null
  17756. && is_undefined(self.value, compressor)
  17757. ) {
  17758. self.value = null;
  17759. }
  17760. return self;
  17761. });
  17762. def_optimize(AST_Import, function(self) {
  17763. return self;
  17764. });
  17765. def_optimize(AST_Call, function(self, compressor) {
  17766. var exp = self.expression;
  17767. var fn = exp;
  17768. inline_array_like_spread(self.args);
  17769. var simple_args = self.args.every((arg) =>
  17770. !(arg instanceof AST_Expansion)
  17771. );
  17772. if (compressor.option("reduce_vars")
  17773. && fn instanceof AST_SymbolRef
  17774. && !has_annotation(self, _NOINLINE)
  17775. ) {
  17776. const fixed = fn.fixed_value();
  17777. if (!retain_top_func(fixed, compressor)) {
  17778. fn = fixed;
  17779. }
  17780. }
  17781. var is_func = fn instanceof AST_Lambda;
  17782. if (is_func && fn.pinned()) return self;
  17783. if (compressor.option("unused")
  17784. && simple_args
  17785. && is_func
  17786. && !fn.uses_arguments) {
  17787. var pos = 0, last = 0;
  17788. for (var i = 0, len = self.args.length; i < len; i++) {
  17789. if (fn.argnames[i] instanceof AST_Expansion) {
  17790. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  17791. var node = self.args[i++].drop_side_effect_free(compressor);
  17792. if (node) {
  17793. self.args[pos++] = node;
  17794. }
  17795. } else while (i < len) {
  17796. self.args[pos++] = self.args[i++];
  17797. }
  17798. last = pos;
  17799. break;
  17800. }
  17801. var trim = i >= fn.argnames.length;
  17802. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  17803. var node = self.args[i].drop_side_effect_free(compressor);
  17804. if (node) {
  17805. self.args[pos++] = node;
  17806. } else if (!trim) {
  17807. self.args[pos++] = make_node(AST_Number, self.args[i], {
  17808. value: 0
  17809. });
  17810. continue;
  17811. }
  17812. } else {
  17813. self.args[pos++] = self.args[i];
  17814. }
  17815. last = pos;
  17816. }
  17817. self.args.length = last;
  17818. }
  17819. if (compressor.option("unsafe")) {
  17820. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  17821. const [argument] = self.args;
  17822. if (argument instanceof AST_Array) {
  17823. return make_node(AST_Array, argument, {
  17824. elements: argument.elements
  17825. }).optimize(compressor);
  17826. }
  17827. }
  17828. if (is_undeclared_ref(exp)) switch (exp.name) {
  17829. case "Array":
  17830. if (self.args.length != 1) {
  17831. return make_node(AST_Array, self, {
  17832. elements: self.args
  17833. }).optimize(compressor);
  17834. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  17835. const elements = [];
  17836. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  17837. return new AST_Array({ elements });
  17838. }
  17839. break;
  17840. case "Object":
  17841. if (self.args.length == 0) {
  17842. return make_node(AST_Object, self, {
  17843. properties: []
  17844. });
  17845. }
  17846. break;
  17847. case "String":
  17848. if (self.args.length == 0) return make_node(AST_String, self, {
  17849. value: ""
  17850. });
  17851. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  17852. left: self.args[0],
  17853. operator: "+",
  17854. right: make_node(AST_String, self, { value: "" })
  17855. }).optimize(compressor);
  17856. break;
  17857. case "Number":
  17858. if (self.args.length == 0) return make_node(AST_Number, self, {
  17859. value: 0
  17860. });
  17861. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  17862. return make_node(AST_UnaryPrefix, self, {
  17863. expression: self.args[0],
  17864. operator: "+"
  17865. }).optimize(compressor);
  17866. }
  17867. break;
  17868. case "Symbol":
  17869. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  17870. self.args.length = 0;
  17871. break;
  17872. case "Boolean":
  17873. if (self.args.length == 0) return make_node(AST_False, self);
  17874. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  17875. expression: make_node(AST_UnaryPrefix, self, {
  17876. expression: self.args[0],
  17877. operator: "!"
  17878. }),
  17879. operator: "!"
  17880. }).optimize(compressor);
  17881. break;
  17882. case "RegExp":
  17883. var params = [];
  17884. if (self.args.length >= 1
  17885. && self.args.length <= 2
  17886. && self.args.every((arg) => {
  17887. var value = arg.evaluate(compressor);
  17888. params.push(value);
  17889. return arg !== value;
  17890. })
  17891. && regexp_is_safe(params[0])
  17892. ) {
  17893. let [ source, flags ] = params;
  17894. source = regexp_source_fix(new RegExp(source).source);
  17895. const rx = make_node(AST_RegExp, self, {
  17896. value: { source, flags }
  17897. });
  17898. if (rx._eval(compressor) !== rx) {
  17899. return rx;
  17900. }
  17901. }
  17902. break;
  17903. } else if (exp instanceof AST_Dot) switch(exp.property) {
  17904. case "toString":
  17905. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  17906. return make_node(AST_Binary, self, {
  17907. left: make_node(AST_String, self, { value: "" }),
  17908. operator: "+",
  17909. right: exp.expression
  17910. }).optimize(compressor);
  17911. }
  17912. break;
  17913. case "join":
  17914. if (exp.expression instanceof AST_Array) EXIT: {
  17915. var separator;
  17916. if (self.args.length > 0) {
  17917. separator = self.args[0].evaluate(compressor);
  17918. if (separator === self.args[0]) break EXIT; // not a constant
  17919. }
  17920. var elements = [];
  17921. var consts = [];
  17922. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  17923. var el = exp.expression.elements[i];
  17924. if (el instanceof AST_Expansion) break EXIT;
  17925. var value = el.evaluate(compressor);
  17926. if (value !== el) {
  17927. consts.push(value);
  17928. } else {
  17929. if (consts.length > 0) {
  17930. elements.push(make_node(AST_String, self, {
  17931. value: consts.join(separator)
  17932. }));
  17933. consts.length = 0;
  17934. }
  17935. elements.push(el);
  17936. }
  17937. }
  17938. if (consts.length > 0) {
  17939. elements.push(make_node(AST_String, self, {
  17940. value: consts.join(separator)
  17941. }));
  17942. }
  17943. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  17944. if (elements.length == 1) {
  17945. if (elements[0].is_string(compressor)) {
  17946. return elements[0];
  17947. }
  17948. return make_node(AST_Binary, elements[0], {
  17949. operator : "+",
  17950. left : make_node(AST_String, self, { value: "" }),
  17951. right : elements[0]
  17952. });
  17953. }
  17954. if (separator == "") {
  17955. var first;
  17956. if (elements[0].is_string(compressor)
  17957. || elements[1].is_string(compressor)) {
  17958. first = elements.shift();
  17959. } else {
  17960. first = make_node(AST_String, self, { value: "" });
  17961. }
  17962. return elements.reduce(function(prev, el) {
  17963. return make_node(AST_Binary, el, {
  17964. operator : "+",
  17965. left : prev,
  17966. right : el
  17967. });
  17968. }, first).optimize(compressor);
  17969. }
  17970. // need this awkward cloning to not affect original element
  17971. // best_of will decide which one to get through.
  17972. var node = self.clone();
  17973. node.expression = node.expression.clone();
  17974. node.expression.expression = node.expression.expression.clone();
  17975. node.expression.expression.elements = elements;
  17976. return best_of(compressor, self, node);
  17977. }
  17978. break;
  17979. case "charAt":
  17980. if (exp.expression.is_string(compressor)) {
  17981. var arg = self.args[0];
  17982. var index = arg ? arg.evaluate(compressor) : 0;
  17983. if (index !== arg) {
  17984. return make_node(AST_Sub, exp, {
  17985. expression: exp.expression,
  17986. property: make_node_from_constant(index | 0, arg || exp)
  17987. }).optimize(compressor);
  17988. }
  17989. }
  17990. break;
  17991. case "apply":
  17992. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  17993. var args = self.args[1].elements.slice();
  17994. args.unshift(self.args[0]);
  17995. return make_node(AST_Call, self, {
  17996. expression: make_node(AST_Dot, exp, {
  17997. expression: exp.expression,
  17998. optional: false,
  17999. property: "call"
  18000. }),
  18001. args: args
  18002. }).optimize(compressor);
  18003. }
  18004. break;
  18005. case "call":
  18006. var func = exp.expression;
  18007. if (func instanceof AST_SymbolRef) {
  18008. func = func.fixed_value();
  18009. }
  18010. if (func instanceof AST_Lambda && !func.contains_this()) {
  18011. return (self.args.length ? make_sequence(this, [
  18012. self.args[0],
  18013. make_node(AST_Call, self, {
  18014. expression: exp.expression,
  18015. args: self.args.slice(1)
  18016. })
  18017. ]) : make_node(AST_Call, self, {
  18018. expression: exp.expression,
  18019. args: []
  18020. })).optimize(compressor);
  18021. }
  18022. break;
  18023. }
  18024. }
  18025. if (compressor.option("unsafe_Function")
  18026. && is_undeclared_ref(exp)
  18027. && exp.name == "Function") {
  18028. // new Function() => function(){}
  18029. if (self.args.length == 0) return make_node(AST_Function, self, {
  18030. argnames: [],
  18031. body: []
  18032. }).optimize(compressor);
  18033. var nth_identifier = compressor.mangle_options && compressor.mangle_options.nth_identifier || base54;
  18034. if (self.args.every((x) => x instanceof AST_String)) {
  18035. // quite a corner-case, but we can handle it:
  18036. // https://github.com/mishoo/UglifyJS2/issues/203
  18037. // if the code argument is a constant, then we can minify it.
  18038. try {
  18039. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  18040. return arg.value;
  18041. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  18042. var ast = parse(code);
  18043. var mangle = { ie8: compressor.option("ie8"), nth_identifier: nth_identifier };
  18044. ast.figure_out_scope(mangle);
  18045. var comp = new Compressor(compressor.options, {
  18046. mangle_options: compressor.mangle_options
  18047. });
  18048. ast = ast.transform(comp);
  18049. ast.figure_out_scope(mangle);
  18050. ast.compute_char_frequency(mangle);
  18051. ast.mangle_names(mangle);
  18052. var fun;
  18053. walk(ast, node => {
  18054. if (is_func_expr(node)) {
  18055. fun = node;
  18056. return walk_abort;
  18057. }
  18058. });
  18059. var code = OutputStream();
  18060. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  18061. self.args = [
  18062. make_node(AST_String, self, {
  18063. value: fun.argnames.map(function(arg) {
  18064. return arg.print_to_string();
  18065. }).join(",")
  18066. }),
  18067. make_node(AST_String, self.args[self.args.length - 1], {
  18068. value: code.get().replace(/^{|}$/g, "")
  18069. })
  18070. ];
  18071. return self;
  18072. } catch (ex) {
  18073. if (!(ex instanceof JS_Parse_Error)) {
  18074. throw ex;
  18075. }
  18076. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  18077. }
  18078. }
  18079. }
  18080. return inline_into_call(self, fn, compressor);
  18081. });
  18082. def_optimize(AST_New, function(self, compressor) {
  18083. if (
  18084. compressor.option("unsafe") &&
  18085. is_undeclared_ref(self.expression) &&
  18086. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  18087. ) return make_node(AST_Call, self, self).transform(compressor);
  18088. return self;
  18089. });
  18090. def_optimize(AST_Sequence, function(self, compressor) {
  18091. if (!compressor.option("side_effects")) return self;
  18092. var expressions = [];
  18093. filter_for_side_effects();
  18094. var end = expressions.length - 1;
  18095. trim_right_for_undefined();
  18096. if (end == 0) {
  18097. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  18098. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  18099. return self;
  18100. }
  18101. self.expressions = expressions;
  18102. return self;
  18103. function filter_for_side_effects() {
  18104. var first = first_in_statement(compressor);
  18105. var last = self.expressions.length - 1;
  18106. self.expressions.forEach(function(expr, index) {
  18107. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  18108. if (expr) {
  18109. merge_sequence(expressions, expr);
  18110. first = false;
  18111. }
  18112. });
  18113. }
  18114. function trim_right_for_undefined() {
  18115. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  18116. if (end < expressions.length - 1) {
  18117. expressions[end] = make_node(AST_UnaryPrefix, self, {
  18118. operator : "void",
  18119. expression : expressions[end]
  18120. });
  18121. expressions.length = end + 1;
  18122. }
  18123. }
  18124. });
  18125. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  18126. if (compressor.option("sequences")) {
  18127. if (this.expression instanceof AST_Sequence) {
  18128. var x = this.expression.expressions.slice();
  18129. var e = this.clone();
  18130. e.expression = x.pop();
  18131. x.push(e);
  18132. return make_sequence(this, x).optimize(compressor);
  18133. }
  18134. }
  18135. return this;
  18136. });
  18137. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  18138. return self.lift_sequences(compressor);
  18139. });
  18140. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  18141. var e = self.expression;
  18142. if (
  18143. self.operator == "delete" &&
  18144. !(
  18145. e instanceof AST_SymbolRef ||
  18146. e instanceof AST_PropAccess ||
  18147. e instanceof AST_Chain ||
  18148. is_identifier_atom(e)
  18149. )
  18150. ) {
  18151. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  18152. }
  18153. var seq = self.lift_sequences(compressor);
  18154. if (seq !== self) {
  18155. return seq;
  18156. }
  18157. if (compressor.option("side_effects") && self.operator == "void") {
  18158. e = e.drop_side_effect_free(compressor);
  18159. if (e) {
  18160. self.expression = e;
  18161. return self;
  18162. } else {
  18163. return make_node(AST_Undefined, self).optimize(compressor);
  18164. }
  18165. }
  18166. if (compressor.in_boolean_context()) {
  18167. switch (self.operator) {
  18168. case "!":
  18169. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  18170. // !!foo ==> foo, if we're in boolean context
  18171. return e.expression;
  18172. }
  18173. if (e instanceof AST_Binary) {
  18174. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  18175. }
  18176. break;
  18177. case "typeof":
  18178. // typeof always returns a non-empty string, thus it's
  18179. // always true in booleans
  18180. // And we don't need to check if it's undeclared, because in typeof, that's OK
  18181. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  18182. e,
  18183. make_node(AST_True, self)
  18184. ])).optimize(compressor);
  18185. }
  18186. }
  18187. if (self.operator == "-" && e instanceof AST_Infinity) {
  18188. e = e.transform(compressor);
  18189. }
  18190. if (e instanceof AST_Binary
  18191. && (self.operator == "+" || self.operator == "-")
  18192. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  18193. return make_node(AST_Binary, self, {
  18194. operator: e.operator,
  18195. left: make_node(AST_UnaryPrefix, e.left, {
  18196. operator: self.operator,
  18197. expression: e.left
  18198. }),
  18199. right: e.right
  18200. });
  18201. }
  18202. // avoids infinite recursion of numerals
  18203. if (self.operator != "-"
  18204. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)) {
  18205. var ev = self.evaluate(compressor);
  18206. if (ev !== self) {
  18207. ev = make_node_from_constant(ev, self).optimize(compressor);
  18208. return best_of(compressor, ev, self);
  18209. }
  18210. }
  18211. return self;
  18212. });
  18213. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  18214. if (compressor.option("sequences")) {
  18215. if (this.left instanceof AST_Sequence) {
  18216. var x = this.left.expressions.slice();
  18217. var e = this.clone();
  18218. e.left = x.pop();
  18219. x.push(e);
  18220. return make_sequence(this, x).optimize(compressor);
  18221. }
  18222. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  18223. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  18224. var x = this.right.expressions;
  18225. var last = x.length - 1;
  18226. for (var i = 0; i < last; i++) {
  18227. if (!assign && x[i].has_side_effects(compressor)) break;
  18228. }
  18229. if (i == last) {
  18230. x = x.slice();
  18231. var e = this.clone();
  18232. e.right = x.pop();
  18233. x.push(e);
  18234. return make_sequence(this, x).optimize(compressor);
  18235. } else if (i > 0) {
  18236. var e = this.clone();
  18237. e.right = make_sequence(this.right, x.slice(i));
  18238. x = x.slice(0, i);
  18239. x.push(e);
  18240. return make_sequence(this, x).optimize(compressor);
  18241. }
  18242. }
  18243. }
  18244. return this;
  18245. });
  18246. var commutativeOperators = makePredicate("== === != !== * & | ^");
  18247. function is_object(node) {
  18248. return node instanceof AST_Array
  18249. || node instanceof AST_Lambda
  18250. || node instanceof AST_Object
  18251. || node instanceof AST_Class;
  18252. }
  18253. def_optimize(AST_Binary, function(self, compressor) {
  18254. function reversible() {
  18255. return self.left.is_constant()
  18256. || self.right.is_constant()
  18257. || !self.left.has_side_effects(compressor)
  18258. && !self.right.has_side_effects(compressor);
  18259. }
  18260. function reverse(op) {
  18261. if (reversible()) {
  18262. if (op) self.operator = op;
  18263. var tmp = self.left;
  18264. self.left = self.right;
  18265. self.right = tmp;
  18266. }
  18267. }
  18268. if (compressor.option("lhs_constants") && commutativeOperators.has(self.operator)) {
  18269. if (self.right.is_constant()
  18270. && !self.left.is_constant()) {
  18271. // if right is a constant, whatever side effects the
  18272. // left side might have could not influence the
  18273. // result. hence, force switch.
  18274. if (!(self.left instanceof AST_Binary
  18275. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  18276. reverse();
  18277. }
  18278. }
  18279. }
  18280. self = self.lift_sequences(compressor);
  18281. if (compressor.option("comparisons")) switch (self.operator) {
  18282. case "===":
  18283. case "!==":
  18284. var is_strict_comparison = true;
  18285. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  18286. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  18287. (self.left.is_boolean() && self.right.is_boolean()) ||
  18288. self.left.equivalent_to(self.right)) {
  18289. self.operator = self.operator.substr(0, 2);
  18290. }
  18291. // XXX: intentionally falling down to the next case
  18292. case "==":
  18293. case "!=":
  18294. // void 0 == x => null == x
  18295. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  18296. self.left = make_node(AST_Null, self.left);
  18297. // x == void 0 => x == null
  18298. } else if (!is_strict_comparison && is_undefined(self.right, compressor)) {
  18299. self.right = make_node(AST_Null, self.right);
  18300. } else if (compressor.option("typeofs")
  18301. // "undefined" == typeof x => undefined === x
  18302. && self.left instanceof AST_String
  18303. && self.left.value == "undefined"
  18304. && self.right instanceof AST_UnaryPrefix
  18305. && self.right.operator == "typeof") {
  18306. var expr = self.right.expression;
  18307. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  18308. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  18309. self.right = expr;
  18310. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  18311. if (self.operator.length == 2) self.operator += "=";
  18312. }
  18313. } else if (compressor.option("typeofs")
  18314. // typeof x === "undefined" => x === undefined
  18315. && self.left instanceof AST_UnaryPrefix
  18316. && self.left.operator == "typeof"
  18317. && self.right instanceof AST_String
  18318. && self.right.value == "undefined") {
  18319. var expr = self.left.expression;
  18320. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  18321. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  18322. self.left = expr;
  18323. self.right = make_node(AST_Undefined, self.right).optimize(compressor);
  18324. if (self.operator.length == 2) self.operator += "=";
  18325. }
  18326. } else if (self.left instanceof AST_SymbolRef
  18327. // obj !== obj => false
  18328. && self.right instanceof AST_SymbolRef
  18329. && self.left.definition() === self.right.definition()
  18330. && is_object(self.left.fixed_value())) {
  18331. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  18332. }
  18333. break;
  18334. case "&&":
  18335. case "||":
  18336. var lhs = self.left;
  18337. if (lhs.operator == self.operator) {
  18338. lhs = lhs.right;
  18339. }
  18340. if (lhs instanceof AST_Binary
  18341. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  18342. && self.right instanceof AST_Binary
  18343. && lhs.operator == self.right.operator
  18344. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  18345. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  18346. && !lhs.right.has_side_effects(compressor)
  18347. && lhs.right.equivalent_to(self.right.right)) {
  18348. var combined = make_node(AST_Binary, self, {
  18349. operator: lhs.operator.slice(0, -1),
  18350. left: make_node(AST_Null, self),
  18351. right: lhs.right
  18352. });
  18353. if (lhs !== self.left) {
  18354. combined = make_node(AST_Binary, self, {
  18355. operator: self.operator,
  18356. left: self.left.left,
  18357. right: combined
  18358. });
  18359. }
  18360. return combined;
  18361. }
  18362. break;
  18363. }
  18364. if (self.operator == "+" && compressor.in_boolean_context()) {
  18365. var ll = self.left.evaluate(compressor);
  18366. var rr = self.right.evaluate(compressor);
  18367. if (ll && typeof ll == "string") {
  18368. return make_sequence(self, [
  18369. self.right,
  18370. make_node(AST_True, self)
  18371. ]).optimize(compressor);
  18372. }
  18373. if (rr && typeof rr == "string") {
  18374. return make_sequence(self, [
  18375. self.left,
  18376. make_node(AST_True, self)
  18377. ]).optimize(compressor);
  18378. }
  18379. }
  18380. if (compressor.option("comparisons") && self.is_boolean()) {
  18381. if (!(compressor.parent() instanceof AST_Binary)
  18382. || compressor.parent() instanceof AST_Assign) {
  18383. var negated = make_node(AST_UnaryPrefix, self, {
  18384. operator: "!",
  18385. expression: self.negate(compressor, first_in_statement(compressor))
  18386. });
  18387. self = best_of(compressor, self, negated);
  18388. }
  18389. if (compressor.option("unsafe_comps")) {
  18390. switch (self.operator) {
  18391. case "<": reverse(">"); break;
  18392. case "<=": reverse(">="); break;
  18393. }
  18394. }
  18395. }
  18396. if (self.operator == "+") {
  18397. if (self.right instanceof AST_String
  18398. && self.right.getValue() == ""
  18399. && self.left.is_string(compressor)) {
  18400. return self.left;
  18401. }
  18402. if (self.left instanceof AST_String
  18403. && self.left.getValue() == ""
  18404. && self.right.is_string(compressor)) {
  18405. return self.right;
  18406. }
  18407. if (self.left instanceof AST_Binary
  18408. && self.left.operator == "+"
  18409. && self.left.left instanceof AST_String
  18410. && self.left.left.getValue() == ""
  18411. && self.right.is_string(compressor)) {
  18412. self.left = self.left.right;
  18413. return self;
  18414. }
  18415. }
  18416. if (compressor.option("evaluate")) {
  18417. switch (self.operator) {
  18418. case "&&":
  18419. var ll = has_flag(self.left, TRUTHY)
  18420. ? true
  18421. : has_flag(self.left, FALSY)
  18422. ? false
  18423. : self.left.evaluate(compressor);
  18424. if (!ll) {
  18425. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  18426. } else if (!(ll instanceof AST_Node)) {
  18427. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  18428. }
  18429. var rr = self.right.evaluate(compressor);
  18430. if (!rr) {
  18431. if (compressor.in_boolean_context()) {
  18432. return make_sequence(self, [
  18433. self.left,
  18434. make_node(AST_False, self)
  18435. ]).optimize(compressor);
  18436. } else {
  18437. set_flag(self, FALSY);
  18438. }
  18439. } else if (!(rr instanceof AST_Node)) {
  18440. var parent = compressor.parent();
  18441. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  18442. return self.left.optimize(compressor);
  18443. }
  18444. }
  18445. // x || false && y ---> x ? y : false
  18446. if (self.left.operator == "||") {
  18447. var lr = self.left.right.evaluate(compressor);
  18448. if (!lr) return make_node(AST_Conditional, self, {
  18449. condition: self.left.left,
  18450. consequent: self.right,
  18451. alternative: self.left.right
  18452. }).optimize(compressor);
  18453. }
  18454. break;
  18455. case "||":
  18456. var ll = has_flag(self.left, TRUTHY)
  18457. ? true
  18458. : has_flag(self.left, FALSY)
  18459. ? false
  18460. : self.left.evaluate(compressor);
  18461. if (!ll) {
  18462. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  18463. } else if (!(ll instanceof AST_Node)) {
  18464. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  18465. }
  18466. var rr = self.right.evaluate(compressor);
  18467. if (!rr) {
  18468. var parent = compressor.parent();
  18469. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  18470. return self.left.optimize(compressor);
  18471. }
  18472. } else if (!(rr instanceof AST_Node)) {
  18473. if (compressor.in_boolean_context()) {
  18474. return make_sequence(self, [
  18475. self.left,
  18476. make_node(AST_True, self)
  18477. ]).optimize(compressor);
  18478. } else {
  18479. set_flag(self, TRUTHY);
  18480. }
  18481. }
  18482. if (self.left.operator == "&&") {
  18483. var lr = self.left.right.evaluate(compressor);
  18484. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  18485. condition: self.left.left,
  18486. consequent: self.left.right,
  18487. alternative: self.right
  18488. }).optimize(compressor);
  18489. }
  18490. break;
  18491. case "??":
  18492. if (is_nullish(self.left, compressor)) {
  18493. return self.right;
  18494. }
  18495. var ll = self.left.evaluate(compressor);
  18496. if (!(ll instanceof AST_Node)) {
  18497. // if we know the value for sure we can simply compute right away.
  18498. return ll == null ? self.right : self.left;
  18499. }
  18500. if (compressor.in_boolean_context()) {
  18501. const rr = self.right.evaluate(compressor);
  18502. if (!(rr instanceof AST_Node) && !rr) {
  18503. return self.left;
  18504. }
  18505. }
  18506. }
  18507. var associative = true;
  18508. switch (self.operator) {
  18509. case "+":
  18510. // (x + "foo") + "bar" => x + "foobar"
  18511. if (self.right instanceof AST_Constant
  18512. && self.left instanceof AST_Binary
  18513. && self.left.operator == "+"
  18514. && self.left.is_string(compressor)) {
  18515. var binary = make_node(AST_Binary, self, {
  18516. operator: "+",
  18517. left: self.left.right,
  18518. right: self.right,
  18519. });
  18520. var r = binary.optimize(compressor);
  18521. if (binary !== r) {
  18522. self = make_node(AST_Binary, self, {
  18523. operator: "+",
  18524. left: self.left.left,
  18525. right: r
  18526. });
  18527. }
  18528. }
  18529. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  18530. if (self.left instanceof AST_Binary
  18531. && self.left.operator == "+"
  18532. && self.left.is_string(compressor)
  18533. && self.right instanceof AST_Binary
  18534. && self.right.operator == "+"
  18535. && self.right.is_string(compressor)) {
  18536. var binary = make_node(AST_Binary, self, {
  18537. operator: "+",
  18538. left: self.left.right,
  18539. right: self.right.left,
  18540. });
  18541. var m = binary.optimize(compressor);
  18542. if (binary !== m) {
  18543. self = make_node(AST_Binary, self, {
  18544. operator: "+",
  18545. left: make_node(AST_Binary, self.left, {
  18546. operator: "+",
  18547. left: self.left.left,
  18548. right: m
  18549. }),
  18550. right: self.right.right
  18551. });
  18552. }
  18553. }
  18554. // a + -b => a - b
  18555. if (self.right instanceof AST_UnaryPrefix
  18556. && self.right.operator == "-"
  18557. && self.left.is_number(compressor)) {
  18558. self = make_node(AST_Binary, self, {
  18559. operator: "-",
  18560. left: self.left,
  18561. right: self.right.expression
  18562. });
  18563. break;
  18564. }
  18565. // -a + b => b - a
  18566. if (self.left instanceof AST_UnaryPrefix
  18567. && self.left.operator == "-"
  18568. && reversible()
  18569. && self.right.is_number(compressor)) {
  18570. self = make_node(AST_Binary, self, {
  18571. operator: "-",
  18572. left: self.right,
  18573. right: self.left.expression
  18574. });
  18575. break;
  18576. }
  18577. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  18578. if (self.left instanceof AST_TemplateString) {
  18579. var l = self.left;
  18580. var r = self.right.evaluate(compressor);
  18581. if (r != self.right) {
  18582. l.segments[l.segments.length - 1].value += String(r);
  18583. return l;
  18584. }
  18585. }
  18586. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  18587. if (self.right instanceof AST_TemplateString) {
  18588. var r = self.right;
  18589. var l = self.left.evaluate(compressor);
  18590. if (l != self.left) {
  18591. r.segments[0].value = String(l) + r.segments[0].value;
  18592. return r;
  18593. }
  18594. }
  18595. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  18596. if (self.left instanceof AST_TemplateString
  18597. && self.right instanceof AST_TemplateString) {
  18598. var l = self.left;
  18599. var segments = l.segments;
  18600. var r = self.right;
  18601. segments[segments.length - 1].value += r.segments[0].value;
  18602. for (var i = 1; i < r.segments.length; i++) {
  18603. segments.push(r.segments[i]);
  18604. }
  18605. return l;
  18606. }
  18607. case "*":
  18608. associative = compressor.option("unsafe_math");
  18609. case "&":
  18610. case "|":
  18611. case "^":
  18612. // a + +b => +b + a
  18613. if (self.left.is_number(compressor)
  18614. && self.right.is_number(compressor)
  18615. && reversible()
  18616. && !(self.left instanceof AST_Binary
  18617. && self.left.operator != self.operator
  18618. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  18619. var reversed = make_node(AST_Binary, self, {
  18620. operator: self.operator,
  18621. left: self.right,
  18622. right: self.left
  18623. });
  18624. if (self.right instanceof AST_Constant
  18625. && !(self.left instanceof AST_Constant)) {
  18626. self = best_of(compressor, reversed, self);
  18627. } else {
  18628. self = best_of(compressor, self, reversed);
  18629. }
  18630. }
  18631. if (associative && self.is_number(compressor)) {
  18632. // a + (b + c) => (a + b) + c
  18633. if (self.right instanceof AST_Binary
  18634. && self.right.operator == self.operator) {
  18635. self = make_node(AST_Binary, self, {
  18636. operator: self.operator,
  18637. left: make_node(AST_Binary, self.left, {
  18638. operator: self.operator,
  18639. left: self.left,
  18640. right: self.right.left,
  18641. start: self.left.start,
  18642. end: self.right.left.end
  18643. }),
  18644. right: self.right.right
  18645. });
  18646. }
  18647. // (n + 2) + 3 => 5 + n
  18648. // (2 * n) * 3 => 6 + n
  18649. if (self.right instanceof AST_Constant
  18650. && self.left instanceof AST_Binary
  18651. && self.left.operator == self.operator) {
  18652. if (self.left.left instanceof AST_Constant) {
  18653. self = make_node(AST_Binary, self, {
  18654. operator: self.operator,
  18655. left: make_node(AST_Binary, self.left, {
  18656. operator: self.operator,
  18657. left: self.left.left,
  18658. right: self.right,
  18659. start: self.left.left.start,
  18660. end: self.right.end
  18661. }),
  18662. right: self.left.right
  18663. });
  18664. } else if (self.left.right instanceof AST_Constant) {
  18665. self = make_node(AST_Binary, self, {
  18666. operator: self.operator,
  18667. left: make_node(AST_Binary, self.left, {
  18668. operator: self.operator,
  18669. left: self.left.right,
  18670. right: self.right,
  18671. start: self.left.right.start,
  18672. end: self.right.end
  18673. }),
  18674. right: self.left.left
  18675. });
  18676. }
  18677. }
  18678. // (a | 1) | (2 | d) => (3 | a) | b
  18679. if (self.left instanceof AST_Binary
  18680. && self.left.operator == self.operator
  18681. && self.left.right instanceof AST_Constant
  18682. && self.right instanceof AST_Binary
  18683. && self.right.operator == self.operator
  18684. && self.right.left instanceof AST_Constant) {
  18685. self = make_node(AST_Binary, self, {
  18686. operator: self.operator,
  18687. left: make_node(AST_Binary, self.left, {
  18688. operator: self.operator,
  18689. left: make_node(AST_Binary, self.left.left, {
  18690. operator: self.operator,
  18691. left: self.left.right,
  18692. right: self.right.left,
  18693. start: self.left.right.start,
  18694. end: self.right.left.end
  18695. }),
  18696. right: self.left.left
  18697. }),
  18698. right: self.right.right
  18699. });
  18700. }
  18701. }
  18702. }
  18703. }
  18704. // x && (y && z) ==> x && y && z
  18705. // x || (y || z) ==> x || y || z
  18706. // x + ("y" + z) ==> x + "y" + z
  18707. // "x" + (y + "z")==> "x" + y + "z"
  18708. if (self.right instanceof AST_Binary
  18709. && self.right.operator == self.operator
  18710. && (lazy_op.has(self.operator)
  18711. || (self.operator == "+"
  18712. && (self.right.left.is_string(compressor)
  18713. || (self.left.is_string(compressor)
  18714. && self.right.right.is_string(compressor)))))
  18715. ) {
  18716. self.left = make_node(AST_Binary, self.left, {
  18717. operator : self.operator,
  18718. left : self.left.transform(compressor),
  18719. right : self.right.left.transform(compressor)
  18720. });
  18721. self.right = self.right.right.transform(compressor);
  18722. return self.transform(compressor);
  18723. }
  18724. var ev = self.evaluate(compressor);
  18725. if (ev !== self) {
  18726. ev = make_node_from_constant(ev, self).optimize(compressor);
  18727. return best_of(compressor, ev, self);
  18728. }
  18729. return self;
  18730. });
  18731. def_optimize(AST_SymbolExport, function(self) {
  18732. return self;
  18733. });
  18734. def_optimize(AST_SymbolRef, function(self, compressor) {
  18735. if (
  18736. !compressor.option("ie8")
  18737. && is_undeclared_ref(self)
  18738. && !compressor.find_parent(AST_With)
  18739. ) {
  18740. switch (self.name) {
  18741. case "undefined":
  18742. return make_node(AST_Undefined, self).optimize(compressor);
  18743. case "NaN":
  18744. return make_node(AST_NaN, self).optimize(compressor);
  18745. case "Infinity":
  18746. return make_node(AST_Infinity, self).optimize(compressor);
  18747. }
  18748. }
  18749. if (compressor.option("reduce_vars") && !compressor.is_lhs()) {
  18750. return inline_into_symbolref(self, compressor);
  18751. } else {
  18752. return self;
  18753. }
  18754. });
  18755. function is_atomic(lhs, self) {
  18756. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  18757. }
  18758. def_optimize(AST_Undefined, function(self, compressor) {
  18759. if (compressor.option("unsafe_undefined")) {
  18760. var undef = find_variable(compressor, "undefined");
  18761. if (undef) {
  18762. var ref = make_node(AST_SymbolRef, self, {
  18763. name : "undefined",
  18764. scope : undef.scope,
  18765. thedef : undef
  18766. });
  18767. set_flag(ref, UNDEFINED);
  18768. return ref;
  18769. }
  18770. }
  18771. var lhs = compressor.is_lhs();
  18772. if (lhs && is_atomic(lhs, self)) return self;
  18773. return make_node(AST_UnaryPrefix, self, {
  18774. operator: "void",
  18775. expression: make_node(AST_Number, self, {
  18776. value: 0
  18777. })
  18778. });
  18779. });
  18780. def_optimize(AST_Infinity, function(self, compressor) {
  18781. var lhs = compressor.is_lhs();
  18782. if (lhs && is_atomic(lhs, self)) return self;
  18783. if (
  18784. compressor.option("keep_infinity")
  18785. && !(lhs && !is_atomic(lhs, self))
  18786. && !find_variable(compressor, "Infinity")
  18787. ) {
  18788. return self;
  18789. }
  18790. return make_node(AST_Binary, self, {
  18791. operator: "/",
  18792. left: make_node(AST_Number, self, {
  18793. value: 1
  18794. }),
  18795. right: make_node(AST_Number, self, {
  18796. value: 0
  18797. })
  18798. });
  18799. });
  18800. def_optimize(AST_NaN, function(self, compressor) {
  18801. var lhs = compressor.is_lhs();
  18802. if (lhs && !is_atomic(lhs, self)
  18803. || find_variable(compressor, "NaN")) {
  18804. return make_node(AST_Binary, self, {
  18805. operator: "/",
  18806. left: make_node(AST_Number, self, {
  18807. value: 0
  18808. }),
  18809. right: make_node(AST_Number, self, {
  18810. value: 0
  18811. })
  18812. });
  18813. }
  18814. return self;
  18815. });
  18816. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  18817. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  18818. def_optimize(AST_Assign, function(self, compressor) {
  18819. if (self.logical) {
  18820. return self.lift_sequences(compressor);
  18821. }
  18822. var def;
  18823. // x = x ---> x
  18824. if (
  18825. self.operator === "="
  18826. && self.left instanceof AST_SymbolRef
  18827. && self.left.name !== "arguments"
  18828. && !(def = self.left.definition()).undeclared
  18829. && self.right.equivalent_to(self.left)
  18830. ) {
  18831. return self.right;
  18832. }
  18833. if (compressor.option("dead_code")
  18834. && self.left instanceof AST_SymbolRef
  18835. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  18836. var level = 0, node, parent = self;
  18837. do {
  18838. node = parent;
  18839. parent = compressor.parent(level++);
  18840. if (parent instanceof AST_Exit) {
  18841. if (in_try(level, parent)) break;
  18842. if (is_reachable(def.scope, [ def ])) break;
  18843. if (self.operator == "=") return self.right;
  18844. def.fixed = false;
  18845. return make_node(AST_Binary, self, {
  18846. operator: self.operator.slice(0, -1),
  18847. left: self.left,
  18848. right: self.right
  18849. }).optimize(compressor);
  18850. }
  18851. } while (parent instanceof AST_Binary && parent.right === node
  18852. || parent instanceof AST_Sequence && parent.tail_node() === node);
  18853. }
  18854. self = self.lift_sequences(compressor);
  18855. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  18856. // x = expr1 OP expr2
  18857. if (self.right.left instanceof AST_SymbolRef
  18858. && self.right.left.name == self.left.name
  18859. && ASSIGN_OPS.has(self.right.operator)) {
  18860. // x = x - 2 ---> x -= 2
  18861. self.operator = self.right.operator + "=";
  18862. self.right = self.right.right;
  18863. } else if (self.right.right instanceof AST_SymbolRef
  18864. && self.right.right.name == self.left.name
  18865. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  18866. && !self.right.left.has_side_effects(compressor)) {
  18867. // x = 2 & x ---> x &= 2
  18868. self.operator = self.right.operator + "=";
  18869. self.right = self.right.left;
  18870. }
  18871. }
  18872. return self;
  18873. function in_try(level, node) {
  18874. function may_assignment_throw() {
  18875. const right = self.right;
  18876. self.right = make_node(AST_Null, right);
  18877. const may_throw = node.may_throw(compressor);
  18878. self.right = right;
  18879. return may_throw;
  18880. }
  18881. var stop_at = self.left.definition().scope.get_defun_scope();
  18882. var parent;
  18883. while ((parent = compressor.parent(level++)) !== stop_at) {
  18884. if (parent instanceof AST_Try) {
  18885. if (parent.bfinally) return true;
  18886. if (parent.bcatch && may_assignment_throw()) return true;
  18887. }
  18888. }
  18889. }
  18890. });
  18891. def_optimize(AST_DefaultAssign, function(self, compressor) {
  18892. if (!compressor.option("evaluate")) {
  18893. return self;
  18894. }
  18895. var evaluateRight = self.right.evaluate(compressor);
  18896. // `[x = undefined] = foo` ---> `[x] = foo`
  18897. // `(arg = undefined) => ...` ---> `(arg) => ...` (unless `keep_fargs`)
  18898. // `((arg = undefined) => ...)()` ---> `((arg) => ...)()`
  18899. let lambda, iife;
  18900. if (evaluateRight === undefined) {
  18901. if (
  18902. (lambda = compressor.parent()) instanceof AST_Lambda
  18903. ? (
  18904. compressor.option("keep_fargs") === false
  18905. || (iife = compressor.parent(1)).TYPE === "Call"
  18906. && iife.expression === lambda
  18907. )
  18908. : true
  18909. ) {
  18910. self = self.left;
  18911. }
  18912. } else if (evaluateRight !== self.right) {
  18913. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  18914. self.right = best_of_expression(evaluateRight, self.right);
  18915. }
  18916. return self;
  18917. });
  18918. function is_nullish_check(check, check_subject, compressor) {
  18919. if (check_subject.may_throw(compressor)) return false;
  18920. let nullish_side;
  18921. // foo == null
  18922. if (
  18923. check instanceof AST_Binary
  18924. && check.operator === "=="
  18925. // which side is nullish?
  18926. && (
  18927. (nullish_side = is_nullish(check.left, compressor) && check.left)
  18928. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  18929. )
  18930. // is the other side the same as the check_subject
  18931. && (
  18932. nullish_side === check.left
  18933. ? check.right
  18934. : check.left
  18935. ).equivalent_to(check_subject)
  18936. ) {
  18937. return true;
  18938. }
  18939. // foo === null || foo === undefined
  18940. if (check instanceof AST_Binary && check.operator === "||") {
  18941. let null_cmp;
  18942. let undefined_cmp;
  18943. const find_comparison = cmp => {
  18944. if (!(
  18945. cmp instanceof AST_Binary
  18946. && (cmp.operator === "===" || cmp.operator === "==")
  18947. )) {
  18948. return false;
  18949. }
  18950. let found = 0;
  18951. let defined_side;
  18952. if (cmp.left instanceof AST_Null) {
  18953. found++;
  18954. null_cmp = cmp;
  18955. defined_side = cmp.right;
  18956. }
  18957. if (cmp.right instanceof AST_Null) {
  18958. found++;
  18959. null_cmp = cmp;
  18960. defined_side = cmp.left;
  18961. }
  18962. if (is_undefined(cmp.left, compressor)) {
  18963. found++;
  18964. undefined_cmp = cmp;
  18965. defined_side = cmp.right;
  18966. }
  18967. if (is_undefined(cmp.right, compressor)) {
  18968. found++;
  18969. undefined_cmp = cmp;
  18970. defined_side = cmp.left;
  18971. }
  18972. if (found !== 1) {
  18973. return false;
  18974. }
  18975. if (!defined_side.equivalent_to(check_subject)) {
  18976. return false;
  18977. }
  18978. return true;
  18979. };
  18980. if (!find_comparison(check.left)) return false;
  18981. if (!find_comparison(check.right)) return false;
  18982. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  18983. return true;
  18984. }
  18985. }
  18986. return false;
  18987. }
  18988. def_optimize(AST_Conditional, function(self, compressor) {
  18989. if (!compressor.option("conditionals")) return self;
  18990. // This looks like lift_sequences(), should probably be under "sequences"
  18991. if (self.condition instanceof AST_Sequence) {
  18992. var expressions = self.condition.expressions.slice();
  18993. self.condition = expressions.pop();
  18994. expressions.push(self);
  18995. return make_sequence(self, expressions);
  18996. }
  18997. var cond = self.condition.evaluate(compressor);
  18998. if (cond !== self.condition) {
  18999. if (cond) {
  19000. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  19001. } else {
  19002. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  19003. }
  19004. }
  19005. var negated = cond.negate(compressor, first_in_statement(compressor));
  19006. if (best_of(compressor, cond, negated) === negated) {
  19007. self = make_node(AST_Conditional, self, {
  19008. condition: negated,
  19009. consequent: self.alternative,
  19010. alternative: self.consequent
  19011. });
  19012. }
  19013. var condition = self.condition;
  19014. var consequent = self.consequent;
  19015. var alternative = self.alternative;
  19016. // x?x:y --> x||y
  19017. if (condition instanceof AST_SymbolRef
  19018. && consequent instanceof AST_SymbolRef
  19019. && condition.definition() === consequent.definition()) {
  19020. return make_node(AST_Binary, self, {
  19021. operator: "||",
  19022. left: condition,
  19023. right: alternative
  19024. });
  19025. }
  19026. // if (foo) exp = something; else exp = something_else;
  19027. // |
  19028. // v
  19029. // exp = foo ? something : something_else;
  19030. if (
  19031. consequent instanceof AST_Assign
  19032. && alternative instanceof AST_Assign
  19033. && consequent.operator === alternative.operator
  19034. && consequent.logical === alternative.logical
  19035. && consequent.left.equivalent_to(alternative.left)
  19036. && (!self.condition.has_side_effects(compressor)
  19037. || consequent.operator == "="
  19038. && !consequent.left.has_side_effects(compressor))
  19039. ) {
  19040. return make_node(AST_Assign, self, {
  19041. operator: consequent.operator,
  19042. left: consequent.left,
  19043. logical: consequent.logical,
  19044. right: make_node(AST_Conditional, self, {
  19045. condition: self.condition,
  19046. consequent: consequent.right,
  19047. alternative: alternative.right
  19048. })
  19049. });
  19050. }
  19051. // x ? y(a) : y(b) --> y(x ? a : b)
  19052. var arg_index;
  19053. if (consequent instanceof AST_Call
  19054. && alternative.TYPE === consequent.TYPE
  19055. && consequent.args.length > 0
  19056. && consequent.args.length == alternative.args.length
  19057. && consequent.expression.equivalent_to(alternative.expression)
  19058. && !self.condition.has_side_effects(compressor)
  19059. && !consequent.expression.has_side_effects(compressor)
  19060. && typeof (arg_index = single_arg_diff()) == "number") {
  19061. var node = consequent.clone();
  19062. node.args[arg_index] = make_node(AST_Conditional, self, {
  19063. condition: self.condition,
  19064. consequent: consequent.args[arg_index],
  19065. alternative: alternative.args[arg_index]
  19066. });
  19067. return node;
  19068. }
  19069. // a ? b : c ? b : d --> (a || c) ? b : d
  19070. if (alternative instanceof AST_Conditional
  19071. && consequent.equivalent_to(alternative.consequent)) {
  19072. return make_node(AST_Conditional, self, {
  19073. condition: make_node(AST_Binary, self, {
  19074. operator: "||",
  19075. left: condition,
  19076. right: alternative.condition
  19077. }),
  19078. consequent: consequent,
  19079. alternative: alternative.alternative
  19080. }).optimize(compressor);
  19081. }
  19082. // a == null ? b : a -> a ?? b
  19083. if (
  19084. compressor.option("ecma") >= 2020 &&
  19085. is_nullish_check(condition, alternative, compressor)
  19086. ) {
  19087. return make_node(AST_Binary, self, {
  19088. operator: "??",
  19089. left: alternative,
  19090. right: consequent
  19091. }).optimize(compressor);
  19092. }
  19093. // a ? b : (c, b) --> (a || c), b
  19094. if (alternative instanceof AST_Sequence
  19095. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  19096. return make_sequence(self, [
  19097. make_node(AST_Binary, self, {
  19098. operator: "||",
  19099. left: condition,
  19100. right: make_sequence(self, alternative.expressions.slice(0, -1))
  19101. }),
  19102. consequent
  19103. ]).optimize(compressor);
  19104. }
  19105. // a ? b : (c && b) --> (a || c) && b
  19106. if (alternative instanceof AST_Binary
  19107. && alternative.operator == "&&"
  19108. && consequent.equivalent_to(alternative.right)) {
  19109. return make_node(AST_Binary, self, {
  19110. operator: "&&",
  19111. left: make_node(AST_Binary, self, {
  19112. operator: "||",
  19113. left: condition,
  19114. right: alternative.left
  19115. }),
  19116. right: consequent
  19117. }).optimize(compressor);
  19118. }
  19119. // x?y?z:a:a --> x&&y?z:a
  19120. if (consequent instanceof AST_Conditional
  19121. && consequent.alternative.equivalent_to(alternative)) {
  19122. return make_node(AST_Conditional, self, {
  19123. condition: make_node(AST_Binary, self, {
  19124. left: self.condition,
  19125. operator: "&&",
  19126. right: consequent.condition
  19127. }),
  19128. consequent: consequent.consequent,
  19129. alternative: alternative
  19130. });
  19131. }
  19132. // x ? y : y --> x, y
  19133. if (consequent.equivalent_to(alternative)) {
  19134. return make_sequence(self, [
  19135. self.condition,
  19136. consequent
  19137. ]).optimize(compressor);
  19138. }
  19139. // x ? y || z : z --> x && y || z
  19140. if (consequent instanceof AST_Binary
  19141. && consequent.operator == "||"
  19142. && consequent.right.equivalent_to(alternative)) {
  19143. return make_node(AST_Binary, self, {
  19144. operator: "||",
  19145. left: make_node(AST_Binary, self, {
  19146. operator: "&&",
  19147. left: self.condition,
  19148. right: consequent.left
  19149. }),
  19150. right: alternative
  19151. }).optimize(compressor);
  19152. }
  19153. const in_bool = compressor.in_boolean_context();
  19154. if (is_true(self.consequent)) {
  19155. if (is_false(self.alternative)) {
  19156. // c ? true : false ---> !!c
  19157. return booleanize(self.condition);
  19158. }
  19159. // c ? true : x ---> !!c || x
  19160. return make_node(AST_Binary, self, {
  19161. operator: "||",
  19162. left: booleanize(self.condition),
  19163. right: self.alternative
  19164. });
  19165. }
  19166. if (is_false(self.consequent)) {
  19167. if (is_true(self.alternative)) {
  19168. // c ? false : true ---> !c
  19169. return booleanize(self.condition.negate(compressor));
  19170. }
  19171. // c ? false : x ---> !c && x
  19172. return make_node(AST_Binary, self, {
  19173. operator: "&&",
  19174. left: booleanize(self.condition.negate(compressor)),
  19175. right: self.alternative
  19176. });
  19177. }
  19178. if (is_true(self.alternative)) {
  19179. // c ? x : true ---> !c || x
  19180. return make_node(AST_Binary, self, {
  19181. operator: "||",
  19182. left: booleanize(self.condition.negate(compressor)),
  19183. right: self.consequent
  19184. });
  19185. }
  19186. if (is_false(self.alternative)) {
  19187. // c ? x : false ---> !!c && x
  19188. return make_node(AST_Binary, self, {
  19189. operator: "&&",
  19190. left: booleanize(self.condition),
  19191. right: self.consequent
  19192. });
  19193. }
  19194. return self;
  19195. function booleanize(node) {
  19196. if (node.is_boolean()) return node;
  19197. // !!expression
  19198. return make_node(AST_UnaryPrefix, node, {
  19199. operator: "!",
  19200. expression: node.negate(compressor)
  19201. });
  19202. }
  19203. // AST_True or !0
  19204. function is_true(node) {
  19205. return node instanceof AST_True
  19206. || in_bool
  19207. && node instanceof AST_Constant
  19208. && node.getValue()
  19209. || (node instanceof AST_UnaryPrefix
  19210. && node.operator == "!"
  19211. && node.expression instanceof AST_Constant
  19212. && !node.expression.getValue());
  19213. }
  19214. // AST_False or !1
  19215. function is_false(node) {
  19216. return node instanceof AST_False
  19217. || in_bool
  19218. && node instanceof AST_Constant
  19219. && !node.getValue()
  19220. || (node instanceof AST_UnaryPrefix
  19221. && node.operator == "!"
  19222. && node.expression instanceof AST_Constant
  19223. && node.expression.getValue());
  19224. }
  19225. function single_arg_diff() {
  19226. var a = consequent.args;
  19227. var b = alternative.args;
  19228. for (var i = 0, len = a.length; i < len; i++) {
  19229. if (a[i] instanceof AST_Expansion) return;
  19230. if (!a[i].equivalent_to(b[i])) {
  19231. if (b[i] instanceof AST_Expansion) return;
  19232. for (var j = i + 1; j < len; j++) {
  19233. if (a[j] instanceof AST_Expansion) return;
  19234. if (!a[j].equivalent_to(b[j])) return;
  19235. }
  19236. return i;
  19237. }
  19238. }
  19239. }
  19240. });
  19241. def_optimize(AST_Boolean, function(self, compressor) {
  19242. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  19243. value: +self.value
  19244. });
  19245. var p = compressor.parent();
  19246. if (compressor.option("booleans_as_integers")) {
  19247. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  19248. p.operator = p.operator.replace(/=$/, "");
  19249. }
  19250. return make_node(AST_Number, self, {
  19251. value: +self.value
  19252. });
  19253. }
  19254. if (compressor.option("booleans")) {
  19255. if (p instanceof AST_Binary && (p.operator == "=="
  19256. || p.operator == "!=")) {
  19257. return make_node(AST_Number, self, {
  19258. value: +self.value
  19259. });
  19260. }
  19261. return make_node(AST_UnaryPrefix, self, {
  19262. operator: "!",
  19263. expression: make_node(AST_Number, self, {
  19264. value: 1 - self.value
  19265. })
  19266. });
  19267. }
  19268. return self;
  19269. });
  19270. function safe_to_flatten(value, compressor) {
  19271. if (value instanceof AST_SymbolRef) {
  19272. value = value.fixed_value();
  19273. }
  19274. if (!value) return false;
  19275. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  19276. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  19277. return compressor.parent() instanceof AST_New;
  19278. }
  19279. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  19280. if (!compressor.option("properties")) return;
  19281. if (key === "__proto__") return;
  19282. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  19283. var expr = this.expression;
  19284. if (expr instanceof AST_Object) {
  19285. var props = expr.properties;
  19286. for (var i = props.length; --i >= 0;) {
  19287. var prop = props[i];
  19288. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  19289. const all_props_flattenable = props.every((p) =>
  19290. (p instanceof AST_ObjectKeyVal
  19291. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  19292. )
  19293. && !p.computed_key()
  19294. );
  19295. if (!all_props_flattenable) return;
  19296. if (!safe_to_flatten(prop.value, compressor)) return;
  19297. return make_node(AST_Sub, this, {
  19298. expression: make_node(AST_Array, expr, {
  19299. elements: props.map(function(prop) {
  19300. var v = prop.value;
  19301. if (v instanceof AST_Accessor) {
  19302. v = make_node(AST_Function, v, v);
  19303. }
  19304. var k = prop.key;
  19305. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  19306. return make_sequence(prop, [ k, v ]);
  19307. }
  19308. return v;
  19309. })
  19310. }),
  19311. property: make_node(AST_Number, this, {
  19312. value: i
  19313. })
  19314. });
  19315. }
  19316. }
  19317. }
  19318. });
  19319. def_optimize(AST_Sub, function(self, compressor) {
  19320. var expr = self.expression;
  19321. var prop = self.property;
  19322. if (compressor.option("properties")) {
  19323. var key = prop.evaluate(compressor);
  19324. if (key !== prop) {
  19325. if (typeof key == "string") {
  19326. if (key == "undefined") {
  19327. key = undefined;
  19328. } else {
  19329. var value = parseFloat(key);
  19330. if (value.toString() == key) {
  19331. key = value;
  19332. }
  19333. }
  19334. }
  19335. prop = self.property = best_of_expression(
  19336. prop,
  19337. make_node_from_constant(key, prop).transform(compressor)
  19338. );
  19339. var property = "" + key;
  19340. if (is_basic_identifier_string(property)
  19341. && property.length <= prop.size() + 1) {
  19342. return make_node(AST_Dot, self, {
  19343. expression: expr,
  19344. optional: self.optional,
  19345. property: property,
  19346. quote: prop.quote,
  19347. }).optimize(compressor);
  19348. }
  19349. }
  19350. }
  19351. var fn;
  19352. OPT_ARGUMENTS: if (compressor.option("arguments")
  19353. && expr instanceof AST_SymbolRef
  19354. && expr.name == "arguments"
  19355. && expr.definition().orig.length == 1
  19356. && (fn = expr.scope) instanceof AST_Lambda
  19357. && fn.uses_arguments
  19358. && !(fn instanceof AST_Arrow)
  19359. && prop instanceof AST_Number) {
  19360. var index = prop.getValue();
  19361. var params = new Set();
  19362. var argnames = fn.argnames;
  19363. for (var n = 0; n < argnames.length; n++) {
  19364. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  19365. break OPT_ARGUMENTS; // destructuring parameter - bail
  19366. }
  19367. var param = argnames[n].name;
  19368. if (params.has(param)) {
  19369. break OPT_ARGUMENTS; // duplicate parameter - bail
  19370. }
  19371. params.add(param);
  19372. }
  19373. var argname = fn.argnames[index];
  19374. if (argname && compressor.has_directive("use strict")) {
  19375. var def = argname.definition();
  19376. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  19377. argname = null;
  19378. }
  19379. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  19380. while (index >= fn.argnames.length) {
  19381. argname = fn.create_symbol(AST_SymbolFunarg, {
  19382. source: fn,
  19383. scope: fn,
  19384. tentative_name: "argument_" + fn.argnames.length,
  19385. });
  19386. fn.argnames.push(argname);
  19387. }
  19388. }
  19389. if (argname) {
  19390. var sym = make_node(AST_SymbolRef, self, argname);
  19391. sym.reference({});
  19392. clear_flag(argname, UNUSED);
  19393. return sym;
  19394. }
  19395. }
  19396. if (compressor.is_lhs()) return self;
  19397. if (key !== prop) {
  19398. var sub = self.flatten_object(property, compressor);
  19399. if (sub) {
  19400. expr = self.expression = sub.expression;
  19401. prop = self.property = sub.property;
  19402. }
  19403. }
  19404. if (compressor.option("properties") && compressor.option("side_effects")
  19405. && prop instanceof AST_Number && expr instanceof AST_Array) {
  19406. var index = prop.getValue();
  19407. var elements = expr.elements;
  19408. var retValue = elements[index];
  19409. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  19410. var flatten = true;
  19411. var values = [];
  19412. for (var i = elements.length; --i > index;) {
  19413. var value = elements[i].drop_side_effect_free(compressor);
  19414. if (value) {
  19415. values.unshift(value);
  19416. if (flatten && value.has_side_effects(compressor)) flatten = false;
  19417. }
  19418. }
  19419. if (retValue instanceof AST_Expansion) break FLATTEN;
  19420. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  19421. if (!flatten) values.unshift(retValue);
  19422. while (--i >= 0) {
  19423. var value = elements[i];
  19424. if (value instanceof AST_Expansion) break FLATTEN;
  19425. value = value.drop_side_effect_free(compressor);
  19426. if (value) values.unshift(value);
  19427. else index--;
  19428. }
  19429. if (flatten) {
  19430. values.push(retValue);
  19431. return make_sequence(self, values).optimize(compressor);
  19432. } else return make_node(AST_Sub, self, {
  19433. expression: make_node(AST_Array, expr, {
  19434. elements: values
  19435. }),
  19436. property: make_node(AST_Number, prop, {
  19437. value: index
  19438. })
  19439. });
  19440. }
  19441. }
  19442. var ev = self.evaluate(compressor);
  19443. if (ev !== self) {
  19444. ev = make_node_from_constant(ev, self).optimize(compressor);
  19445. return best_of(compressor, ev, self);
  19446. }
  19447. return self;
  19448. });
  19449. def_optimize(AST_Chain, function (self, compressor) {
  19450. if (is_nullish(self.expression, compressor)) {
  19451. let parent = compressor.parent();
  19452. // It's valid to delete a nullish optional chain, but if we optimized
  19453. // this to `delete undefined` then it would appear to be a syntax error
  19454. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  19455. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  19456. return make_node_from_constant(0, self);
  19457. }
  19458. return make_node(AST_Undefined, self);
  19459. }
  19460. return self;
  19461. });
  19462. def_optimize(AST_Dot, function(self, compressor) {
  19463. const parent = compressor.parent();
  19464. if (compressor.is_lhs()) return self;
  19465. if (compressor.option("unsafe_proto")
  19466. && self.expression instanceof AST_Dot
  19467. && self.expression.property == "prototype") {
  19468. var exp = self.expression.expression;
  19469. if (is_undeclared_ref(exp)) switch (exp.name) {
  19470. case "Array":
  19471. self.expression = make_node(AST_Array, self.expression, {
  19472. elements: []
  19473. });
  19474. break;
  19475. case "Function":
  19476. self.expression = make_node(AST_Function, self.expression, {
  19477. argnames: [],
  19478. body: []
  19479. });
  19480. break;
  19481. case "Number":
  19482. self.expression = make_node(AST_Number, self.expression, {
  19483. value: 0
  19484. });
  19485. break;
  19486. case "Object":
  19487. self.expression = make_node(AST_Object, self.expression, {
  19488. properties: []
  19489. });
  19490. break;
  19491. case "RegExp":
  19492. self.expression = make_node(AST_RegExp, self.expression, {
  19493. value: { source: "t", flags: "" }
  19494. });
  19495. break;
  19496. case "String":
  19497. self.expression = make_node(AST_String, self.expression, {
  19498. value: ""
  19499. });
  19500. break;
  19501. }
  19502. }
  19503. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  19504. const sub = self.flatten_object(self.property, compressor);
  19505. if (sub) return sub.optimize(compressor);
  19506. }
  19507. if (self.expression instanceof AST_PropAccess
  19508. && parent instanceof AST_PropAccess) {
  19509. return self;
  19510. }
  19511. let ev = self.evaluate(compressor);
  19512. if (ev !== self) {
  19513. ev = make_node_from_constant(ev, self).optimize(compressor);
  19514. return best_of(compressor, ev, self);
  19515. }
  19516. return self;
  19517. });
  19518. function literals_in_boolean_context(self, compressor) {
  19519. if (compressor.in_boolean_context()) {
  19520. return best_of(compressor, self, make_sequence(self, [
  19521. self,
  19522. make_node(AST_True, self)
  19523. ]).optimize(compressor));
  19524. }
  19525. return self;
  19526. }
  19527. function inline_array_like_spread(elements) {
  19528. for (var i = 0; i < elements.length; i++) {
  19529. var el = elements[i];
  19530. if (el instanceof AST_Expansion) {
  19531. var expr = el.expression;
  19532. if (
  19533. expr instanceof AST_Array
  19534. && !expr.elements.some(elm => elm instanceof AST_Hole)
  19535. ) {
  19536. elements.splice(i, 1, ...expr.elements);
  19537. // Step back one, as the element at i is now new.
  19538. i--;
  19539. }
  19540. // In array-like spread, spreading a non-iterable value is TypeError.
  19541. // We therefore can’t optimize anything else, unlike with object spread.
  19542. }
  19543. }
  19544. }
  19545. def_optimize(AST_Array, function(self, compressor) {
  19546. var optimized = literals_in_boolean_context(self, compressor);
  19547. if (optimized !== self) {
  19548. return optimized;
  19549. }
  19550. inline_array_like_spread(self.elements);
  19551. return self;
  19552. });
  19553. function inline_object_prop_spread(props, compressor) {
  19554. for (var i = 0; i < props.length; i++) {
  19555. var prop = props[i];
  19556. if (prop instanceof AST_Expansion) {
  19557. const expr = prop.expression;
  19558. if (
  19559. expr instanceof AST_Object
  19560. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  19561. ) {
  19562. props.splice(i, 1, ...expr.properties);
  19563. // Step back one, as the property at i is now new.
  19564. i--;
  19565. } else if (expr instanceof AST_Constant
  19566. && !(expr instanceof AST_String)) {
  19567. // Unlike array-like spread, in object spread, spreading a
  19568. // non-iterable value silently does nothing; it is thus safe
  19569. // to remove. AST_String is the only iterable AST_Constant.
  19570. props.splice(i, 1);
  19571. i--;
  19572. } else if (is_nullish(expr, compressor)) {
  19573. // Likewise, null and undefined can be silently removed.
  19574. props.splice(i, 1);
  19575. i--;
  19576. }
  19577. }
  19578. }
  19579. }
  19580. def_optimize(AST_Object, function(self, compressor) {
  19581. var optimized = literals_in_boolean_context(self, compressor);
  19582. if (optimized !== self) {
  19583. return optimized;
  19584. }
  19585. inline_object_prop_spread(self.properties, compressor);
  19586. return self;
  19587. });
  19588. def_optimize(AST_RegExp, literals_in_boolean_context);
  19589. def_optimize(AST_Return, function(self, compressor) {
  19590. if (self.value && is_undefined(self.value, compressor)) {
  19591. self.value = null;
  19592. }
  19593. return self;
  19594. });
  19595. def_optimize(AST_Arrow, opt_AST_Lambda);
  19596. def_optimize(AST_Function, function(self, compressor) {
  19597. self = opt_AST_Lambda(self, compressor);
  19598. if (compressor.option("unsafe_arrows")
  19599. && compressor.option("ecma") >= 2015
  19600. && !self.name
  19601. && !self.is_generator
  19602. && !self.uses_arguments
  19603. && !self.pinned()) {
  19604. const uses_this = walk(self, node => {
  19605. if (node instanceof AST_This) return walk_abort;
  19606. });
  19607. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  19608. }
  19609. return self;
  19610. });
  19611. def_optimize(AST_Class, function(self) {
  19612. // HACK to avoid compress failure.
  19613. // AST_Class is not really an AST_Scope/AST_Block as it lacks a body.
  19614. return self;
  19615. });
  19616. def_optimize(AST_ClassStaticBlock, function(self, compressor) {
  19617. tighten_body(self.body, compressor);
  19618. return self;
  19619. });
  19620. def_optimize(AST_Yield, function(self, compressor) {
  19621. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  19622. self.expression = null;
  19623. }
  19624. return self;
  19625. });
  19626. def_optimize(AST_TemplateString, function(self, compressor) {
  19627. if (
  19628. !compressor.option("evaluate")
  19629. || compressor.parent() instanceof AST_PrefixedTemplateString
  19630. ) {
  19631. return self;
  19632. }
  19633. var segments = [];
  19634. for (var i = 0; i < self.segments.length; i++) {
  19635. var segment = self.segments[i];
  19636. if (segment instanceof AST_Node) {
  19637. var result = segment.evaluate(compressor);
  19638. // Evaluate to constant value
  19639. // Constant value shorter than ${segment}
  19640. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  19641. // There should always be a previous and next segment if segment is a node
  19642. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  19643. continue;
  19644. }
  19645. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  19646. // TODO:
  19647. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  19648. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  19649. if (segment instanceof AST_TemplateString) {
  19650. var inners = segment.segments;
  19651. segments[segments.length - 1].value += inners[0].value;
  19652. for (var j = 1; j < inners.length; j++) {
  19653. segment = inners[j];
  19654. segments.push(segment);
  19655. }
  19656. continue;
  19657. }
  19658. }
  19659. segments.push(segment);
  19660. }
  19661. self.segments = segments;
  19662. // `foo` => "foo"
  19663. if (segments.length == 1) {
  19664. return make_node(AST_String, self, segments[0]);
  19665. }
  19666. if (
  19667. segments.length === 3
  19668. && segments[1] instanceof AST_Node
  19669. && (
  19670. segments[1].is_string(compressor)
  19671. || segments[1].is_number(compressor)
  19672. || is_nullish(segments[1], compressor)
  19673. || compressor.option("unsafe")
  19674. )
  19675. ) {
  19676. // `foo${bar}` => "foo" + bar
  19677. if (segments[2].value === "") {
  19678. return make_node(AST_Binary, self, {
  19679. operator: "+",
  19680. left: make_node(AST_String, self, {
  19681. value: segments[0].value,
  19682. }),
  19683. right: segments[1],
  19684. });
  19685. }
  19686. // `${bar}baz` => bar + "baz"
  19687. if (segments[0].value === "") {
  19688. return make_node(AST_Binary, self, {
  19689. operator: "+",
  19690. left: segments[1],
  19691. right: make_node(AST_String, self, {
  19692. value: segments[2].value,
  19693. }),
  19694. });
  19695. }
  19696. }
  19697. return self;
  19698. });
  19699. def_optimize(AST_PrefixedTemplateString, function(self) {
  19700. return self;
  19701. });
  19702. // ["p"]:1 ---> p:1
  19703. // [42]:1 ---> 42:1
  19704. function lift_key(self, compressor) {
  19705. if (!compressor.option("computed_props")) return self;
  19706. // save a comparison in the typical case
  19707. if (!(self.key instanceof AST_Constant)) return self;
  19708. // allow certain acceptable props as not all AST_Constants are true constants
  19709. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  19710. if (self.key.value === "__proto__") return self;
  19711. if (self.key.value == "constructor"
  19712. && compressor.parent() instanceof AST_Class) return self;
  19713. if (self instanceof AST_ObjectKeyVal) {
  19714. self.quote = self.key.quote;
  19715. self.key = self.key.value;
  19716. } else if (self instanceof AST_ClassProperty) {
  19717. self.quote = self.key.quote;
  19718. self.key = make_node(AST_SymbolClassProperty, self.key, {
  19719. name: self.key.value
  19720. });
  19721. } else {
  19722. self.quote = self.key.quote;
  19723. self.key = make_node(AST_SymbolMethod, self.key, {
  19724. name: self.key.value
  19725. });
  19726. }
  19727. }
  19728. return self;
  19729. }
  19730. def_optimize(AST_ObjectProperty, lift_key);
  19731. def_optimize(AST_ConciseMethod, function(self, compressor) {
  19732. lift_key(self, compressor);
  19733. // p(){return x;} ---> p:()=>x
  19734. if (compressor.option("arrows")
  19735. && compressor.parent() instanceof AST_Object
  19736. && !self.is_generator
  19737. && !self.value.uses_arguments
  19738. && !self.value.pinned()
  19739. && self.value.body.length == 1
  19740. && self.value.body[0] instanceof AST_Return
  19741. && self.value.body[0].value
  19742. && !self.value.contains_this()) {
  19743. var arrow = make_node(AST_Arrow, self.value, self.value);
  19744. arrow.async = self.async;
  19745. arrow.is_generator = self.is_generator;
  19746. return make_node(AST_ObjectKeyVal, self, {
  19747. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  19748. value: arrow,
  19749. quote: self.quote,
  19750. });
  19751. }
  19752. return self;
  19753. });
  19754. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  19755. lift_key(self, compressor);
  19756. // p:function(){} ---> p(){}
  19757. // p:function*(){} ---> *p(){}
  19758. // p:async function(){} ---> async p(){}
  19759. // p:()=>{} ---> p(){}
  19760. // p:async()=>{} ---> async p(){}
  19761. var unsafe_methods = compressor.option("unsafe_methods");
  19762. if (unsafe_methods
  19763. && compressor.option("ecma") >= 2015
  19764. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  19765. var key = self.key;
  19766. var value = self.value;
  19767. var is_arrow_with_block = value instanceof AST_Arrow
  19768. && Array.isArray(value.body)
  19769. && !value.contains_this();
  19770. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  19771. return make_node(AST_ConciseMethod, self, {
  19772. async: value.async,
  19773. is_generator: value.is_generator,
  19774. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  19775. name: key,
  19776. }),
  19777. value: make_node(AST_Accessor, value, value),
  19778. quote: self.quote,
  19779. });
  19780. }
  19781. }
  19782. return self;
  19783. });
  19784. def_optimize(AST_Destructuring, function(self, compressor) {
  19785. if (compressor.option("pure_getters") == true
  19786. && compressor.option("unused")
  19787. && !self.is_array
  19788. && Array.isArray(self.names)
  19789. && !is_destructuring_export_decl(compressor)
  19790. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  19791. var keep = [];
  19792. for (var i = 0; i < self.names.length; i++) {
  19793. var elem = self.names[i];
  19794. if (!(elem instanceof AST_ObjectKeyVal
  19795. && typeof elem.key == "string"
  19796. && elem.value instanceof AST_SymbolDeclaration
  19797. && !should_retain(compressor, elem.value.definition()))) {
  19798. keep.push(elem);
  19799. }
  19800. }
  19801. if (keep.length != self.names.length) {
  19802. self.names = keep;
  19803. }
  19804. }
  19805. return self;
  19806. function is_destructuring_export_decl(compressor) {
  19807. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  19808. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  19809. var parent = compressor.parent(p);
  19810. if (!parent) return false;
  19811. if (a === 0 && parent.TYPE == "Destructuring") continue;
  19812. if (!ancestors[a].test(parent.TYPE)) {
  19813. return false;
  19814. }
  19815. a++;
  19816. }
  19817. return true;
  19818. }
  19819. function should_retain(compressor, def) {
  19820. if (def.references.length) return true;
  19821. if (!def.global) return false;
  19822. if (compressor.toplevel.vars) {
  19823. if (compressor.top_retain) {
  19824. return compressor.top_retain(def);
  19825. }
  19826. return false;
  19827. }
  19828. return true;
  19829. }
  19830. });
  19831. /***********************************************************************
  19832. A JavaScript tokenizer / parser / beautifier / compressor.
  19833. https://github.com/mishoo/UglifyJS2
  19834. -------------------------------- (C) ---------------------------------
  19835. Author: Mihai Bazon
  19836. <mihai.bazon@gmail.com>
  19837. http://mihai.bazon.net/blog
  19838. Distributed under the BSD license:
  19839. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  19840. Redistribution and use in source and binary forms, with or without
  19841. modification, are permitted provided that the following conditions
  19842. are met:
  19843. * Redistributions of source code must retain the above
  19844. copyright notice, this list of conditions and the following
  19845. disclaimer.
  19846. * Redistributions in binary form must reproduce the above
  19847. copyright notice, this list of conditions and the following
  19848. disclaimer in the documentation and/or other materials
  19849. provided with the distribution.
  19850. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  19851. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19852. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19853. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  19854. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  19855. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19856. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19857. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19858. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  19859. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  19860. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  19861. SUCH DAMAGE.
  19862. ***********************************************************************/
  19863. // a small wrapper around source-map and @jridgewell/source-map
  19864. async function SourceMap(options) {
  19865. options = defaults(options, {
  19866. file : null,
  19867. root : null,
  19868. orig : null,
  19869. files: {},
  19870. });
  19871. var orig_map;
  19872. var generator = new sourceMap.SourceMapGenerator({
  19873. file : options.file,
  19874. sourceRoot : options.root
  19875. });
  19876. let sourcesContent = {__proto__: null};
  19877. let files = options.files;
  19878. for (var name in files) if (HOP(files, name)) {
  19879. sourcesContent[name] = files[name];
  19880. }
  19881. if (options.orig) {
  19882. // We support both @jridgewell/source-map (which has a sync
  19883. // SourceMapConsumer) and source-map (which has an async
  19884. // SourceMapConsumer).
  19885. orig_map = await new sourceMap.SourceMapConsumer(options.orig);
  19886. if (orig_map.sourcesContent) {
  19887. orig_map.sources.forEach(function(source, i) {
  19888. var content = orig_map.sourcesContent[i];
  19889. if (content) {
  19890. sourcesContent[source] = content;
  19891. }
  19892. });
  19893. }
  19894. }
  19895. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  19896. let generatedPos = { line: gen_line, column: gen_col };
  19897. if (orig_map) {
  19898. var info = orig_map.originalPositionFor({
  19899. line: orig_line,
  19900. column: orig_col
  19901. });
  19902. if (info.source === null) {
  19903. generator.addMapping({
  19904. generated: generatedPos,
  19905. original: null,
  19906. source: null,
  19907. name: null
  19908. });
  19909. return;
  19910. }
  19911. source = info.source;
  19912. orig_line = info.line;
  19913. orig_col = info.column;
  19914. name = info.name || name;
  19915. }
  19916. generator.addMapping({
  19917. generated : generatedPos,
  19918. original : { line: orig_line, column: orig_col },
  19919. source : source,
  19920. name : name
  19921. });
  19922. generator.setSourceContent(source, sourcesContent[source]);
  19923. }
  19924. function clean(map) {
  19925. const allNull = map.sourcesContent && map.sourcesContent.every(c => c == null);
  19926. if (allNull) delete map.sourcesContent;
  19927. if (map.file === undefined) delete map.file;
  19928. if (map.sourceRoot === undefined) delete map.sourceRoot;
  19929. return map;
  19930. }
  19931. function getDecoded() {
  19932. if (!generator.toDecodedMap) return null;
  19933. return clean(generator.toDecodedMap());
  19934. }
  19935. function getEncoded() {
  19936. return clean(generator.toJSON());
  19937. }
  19938. function destroy() {
  19939. // @jridgewell/source-map's SourceMapConsumer does not need to be
  19940. // manually freed.
  19941. if (orig_map && orig_map.destroy) orig_map.destroy();
  19942. }
  19943. return {
  19944. add,
  19945. getDecoded,
  19946. getEncoded,
  19947. destroy,
  19948. };
  19949. }
  19950. var domprops = [
  19951. "$&",
  19952. "$'",
  19953. "$*",
  19954. "$+",
  19955. "$1",
  19956. "$2",
  19957. "$3",
  19958. "$4",
  19959. "$5",
  19960. "$6",
  19961. "$7",
  19962. "$8",
  19963. "$9",
  19964. "$_",
  19965. "$`",
  19966. "$input",
  19967. "-moz-animation",
  19968. "-moz-animation-delay",
  19969. "-moz-animation-direction",
  19970. "-moz-animation-duration",
  19971. "-moz-animation-fill-mode",
  19972. "-moz-animation-iteration-count",
  19973. "-moz-animation-name",
  19974. "-moz-animation-play-state",
  19975. "-moz-animation-timing-function",
  19976. "-moz-appearance",
  19977. "-moz-backface-visibility",
  19978. "-moz-border-end",
  19979. "-moz-border-end-color",
  19980. "-moz-border-end-style",
  19981. "-moz-border-end-width",
  19982. "-moz-border-image",
  19983. "-moz-border-start",
  19984. "-moz-border-start-color",
  19985. "-moz-border-start-style",
  19986. "-moz-border-start-width",
  19987. "-moz-box-align",
  19988. "-moz-box-direction",
  19989. "-moz-box-flex",
  19990. "-moz-box-ordinal-group",
  19991. "-moz-box-orient",
  19992. "-moz-box-pack",
  19993. "-moz-box-sizing",
  19994. "-moz-float-edge",
  19995. "-moz-font-feature-settings",
  19996. "-moz-font-language-override",
  19997. "-moz-force-broken-image-icon",
  19998. "-moz-hyphens",
  19999. "-moz-image-region",
  20000. "-moz-margin-end",
  20001. "-moz-margin-start",
  20002. "-moz-orient",
  20003. "-moz-osx-font-smoothing",
  20004. "-moz-outline-radius",
  20005. "-moz-outline-radius-bottomleft",
  20006. "-moz-outline-radius-bottomright",
  20007. "-moz-outline-radius-topleft",
  20008. "-moz-outline-radius-topright",
  20009. "-moz-padding-end",
  20010. "-moz-padding-start",
  20011. "-moz-perspective",
  20012. "-moz-perspective-origin",
  20013. "-moz-tab-size",
  20014. "-moz-text-size-adjust",
  20015. "-moz-transform",
  20016. "-moz-transform-origin",
  20017. "-moz-transform-style",
  20018. "-moz-transition",
  20019. "-moz-transition-delay",
  20020. "-moz-transition-duration",
  20021. "-moz-transition-property",
  20022. "-moz-transition-timing-function",
  20023. "-moz-user-focus",
  20024. "-moz-user-input",
  20025. "-moz-user-modify",
  20026. "-moz-user-select",
  20027. "-moz-window-dragging",
  20028. "-webkit-align-content",
  20029. "-webkit-align-items",
  20030. "-webkit-align-self",
  20031. "-webkit-animation",
  20032. "-webkit-animation-delay",
  20033. "-webkit-animation-direction",
  20034. "-webkit-animation-duration",
  20035. "-webkit-animation-fill-mode",
  20036. "-webkit-animation-iteration-count",
  20037. "-webkit-animation-name",
  20038. "-webkit-animation-play-state",
  20039. "-webkit-animation-timing-function",
  20040. "-webkit-appearance",
  20041. "-webkit-backface-visibility",
  20042. "-webkit-background-clip",
  20043. "-webkit-background-origin",
  20044. "-webkit-background-size",
  20045. "-webkit-border-bottom-left-radius",
  20046. "-webkit-border-bottom-right-radius",
  20047. "-webkit-border-image",
  20048. "-webkit-border-radius",
  20049. "-webkit-border-top-left-radius",
  20050. "-webkit-border-top-right-radius",
  20051. "-webkit-box-align",
  20052. "-webkit-box-direction",
  20053. "-webkit-box-flex",
  20054. "-webkit-box-ordinal-group",
  20055. "-webkit-box-orient",
  20056. "-webkit-box-pack",
  20057. "-webkit-box-shadow",
  20058. "-webkit-box-sizing",
  20059. "-webkit-filter",
  20060. "-webkit-flex",
  20061. "-webkit-flex-basis",
  20062. "-webkit-flex-direction",
  20063. "-webkit-flex-flow",
  20064. "-webkit-flex-grow",
  20065. "-webkit-flex-shrink",
  20066. "-webkit-flex-wrap",
  20067. "-webkit-justify-content",
  20068. "-webkit-line-clamp",
  20069. "-webkit-mask",
  20070. "-webkit-mask-clip",
  20071. "-webkit-mask-composite",
  20072. "-webkit-mask-image",
  20073. "-webkit-mask-origin",
  20074. "-webkit-mask-position",
  20075. "-webkit-mask-position-x",
  20076. "-webkit-mask-position-y",
  20077. "-webkit-mask-repeat",
  20078. "-webkit-mask-size",
  20079. "-webkit-order",
  20080. "-webkit-perspective",
  20081. "-webkit-perspective-origin",
  20082. "-webkit-text-fill-color",
  20083. "-webkit-text-size-adjust",
  20084. "-webkit-text-stroke",
  20085. "-webkit-text-stroke-color",
  20086. "-webkit-text-stroke-width",
  20087. "-webkit-transform",
  20088. "-webkit-transform-origin",
  20089. "-webkit-transform-style",
  20090. "-webkit-transition",
  20091. "-webkit-transition-delay",
  20092. "-webkit-transition-duration",
  20093. "-webkit-transition-property",
  20094. "-webkit-transition-timing-function",
  20095. "-webkit-user-select",
  20096. "0",
  20097. "1",
  20098. "10",
  20099. "11",
  20100. "12",
  20101. "13",
  20102. "14",
  20103. "15",
  20104. "16",
  20105. "17",
  20106. "18",
  20107. "19",
  20108. "2",
  20109. "20",
  20110. "3",
  20111. "4",
  20112. "5",
  20113. "6",
  20114. "7",
  20115. "8",
  20116. "9",
  20117. "@@iterator",
  20118. "ABORT_ERR",
  20119. "ACTIVE",
  20120. "ACTIVE_ATTRIBUTES",
  20121. "ACTIVE_TEXTURE",
  20122. "ACTIVE_UNIFORMS",
  20123. "ACTIVE_UNIFORM_BLOCKS",
  20124. "ADDITION",
  20125. "ALIASED_LINE_WIDTH_RANGE",
  20126. "ALIASED_POINT_SIZE_RANGE",
  20127. "ALLOW_KEYBOARD_INPUT",
  20128. "ALLPASS",
  20129. "ALPHA",
  20130. "ALPHA_BITS",
  20131. "ALREADY_SIGNALED",
  20132. "ALT_MASK",
  20133. "ALWAYS",
  20134. "ANY_SAMPLES_PASSED",
  20135. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  20136. "ANY_TYPE",
  20137. "ANY_UNORDERED_NODE_TYPE",
  20138. "ARRAY_BUFFER",
  20139. "ARRAY_BUFFER_BINDING",
  20140. "ATTACHED_SHADERS",
  20141. "ATTRIBUTE_NODE",
  20142. "AT_TARGET",
  20143. "AbortController",
  20144. "AbortSignal",
  20145. "AbsoluteOrientationSensor",
  20146. "AbstractRange",
  20147. "Accelerometer",
  20148. "AddSearchProvider",
  20149. "AggregateError",
  20150. "AnalyserNode",
  20151. "Animation",
  20152. "AnimationEffect",
  20153. "AnimationEvent",
  20154. "AnimationPlaybackEvent",
  20155. "AnimationTimeline",
  20156. "AnonXMLHttpRequest",
  20157. "Any",
  20158. "ApplicationCache",
  20159. "ApplicationCacheErrorEvent",
  20160. "Array",
  20161. "ArrayBuffer",
  20162. "ArrayType",
  20163. "Atomics",
  20164. "Attr",
  20165. "Audio",
  20166. "AudioBuffer",
  20167. "AudioBufferSourceNode",
  20168. "AudioContext",
  20169. "AudioDestinationNode",
  20170. "AudioListener",
  20171. "AudioNode",
  20172. "AudioParam",
  20173. "AudioParamMap",
  20174. "AudioProcessingEvent",
  20175. "AudioScheduledSourceNode",
  20176. "AudioStreamTrack",
  20177. "AudioWorklet",
  20178. "AudioWorkletNode",
  20179. "AuthenticatorAssertionResponse",
  20180. "AuthenticatorAttestationResponse",
  20181. "AuthenticatorResponse",
  20182. "AutocompleteErrorEvent",
  20183. "BACK",
  20184. "BAD_BOUNDARYPOINTS_ERR",
  20185. "BAD_REQUEST",
  20186. "BANDPASS",
  20187. "BLEND",
  20188. "BLEND_COLOR",
  20189. "BLEND_DST_ALPHA",
  20190. "BLEND_DST_RGB",
  20191. "BLEND_EQUATION",
  20192. "BLEND_EQUATION_ALPHA",
  20193. "BLEND_EQUATION_RGB",
  20194. "BLEND_SRC_ALPHA",
  20195. "BLEND_SRC_RGB",
  20196. "BLUE_BITS",
  20197. "BLUR",
  20198. "BOOL",
  20199. "BOOLEAN_TYPE",
  20200. "BOOL_VEC2",
  20201. "BOOL_VEC3",
  20202. "BOOL_VEC4",
  20203. "BOTH",
  20204. "BROWSER_DEFAULT_WEBGL",
  20205. "BUBBLING_PHASE",
  20206. "BUFFER_SIZE",
  20207. "BUFFER_USAGE",
  20208. "BYTE",
  20209. "BYTES_PER_ELEMENT",
  20210. "BackgroundFetchManager",
  20211. "BackgroundFetchRecord",
  20212. "BackgroundFetchRegistration",
  20213. "BarProp",
  20214. "BarcodeDetector",
  20215. "BaseAudioContext",
  20216. "BaseHref",
  20217. "BatteryManager",
  20218. "BeforeInstallPromptEvent",
  20219. "BeforeLoadEvent",
  20220. "BeforeUnloadEvent",
  20221. "BigInt",
  20222. "BigInt64Array",
  20223. "BigUint64Array",
  20224. "BiquadFilterNode",
  20225. "Blob",
  20226. "BlobEvent",
  20227. "Bluetooth",
  20228. "BluetoothCharacteristicProperties",
  20229. "BluetoothDevice",
  20230. "BluetoothRemoteGATTCharacteristic",
  20231. "BluetoothRemoteGATTDescriptor",
  20232. "BluetoothRemoteGATTServer",
  20233. "BluetoothRemoteGATTService",
  20234. "BluetoothUUID",
  20235. "Boolean",
  20236. "BroadcastChannel",
  20237. "ByteLengthQueuingStrategy",
  20238. "CAPTURING_PHASE",
  20239. "CCW",
  20240. "CDATASection",
  20241. "CDATA_SECTION_NODE",
  20242. "CHANGE",
  20243. "CHARSET_RULE",
  20244. "CHECKING",
  20245. "CLAMP_TO_EDGE",
  20246. "CLICK",
  20247. "CLOSED",
  20248. "CLOSING",
  20249. "COLOR",
  20250. "COLOR_ATTACHMENT0",
  20251. "COLOR_ATTACHMENT1",
  20252. "COLOR_ATTACHMENT10",
  20253. "COLOR_ATTACHMENT11",
  20254. "COLOR_ATTACHMENT12",
  20255. "COLOR_ATTACHMENT13",
  20256. "COLOR_ATTACHMENT14",
  20257. "COLOR_ATTACHMENT15",
  20258. "COLOR_ATTACHMENT2",
  20259. "COLOR_ATTACHMENT3",
  20260. "COLOR_ATTACHMENT4",
  20261. "COLOR_ATTACHMENT5",
  20262. "COLOR_ATTACHMENT6",
  20263. "COLOR_ATTACHMENT7",
  20264. "COLOR_ATTACHMENT8",
  20265. "COLOR_ATTACHMENT9",
  20266. "COLOR_BUFFER_BIT",
  20267. "COLOR_CLEAR_VALUE",
  20268. "COLOR_WRITEMASK",
  20269. "COMMENT_NODE",
  20270. "COMPARE_REF_TO_TEXTURE",
  20271. "COMPILE_STATUS",
  20272. "COMPLETION_STATUS_KHR",
  20273. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  20274. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  20275. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  20276. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  20277. "COMPRESSED_TEXTURE_FORMATS",
  20278. "CONDITION_SATISFIED",
  20279. "CONFIGURATION_UNSUPPORTED",
  20280. "CONNECTING",
  20281. "CONSTANT_ALPHA",
  20282. "CONSTANT_COLOR",
  20283. "CONSTRAINT_ERR",
  20284. "CONTEXT_LOST_WEBGL",
  20285. "CONTROL_MASK",
  20286. "COPY_READ_BUFFER",
  20287. "COPY_READ_BUFFER_BINDING",
  20288. "COPY_WRITE_BUFFER",
  20289. "COPY_WRITE_BUFFER_BINDING",
  20290. "COUNTER_STYLE_RULE",
  20291. "CSS",
  20292. "CSS2Properties",
  20293. "CSSAnimation",
  20294. "CSSCharsetRule",
  20295. "CSSConditionRule",
  20296. "CSSCounterStyleRule",
  20297. "CSSFontFaceRule",
  20298. "CSSFontFeatureValuesRule",
  20299. "CSSGroupingRule",
  20300. "CSSImageValue",
  20301. "CSSImportRule",
  20302. "CSSKeyframeRule",
  20303. "CSSKeyframesRule",
  20304. "CSSKeywordValue",
  20305. "CSSMathInvert",
  20306. "CSSMathMax",
  20307. "CSSMathMin",
  20308. "CSSMathNegate",
  20309. "CSSMathProduct",
  20310. "CSSMathSum",
  20311. "CSSMathValue",
  20312. "CSSMatrixComponent",
  20313. "CSSMediaRule",
  20314. "CSSMozDocumentRule",
  20315. "CSSNameSpaceRule",
  20316. "CSSNamespaceRule",
  20317. "CSSNumericArray",
  20318. "CSSNumericValue",
  20319. "CSSPageRule",
  20320. "CSSPerspective",
  20321. "CSSPositionValue",
  20322. "CSSPrimitiveValue",
  20323. "CSSRotate",
  20324. "CSSRule",
  20325. "CSSRuleList",
  20326. "CSSScale",
  20327. "CSSSkew",
  20328. "CSSSkewX",
  20329. "CSSSkewY",
  20330. "CSSStyleDeclaration",
  20331. "CSSStyleRule",
  20332. "CSSStyleSheet",
  20333. "CSSStyleValue",
  20334. "CSSSupportsRule",
  20335. "CSSTransformComponent",
  20336. "CSSTransformValue",
  20337. "CSSTransition",
  20338. "CSSTranslate",
  20339. "CSSUnitValue",
  20340. "CSSUnknownRule",
  20341. "CSSUnparsedValue",
  20342. "CSSValue",
  20343. "CSSValueList",
  20344. "CSSVariableReferenceValue",
  20345. "CSSVariablesDeclaration",
  20346. "CSSVariablesRule",
  20347. "CSSViewportRule",
  20348. "CSS_ATTR",
  20349. "CSS_CM",
  20350. "CSS_COUNTER",
  20351. "CSS_CUSTOM",
  20352. "CSS_DEG",
  20353. "CSS_DIMENSION",
  20354. "CSS_EMS",
  20355. "CSS_EXS",
  20356. "CSS_FILTER_BLUR",
  20357. "CSS_FILTER_BRIGHTNESS",
  20358. "CSS_FILTER_CONTRAST",
  20359. "CSS_FILTER_CUSTOM",
  20360. "CSS_FILTER_DROP_SHADOW",
  20361. "CSS_FILTER_GRAYSCALE",
  20362. "CSS_FILTER_HUE_ROTATE",
  20363. "CSS_FILTER_INVERT",
  20364. "CSS_FILTER_OPACITY",
  20365. "CSS_FILTER_REFERENCE",
  20366. "CSS_FILTER_SATURATE",
  20367. "CSS_FILTER_SEPIA",
  20368. "CSS_GRAD",
  20369. "CSS_HZ",
  20370. "CSS_IDENT",
  20371. "CSS_IN",
  20372. "CSS_INHERIT",
  20373. "CSS_KHZ",
  20374. "CSS_MATRIX",
  20375. "CSS_MATRIX3D",
  20376. "CSS_MM",
  20377. "CSS_MS",
  20378. "CSS_NUMBER",
  20379. "CSS_PC",
  20380. "CSS_PERCENTAGE",
  20381. "CSS_PERSPECTIVE",
  20382. "CSS_PRIMITIVE_VALUE",
  20383. "CSS_PT",
  20384. "CSS_PX",
  20385. "CSS_RAD",
  20386. "CSS_RECT",
  20387. "CSS_RGBCOLOR",
  20388. "CSS_ROTATE",
  20389. "CSS_ROTATE3D",
  20390. "CSS_ROTATEX",
  20391. "CSS_ROTATEY",
  20392. "CSS_ROTATEZ",
  20393. "CSS_S",
  20394. "CSS_SCALE",
  20395. "CSS_SCALE3D",
  20396. "CSS_SCALEX",
  20397. "CSS_SCALEY",
  20398. "CSS_SCALEZ",
  20399. "CSS_SKEW",
  20400. "CSS_SKEWX",
  20401. "CSS_SKEWY",
  20402. "CSS_STRING",
  20403. "CSS_TRANSLATE",
  20404. "CSS_TRANSLATE3D",
  20405. "CSS_TRANSLATEX",
  20406. "CSS_TRANSLATEY",
  20407. "CSS_TRANSLATEZ",
  20408. "CSS_UNKNOWN",
  20409. "CSS_URI",
  20410. "CSS_VALUE_LIST",
  20411. "CSS_VH",
  20412. "CSS_VMAX",
  20413. "CSS_VMIN",
  20414. "CSS_VW",
  20415. "CULL_FACE",
  20416. "CULL_FACE_MODE",
  20417. "CURRENT_PROGRAM",
  20418. "CURRENT_QUERY",
  20419. "CURRENT_VERTEX_ATTRIB",
  20420. "CUSTOM",
  20421. "CW",
  20422. "Cache",
  20423. "CacheStorage",
  20424. "CanvasCaptureMediaStream",
  20425. "CanvasCaptureMediaStreamTrack",
  20426. "CanvasGradient",
  20427. "CanvasPattern",
  20428. "CanvasRenderingContext2D",
  20429. "CaretPosition",
  20430. "ChannelMergerNode",
  20431. "ChannelSplitterNode",
  20432. "CharacterData",
  20433. "ClientRect",
  20434. "ClientRectList",
  20435. "Clipboard",
  20436. "ClipboardEvent",
  20437. "ClipboardItem",
  20438. "CloseEvent",
  20439. "Collator",
  20440. "CommandEvent",
  20441. "Comment",
  20442. "CompileError",
  20443. "CompositionEvent",
  20444. "CompressionStream",
  20445. "Console",
  20446. "ConstantSourceNode",
  20447. "Controllers",
  20448. "ConvolverNode",
  20449. "CountQueuingStrategy",
  20450. "Counter",
  20451. "Credential",
  20452. "CredentialsContainer",
  20453. "Crypto",
  20454. "CryptoKey",
  20455. "CustomElementRegistry",
  20456. "CustomEvent",
  20457. "DATABASE_ERR",
  20458. "DATA_CLONE_ERR",
  20459. "DATA_ERR",
  20460. "DBLCLICK",
  20461. "DECR",
  20462. "DECR_WRAP",
  20463. "DELETE_STATUS",
  20464. "DEPTH",
  20465. "DEPTH24_STENCIL8",
  20466. "DEPTH32F_STENCIL8",
  20467. "DEPTH_ATTACHMENT",
  20468. "DEPTH_BITS",
  20469. "DEPTH_BUFFER_BIT",
  20470. "DEPTH_CLEAR_VALUE",
  20471. "DEPTH_COMPONENT",
  20472. "DEPTH_COMPONENT16",
  20473. "DEPTH_COMPONENT24",
  20474. "DEPTH_COMPONENT32F",
  20475. "DEPTH_FUNC",
  20476. "DEPTH_RANGE",
  20477. "DEPTH_STENCIL",
  20478. "DEPTH_STENCIL_ATTACHMENT",
  20479. "DEPTH_TEST",
  20480. "DEPTH_WRITEMASK",
  20481. "DEVICE_INELIGIBLE",
  20482. "DIRECTION_DOWN",
  20483. "DIRECTION_LEFT",
  20484. "DIRECTION_RIGHT",
  20485. "DIRECTION_UP",
  20486. "DISABLED",
  20487. "DISPATCH_REQUEST_ERR",
  20488. "DITHER",
  20489. "DOCUMENT_FRAGMENT_NODE",
  20490. "DOCUMENT_NODE",
  20491. "DOCUMENT_POSITION_CONTAINED_BY",
  20492. "DOCUMENT_POSITION_CONTAINS",
  20493. "DOCUMENT_POSITION_DISCONNECTED",
  20494. "DOCUMENT_POSITION_FOLLOWING",
  20495. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  20496. "DOCUMENT_POSITION_PRECEDING",
  20497. "DOCUMENT_TYPE_NODE",
  20498. "DOMCursor",
  20499. "DOMError",
  20500. "DOMException",
  20501. "DOMImplementation",
  20502. "DOMImplementationLS",
  20503. "DOMMatrix",
  20504. "DOMMatrixReadOnly",
  20505. "DOMParser",
  20506. "DOMPoint",
  20507. "DOMPointReadOnly",
  20508. "DOMQuad",
  20509. "DOMRect",
  20510. "DOMRectList",
  20511. "DOMRectReadOnly",
  20512. "DOMRequest",
  20513. "DOMSTRING_SIZE_ERR",
  20514. "DOMSettableTokenList",
  20515. "DOMStringList",
  20516. "DOMStringMap",
  20517. "DOMTokenList",
  20518. "DOMTransactionEvent",
  20519. "DOM_DELTA_LINE",
  20520. "DOM_DELTA_PAGE",
  20521. "DOM_DELTA_PIXEL",
  20522. "DOM_INPUT_METHOD_DROP",
  20523. "DOM_INPUT_METHOD_HANDWRITING",
  20524. "DOM_INPUT_METHOD_IME",
  20525. "DOM_INPUT_METHOD_KEYBOARD",
  20526. "DOM_INPUT_METHOD_MULTIMODAL",
  20527. "DOM_INPUT_METHOD_OPTION",
  20528. "DOM_INPUT_METHOD_PASTE",
  20529. "DOM_INPUT_METHOD_SCRIPT",
  20530. "DOM_INPUT_METHOD_UNKNOWN",
  20531. "DOM_INPUT_METHOD_VOICE",
  20532. "DOM_KEY_LOCATION_JOYSTICK",
  20533. "DOM_KEY_LOCATION_LEFT",
  20534. "DOM_KEY_LOCATION_MOBILE",
  20535. "DOM_KEY_LOCATION_NUMPAD",
  20536. "DOM_KEY_LOCATION_RIGHT",
  20537. "DOM_KEY_LOCATION_STANDARD",
  20538. "DOM_VK_0",
  20539. "DOM_VK_1",
  20540. "DOM_VK_2",
  20541. "DOM_VK_3",
  20542. "DOM_VK_4",
  20543. "DOM_VK_5",
  20544. "DOM_VK_6",
  20545. "DOM_VK_7",
  20546. "DOM_VK_8",
  20547. "DOM_VK_9",
  20548. "DOM_VK_A",
  20549. "DOM_VK_ACCEPT",
  20550. "DOM_VK_ADD",
  20551. "DOM_VK_ALT",
  20552. "DOM_VK_ALTGR",
  20553. "DOM_VK_AMPERSAND",
  20554. "DOM_VK_ASTERISK",
  20555. "DOM_VK_AT",
  20556. "DOM_VK_ATTN",
  20557. "DOM_VK_B",
  20558. "DOM_VK_BACKSPACE",
  20559. "DOM_VK_BACK_QUOTE",
  20560. "DOM_VK_BACK_SLASH",
  20561. "DOM_VK_BACK_SPACE",
  20562. "DOM_VK_C",
  20563. "DOM_VK_CANCEL",
  20564. "DOM_VK_CAPS_LOCK",
  20565. "DOM_VK_CIRCUMFLEX",
  20566. "DOM_VK_CLEAR",
  20567. "DOM_VK_CLOSE_BRACKET",
  20568. "DOM_VK_CLOSE_CURLY_BRACKET",
  20569. "DOM_VK_CLOSE_PAREN",
  20570. "DOM_VK_COLON",
  20571. "DOM_VK_COMMA",
  20572. "DOM_VK_CONTEXT_MENU",
  20573. "DOM_VK_CONTROL",
  20574. "DOM_VK_CONVERT",
  20575. "DOM_VK_CRSEL",
  20576. "DOM_VK_CTRL",
  20577. "DOM_VK_D",
  20578. "DOM_VK_DECIMAL",
  20579. "DOM_VK_DELETE",
  20580. "DOM_VK_DIVIDE",
  20581. "DOM_VK_DOLLAR",
  20582. "DOM_VK_DOUBLE_QUOTE",
  20583. "DOM_VK_DOWN",
  20584. "DOM_VK_E",
  20585. "DOM_VK_EISU",
  20586. "DOM_VK_END",
  20587. "DOM_VK_ENTER",
  20588. "DOM_VK_EQUALS",
  20589. "DOM_VK_EREOF",
  20590. "DOM_VK_ESCAPE",
  20591. "DOM_VK_EXCLAMATION",
  20592. "DOM_VK_EXECUTE",
  20593. "DOM_VK_EXSEL",
  20594. "DOM_VK_F",
  20595. "DOM_VK_F1",
  20596. "DOM_VK_F10",
  20597. "DOM_VK_F11",
  20598. "DOM_VK_F12",
  20599. "DOM_VK_F13",
  20600. "DOM_VK_F14",
  20601. "DOM_VK_F15",
  20602. "DOM_VK_F16",
  20603. "DOM_VK_F17",
  20604. "DOM_VK_F18",
  20605. "DOM_VK_F19",
  20606. "DOM_VK_F2",
  20607. "DOM_VK_F20",
  20608. "DOM_VK_F21",
  20609. "DOM_VK_F22",
  20610. "DOM_VK_F23",
  20611. "DOM_VK_F24",
  20612. "DOM_VK_F25",
  20613. "DOM_VK_F26",
  20614. "DOM_VK_F27",
  20615. "DOM_VK_F28",
  20616. "DOM_VK_F29",
  20617. "DOM_VK_F3",
  20618. "DOM_VK_F30",
  20619. "DOM_VK_F31",
  20620. "DOM_VK_F32",
  20621. "DOM_VK_F33",
  20622. "DOM_VK_F34",
  20623. "DOM_VK_F35",
  20624. "DOM_VK_F36",
  20625. "DOM_VK_F4",
  20626. "DOM_VK_F5",
  20627. "DOM_VK_F6",
  20628. "DOM_VK_F7",
  20629. "DOM_VK_F8",
  20630. "DOM_VK_F9",
  20631. "DOM_VK_FINAL",
  20632. "DOM_VK_FRONT",
  20633. "DOM_VK_G",
  20634. "DOM_VK_GREATER_THAN",
  20635. "DOM_VK_H",
  20636. "DOM_VK_HANGUL",
  20637. "DOM_VK_HANJA",
  20638. "DOM_VK_HASH",
  20639. "DOM_VK_HELP",
  20640. "DOM_VK_HK_TOGGLE",
  20641. "DOM_VK_HOME",
  20642. "DOM_VK_HYPHEN_MINUS",
  20643. "DOM_VK_I",
  20644. "DOM_VK_INSERT",
  20645. "DOM_VK_J",
  20646. "DOM_VK_JUNJA",
  20647. "DOM_VK_K",
  20648. "DOM_VK_KANA",
  20649. "DOM_VK_KANJI",
  20650. "DOM_VK_L",
  20651. "DOM_VK_LEFT",
  20652. "DOM_VK_LEFT_TAB",
  20653. "DOM_VK_LESS_THAN",
  20654. "DOM_VK_M",
  20655. "DOM_VK_META",
  20656. "DOM_VK_MODECHANGE",
  20657. "DOM_VK_MULTIPLY",
  20658. "DOM_VK_N",
  20659. "DOM_VK_NONCONVERT",
  20660. "DOM_VK_NUMPAD0",
  20661. "DOM_VK_NUMPAD1",
  20662. "DOM_VK_NUMPAD2",
  20663. "DOM_VK_NUMPAD3",
  20664. "DOM_VK_NUMPAD4",
  20665. "DOM_VK_NUMPAD5",
  20666. "DOM_VK_NUMPAD6",
  20667. "DOM_VK_NUMPAD7",
  20668. "DOM_VK_NUMPAD8",
  20669. "DOM_VK_NUMPAD9",
  20670. "DOM_VK_NUM_LOCK",
  20671. "DOM_VK_O",
  20672. "DOM_VK_OEM_1",
  20673. "DOM_VK_OEM_102",
  20674. "DOM_VK_OEM_2",
  20675. "DOM_VK_OEM_3",
  20676. "DOM_VK_OEM_4",
  20677. "DOM_VK_OEM_5",
  20678. "DOM_VK_OEM_6",
  20679. "DOM_VK_OEM_7",
  20680. "DOM_VK_OEM_8",
  20681. "DOM_VK_OEM_COMMA",
  20682. "DOM_VK_OEM_MINUS",
  20683. "DOM_VK_OEM_PERIOD",
  20684. "DOM_VK_OEM_PLUS",
  20685. "DOM_VK_OPEN_BRACKET",
  20686. "DOM_VK_OPEN_CURLY_BRACKET",
  20687. "DOM_VK_OPEN_PAREN",
  20688. "DOM_VK_P",
  20689. "DOM_VK_PA1",
  20690. "DOM_VK_PAGEDOWN",
  20691. "DOM_VK_PAGEUP",
  20692. "DOM_VK_PAGE_DOWN",
  20693. "DOM_VK_PAGE_UP",
  20694. "DOM_VK_PAUSE",
  20695. "DOM_VK_PERCENT",
  20696. "DOM_VK_PERIOD",
  20697. "DOM_VK_PIPE",
  20698. "DOM_VK_PLAY",
  20699. "DOM_VK_PLUS",
  20700. "DOM_VK_PRINT",
  20701. "DOM_VK_PRINTSCREEN",
  20702. "DOM_VK_PROCESSKEY",
  20703. "DOM_VK_PROPERITES",
  20704. "DOM_VK_Q",
  20705. "DOM_VK_QUESTION_MARK",
  20706. "DOM_VK_QUOTE",
  20707. "DOM_VK_R",
  20708. "DOM_VK_REDO",
  20709. "DOM_VK_RETURN",
  20710. "DOM_VK_RIGHT",
  20711. "DOM_VK_S",
  20712. "DOM_VK_SCROLL_LOCK",
  20713. "DOM_VK_SELECT",
  20714. "DOM_VK_SEMICOLON",
  20715. "DOM_VK_SEPARATOR",
  20716. "DOM_VK_SHIFT",
  20717. "DOM_VK_SLASH",
  20718. "DOM_VK_SLEEP",
  20719. "DOM_VK_SPACE",
  20720. "DOM_VK_SUBTRACT",
  20721. "DOM_VK_T",
  20722. "DOM_VK_TAB",
  20723. "DOM_VK_TILDE",
  20724. "DOM_VK_U",
  20725. "DOM_VK_UNDERSCORE",
  20726. "DOM_VK_UNDO",
  20727. "DOM_VK_UNICODE",
  20728. "DOM_VK_UP",
  20729. "DOM_VK_V",
  20730. "DOM_VK_VOLUME_DOWN",
  20731. "DOM_VK_VOLUME_MUTE",
  20732. "DOM_VK_VOLUME_UP",
  20733. "DOM_VK_W",
  20734. "DOM_VK_WIN",
  20735. "DOM_VK_WINDOW",
  20736. "DOM_VK_WIN_ICO_00",
  20737. "DOM_VK_WIN_ICO_CLEAR",
  20738. "DOM_VK_WIN_ICO_HELP",
  20739. "DOM_VK_WIN_OEM_ATTN",
  20740. "DOM_VK_WIN_OEM_AUTO",
  20741. "DOM_VK_WIN_OEM_BACKTAB",
  20742. "DOM_VK_WIN_OEM_CLEAR",
  20743. "DOM_VK_WIN_OEM_COPY",
  20744. "DOM_VK_WIN_OEM_CUSEL",
  20745. "DOM_VK_WIN_OEM_ENLW",
  20746. "DOM_VK_WIN_OEM_FINISH",
  20747. "DOM_VK_WIN_OEM_FJ_JISHO",
  20748. "DOM_VK_WIN_OEM_FJ_LOYA",
  20749. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  20750. "DOM_VK_WIN_OEM_FJ_ROYA",
  20751. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  20752. "DOM_VK_WIN_OEM_JUMP",
  20753. "DOM_VK_WIN_OEM_PA1",
  20754. "DOM_VK_WIN_OEM_PA2",
  20755. "DOM_VK_WIN_OEM_PA3",
  20756. "DOM_VK_WIN_OEM_RESET",
  20757. "DOM_VK_WIN_OEM_WSCTRL",
  20758. "DOM_VK_X",
  20759. "DOM_VK_XF86XK_ADD_FAVORITE",
  20760. "DOM_VK_XF86XK_APPLICATION_LEFT",
  20761. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  20762. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  20763. "DOM_VK_XF86XK_AUDIO_FORWARD",
  20764. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  20765. "DOM_VK_XF86XK_AUDIO_MEDIA",
  20766. "DOM_VK_XF86XK_AUDIO_MUTE",
  20767. "DOM_VK_XF86XK_AUDIO_NEXT",
  20768. "DOM_VK_XF86XK_AUDIO_PAUSE",
  20769. "DOM_VK_XF86XK_AUDIO_PLAY",
  20770. "DOM_VK_XF86XK_AUDIO_PREV",
  20771. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  20772. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  20773. "DOM_VK_XF86XK_AUDIO_RECORD",
  20774. "DOM_VK_XF86XK_AUDIO_REPEAT",
  20775. "DOM_VK_XF86XK_AUDIO_REWIND",
  20776. "DOM_VK_XF86XK_AUDIO_STOP",
  20777. "DOM_VK_XF86XK_AWAY",
  20778. "DOM_VK_XF86XK_BACK",
  20779. "DOM_VK_XF86XK_BACK_FORWARD",
  20780. "DOM_VK_XF86XK_BATTERY",
  20781. "DOM_VK_XF86XK_BLUE",
  20782. "DOM_VK_XF86XK_BLUETOOTH",
  20783. "DOM_VK_XF86XK_BOOK",
  20784. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  20785. "DOM_VK_XF86XK_CALCULATOR",
  20786. "DOM_VK_XF86XK_CALENDAR",
  20787. "DOM_VK_XF86XK_CD",
  20788. "DOM_VK_XF86XK_CLOSE",
  20789. "DOM_VK_XF86XK_COMMUNITY",
  20790. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  20791. "DOM_VK_XF86XK_COPY",
  20792. "DOM_VK_XF86XK_CUT",
  20793. "DOM_VK_XF86XK_CYCLE_ANGLE",
  20794. "DOM_VK_XF86XK_DISPLAY",
  20795. "DOM_VK_XF86XK_DOCUMENTS",
  20796. "DOM_VK_XF86XK_DOS",
  20797. "DOM_VK_XF86XK_EJECT",
  20798. "DOM_VK_XF86XK_EXCEL",
  20799. "DOM_VK_XF86XK_EXPLORER",
  20800. "DOM_VK_XF86XK_FAVORITES",
  20801. "DOM_VK_XF86XK_FINANCE",
  20802. "DOM_VK_XF86XK_FORWARD",
  20803. "DOM_VK_XF86XK_FRAME_BACK",
  20804. "DOM_VK_XF86XK_FRAME_FORWARD",
  20805. "DOM_VK_XF86XK_GAME",
  20806. "DOM_VK_XF86XK_GO",
  20807. "DOM_VK_XF86XK_GREEN",
  20808. "DOM_VK_XF86XK_HIBERNATE",
  20809. "DOM_VK_XF86XK_HISTORY",
  20810. "DOM_VK_XF86XK_HOME_PAGE",
  20811. "DOM_VK_XF86XK_HOT_LINKS",
  20812. "DOM_VK_XF86XK_I_TOUCH",
  20813. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  20814. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  20815. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  20816. "DOM_VK_XF86XK_LAUNCH0",
  20817. "DOM_VK_XF86XK_LAUNCH1",
  20818. "DOM_VK_XF86XK_LAUNCH2",
  20819. "DOM_VK_XF86XK_LAUNCH3",
  20820. "DOM_VK_XF86XK_LAUNCH4",
  20821. "DOM_VK_XF86XK_LAUNCH5",
  20822. "DOM_VK_XF86XK_LAUNCH6",
  20823. "DOM_VK_XF86XK_LAUNCH7",
  20824. "DOM_VK_XF86XK_LAUNCH8",
  20825. "DOM_VK_XF86XK_LAUNCH9",
  20826. "DOM_VK_XF86XK_LAUNCH_A",
  20827. "DOM_VK_XF86XK_LAUNCH_B",
  20828. "DOM_VK_XF86XK_LAUNCH_C",
  20829. "DOM_VK_XF86XK_LAUNCH_D",
  20830. "DOM_VK_XF86XK_LAUNCH_E",
  20831. "DOM_VK_XF86XK_LAUNCH_F",
  20832. "DOM_VK_XF86XK_LIGHT_BULB",
  20833. "DOM_VK_XF86XK_LOG_OFF",
  20834. "DOM_VK_XF86XK_MAIL",
  20835. "DOM_VK_XF86XK_MAIL_FORWARD",
  20836. "DOM_VK_XF86XK_MARKET",
  20837. "DOM_VK_XF86XK_MEETING",
  20838. "DOM_VK_XF86XK_MEMO",
  20839. "DOM_VK_XF86XK_MENU_KB",
  20840. "DOM_VK_XF86XK_MENU_PB",
  20841. "DOM_VK_XF86XK_MESSENGER",
  20842. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  20843. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  20844. "DOM_VK_XF86XK_MUSIC",
  20845. "DOM_VK_XF86XK_MY_COMPUTER",
  20846. "DOM_VK_XF86XK_MY_SITES",
  20847. "DOM_VK_XF86XK_NEW",
  20848. "DOM_VK_XF86XK_NEWS",
  20849. "DOM_VK_XF86XK_OFFICE_HOME",
  20850. "DOM_VK_XF86XK_OPEN",
  20851. "DOM_VK_XF86XK_OPEN_URL",
  20852. "DOM_VK_XF86XK_OPTION",
  20853. "DOM_VK_XF86XK_PASTE",
  20854. "DOM_VK_XF86XK_PHONE",
  20855. "DOM_VK_XF86XK_PICTURES",
  20856. "DOM_VK_XF86XK_POWER_DOWN",
  20857. "DOM_VK_XF86XK_POWER_OFF",
  20858. "DOM_VK_XF86XK_RED",
  20859. "DOM_VK_XF86XK_REFRESH",
  20860. "DOM_VK_XF86XK_RELOAD",
  20861. "DOM_VK_XF86XK_REPLY",
  20862. "DOM_VK_XF86XK_ROCKER_DOWN",
  20863. "DOM_VK_XF86XK_ROCKER_ENTER",
  20864. "DOM_VK_XF86XK_ROCKER_UP",
  20865. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  20866. "DOM_VK_XF86XK_ROTATION_KB",
  20867. "DOM_VK_XF86XK_ROTATION_PB",
  20868. "DOM_VK_XF86XK_SAVE",
  20869. "DOM_VK_XF86XK_SCREEN_SAVER",
  20870. "DOM_VK_XF86XK_SCROLL_CLICK",
  20871. "DOM_VK_XF86XK_SCROLL_DOWN",
  20872. "DOM_VK_XF86XK_SCROLL_UP",
  20873. "DOM_VK_XF86XK_SEARCH",
  20874. "DOM_VK_XF86XK_SEND",
  20875. "DOM_VK_XF86XK_SHOP",
  20876. "DOM_VK_XF86XK_SPELL",
  20877. "DOM_VK_XF86XK_SPLIT_SCREEN",
  20878. "DOM_VK_XF86XK_STANDBY",
  20879. "DOM_VK_XF86XK_START",
  20880. "DOM_VK_XF86XK_STOP",
  20881. "DOM_VK_XF86XK_SUBTITLE",
  20882. "DOM_VK_XF86XK_SUPPORT",
  20883. "DOM_VK_XF86XK_SUSPEND",
  20884. "DOM_VK_XF86XK_TASK_PANE",
  20885. "DOM_VK_XF86XK_TERMINAL",
  20886. "DOM_VK_XF86XK_TIME",
  20887. "DOM_VK_XF86XK_TOOLS",
  20888. "DOM_VK_XF86XK_TOP_MENU",
  20889. "DOM_VK_XF86XK_TO_DO_LIST",
  20890. "DOM_VK_XF86XK_TRAVEL",
  20891. "DOM_VK_XF86XK_USER1KB",
  20892. "DOM_VK_XF86XK_USER2KB",
  20893. "DOM_VK_XF86XK_USER_PB",
  20894. "DOM_VK_XF86XK_UWB",
  20895. "DOM_VK_XF86XK_VENDOR_HOME",
  20896. "DOM_VK_XF86XK_VIDEO",
  20897. "DOM_VK_XF86XK_VIEW",
  20898. "DOM_VK_XF86XK_WAKE_UP",
  20899. "DOM_VK_XF86XK_WEB_CAM",
  20900. "DOM_VK_XF86XK_WHEEL_BUTTON",
  20901. "DOM_VK_XF86XK_WLAN",
  20902. "DOM_VK_XF86XK_WORD",
  20903. "DOM_VK_XF86XK_WWW",
  20904. "DOM_VK_XF86XK_XFER",
  20905. "DOM_VK_XF86XK_YELLOW",
  20906. "DOM_VK_XF86XK_ZOOM_IN",
  20907. "DOM_VK_XF86XK_ZOOM_OUT",
  20908. "DOM_VK_Y",
  20909. "DOM_VK_Z",
  20910. "DOM_VK_ZOOM",
  20911. "DONE",
  20912. "DONT_CARE",
  20913. "DOWNLOADING",
  20914. "DRAGDROP",
  20915. "DRAW_BUFFER0",
  20916. "DRAW_BUFFER1",
  20917. "DRAW_BUFFER10",
  20918. "DRAW_BUFFER11",
  20919. "DRAW_BUFFER12",
  20920. "DRAW_BUFFER13",
  20921. "DRAW_BUFFER14",
  20922. "DRAW_BUFFER15",
  20923. "DRAW_BUFFER2",
  20924. "DRAW_BUFFER3",
  20925. "DRAW_BUFFER4",
  20926. "DRAW_BUFFER5",
  20927. "DRAW_BUFFER6",
  20928. "DRAW_BUFFER7",
  20929. "DRAW_BUFFER8",
  20930. "DRAW_BUFFER9",
  20931. "DRAW_FRAMEBUFFER",
  20932. "DRAW_FRAMEBUFFER_BINDING",
  20933. "DST_ALPHA",
  20934. "DST_COLOR",
  20935. "DYNAMIC_COPY",
  20936. "DYNAMIC_DRAW",
  20937. "DYNAMIC_READ",
  20938. "DataChannel",
  20939. "DataTransfer",
  20940. "DataTransferItem",
  20941. "DataTransferItemList",
  20942. "DataView",
  20943. "Date",
  20944. "DateTimeFormat",
  20945. "DecompressionStream",
  20946. "DelayNode",
  20947. "DeprecationReportBody",
  20948. "DesktopNotification",
  20949. "DesktopNotificationCenter",
  20950. "DeviceLightEvent",
  20951. "DeviceMotionEvent",
  20952. "DeviceMotionEventAcceleration",
  20953. "DeviceMotionEventRotationRate",
  20954. "DeviceOrientationEvent",
  20955. "DeviceProximityEvent",
  20956. "DeviceStorage",
  20957. "DeviceStorageChangeEvent",
  20958. "Directory",
  20959. "DisplayNames",
  20960. "Document",
  20961. "DocumentFragment",
  20962. "DocumentTimeline",
  20963. "DocumentType",
  20964. "DragEvent",
  20965. "DynamicsCompressorNode",
  20966. "E",
  20967. "ELEMENT_ARRAY_BUFFER",
  20968. "ELEMENT_ARRAY_BUFFER_BINDING",
  20969. "ELEMENT_NODE",
  20970. "EMPTY",
  20971. "ENCODING_ERR",
  20972. "ENDED",
  20973. "END_TO_END",
  20974. "END_TO_START",
  20975. "ENTITY_NODE",
  20976. "ENTITY_REFERENCE_NODE",
  20977. "EPSILON",
  20978. "EQUAL",
  20979. "EQUALPOWER",
  20980. "ERROR",
  20981. "EXPONENTIAL_DISTANCE",
  20982. "Element",
  20983. "ElementInternals",
  20984. "ElementQuery",
  20985. "EnterPictureInPictureEvent",
  20986. "Entity",
  20987. "EntityReference",
  20988. "Error",
  20989. "ErrorEvent",
  20990. "EvalError",
  20991. "Event",
  20992. "EventException",
  20993. "EventSource",
  20994. "EventTarget",
  20995. "External",
  20996. "FASTEST",
  20997. "FIDOSDK",
  20998. "FILTER_ACCEPT",
  20999. "FILTER_INTERRUPT",
  21000. "FILTER_REJECT",
  21001. "FILTER_SKIP",
  21002. "FINISHED_STATE",
  21003. "FIRST_ORDERED_NODE_TYPE",
  21004. "FLOAT",
  21005. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  21006. "FLOAT_MAT2",
  21007. "FLOAT_MAT2x3",
  21008. "FLOAT_MAT2x4",
  21009. "FLOAT_MAT3",
  21010. "FLOAT_MAT3x2",
  21011. "FLOAT_MAT3x4",
  21012. "FLOAT_MAT4",
  21013. "FLOAT_MAT4x2",
  21014. "FLOAT_MAT4x3",
  21015. "FLOAT_VEC2",
  21016. "FLOAT_VEC3",
  21017. "FLOAT_VEC4",
  21018. "FOCUS",
  21019. "FONT_FACE_RULE",
  21020. "FONT_FEATURE_VALUES_RULE",
  21021. "FRAGMENT_SHADER",
  21022. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  21023. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  21024. "FRAMEBUFFER",
  21025. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  21026. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  21027. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  21028. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  21029. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  21030. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  21031. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  21032. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  21033. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  21034. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  21035. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  21036. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  21037. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  21038. "FRAMEBUFFER_BINDING",
  21039. "FRAMEBUFFER_COMPLETE",
  21040. "FRAMEBUFFER_DEFAULT",
  21041. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  21042. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  21043. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  21044. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  21045. "FRAMEBUFFER_UNSUPPORTED",
  21046. "FRONT",
  21047. "FRONT_AND_BACK",
  21048. "FRONT_FACE",
  21049. "FUNC_ADD",
  21050. "FUNC_REVERSE_SUBTRACT",
  21051. "FUNC_SUBTRACT",
  21052. "FeaturePolicy",
  21053. "FeaturePolicyViolationReportBody",
  21054. "FederatedCredential",
  21055. "Feed",
  21056. "FeedEntry",
  21057. "File",
  21058. "FileError",
  21059. "FileList",
  21060. "FileReader",
  21061. "FileSystem",
  21062. "FileSystemDirectoryEntry",
  21063. "FileSystemDirectoryReader",
  21064. "FileSystemEntry",
  21065. "FileSystemFileEntry",
  21066. "FinalizationRegistry",
  21067. "FindInPage",
  21068. "Float32Array",
  21069. "Float64Array",
  21070. "FocusEvent",
  21071. "FontFace",
  21072. "FontFaceSet",
  21073. "FontFaceSetLoadEvent",
  21074. "FormData",
  21075. "FormDataEvent",
  21076. "FragmentDirective",
  21077. "Function",
  21078. "GENERATE_MIPMAP_HINT",
  21079. "GEQUAL",
  21080. "GREATER",
  21081. "GREEN_BITS",
  21082. "GainNode",
  21083. "Gamepad",
  21084. "GamepadAxisMoveEvent",
  21085. "GamepadButton",
  21086. "GamepadButtonEvent",
  21087. "GamepadEvent",
  21088. "GamepadHapticActuator",
  21089. "GamepadPose",
  21090. "Geolocation",
  21091. "GeolocationCoordinates",
  21092. "GeolocationPosition",
  21093. "GeolocationPositionError",
  21094. "GestureEvent",
  21095. "Global",
  21096. "Gyroscope",
  21097. "HALF_FLOAT",
  21098. "HAVE_CURRENT_DATA",
  21099. "HAVE_ENOUGH_DATA",
  21100. "HAVE_FUTURE_DATA",
  21101. "HAVE_METADATA",
  21102. "HAVE_NOTHING",
  21103. "HEADERS_RECEIVED",
  21104. "HIDDEN",
  21105. "HIERARCHY_REQUEST_ERR",
  21106. "HIGHPASS",
  21107. "HIGHSHELF",
  21108. "HIGH_FLOAT",
  21109. "HIGH_INT",
  21110. "HORIZONTAL",
  21111. "HORIZONTAL_AXIS",
  21112. "HRTF",
  21113. "HTMLAllCollection",
  21114. "HTMLAnchorElement",
  21115. "HTMLAppletElement",
  21116. "HTMLAreaElement",
  21117. "HTMLAudioElement",
  21118. "HTMLBRElement",
  21119. "HTMLBaseElement",
  21120. "HTMLBaseFontElement",
  21121. "HTMLBlockquoteElement",
  21122. "HTMLBodyElement",
  21123. "HTMLButtonElement",
  21124. "HTMLCanvasElement",
  21125. "HTMLCollection",
  21126. "HTMLCommandElement",
  21127. "HTMLContentElement",
  21128. "HTMLDListElement",
  21129. "HTMLDataElement",
  21130. "HTMLDataListElement",
  21131. "HTMLDetailsElement",
  21132. "HTMLDialogElement",
  21133. "HTMLDirectoryElement",
  21134. "HTMLDivElement",
  21135. "HTMLDocument",
  21136. "HTMLElement",
  21137. "HTMLEmbedElement",
  21138. "HTMLFieldSetElement",
  21139. "HTMLFontElement",
  21140. "HTMLFormControlsCollection",
  21141. "HTMLFormElement",
  21142. "HTMLFrameElement",
  21143. "HTMLFrameSetElement",
  21144. "HTMLHRElement",
  21145. "HTMLHeadElement",
  21146. "HTMLHeadingElement",
  21147. "HTMLHtmlElement",
  21148. "HTMLIFrameElement",
  21149. "HTMLImageElement",
  21150. "HTMLInputElement",
  21151. "HTMLIsIndexElement",
  21152. "HTMLKeygenElement",
  21153. "HTMLLIElement",
  21154. "HTMLLabelElement",
  21155. "HTMLLegendElement",
  21156. "HTMLLinkElement",
  21157. "HTMLMapElement",
  21158. "HTMLMarqueeElement",
  21159. "HTMLMediaElement",
  21160. "HTMLMenuElement",
  21161. "HTMLMenuItemElement",
  21162. "HTMLMetaElement",
  21163. "HTMLMeterElement",
  21164. "HTMLModElement",
  21165. "HTMLOListElement",
  21166. "HTMLObjectElement",
  21167. "HTMLOptGroupElement",
  21168. "HTMLOptionElement",
  21169. "HTMLOptionsCollection",
  21170. "HTMLOutputElement",
  21171. "HTMLParagraphElement",
  21172. "HTMLParamElement",
  21173. "HTMLPictureElement",
  21174. "HTMLPreElement",
  21175. "HTMLProgressElement",
  21176. "HTMLPropertiesCollection",
  21177. "HTMLQuoteElement",
  21178. "HTMLScriptElement",
  21179. "HTMLSelectElement",
  21180. "HTMLShadowElement",
  21181. "HTMLSlotElement",
  21182. "HTMLSourceElement",
  21183. "HTMLSpanElement",
  21184. "HTMLStyleElement",
  21185. "HTMLTableCaptionElement",
  21186. "HTMLTableCellElement",
  21187. "HTMLTableColElement",
  21188. "HTMLTableElement",
  21189. "HTMLTableRowElement",
  21190. "HTMLTableSectionElement",
  21191. "HTMLTemplateElement",
  21192. "HTMLTextAreaElement",
  21193. "HTMLTimeElement",
  21194. "HTMLTitleElement",
  21195. "HTMLTrackElement",
  21196. "HTMLUListElement",
  21197. "HTMLUnknownElement",
  21198. "HTMLVideoElement",
  21199. "HashChangeEvent",
  21200. "Headers",
  21201. "History",
  21202. "Hz",
  21203. "ICE_CHECKING",
  21204. "ICE_CLOSED",
  21205. "ICE_COMPLETED",
  21206. "ICE_CONNECTED",
  21207. "ICE_FAILED",
  21208. "ICE_GATHERING",
  21209. "ICE_WAITING",
  21210. "IDBCursor",
  21211. "IDBCursorWithValue",
  21212. "IDBDatabase",
  21213. "IDBDatabaseException",
  21214. "IDBFactory",
  21215. "IDBFileHandle",
  21216. "IDBFileRequest",
  21217. "IDBIndex",
  21218. "IDBKeyRange",
  21219. "IDBMutableFile",
  21220. "IDBObjectStore",
  21221. "IDBOpenDBRequest",
  21222. "IDBRequest",
  21223. "IDBTransaction",
  21224. "IDBVersionChangeEvent",
  21225. "IDLE",
  21226. "IIRFilterNode",
  21227. "IMPLEMENTATION_COLOR_READ_FORMAT",
  21228. "IMPLEMENTATION_COLOR_READ_TYPE",
  21229. "IMPORT_RULE",
  21230. "INCR",
  21231. "INCR_WRAP",
  21232. "INDEX_SIZE_ERR",
  21233. "INT",
  21234. "INTERLEAVED_ATTRIBS",
  21235. "INT_2_10_10_10_REV",
  21236. "INT_SAMPLER_2D",
  21237. "INT_SAMPLER_2D_ARRAY",
  21238. "INT_SAMPLER_3D",
  21239. "INT_SAMPLER_CUBE",
  21240. "INT_VEC2",
  21241. "INT_VEC3",
  21242. "INT_VEC4",
  21243. "INUSE_ATTRIBUTE_ERR",
  21244. "INVALID_ACCESS_ERR",
  21245. "INVALID_CHARACTER_ERR",
  21246. "INVALID_ENUM",
  21247. "INVALID_EXPRESSION_ERR",
  21248. "INVALID_FRAMEBUFFER_OPERATION",
  21249. "INVALID_INDEX",
  21250. "INVALID_MODIFICATION_ERR",
  21251. "INVALID_NODE_TYPE_ERR",
  21252. "INVALID_OPERATION",
  21253. "INVALID_STATE_ERR",
  21254. "INVALID_VALUE",
  21255. "INVERSE_DISTANCE",
  21256. "INVERT",
  21257. "IceCandidate",
  21258. "IdleDeadline",
  21259. "Image",
  21260. "ImageBitmap",
  21261. "ImageBitmapRenderingContext",
  21262. "ImageCapture",
  21263. "ImageData",
  21264. "Infinity",
  21265. "InputDeviceCapabilities",
  21266. "InputDeviceInfo",
  21267. "InputEvent",
  21268. "InputMethodContext",
  21269. "InstallTrigger",
  21270. "InstallTriggerImpl",
  21271. "Instance",
  21272. "Int16Array",
  21273. "Int32Array",
  21274. "Int8Array",
  21275. "Intent",
  21276. "InternalError",
  21277. "IntersectionObserver",
  21278. "IntersectionObserverEntry",
  21279. "Intl",
  21280. "IsSearchProviderInstalled",
  21281. "Iterator",
  21282. "JSON",
  21283. "KEEP",
  21284. "KEYDOWN",
  21285. "KEYFRAMES_RULE",
  21286. "KEYFRAME_RULE",
  21287. "KEYPRESS",
  21288. "KEYUP",
  21289. "KeyEvent",
  21290. "Keyboard",
  21291. "KeyboardEvent",
  21292. "KeyboardLayoutMap",
  21293. "KeyframeEffect",
  21294. "LENGTHADJUST_SPACING",
  21295. "LENGTHADJUST_SPACINGANDGLYPHS",
  21296. "LENGTHADJUST_UNKNOWN",
  21297. "LEQUAL",
  21298. "LESS",
  21299. "LINEAR",
  21300. "LINEAR_DISTANCE",
  21301. "LINEAR_MIPMAP_LINEAR",
  21302. "LINEAR_MIPMAP_NEAREST",
  21303. "LINES",
  21304. "LINE_LOOP",
  21305. "LINE_STRIP",
  21306. "LINE_WIDTH",
  21307. "LINK_STATUS",
  21308. "LIVE",
  21309. "LN10",
  21310. "LN2",
  21311. "LOADED",
  21312. "LOADING",
  21313. "LOG10E",
  21314. "LOG2E",
  21315. "LOWPASS",
  21316. "LOWSHELF",
  21317. "LOW_FLOAT",
  21318. "LOW_INT",
  21319. "LSException",
  21320. "LSParserFilter",
  21321. "LUMINANCE",
  21322. "LUMINANCE_ALPHA",
  21323. "LargestContentfulPaint",
  21324. "LayoutShift",
  21325. "LayoutShiftAttribution",
  21326. "LinearAccelerationSensor",
  21327. "LinkError",
  21328. "ListFormat",
  21329. "LocalMediaStream",
  21330. "Locale",
  21331. "Location",
  21332. "Lock",
  21333. "LockManager",
  21334. "MAX",
  21335. "MAX_3D_TEXTURE_SIZE",
  21336. "MAX_ARRAY_TEXTURE_LAYERS",
  21337. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  21338. "MAX_COLOR_ATTACHMENTS",
  21339. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  21340. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  21341. "MAX_COMBINED_UNIFORM_BLOCKS",
  21342. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  21343. "MAX_CUBE_MAP_TEXTURE_SIZE",
  21344. "MAX_DRAW_BUFFERS",
  21345. "MAX_ELEMENTS_INDICES",
  21346. "MAX_ELEMENTS_VERTICES",
  21347. "MAX_ELEMENT_INDEX",
  21348. "MAX_FRAGMENT_INPUT_COMPONENTS",
  21349. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  21350. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  21351. "MAX_FRAGMENT_UNIFORM_VECTORS",
  21352. "MAX_PROGRAM_TEXEL_OFFSET",
  21353. "MAX_RENDERBUFFER_SIZE",
  21354. "MAX_SAFE_INTEGER",
  21355. "MAX_SAMPLES",
  21356. "MAX_SERVER_WAIT_TIMEOUT",
  21357. "MAX_TEXTURE_IMAGE_UNITS",
  21358. "MAX_TEXTURE_LOD_BIAS",
  21359. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  21360. "MAX_TEXTURE_SIZE",
  21361. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  21362. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  21363. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  21364. "MAX_UNIFORM_BLOCK_SIZE",
  21365. "MAX_UNIFORM_BUFFER_BINDINGS",
  21366. "MAX_VALUE",
  21367. "MAX_VARYING_COMPONENTS",
  21368. "MAX_VARYING_VECTORS",
  21369. "MAX_VERTEX_ATTRIBS",
  21370. "MAX_VERTEX_OUTPUT_COMPONENTS",
  21371. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  21372. "MAX_VERTEX_UNIFORM_BLOCKS",
  21373. "MAX_VERTEX_UNIFORM_COMPONENTS",
  21374. "MAX_VERTEX_UNIFORM_VECTORS",
  21375. "MAX_VIEWPORT_DIMS",
  21376. "MEDIA_ERR_ABORTED",
  21377. "MEDIA_ERR_DECODE",
  21378. "MEDIA_ERR_ENCRYPTED",
  21379. "MEDIA_ERR_NETWORK",
  21380. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  21381. "MEDIA_KEYERR_CLIENT",
  21382. "MEDIA_KEYERR_DOMAIN",
  21383. "MEDIA_KEYERR_HARDWARECHANGE",
  21384. "MEDIA_KEYERR_OUTPUT",
  21385. "MEDIA_KEYERR_SERVICE",
  21386. "MEDIA_KEYERR_UNKNOWN",
  21387. "MEDIA_RULE",
  21388. "MEDIUM_FLOAT",
  21389. "MEDIUM_INT",
  21390. "META_MASK",
  21391. "MIDIAccess",
  21392. "MIDIConnectionEvent",
  21393. "MIDIInput",
  21394. "MIDIInputMap",
  21395. "MIDIMessageEvent",
  21396. "MIDIOutput",
  21397. "MIDIOutputMap",
  21398. "MIDIPort",
  21399. "MIN",
  21400. "MIN_PROGRAM_TEXEL_OFFSET",
  21401. "MIN_SAFE_INTEGER",
  21402. "MIN_VALUE",
  21403. "MIRRORED_REPEAT",
  21404. "MODE_ASYNCHRONOUS",
  21405. "MODE_SYNCHRONOUS",
  21406. "MODIFICATION",
  21407. "MOUSEDOWN",
  21408. "MOUSEDRAG",
  21409. "MOUSEMOVE",
  21410. "MOUSEOUT",
  21411. "MOUSEOVER",
  21412. "MOUSEUP",
  21413. "MOZ_KEYFRAMES_RULE",
  21414. "MOZ_KEYFRAME_RULE",
  21415. "MOZ_SOURCE_CURSOR",
  21416. "MOZ_SOURCE_ERASER",
  21417. "MOZ_SOURCE_KEYBOARD",
  21418. "MOZ_SOURCE_MOUSE",
  21419. "MOZ_SOURCE_PEN",
  21420. "MOZ_SOURCE_TOUCH",
  21421. "MOZ_SOURCE_UNKNOWN",
  21422. "MSGESTURE_FLAG_BEGIN",
  21423. "MSGESTURE_FLAG_CANCEL",
  21424. "MSGESTURE_FLAG_END",
  21425. "MSGESTURE_FLAG_INERTIA",
  21426. "MSGESTURE_FLAG_NONE",
  21427. "MSPOINTER_TYPE_MOUSE",
  21428. "MSPOINTER_TYPE_PEN",
  21429. "MSPOINTER_TYPE_TOUCH",
  21430. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  21431. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  21432. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  21433. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  21434. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  21435. "MS_ASYNC_OP_STATUS_CANCELED",
  21436. "MS_ASYNC_OP_STATUS_ERROR",
  21437. "MS_ASYNC_OP_STATUS_SUCCESS",
  21438. "MS_MANIPULATION_STATE_ACTIVE",
  21439. "MS_MANIPULATION_STATE_CANCELLED",
  21440. "MS_MANIPULATION_STATE_COMMITTED",
  21441. "MS_MANIPULATION_STATE_DRAGGING",
  21442. "MS_MANIPULATION_STATE_INERTIA",
  21443. "MS_MANIPULATION_STATE_PRESELECT",
  21444. "MS_MANIPULATION_STATE_SELECTING",
  21445. "MS_MANIPULATION_STATE_STOPPED",
  21446. "MS_MEDIA_ERR_ENCRYPTED",
  21447. "MS_MEDIA_KEYERR_CLIENT",
  21448. "MS_MEDIA_KEYERR_DOMAIN",
  21449. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  21450. "MS_MEDIA_KEYERR_OUTPUT",
  21451. "MS_MEDIA_KEYERR_SERVICE",
  21452. "MS_MEDIA_KEYERR_UNKNOWN",
  21453. "Map",
  21454. "Math",
  21455. "MathMLElement",
  21456. "MediaCapabilities",
  21457. "MediaCapabilitiesInfo",
  21458. "MediaController",
  21459. "MediaDeviceInfo",
  21460. "MediaDevices",
  21461. "MediaElementAudioSourceNode",
  21462. "MediaEncryptedEvent",
  21463. "MediaError",
  21464. "MediaKeyError",
  21465. "MediaKeyEvent",
  21466. "MediaKeyMessageEvent",
  21467. "MediaKeyNeededEvent",
  21468. "MediaKeySession",
  21469. "MediaKeyStatusMap",
  21470. "MediaKeySystemAccess",
  21471. "MediaKeys",
  21472. "MediaList",
  21473. "MediaMetadata",
  21474. "MediaQueryList",
  21475. "MediaQueryListEvent",
  21476. "MediaRecorder",
  21477. "MediaRecorderErrorEvent",
  21478. "MediaSession",
  21479. "MediaSettingsRange",
  21480. "MediaSource",
  21481. "MediaStream",
  21482. "MediaStreamAudioDestinationNode",
  21483. "MediaStreamAudioSourceNode",
  21484. "MediaStreamEvent",
  21485. "MediaStreamTrack",
  21486. "MediaStreamTrackAudioSourceNode",
  21487. "MediaStreamTrackEvent",
  21488. "Memory",
  21489. "MessageChannel",
  21490. "MessageEvent",
  21491. "MessagePort",
  21492. "Methods",
  21493. "MimeType",
  21494. "MimeTypeArray",
  21495. "Module",
  21496. "MouseEvent",
  21497. "MouseScrollEvent",
  21498. "MozAnimation",
  21499. "MozAnimationDelay",
  21500. "MozAnimationDirection",
  21501. "MozAnimationDuration",
  21502. "MozAnimationFillMode",
  21503. "MozAnimationIterationCount",
  21504. "MozAnimationName",
  21505. "MozAnimationPlayState",
  21506. "MozAnimationTimingFunction",
  21507. "MozAppearance",
  21508. "MozBackfaceVisibility",
  21509. "MozBinding",
  21510. "MozBorderBottomColors",
  21511. "MozBorderEnd",
  21512. "MozBorderEndColor",
  21513. "MozBorderEndStyle",
  21514. "MozBorderEndWidth",
  21515. "MozBorderImage",
  21516. "MozBorderLeftColors",
  21517. "MozBorderRightColors",
  21518. "MozBorderStart",
  21519. "MozBorderStartColor",
  21520. "MozBorderStartStyle",
  21521. "MozBorderStartWidth",
  21522. "MozBorderTopColors",
  21523. "MozBoxAlign",
  21524. "MozBoxDirection",
  21525. "MozBoxFlex",
  21526. "MozBoxOrdinalGroup",
  21527. "MozBoxOrient",
  21528. "MozBoxPack",
  21529. "MozBoxSizing",
  21530. "MozCSSKeyframeRule",
  21531. "MozCSSKeyframesRule",
  21532. "MozColumnCount",
  21533. "MozColumnFill",
  21534. "MozColumnGap",
  21535. "MozColumnRule",
  21536. "MozColumnRuleColor",
  21537. "MozColumnRuleStyle",
  21538. "MozColumnRuleWidth",
  21539. "MozColumnWidth",
  21540. "MozColumns",
  21541. "MozContactChangeEvent",
  21542. "MozFloatEdge",
  21543. "MozFontFeatureSettings",
  21544. "MozFontLanguageOverride",
  21545. "MozForceBrokenImageIcon",
  21546. "MozHyphens",
  21547. "MozImageRegion",
  21548. "MozMarginEnd",
  21549. "MozMarginStart",
  21550. "MozMmsEvent",
  21551. "MozMmsMessage",
  21552. "MozMobileMessageThread",
  21553. "MozOSXFontSmoothing",
  21554. "MozOrient",
  21555. "MozOsxFontSmoothing",
  21556. "MozOutlineRadius",
  21557. "MozOutlineRadiusBottomleft",
  21558. "MozOutlineRadiusBottomright",
  21559. "MozOutlineRadiusTopleft",
  21560. "MozOutlineRadiusTopright",
  21561. "MozPaddingEnd",
  21562. "MozPaddingStart",
  21563. "MozPerspective",
  21564. "MozPerspectiveOrigin",
  21565. "MozPowerManager",
  21566. "MozSettingsEvent",
  21567. "MozSmsEvent",
  21568. "MozSmsMessage",
  21569. "MozStackSizing",
  21570. "MozTabSize",
  21571. "MozTextAlignLast",
  21572. "MozTextDecorationColor",
  21573. "MozTextDecorationLine",
  21574. "MozTextDecorationStyle",
  21575. "MozTextSizeAdjust",
  21576. "MozTransform",
  21577. "MozTransformOrigin",
  21578. "MozTransformStyle",
  21579. "MozTransition",
  21580. "MozTransitionDelay",
  21581. "MozTransitionDuration",
  21582. "MozTransitionProperty",
  21583. "MozTransitionTimingFunction",
  21584. "MozUserFocus",
  21585. "MozUserInput",
  21586. "MozUserModify",
  21587. "MozUserSelect",
  21588. "MozWindowDragging",
  21589. "MozWindowShadow",
  21590. "MutationEvent",
  21591. "MutationObserver",
  21592. "MutationRecord",
  21593. "NAMESPACE_ERR",
  21594. "NAMESPACE_RULE",
  21595. "NEAREST",
  21596. "NEAREST_MIPMAP_LINEAR",
  21597. "NEAREST_MIPMAP_NEAREST",
  21598. "NEGATIVE_INFINITY",
  21599. "NETWORK_EMPTY",
  21600. "NETWORK_ERR",
  21601. "NETWORK_IDLE",
  21602. "NETWORK_LOADED",
  21603. "NETWORK_LOADING",
  21604. "NETWORK_NO_SOURCE",
  21605. "NEVER",
  21606. "NEW",
  21607. "NEXT",
  21608. "NEXT_NO_DUPLICATE",
  21609. "NICEST",
  21610. "NODE_AFTER",
  21611. "NODE_BEFORE",
  21612. "NODE_BEFORE_AND_AFTER",
  21613. "NODE_INSIDE",
  21614. "NONE",
  21615. "NON_TRANSIENT_ERR",
  21616. "NOTATION_NODE",
  21617. "NOTCH",
  21618. "NOTEQUAL",
  21619. "NOT_ALLOWED_ERR",
  21620. "NOT_FOUND_ERR",
  21621. "NOT_READABLE_ERR",
  21622. "NOT_SUPPORTED_ERR",
  21623. "NO_DATA_ALLOWED_ERR",
  21624. "NO_ERR",
  21625. "NO_ERROR",
  21626. "NO_MODIFICATION_ALLOWED_ERR",
  21627. "NUMBER_TYPE",
  21628. "NUM_COMPRESSED_TEXTURE_FORMATS",
  21629. "NaN",
  21630. "NamedNodeMap",
  21631. "NavigationPreloadManager",
  21632. "Navigator",
  21633. "NearbyLinks",
  21634. "NetworkInformation",
  21635. "Node",
  21636. "NodeFilter",
  21637. "NodeIterator",
  21638. "NodeList",
  21639. "Notation",
  21640. "Notification",
  21641. "NotifyPaintEvent",
  21642. "Number",
  21643. "NumberFormat",
  21644. "OBJECT_TYPE",
  21645. "OBSOLETE",
  21646. "OK",
  21647. "ONE",
  21648. "ONE_MINUS_CONSTANT_ALPHA",
  21649. "ONE_MINUS_CONSTANT_COLOR",
  21650. "ONE_MINUS_DST_ALPHA",
  21651. "ONE_MINUS_DST_COLOR",
  21652. "ONE_MINUS_SRC_ALPHA",
  21653. "ONE_MINUS_SRC_COLOR",
  21654. "OPEN",
  21655. "OPENED",
  21656. "OPENING",
  21657. "ORDERED_NODE_ITERATOR_TYPE",
  21658. "ORDERED_NODE_SNAPSHOT_TYPE",
  21659. "OTHER_ERROR",
  21660. "OUT_OF_MEMORY",
  21661. "Object",
  21662. "OfflineAudioCompletionEvent",
  21663. "OfflineAudioContext",
  21664. "OfflineResourceList",
  21665. "OffscreenCanvas",
  21666. "OffscreenCanvasRenderingContext2D",
  21667. "Option",
  21668. "OrientationSensor",
  21669. "OscillatorNode",
  21670. "OverconstrainedError",
  21671. "OverflowEvent",
  21672. "PACK_ALIGNMENT",
  21673. "PACK_ROW_LENGTH",
  21674. "PACK_SKIP_PIXELS",
  21675. "PACK_SKIP_ROWS",
  21676. "PAGE_RULE",
  21677. "PARSE_ERR",
  21678. "PATHSEG_ARC_ABS",
  21679. "PATHSEG_ARC_REL",
  21680. "PATHSEG_CLOSEPATH",
  21681. "PATHSEG_CURVETO_CUBIC_ABS",
  21682. "PATHSEG_CURVETO_CUBIC_REL",
  21683. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  21684. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  21685. "PATHSEG_CURVETO_QUADRATIC_ABS",
  21686. "PATHSEG_CURVETO_QUADRATIC_REL",
  21687. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  21688. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  21689. "PATHSEG_LINETO_ABS",
  21690. "PATHSEG_LINETO_HORIZONTAL_ABS",
  21691. "PATHSEG_LINETO_HORIZONTAL_REL",
  21692. "PATHSEG_LINETO_REL",
  21693. "PATHSEG_LINETO_VERTICAL_ABS",
  21694. "PATHSEG_LINETO_VERTICAL_REL",
  21695. "PATHSEG_MOVETO_ABS",
  21696. "PATHSEG_MOVETO_REL",
  21697. "PATHSEG_UNKNOWN",
  21698. "PATH_EXISTS_ERR",
  21699. "PEAKING",
  21700. "PERMISSION_DENIED",
  21701. "PERSISTENT",
  21702. "PI",
  21703. "PIXEL_PACK_BUFFER",
  21704. "PIXEL_PACK_BUFFER_BINDING",
  21705. "PIXEL_UNPACK_BUFFER",
  21706. "PIXEL_UNPACK_BUFFER_BINDING",
  21707. "PLAYING_STATE",
  21708. "POINTS",
  21709. "POLYGON_OFFSET_FACTOR",
  21710. "POLYGON_OFFSET_FILL",
  21711. "POLYGON_OFFSET_UNITS",
  21712. "POSITION_UNAVAILABLE",
  21713. "POSITIVE_INFINITY",
  21714. "PREV",
  21715. "PREV_NO_DUPLICATE",
  21716. "PROCESSING_INSTRUCTION_NODE",
  21717. "PageChangeEvent",
  21718. "PageTransitionEvent",
  21719. "PaintRequest",
  21720. "PaintRequestList",
  21721. "PannerNode",
  21722. "PasswordCredential",
  21723. "Path2D",
  21724. "PaymentAddress",
  21725. "PaymentInstruments",
  21726. "PaymentManager",
  21727. "PaymentMethodChangeEvent",
  21728. "PaymentRequest",
  21729. "PaymentRequestUpdateEvent",
  21730. "PaymentResponse",
  21731. "Performance",
  21732. "PerformanceElementTiming",
  21733. "PerformanceEntry",
  21734. "PerformanceEventTiming",
  21735. "PerformanceLongTaskTiming",
  21736. "PerformanceMark",
  21737. "PerformanceMeasure",
  21738. "PerformanceNavigation",
  21739. "PerformanceNavigationTiming",
  21740. "PerformanceObserver",
  21741. "PerformanceObserverEntryList",
  21742. "PerformancePaintTiming",
  21743. "PerformanceResourceTiming",
  21744. "PerformanceServerTiming",
  21745. "PerformanceTiming",
  21746. "PeriodicSyncManager",
  21747. "PeriodicWave",
  21748. "PermissionStatus",
  21749. "Permissions",
  21750. "PhotoCapabilities",
  21751. "PictureInPictureWindow",
  21752. "Plugin",
  21753. "PluginArray",
  21754. "PluralRules",
  21755. "PointerEvent",
  21756. "PopStateEvent",
  21757. "PopupBlockedEvent",
  21758. "Presentation",
  21759. "PresentationAvailability",
  21760. "PresentationConnection",
  21761. "PresentationConnectionAvailableEvent",
  21762. "PresentationConnectionCloseEvent",
  21763. "PresentationConnectionList",
  21764. "PresentationReceiver",
  21765. "PresentationRequest",
  21766. "ProcessingInstruction",
  21767. "ProgressEvent",
  21768. "Promise",
  21769. "PromiseRejectionEvent",
  21770. "PropertyNodeList",
  21771. "Proxy",
  21772. "PublicKeyCredential",
  21773. "PushManager",
  21774. "PushSubscription",
  21775. "PushSubscriptionOptions",
  21776. "Q",
  21777. "QUERY_RESULT",
  21778. "QUERY_RESULT_AVAILABLE",
  21779. "QUOTA_ERR",
  21780. "QUOTA_EXCEEDED_ERR",
  21781. "QueryInterface",
  21782. "R11F_G11F_B10F",
  21783. "R16F",
  21784. "R16I",
  21785. "R16UI",
  21786. "R32F",
  21787. "R32I",
  21788. "R32UI",
  21789. "R8",
  21790. "R8I",
  21791. "R8UI",
  21792. "R8_SNORM",
  21793. "RASTERIZER_DISCARD",
  21794. "READ_BUFFER",
  21795. "READ_FRAMEBUFFER",
  21796. "READ_FRAMEBUFFER_BINDING",
  21797. "READ_ONLY",
  21798. "READ_ONLY_ERR",
  21799. "READ_WRITE",
  21800. "RED",
  21801. "RED_BITS",
  21802. "RED_INTEGER",
  21803. "REMOVAL",
  21804. "RENDERBUFFER",
  21805. "RENDERBUFFER_ALPHA_SIZE",
  21806. "RENDERBUFFER_BINDING",
  21807. "RENDERBUFFER_BLUE_SIZE",
  21808. "RENDERBUFFER_DEPTH_SIZE",
  21809. "RENDERBUFFER_GREEN_SIZE",
  21810. "RENDERBUFFER_HEIGHT",
  21811. "RENDERBUFFER_INTERNAL_FORMAT",
  21812. "RENDERBUFFER_RED_SIZE",
  21813. "RENDERBUFFER_SAMPLES",
  21814. "RENDERBUFFER_STENCIL_SIZE",
  21815. "RENDERBUFFER_WIDTH",
  21816. "RENDERER",
  21817. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  21818. "RENDERING_INTENT_AUTO",
  21819. "RENDERING_INTENT_PERCEPTUAL",
  21820. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  21821. "RENDERING_INTENT_SATURATION",
  21822. "RENDERING_INTENT_UNKNOWN",
  21823. "REPEAT",
  21824. "REPLACE",
  21825. "RG",
  21826. "RG16F",
  21827. "RG16I",
  21828. "RG16UI",
  21829. "RG32F",
  21830. "RG32I",
  21831. "RG32UI",
  21832. "RG8",
  21833. "RG8I",
  21834. "RG8UI",
  21835. "RG8_SNORM",
  21836. "RGB",
  21837. "RGB10_A2",
  21838. "RGB10_A2UI",
  21839. "RGB16F",
  21840. "RGB16I",
  21841. "RGB16UI",
  21842. "RGB32F",
  21843. "RGB32I",
  21844. "RGB32UI",
  21845. "RGB565",
  21846. "RGB5_A1",
  21847. "RGB8",
  21848. "RGB8I",
  21849. "RGB8UI",
  21850. "RGB8_SNORM",
  21851. "RGB9_E5",
  21852. "RGBA",
  21853. "RGBA16F",
  21854. "RGBA16I",
  21855. "RGBA16UI",
  21856. "RGBA32F",
  21857. "RGBA32I",
  21858. "RGBA32UI",
  21859. "RGBA4",
  21860. "RGBA8",
  21861. "RGBA8I",
  21862. "RGBA8UI",
  21863. "RGBA8_SNORM",
  21864. "RGBA_INTEGER",
  21865. "RGBColor",
  21866. "RGB_INTEGER",
  21867. "RG_INTEGER",
  21868. "ROTATION_CLOCKWISE",
  21869. "ROTATION_COUNTERCLOCKWISE",
  21870. "RTCCertificate",
  21871. "RTCDTMFSender",
  21872. "RTCDTMFToneChangeEvent",
  21873. "RTCDataChannel",
  21874. "RTCDataChannelEvent",
  21875. "RTCDtlsTransport",
  21876. "RTCError",
  21877. "RTCErrorEvent",
  21878. "RTCIceCandidate",
  21879. "RTCIceTransport",
  21880. "RTCPeerConnection",
  21881. "RTCPeerConnectionIceErrorEvent",
  21882. "RTCPeerConnectionIceEvent",
  21883. "RTCRtpReceiver",
  21884. "RTCRtpSender",
  21885. "RTCRtpTransceiver",
  21886. "RTCSctpTransport",
  21887. "RTCSessionDescription",
  21888. "RTCStatsReport",
  21889. "RTCTrackEvent",
  21890. "RadioNodeList",
  21891. "Range",
  21892. "RangeError",
  21893. "RangeException",
  21894. "ReadableStream",
  21895. "ReadableStreamDefaultReader",
  21896. "RecordErrorEvent",
  21897. "Rect",
  21898. "ReferenceError",
  21899. "Reflect",
  21900. "RegExp",
  21901. "RelativeOrientationSensor",
  21902. "RelativeTimeFormat",
  21903. "RemotePlayback",
  21904. "Report",
  21905. "ReportBody",
  21906. "ReportingObserver",
  21907. "Request",
  21908. "ResizeObserver",
  21909. "ResizeObserverEntry",
  21910. "ResizeObserverSize",
  21911. "Response",
  21912. "RuntimeError",
  21913. "SAMPLER_2D",
  21914. "SAMPLER_2D_ARRAY",
  21915. "SAMPLER_2D_ARRAY_SHADOW",
  21916. "SAMPLER_2D_SHADOW",
  21917. "SAMPLER_3D",
  21918. "SAMPLER_BINDING",
  21919. "SAMPLER_CUBE",
  21920. "SAMPLER_CUBE_SHADOW",
  21921. "SAMPLES",
  21922. "SAMPLE_ALPHA_TO_COVERAGE",
  21923. "SAMPLE_BUFFERS",
  21924. "SAMPLE_COVERAGE",
  21925. "SAMPLE_COVERAGE_INVERT",
  21926. "SAMPLE_COVERAGE_VALUE",
  21927. "SAWTOOTH",
  21928. "SCHEDULED_STATE",
  21929. "SCISSOR_BOX",
  21930. "SCISSOR_TEST",
  21931. "SCROLL_PAGE_DOWN",
  21932. "SCROLL_PAGE_UP",
  21933. "SDP_ANSWER",
  21934. "SDP_OFFER",
  21935. "SDP_PRANSWER",
  21936. "SECURITY_ERR",
  21937. "SELECT",
  21938. "SEPARATE_ATTRIBS",
  21939. "SERIALIZE_ERR",
  21940. "SEVERITY_ERROR",
  21941. "SEVERITY_FATAL_ERROR",
  21942. "SEVERITY_WARNING",
  21943. "SHADER_COMPILER",
  21944. "SHADER_TYPE",
  21945. "SHADING_LANGUAGE_VERSION",
  21946. "SHIFT_MASK",
  21947. "SHORT",
  21948. "SHOWING",
  21949. "SHOW_ALL",
  21950. "SHOW_ATTRIBUTE",
  21951. "SHOW_CDATA_SECTION",
  21952. "SHOW_COMMENT",
  21953. "SHOW_DOCUMENT",
  21954. "SHOW_DOCUMENT_FRAGMENT",
  21955. "SHOW_DOCUMENT_TYPE",
  21956. "SHOW_ELEMENT",
  21957. "SHOW_ENTITY",
  21958. "SHOW_ENTITY_REFERENCE",
  21959. "SHOW_NOTATION",
  21960. "SHOW_PROCESSING_INSTRUCTION",
  21961. "SHOW_TEXT",
  21962. "SIGNALED",
  21963. "SIGNED_NORMALIZED",
  21964. "SINE",
  21965. "SOUNDFIELD",
  21966. "SQLException",
  21967. "SQRT1_2",
  21968. "SQRT2",
  21969. "SQUARE",
  21970. "SRC_ALPHA",
  21971. "SRC_ALPHA_SATURATE",
  21972. "SRC_COLOR",
  21973. "SRGB",
  21974. "SRGB8",
  21975. "SRGB8_ALPHA8",
  21976. "START_TO_END",
  21977. "START_TO_START",
  21978. "STATIC_COPY",
  21979. "STATIC_DRAW",
  21980. "STATIC_READ",
  21981. "STENCIL",
  21982. "STENCIL_ATTACHMENT",
  21983. "STENCIL_BACK_FAIL",
  21984. "STENCIL_BACK_FUNC",
  21985. "STENCIL_BACK_PASS_DEPTH_FAIL",
  21986. "STENCIL_BACK_PASS_DEPTH_PASS",
  21987. "STENCIL_BACK_REF",
  21988. "STENCIL_BACK_VALUE_MASK",
  21989. "STENCIL_BACK_WRITEMASK",
  21990. "STENCIL_BITS",
  21991. "STENCIL_BUFFER_BIT",
  21992. "STENCIL_CLEAR_VALUE",
  21993. "STENCIL_FAIL",
  21994. "STENCIL_FUNC",
  21995. "STENCIL_INDEX",
  21996. "STENCIL_INDEX8",
  21997. "STENCIL_PASS_DEPTH_FAIL",
  21998. "STENCIL_PASS_DEPTH_PASS",
  21999. "STENCIL_REF",
  22000. "STENCIL_TEST",
  22001. "STENCIL_VALUE_MASK",
  22002. "STENCIL_WRITEMASK",
  22003. "STREAM_COPY",
  22004. "STREAM_DRAW",
  22005. "STREAM_READ",
  22006. "STRING_TYPE",
  22007. "STYLE_RULE",
  22008. "SUBPIXEL_BITS",
  22009. "SUPPORTS_RULE",
  22010. "SVGAElement",
  22011. "SVGAltGlyphDefElement",
  22012. "SVGAltGlyphElement",
  22013. "SVGAltGlyphItemElement",
  22014. "SVGAngle",
  22015. "SVGAnimateColorElement",
  22016. "SVGAnimateElement",
  22017. "SVGAnimateMotionElement",
  22018. "SVGAnimateTransformElement",
  22019. "SVGAnimatedAngle",
  22020. "SVGAnimatedBoolean",
  22021. "SVGAnimatedEnumeration",
  22022. "SVGAnimatedInteger",
  22023. "SVGAnimatedLength",
  22024. "SVGAnimatedLengthList",
  22025. "SVGAnimatedNumber",
  22026. "SVGAnimatedNumberList",
  22027. "SVGAnimatedPreserveAspectRatio",
  22028. "SVGAnimatedRect",
  22029. "SVGAnimatedString",
  22030. "SVGAnimatedTransformList",
  22031. "SVGAnimationElement",
  22032. "SVGCircleElement",
  22033. "SVGClipPathElement",
  22034. "SVGColor",
  22035. "SVGComponentTransferFunctionElement",
  22036. "SVGCursorElement",
  22037. "SVGDefsElement",
  22038. "SVGDescElement",
  22039. "SVGDiscardElement",
  22040. "SVGDocument",
  22041. "SVGElement",
  22042. "SVGElementInstance",
  22043. "SVGElementInstanceList",
  22044. "SVGEllipseElement",
  22045. "SVGException",
  22046. "SVGFEBlendElement",
  22047. "SVGFEColorMatrixElement",
  22048. "SVGFEComponentTransferElement",
  22049. "SVGFECompositeElement",
  22050. "SVGFEConvolveMatrixElement",
  22051. "SVGFEDiffuseLightingElement",
  22052. "SVGFEDisplacementMapElement",
  22053. "SVGFEDistantLightElement",
  22054. "SVGFEDropShadowElement",
  22055. "SVGFEFloodElement",
  22056. "SVGFEFuncAElement",
  22057. "SVGFEFuncBElement",
  22058. "SVGFEFuncGElement",
  22059. "SVGFEFuncRElement",
  22060. "SVGFEGaussianBlurElement",
  22061. "SVGFEImageElement",
  22062. "SVGFEMergeElement",
  22063. "SVGFEMergeNodeElement",
  22064. "SVGFEMorphologyElement",
  22065. "SVGFEOffsetElement",
  22066. "SVGFEPointLightElement",
  22067. "SVGFESpecularLightingElement",
  22068. "SVGFESpotLightElement",
  22069. "SVGFETileElement",
  22070. "SVGFETurbulenceElement",
  22071. "SVGFilterElement",
  22072. "SVGFontElement",
  22073. "SVGFontFaceElement",
  22074. "SVGFontFaceFormatElement",
  22075. "SVGFontFaceNameElement",
  22076. "SVGFontFaceSrcElement",
  22077. "SVGFontFaceUriElement",
  22078. "SVGForeignObjectElement",
  22079. "SVGGElement",
  22080. "SVGGeometryElement",
  22081. "SVGGlyphElement",
  22082. "SVGGlyphRefElement",
  22083. "SVGGradientElement",
  22084. "SVGGraphicsElement",
  22085. "SVGHKernElement",
  22086. "SVGImageElement",
  22087. "SVGLength",
  22088. "SVGLengthList",
  22089. "SVGLineElement",
  22090. "SVGLinearGradientElement",
  22091. "SVGMPathElement",
  22092. "SVGMarkerElement",
  22093. "SVGMaskElement",
  22094. "SVGMatrix",
  22095. "SVGMetadataElement",
  22096. "SVGMissingGlyphElement",
  22097. "SVGNumber",
  22098. "SVGNumberList",
  22099. "SVGPaint",
  22100. "SVGPathElement",
  22101. "SVGPathSeg",
  22102. "SVGPathSegArcAbs",
  22103. "SVGPathSegArcRel",
  22104. "SVGPathSegClosePath",
  22105. "SVGPathSegCurvetoCubicAbs",
  22106. "SVGPathSegCurvetoCubicRel",
  22107. "SVGPathSegCurvetoCubicSmoothAbs",
  22108. "SVGPathSegCurvetoCubicSmoothRel",
  22109. "SVGPathSegCurvetoQuadraticAbs",
  22110. "SVGPathSegCurvetoQuadraticRel",
  22111. "SVGPathSegCurvetoQuadraticSmoothAbs",
  22112. "SVGPathSegCurvetoQuadraticSmoothRel",
  22113. "SVGPathSegLinetoAbs",
  22114. "SVGPathSegLinetoHorizontalAbs",
  22115. "SVGPathSegLinetoHorizontalRel",
  22116. "SVGPathSegLinetoRel",
  22117. "SVGPathSegLinetoVerticalAbs",
  22118. "SVGPathSegLinetoVerticalRel",
  22119. "SVGPathSegList",
  22120. "SVGPathSegMovetoAbs",
  22121. "SVGPathSegMovetoRel",
  22122. "SVGPatternElement",
  22123. "SVGPoint",
  22124. "SVGPointList",
  22125. "SVGPolygonElement",
  22126. "SVGPolylineElement",
  22127. "SVGPreserveAspectRatio",
  22128. "SVGRadialGradientElement",
  22129. "SVGRect",
  22130. "SVGRectElement",
  22131. "SVGRenderingIntent",
  22132. "SVGSVGElement",
  22133. "SVGScriptElement",
  22134. "SVGSetElement",
  22135. "SVGStopElement",
  22136. "SVGStringList",
  22137. "SVGStyleElement",
  22138. "SVGSwitchElement",
  22139. "SVGSymbolElement",
  22140. "SVGTRefElement",
  22141. "SVGTSpanElement",
  22142. "SVGTextContentElement",
  22143. "SVGTextElement",
  22144. "SVGTextPathElement",
  22145. "SVGTextPositioningElement",
  22146. "SVGTitleElement",
  22147. "SVGTransform",
  22148. "SVGTransformList",
  22149. "SVGUnitTypes",
  22150. "SVGUseElement",
  22151. "SVGVKernElement",
  22152. "SVGViewElement",
  22153. "SVGViewSpec",
  22154. "SVGZoomAndPan",
  22155. "SVGZoomEvent",
  22156. "SVG_ANGLETYPE_DEG",
  22157. "SVG_ANGLETYPE_GRAD",
  22158. "SVG_ANGLETYPE_RAD",
  22159. "SVG_ANGLETYPE_UNKNOWN",
  22160. "SVG_ANGLETYPE_UNSPECIFIED",
  22161. "SVG_CHANNEL_A",
  22162. "SVG_CHANNEL_B",
  22163. "SVG_CHANNEL_G",
  22164. "SVG_CHANNEL_R",
  22165. "SVG_CHANNEL_UNKNOWN",
  22166. "SVG_COLORTYPE_CURRENTCOLOR",
  22167. "SVG_COLORTYPE_RGBCOLOR",
  22168. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  22169. "SVG_COLORTYPE_UNKNOWN",
  22170. "SVG_EDGEMODE_DUPLICATE",
  22171. "SVG_EDGEMODE_NONE",
  22172. "SVG_EDGEMODE_UNKNOWN",
  22173. "SVG_EDGEMODE_WRAP",
  22174. "SVG_FEBLEND_MODE_COLOR",
  22175. "SVG_FEBLEND_MODE_COLOR_BURN",
  22176. "SVG_FEBLEND_MODE_COLOR_DODGE",
  22177. "SVG_FEBLEND_MODE_DARKEN",
  22178. "SVG_FEBLEND_MODE_DIFFERENCE",
  22179. "SVG_FEBLEND_MODE_EXCLUSION",
  22180. "SVG_FEBLEND_MODE_HARD_LIGHT",
  22181. "SVG_FEBLEND_MODE_HUE",
  22182. "SVG_FEBLEND_MODE_LIGHTEN",
  22183. "SVG_FEBLEND_MODE_LUMINOSITY",
  22184. "SVG_FEBLEND_MODE_MULTIPLY",
  22185. "SVG_FEBLEND_MODE_NORMAL",
  22186. "SVG_FEBLEND_MODE_OVERLAY",
  22187. "SVG_FEBLEND_MODE_SATURATION",
  22188. "SVG_FEBLEND_MODE_SCREEN",
  22189. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  22190. "SVG_FEBLEND_MODE_UNKNOWN",
  22191. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  22192. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  22193. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  22194. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  22195. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  22196. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  22197. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  22198. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  22199. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  22200. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  22201. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  22202. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  22203. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  22204. "SVG_FECOMPOSITE_OPERATOR_IN",
  22205. "SVG_FECOMPOSITE_OPERATOR_OUT",
  22206. "SVG_FECOMPOSITE_OPERATOR_OVER",
  22207. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  22208. "SVG_FECOMPOSITE_OPERATOR_XOR",
  22209. "SVG_INVALID_VALUE_ERR",
  22210. "SVG_LENGTHTYPE_CM",
  22211. "SVG_LENGTHTYPE_EMS",
  22212. "SVG_LENGTHTYPE_EXS",
  22213. "SVG_LENGTHTYPE_IN",
  22214. "SVG_LENGTHTYPE_MM",
  22215. "SVG_LENGTHTYPE_NUMBER",
  22216. "SVG_LENGTHTYPE_PC",
  22217. "SVG_LENGTHTYPE_PERCENTAGE",
  22218. "SVG_LENGTHTYPE_PT",
  22219. "SVG_LENGTHTYPE_PX",
  22220. "SVG_LENGTHTYPE_UNKNOWN",
  22221. "SVG_MARKERUNITS_STROKEWIDTH",
  22222. "SVG_MARKERUNITS_UNKNOWN",
  22223. "SVG_MARKERUNITS_USERSPACEONUSE",
  22224. "SVG_MARKER_ORIENT_ANGLE",
  22225. "SVG_MARKER_ORIENT_AUTO",
  22226. "SVG_MARKER_ORIENT_UNKNOWN",
  22227. "SVG_MASKTYPE_ALPHA",
  22228. "SVG_MASKTYPE_LUMINANCE",
  22229. "SVG_MATRIX_NOT_INVERTABLE",
  22230. "SVG_MEETORSLICE_MEET",
  22231. "SVG_MEETORSLICE_SLICE",
  22232. "SVG_MEETORSLICE_UNKNOWN",
  22233. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  22234. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  22235. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  22236. "SVG_PAINTTYPE_CURRENTCOLOR",
  22237. "SVG_PAINTTYPE_NONE",
  22238. "SVG_PAINTTYPE_RGBCOLOR",
  22239. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  22240. "SVG_PAINTTYPE_UNKNOWN",
  22241. "SVG_PAINTTYPE_URI",
  22242. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  22243. "SVG_PAINTTYPE_URI_NONE",
  22244. "SVG_PAINTTYPE_URI_RGBCOLOR",
  22245. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  22246. "SVG_PRESERVEASPECTRATIO_NONE",
  22247. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  22248. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  22249. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  22250. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  22251. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  22252. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  22253. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  22254. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  22255. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  22256. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  22257. "SVG_SPREADMETHOD_PAD",
  22258. "SVG_SPREADMETHOD_REFLECT",
  22259. "SVG_SPREADMETHOD_REPEAT",
  22260. "SVG_SPREADMETHOD_UNKNOWN",
  22261. "SVG_STITCHTYPE_NOSTITCH",
  22262. "SVG_STITCHTYPE_STITCH",
  22263. "SVG_STITCHTYPE_UNKNOWN",
  22264. "SVG_TRANSFORM_MATRIX",
  22265. "SVG_TRANSFORM_ROTATE",
  22266. "SVG_TRANSFORM_SCALE",
  22267. "SVG_TRANSFORM_SKEWX",
  22268. "SVG_TRANSFORM_SKEWY",
  22269. "SVG_TRANSFORM_TRANSLATE",
  22270. "SVG_TRANSFORM_UNKNOWN",
  22271. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  22272. "SVG_TURBULENCE_TYPE_TURBULENCE",
  22273. "SVG_TURBULENCE_TYPE_UNKNOWN",
  22274. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  22275. "SVG_UNIT_TYPE_UNKNOWN",
  22276. "SVG_UNIT_TYPE_USERSPACEONUSE",
  22277. "SVG_WRONG_TYPE_ERR",
  22278. "SVG_ZOOMANDPAN_DISABLE",
  22279. "SVG_ZOOMANDPAN_MAGNIFY",
  22280. "SVG_ZOOMANDPAN_UNKNOWN",
  22281. "SYNC_CONDITION",
  22282. "SYNC_FENCE",
  22283. "SYNC_FLAGS",
  22284. "SYNC_FLUSH_COMMANDS_BIT",
  22285. "SYNC_GPU_COMMANDS_COMPLETE",
  22286. "SYNC_STATUS",
  22287. "SYNTAX_ERR",
  22288. "SavedPages",
  22289. "Screen",
  22290. "ScreenOrientation",
  22291. "Script",
  22292. "ScriptProcessorNode",
  22293. "ScrollAreaEvent",
  22294. "SecurityPolicyViolationEvent",
  22295. "Selection",
  22296. "Sensor",
  22297. "SensorErrorEvent",
  22298. "ServiceWorker",
  22299. "ServiceWorkerContainer",
  22300. "ServiceWorkerRegistration",
  22301. "SessionDescription",
  22302. "Set",
  22303. "ShadowRoot",
  22304. "SharedArrayBuffer",
  22305. "SharedWorker",
  22306. "SimpleGestureEvent",
  22307. "SourceBuffer",
  22308. "SourceBufferList",
  22309. "SpeechSynthesis",
  22310. "SpeechSynthesisErrorEvent",
  22311. "SpeechSynthesisEvent",
  22312. "SpeechSynthesisUtterance",
  22313. "SpeechSynthesisVoice",
  22314. "StaticRange",
  22315. "StereoPannerNode",
  22316. "StopIteration",
  22317. "Storage",
  22318. "StorageEvent",
  22319. "StorageManager",
  22320. "String",
  22321. "StructType",
  22322. "StylePropertyMap",
  22323. "StylePropertyMapReadOnly",
  22324. "StyleSheet",
  22325. "StyleSheetList",
  22326. "SubmitEvent",
  22327. "SubtleCrypto",
  22328. "Symbol",
  22329. "SyncManager",
  22330. "SyntaxError",
  22331. "TEMPORARY",
  22332. "TEXTPATH_METHODTYPE_ALIGN",
  22333. "TEXTPATH_METHODTYPE_STRETCH",
  22334. "TEXTPATH_METHODTYPE_UNKNOWN",
  22335. "TEXTPATH_SPACINGTYPE_AUTO",
  22336. "TEXTPATH_SPACINGTYPE_EXACT",
  22337. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  22338. "TEXTURE",
  22339. "TEXTURE0",
  22340. "TEXTURE1",
  22341. "TEXTURE10",
  22342. "TEXTURE11",
  22343. "TEXTURE12",
  22344. "TEXTURE13",
  22345. "TEXTURE14",
  22346. "TEXTURE15",
  22347. "TEXTURE16",
  22348. "TEXTURE17",
  22349. "TEXTURE18",
  22350. "TEXTURE19",
  22351. "TEXTURE2",
  22352. "TEXTURE20",
  22353. "TEXTURE21",
  22354. "TEXTURE22",
  22355. "TEXTURE23",
  22356. "TEXTURE24",
  22357. "TEXTURE25",
  22358. "TEXTURE26",
  22359. "TEXTURE27",
  22360. "TEXTURE28",
  22361. "TEXTURE29",
  22362. "TEXTURE3",
  22363. "TEXTURE30",
  22364. "TEXTURE31",
  22365. "TEXTURE4",
  22366. "TEXTURE5",
  22367. "TEXTURE6",
  22368. "TEXTURE7",
  22369. "TEXTURE8",
  22370. "TEXTURE9",
  22371. "TEXTURE_2D",
  22372. "TEXTURE_2D_ARRAY",
  22373. "TEXTURE_3D",
  22374. "TEXTURE_BASE_LEVEL",
  22375. "TEXTURE_BINDING_2D",
  22376. "TEXTURE_BINDING_2D_ARRAY",
  22377. "TEXTURE_BINDING_3D",
  22378. "TEXTURE_BINDING_CUBE_MAP",
  22379. "TEXTURE_COMPARE_FUNC",
  22380. "TEXTURE_COMPARE_MODE",
  22381. "TEXTURE_CUBE_MAP",
  22382. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  22383. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  22384. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  22385. "TEXTURE_CUBE_MAP_POSITIVE_X",
  22386. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  22387. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  22388. "TEXTURE_IMMUTABLE_FORMAT",
  22389. "TEXTURE_IMMUTABLE_LEVELS",
  22390. "TEXTURE_MAG_FILTER",
  22391. "TEXTURE_MAX_ANISOTROPY_EXT",
  22392. "TEXTURE_MAX_LEVEL",
  22393. "TEXTURE_MAX_LOD",
  22394. "TEXTURE_MIN_FILTER",
  22395. "TEXTURE_MIN_LOD",
  22396. "TEXTURE_WRAP_R",
  22397. "TEXTURE_WRAP_S",
  22398. "TEXTURE_WRAP_T",
  22399. "TEXT_NODE",
  22400. "TIMEOUT",
  22401. "TIMEOUT_ERR",
  22402. "TIMEOUT_EXPIRED",
  22403. "TIMEOUT_IGNORED",
  22404. "TOO_LARGE_ERR",
  22405. "TRANSACTION_INACTIVE_ERR",
  22406. "TRANSFORM_FEEDBACK",
  22407. "TRANSFORM_FEEDBACK_ACTIVE",
  22408. "TRANSFORM_FEEDBACK_BINDING",
  22409. "TRANSFORM_FEEDBACK_BUFFER",
  22410. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  22411. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  22412. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  22413. "TRANSFORM_FEEDBACK_BUFFER_START",
  22414. "TRANSFORM_FEEDBACK_PAUSED",
  22415. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  22416. "TRANSFORM_FEEDBACK_VARYINGS",
  22417. "TRIANGLE",
  22418. "TRIANGLES",
  22419. "TRIANGLE_FAN",
  22420. "TRIANGLE_STRIP",
  22421. "TYPE_BACK_FORWARD",
  22422. "TYPE_ERR",
  22423. "TYPE_MISMATCH_ERR",
  22424. "TYPE_NAVIGATE",
  22425. "TYPE_RELOAD",
  22426. "TYPE_RESERVED",
  22427. "Table",
  22428. "TaskAttributionTiming",
  22429. "Text",
  22430. "TextDecoder",
  22431. "TextDecoderStream",
  22432. "TextEncoder",
  22433. "TextEncoderStream",
  22434. "TextEvent",
  22435. "TextMetrics",
  22436. "TextTrack",
  22437. "TextTrackCue",
  22438. "TextTrackCueList",
  22439. "TextTrackList",
  22440. "TimeEvent",
  22441. "TimeRanges",
  22442. "Touch",
  22443. "TouchEvent",
  22444. "TouchList",
  22445. "TrackEvent",
  22446. "TransformStream",
  22447. "TransitionEvent",
  22448. "TreeWalker",
  22449. "TrustedHTML",
  22450. "TrustedScript",
  22451. "TrustedScriptURL",
  22452. "TrustedTypePolicy",
  22453. "TrustedTypePolicyFactory",
  22454. "TypeError",
  22455. "TypedObject",
  22456. "U2F",
  22457. "UIEvent",
  22458. "UNCACHED",
  22459. "UNIFORM_ARRAY_STRIDE",
  22460. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  22461. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  22462. "UNIFORM_BLOCK_BINDING",
  22463. "UNIFORM_BLOCK_DATA_SIZE",
  22464. "UNIFORM_BLOCK_INDEX",
  22465. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  22466. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  22467. "UNIFORM_BUFFER",
  22468. "UNIFORM_BUFFER_BINDING",
  22469. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  22470. "UNIFORM_BUFFER_SIZE",
  22471. "UNIFORM_BUFFER_START",
  22472. "UNIFORM_IS_ROW_MAJOR",
  22473. "UNIFORM_MATRIX_STRIDE",
  22474. "UNIFORM_OFFSET",
  22475. "UNIFORM_SIZE",
  22476. "UNIFORM_TYPE",
  22477. "UNKNOWN_ERR",
  22478. "UNKNOWN_RULE",
  22479. "UNMASKED_RENDERER_WEBGL",
  22480. "UNMASKED_VENDOR_WEBGL",
  22481. "UNORDERED_NODE_ITERATOR_TYPE",
  22482. "UNORDERED_NODE_SNAPSHOT_TYPE",
  22483. "UNPACK_ALIGNMENT",
  22484. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  22485. "UNPACK_FLIP_Y_WEBGL",
  22486. "UNPACK_IMAGE_HEIGHT",
  22487. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  22488. "UNPACK_ROW_LENGTH",
  22489. "UNPACK_SKIP_IMAGES",
  22490. "UNPACK_SKIP_PIXELS",
  22491. "UNPACK_SKIP_ROWS",
  22492. "UNSCHEDULED_STATE",
  22493. "UNSENT",
  22494. "UNSIGNALED",
  22495. "UNSIGNED_BYTE",
  22496. "UNSIGNED_INT",
  22497. "UNSIGNED_INT_10F_11F_11F_REV",
  22498. "UNSIGNED_INT_24_8",
  22499. "UNSIGNED_INT_2_10_10_10_REV",
  22500. "UNSIGNED_INT_5_9_9_9_REV",
  22501. "UNSIGNED_INT_SAMPLER_2D",
  22502. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  22503. "UNSIGNED_INT_SAMPLER_3D",
  22504. "UNSIGNED_INT_SAMPLER_CUBE",
  22505. "UNSIGNED_INT_VEC2",
  22506. "UNSIGNED_INT_VEC3",
  22507. "UNSIGNED_INT_VEC4",
  22508. "UNSIGNED_NORMALIZED",
  22509. "UNSIGNED_SHORT",
  22510. "UNSIGNED_SHORT_4_4_4_4",
  22511. "UNSIGNED_SHORT_5_5_5_1",
  22512. "UNSIGNED_SHORT_5_6_5",
  22513. "UNSPECIFIED_EVENT_TYPE_ERR",
  22514. "UPDATEREADY",
  22515. "URIError",
  22516. "URL",
  22517. "URLSearchParams",
  22518. "URLUnencoded",
  22519. "URL_MISMATCH_ERR",
  22520. "USB",
  22521. "USBAlternateInterface",
  22522. "USBConfiguration",
  22523. "USBConnectionEvent",
  22524. "USBDevice",
  22525. "USBEndpoint",
  22526. "USBInTransferResult",
  22527. "USBInterface",
  22528. "USBIsochronousInTransferPacket",
  22529. "USBIsochronousInTransferResult",
  22530. "USBIsochronousOutTransferPacket",
  22531. "USBIsochronousOutTransferResult",
  22532. "USBOutTransferResult",
  22533. "UTC",
  22534. "Uint16Array",
  22535. "Uint32Array",
  22536. "Uint8Array",
  22537. "Uint8ClampedArray",
  22538. "UserActivation",
  22539. "UserMessageHandler",
  22540. "UserMessageHandlersNamespace",
  22541. "UserProximityEvent",
  22542. "VALIDATE_STATUS",
  22543. "VALIDATION_ERR",
  22544. "VARIABLES_RULE",
  22545. "VENDOR",
  22546. "VERSION",
  22547. "VERSION_CHANGE",
  22548. "VERSION_ERR",
  22549. "VERTEX_ARRAY_BINDING",
  22550. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  22551. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  22552. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  22553. "VERTEX_ATTRIB_ARRAY_ENABLED",
  22554. "VERTEX_ATTRIB_ARRAY_INTEGER",
  22555. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  22556. "VERTEX_ATTRIB_ARRAY_POINTER",
  22557. "VERTEX_ATTRIB_ARRAY_SIZE",
  22558. "VERTEX_ATTRIB_ARRAY_STRIDE",
  22559. "VERTEX_ATTRIB_ARRAY_TYPE",
  22560. "VERTEX_SHADER",
  22561. "VERTICAL",
  22562. "VERTICAL_AXIS",
  22563. "VER_ERR",
  22564. "VIEWPORT",
  22565. "VIEWPORT_RULE",
  22566. "VRDisplay",
  22567. "VRDisplayCapabilities",
  22568. "VRDisplayEvent",
  22569. "VREyeParameters",
  22570. "VRFieldOfView",
  22571. "VRFrameData",
  22572. "VRPose",
  22573. "VRStageParameters",
  22574. "VTTCue",
  22575. "VTTRegion",
  22576. "ValidityState",
  22577. "VideoPlaybackQuality",
  22578. "VideoStreamTrack",
  22579. "VisualViewport",
  22580. "WAIT_FAILED",
  22581. "WEBKIT_FILTER_RULE",
  22582. "WEBKIT_KEYFRAMES_RULE",
  22583. "WEBKIT_KEYFRAME_RULE",
  22584. "WEBKIT_REGION_RULE",
  22585. "WRONG_DOCUMENT_ERR",
  22586. "WakeLock",
  22587. "WakeLockSentinel",
  22588. "WasmAnyRef",
  22589. "WaveShaperNode",
  22590. "WeakMap",
  22591. "WeakRef",
  22592. "WeakSet",
  22593. "WebAssembly",
  22594. "WebGL2RenderingContext",
  22595. "WebGLActiveInfo",
  22596. "WebGLBuffer",
  22597. "WebGLContextEvent",
  22598. "WebGLFramebuffer",
  22599. "WebGLProgram",
  22600. "WebGLQuery",
  22601. "WebGLRenderbuffer",
  22602. "WebGLRenderingContext",
  22603. "WebGLSampler",
  22604. "WebGLShader",
  22605. "WebGLShaderPrecisionFormat",
  22606. "WebGLSync",
  22607. "WebGLTexture",
  22608. "WebGLTransformFeedback",
  22609. "WebGLUniformLocation",
  22610. "WebGLVertexArray",
  22611. "WebGLVertexArrayObject",
  22612. "WebKitAnimationEvent",
  22613. "WebKitBlobBuilder",
  22614. "WebKitCSSFilterRule",
  22615. "WebKitCSSFilterValue",
  22616. "WebKitCSSKeyframeRule",
  22617. "WebKitCSSKeyframesRule",
  22618. "WebKitCSSMatrix",
  22619. "WebKitCSSRegionRule",
  22620. "WebKitCSSTransformValue",
  22621. "WebKitDataCue",
  22622. "WebKitGamepad",
  22623. "WebKitMediaKeyError",
  22624. "WebKitMediaKeyMessageEvent",
  22625. "WebKitMediaKeySession",
  22626. "WebKitMediaKeys",
  22627. "WebKitMediaSource",
  22628. "WebKitMutationObserver",
  22629. "WebKitNamespace",
  22630. "WebKitPlaybackTargetAvailabilityEvent",
  22631. "WebKitPoint",
  22632. "WebKitShadowRoot",
  22633. "WebKitSourceBuffer",
  22634. "WebKitSourceBufferList",
  22635. "WebKitTransitionEvent",
  22636. "WebSocket",
  22637. "WebkitAlignContent",
  22638. "WebkitAlignItems",
  22639. "WebkitAlignSelf",
  22640. "WebkitAnimation",
  22641. "WebkitAnimationDelay",
  22642. "WebkitAnimationDirection",
  22643. "WebkitAnimationDuration",
  22644. "WebkitAnimationFillMode",
  22645. "WebkitAnimationIterationCount",
  22646. "WebkitAnimationName",
  22647. "WebkitAnimationPlayState",
  22648. "WebkitAnimationTimingFunction",
  22649. "WebkitAppearance",
  22650. "WebkitBackfaceVisibility",
  22651. "WebkitBackgroundClip",
  22652. "WebkitBackgroundOrigin",
  22653. "WebkitBackgroundSize",
  22654. "WebkitBorderBottomLeftRadius",
  22655. "WebkitBorderBottomRightRadius",
  22656. "WebkitBorderImage",
  22657. "WebkitBorderRadius",
  22658. "WebkitBorderTopLeftRadius",
  22659. "WebkitBorderTopRightRadius",
  22660. "WebkitBoxAlign",
  22661. "WebkitBoxDirection",
  22662. "WebkitBoxFlex",
  22663. "WebkitBoxOrdinalGroup",
  22664. "WebkitBoxOrient",
  22665. "WebkitBoxPack",
  22666. "WebkitBoxShadow",
  22667. "WebkitBoxSizing",
  22668. "WebkitFilter",
  22669. "WebkitFlex",
  22670. "WebkitFlexBasis",
  22671. "WebkitFlexDirection",
  22672. "WebkitFlexFlow",
  22673. "WebkitFlexGrow",
  22674. "WebkitFlexShrink",
  22675. "WebkitFlexWrap",
  22676. "WebkitJustifyContent",
  22677. "WebkitLineClamp",
  22678. "WebkitMask",
  22679. "WebkitMaskClip",
  22680. "WebkitMaskComposite",
  22681. "WebkitMaskImage",
  22682. "WebkitMaskOrigin",
  22683. "WebkitMaskPosition",
  22684. "WebkitMaskPositionX",
  22685. "WebkitMaskPositionY",
  22686. "WebkitMaskRepeat",
  22687. "WebkitMaskSize",
  22688. "WebkitOrder",
  22689. "WebkitPerspective",
  22690. "WebkitPerspectiveOrigin",
  22691. "WebkitTextFillColor",
  22692. "WebkitTextSizeAdjust",
  22693. "WebkitTextStroke",
  22694. "WebkitTextStrokeColor",
  22695. "WebkitTextStrokeWidth",
  22696. "WebkitTransform",
  22697. "WebkitTransformOrigin",
  22698. "WebkitTransformStyle",
  22699. "WebkitTransition",
  22700. "WebkitTransitionDelay",
  22701. "WebkitTransitionDuration",
  22702. "WebkitTransitionProperty",
  22703. "WebkitTransitionTimingFunction",
  22704. "WebkitUserSelect",
  22705. "WheelEvent",
  22706. "Window",
  22707. "Worker",
  22708. "Worklet",
  22709. "WritableStream",
  22710. "WritableStreamDefaultWriter",
  22711. "XMLDocument",
  22712. "XMLHttpRequest",
  22713. "XMLHttpRequestEventTarget",
  22714. "XMLHttpRequestException",
  22715. "XMLHttpRequestProgressEvent",
  22716. "XMLHttpRequestUpload",
  22717. "XMLSerializer",
  22718. "XMLStylesheetProcessingInstruction",
  22719. "XPathEvaluator",
  22720. "XPathException",
  22721. "XPathExpression",
  22722. "XPathNSResolver",
  22723. "XPathResult",
  22724. "XRBoundedReferenceSpace",
  22725. "XRDOMOverlayState",
  22726. "XRFrame",
  22727. "XRHitTestResult",
  22728. "XRHitTestSource",
  22729. "XRInputSource",
  22730. "XRInputSourceArray",
  22731. "XRInputSourceEvent",
  22732. "XRInputSourcesChangeEvent",
  22733. "XRLayer",
  22734. "XRPose",
  22735. "XRRay",
  22736. "XRReferenceSpace",
  22737. "XRReferenceSpaceEvent",
  22738. "XRRenderState",
  22739. "XRRigidTransform",
  22740. "XRSession",
  22741. "XRSessionEvent",
  22742. "XRSpace",
  22743. "XRSystem",
  22744. "XRTransientInputHitTestResult",
  22745. "XRTransientInputHitTestSource",
  22746. "XRView",
  22747. "XRViewerPose",
  22748. "XRViewport",
  22749. "XRWebGLLayer",
  22750. "XSLTProcessor",
  22751. "ZERO",
  22752. "_XD0M_",
  22753. "_YD0M_",
  22754. "__defineGetter__",
  22755. "__defineSetter__",
  22756. "__lookupGetter__",
  22757. "__lookupSetter__",
  22758. "__opera",
  22759. "__proto__",
  22760. "_browserjsran",
  22761. "a",
  22762. "aLink",
  22763. "abbr",
  22764. "abort",
  22765. "aborted",
  22766. "abs",
  22767. "absolute",
  22768. "acceleration",
  22769. "accelerationIncludingGravity",
  22770. "accelerator",
  22771. "accept",
  22772. "acceptCharset",
  22773. "acceptNode",
  22774. "accessKey",
  22775. "accessKeyLabel",
  22776. "accuracy",
  22777. "acos",
  22778. "acosh",
  22779. "action",
  22780. "actionURL",
  22781. "actions",
  22782. "activated",
  22783. "active",
  22784. "activeCues",
  22785. "activeElement",
  22786. "activeSourceBuffers",
  22787. "activeSourceCount",
  22788. "activeTexture",
  22789. "activeVRDisplays",
  22790. "actualBoundingBoxAscent",
  22791. "actualBoundingBoxDescent",
  22792. "actualBoundingBoxLeft",
  22793. "actualBoundingBoxRight",
  22794. "add",
  22795. "addAll",
  22796. "addBehavior",
  22797. "addCandidate",
  22798. "addColorStop",
  22799. "addCue",
  22800. "addElement",
  22801. "addEventListener",
  22802. "addFilter",
  22803. "addFromString",
  22804. "addFromUri",
  22805. "addIceCandidate",
  22806. "addImport",
  22807. "addListener",
  22808. "addModule",
  22809. "addNamed",
  22810. "addPageRule",
  22811. "addPath",
  22812. "addPointer",
  22813. "addRange",
  22814. "addRegion",
  22815. "addRule",
  22816. "addSearchEngine",
  22817. "addSourceBuffer",
  22818. "addStream",
  22819. "addTextTrack",
  22820. "addTrack",
  22821. "addTransceiver",
  22822. "addWakeLockListener",
  22823. "added",
  22824. "addedNodes",
  22825. "additionalName",
  22826. "additiveSymbols",
  22827. "addons",
  22828. "address",
  22829. "addressLine",
  22830. "adoptNode",
  22831. "adoptedStyleSheets",
  22832. "adr",
  22833. "advance",
  22834. "after",
  22835. "album",
  22836. "alert",
  22837. "algorithm",
  22838. "align",
  22839. "align-content",
  22840. "align-items",
  22841. "align-self",
  22842. "alignContent",
  22843. "alignItems",
  22844. "alignSelf",
  22845. "alignmentBaseline",
  22846. "alinkColor",
  22847. "all",
  22848. "allSettled",
  22849. "allow",
  22850. "allowFullscreen",
  22851. "allowPaymentRequest",
  22852. "allowedDirections",
  22853. "allowedFeatures",
  22854. "allowedToPlay",
  22855. "allowsFeature",
  22856. "alpha",
  22857. "alt",
  22858. "altGraphKey",
  22859. "altHtml",
  22860. "altKey",
  22861. "altLeft",
  22862. "alternate",
  22863. "alternateSetting",
  22864. "alternates",
  22865. "altitude",
  22866. "altitudeAccuracy",
  22867. "amplitude",
  22868. "ancestorOrigins",
  22869. "anchor",
  22870. "anchorNode",
  22871. "anchorOffset",
  22872. "anchors",
  22873. "and",
  22874. "angle",
  22875. "angularAcceleration",
  22876. "angularVelocity",
  22877. "animVal",
  22878. "animate",
  22879. "animatedInstanceRoot",
  22880. "animatedNormalizedPathSegList",
  22881. "animatedPathSegList",
  22882. "animatedPoints",
  22883. "animation",
  22884. "animation-delay",
  22885. "animation-direction",
  22886. "animation-duration",
  22887. "animation-fill-mode",
  22888. "animation-iteration-count",
  22889. "animation-name",
  22890. "animation-play-state",
  22891. "animation-timing-function",
  22892. "animationDelay",
  22893. "animationDirection",
  22894. "animationDuration",
  22895. "animationFillMode",
  22896. "animationIterationCount",
  22897. "animationName",
  22898. "animationPlayState",
  22899. "animationStartTime",
  22900. "animationTimingFunction",
  22901. "animationsPaused",
  22902. "anniversary",
  22903. "antialias",
  22904. "anticipatedRemoval",
  22905. "any",
  22906. "app",
  22907. "appCodeName",
  22908. "appMinorVersion",
  22909. "appName",
  22910. "appNotifications",
  22911. "appVersion",
  22912. "appearance",
  22913. "append",
  22914. "appendBuffer",
  22915. "appendChild",
  22916. "appendData",
  22917. "appendItem",
  22918. "appendMedium",
  22919. "appendNamed",
  22920. "appendRule",
  22921. "appendStream",
  22922. "appendWindowEnd",
  22923. "appendWindowStart",
  22924. "applets",
  22925. "applicationCache",
  22926. "applicationServerKey",
  22927. "apply",
  22928. "applyConstraints",
  22929. "applyElement",
  22930. "arc",
  22931. "arcTo",
  22932. "architecture",
  22933. "archive",
  22934. "areas",
  22935. "arguments",
  22936. "ariaAtomic",
  22937. "ariaAutoComplete",
  22938. "ariaBusy",
  22939. "ariaChecked",
  22940. "ariaColCount",
  22941. "ariaColIndex",
  22942. "ariaColSpan",
  22943. "ariaCurrent",
  22944. "ariaDescription",
  22945. "ariaDisabled",
  22946. "ariaExpanded",
  22947. "ariaHasPopup",
  22948. "ariaHidden",
  22949. "ariaKeyShortcuts",
  22950. "ariaLabel",
  22951. "ariaLevel",
  22952. "ariaLive",
  22953. "ariaModal",
  22954. "ariaMultiLine",
  22955. "ariaMultiSelectable",
  22956. "ariaOrientation",
  22957. "ariaPlaceholder",
  22958. "ariaPosInSet",
  22959. "ariaPressed",
  22960. "ariaReadOnly",
  22961. "ariaRelevant",
  22962. "ariaRequired",
  22963. "ariaRoleDescription",
  22964. "ariaRowCount",
  22965. "ariaRowIndex",
  22966. "ariaRowSpan",
  22967. "ariaSelected",
  22968. "ariaSetSize",
  22969. "ariaSort",
  22970. "ariaValueMax",
  22971. "ariaValueMin",
  22972. "ariaValueNow",
  22973. "ariaValueText",
  22974. "arrayBuffer",
  22975. "artist",
  22976. "artwork",
  22977. "as",
  22978. "asIntN",
  22979. "asUintN",
  22980. "asin",
  22981. "asinh",
  22982. "assert",
  22983. "assign",
  22984. "assignedElements",
  22985. "assignedNodes",
  22986. "assignedSlot",
  22987. "async",
  22988. "asyncIterator",
  22989. "atEnd",
  22990. "atan",
  22991. "atan2",
  22992. "atanh",
  22993. "atob",
  22994. "attachEvent",
  22995. "attachInternals",
  22996. "attachShader",
  22997. "attachShadow",
  22998. "attachments",
  22999. "attack",
  23000. "attestationObject",
  23001. "attrChange",
  23002. "attrName",
  23003. "attributeFilter",
  23004. "attributeName",
  23005. "attributeNamespace",
  23006. "attributeOldValue",
  23007. "attributeStyleMap",
  23008. "attributes",
  23009. "attribution",
  23010. "audioBitsPerSecond",
  23011. "audioTracks",
  23012. "audioWorklet",
  23013. "authenticatedSignedWrites",
  23014. "authenticatorData",
  23015. "autoIncrement",
  23016. "autobuffer",
  23017. "autocapitalize",
  23018. "autocomplete",
  23019. "autocorrect",
  23020. "autofocus",
  23021. "automationRate",
  23022. "autoplay",
  23023. "availHeight",
  23024. "availLeft",
  23025. "availTop",
  23026. "availWidth",
  23027. "availability",
  23028. "available",
  23029. "aversion",
  23030. "ax",
  23031. "axes",
  23032. "axis",
  23033. "ay",
  23034. "azimuth",
  23035. "b",
  23036. "back",
  23037. "backface-visibility",
  23038. "backfaceVisibility",
  23039. "background",
  23040. "background-attachment",
  23041. "background-blend-mode",
  23042. "background-clip",
  23043. "background-color",
  23044. "background-image",
  23045. "background-origin",
  23046. "background-position",
  23047. "background-position-x",
  23048. "background-position-y",
  23049. "background-repeat",
  23050. "background-size",
  23051. "backgroundAttachment",
  23052. "backgroundBlendMode",
  23053. "backgroundClip",
  23054. "backgroundColor",
  23055. "backgroundFetch",
  23056. "backgroundImage",
  23057. "backgroundOrigin",
  23058. "backgroundPosition",
  23059. "backgroundPositionX",
  23060. "backgroundPositionY",
  23061. "backgroundRepeat",
  23062. "backgroundSize",
  23063. "badInput",
  23064. "badge",
  23065. "balance",
  23066. "baseFrequencyX",
  23067. "baseFrequencyY",
  23068. "baseLatency",
  23069. "baseLayer",
  23070. "baseNode",
  23071. "baseOffset",
  23072. "baseURI",
  23073. "baseVal",
  23074. "baselineShift",
  23075. "battery",
  23076. "bday",
  23077. "before",
  23078. "beginElement",
  23079. "beginElementAt",
  23080. "beginPath",
  23081. "beginQuery",
  23082. "beginTransformFeedback",
  23083. "behavior",
  23084. "behaviorCookie",
  23085. "behaviorPart",
  23086. "behaviorUrns",
  23087. "beta",
  23088. "bezierCurveTo",
  23089. "bgColor",
  23090. "bgProperties",
  23091. "bias",
  23092. "big",
  23093. "bigint64",
  23094. "biguint64",
  23095. "binaryType",
  23096. "bind",
  23097. "bindAttribLocation",
  23098. "bindBuffer",
  23099. "bindBufferBase",
  23100. "bindBufferRange",
  23101. "bindFramebuffer",
  23102. "bindRenderbuffer",
  23103. "bindSampler",
  23104. "bindTexture",
  23105. "bindTransformFeedback",
  23106. "bindVertexArray",
  23107. "bitness",
  23108. "blendColor",
  23109. "blendEquation",
  23110. "blendEquationSeparate",
  23111. "blendFunc",
  23112. "blendFuncSeparate",
  23113. "blink",
  23114. "blitFramebuffer",
  23115. "blob",
  23116. "block-size",
  23117. "blockDirection",
  23118. "blockSize",
  23119. "blockedURI",
  23120. "blue",
  23121. "bluetooth",
  23122. "blur",
  23123. "body",
  23124. "bodyUsed",
  23125. "bold",
  23126. "bookmarks",
  23127. "booleanValue",
  23128. "border",
  23129. "border-block",
  23130. "border-block-color",
  23131. "border-block-end",
  23132. "border-block-end-color",
  23133. "border-block-end-style",
  23134. "border-block-end-width",
  23135. "border-block-start",
  23136. "border-block-start-color",
  23137. "border-block-start-style",
  23138. "border-block-start-width",
  23139. "border-block-style",
  23140. "border-block-width",
  23141. "border-bottom",
  23142. "border-bottom-color",
  23143. "border-bottom-left-radius",
  23144. "border-bottom-right-radius",
  23145. "border-bottom-style",
  23146. "border-bottom-width",
  23147. "border-collapse",
  23148. "border-color",
  23149. "border-end-end-radius",
  23150. "border-end-start-radius",
  23151. "border-image",
  23152. "border-image-outset",
  23153. "border-image-repeat",
  23154. "border-image-slice",
  23155. "border-image-source",
  23156. "border-image-width",
  23157. "border-inline",
  23158. "border-inline-color",
  23159. "border-inline-end",
  23160. "border-inline-end-color",
  23161. "border-inline-end-style",
  23162. "border-inline-end-width",
  23163. "border-inline-start",
  23164. "border-inline-start-color",
  23165. "border-inline-start-style",
  23166. "border-inline-start-width",
  23167. "border-inline-style",
  23168. "border-inline-width",
  23169. "border-left",
  23170. "border-left-color",
  23171. "border-left-style",
  23172. "border-left-width",
  23173. "border-radius",
  23174. "border-right",
  23175. "border-right-color",
  23176. "border-right-style",
  23177. "border-right-width",
  23178. "border-spacing",
  23179. "border-start-end-radius",
  23180. "border-start-start-radius",
  23181. "border-style",
  23182. "border-top",
  23183. "border-top-color",
  23184. "border-top-left-radius",
  23185. "border-top-right-radius",
  23186. "border-top-style",
  23187. "border-top-width",
  23188. "border-width",
  23189. "borderBlock",
  23190. "borderBlockColor",
  23191. "borderBlockEnd",
  23192. "borderBlockEndColor",
  23193. "borderBlockEndStyle",
  23194. "borderBlockEndWidth",
  23195. "borderBlockStart",
  23196. "borderBlockStartColor",
  23197. "borderBlockStartStyle",
  23198. "borderBlockStartWidth",
  23199. "borderBlockStyle",
  23200. "borderBlockWidth",
  23201. "borderBottom",
  23202. "borderBottomColor",
  23203. "borderBottomLeftRadius",
  23204. "borderBottomRightRadius",
  23205. "borderBottomStyle",
  23206. "borderBottomWidth",
  23207. "borderBoxSize",
  23208. "borderCollapse",
  23209. "borderColor",
  23210. "borderColorDark",
  23211. "borderColorLight",
  23212. "borderEndEndRadius",
  23213. "borderEndStartRadius",
  23214. "borderImage",
  23215. "borderImageOutset",
  23216. "borderImageRepeat",
  23217. "borderImageSlice",
  23218. "borderImageSource",
  23219. "borderImageWidth",
  23220. "borderInline",
  23221. "borderInlineColor",
  23222. "borderInlineEnd",
  23223. "borderInlineEndColor",
  23224. "borderInlineEndStyle",
  23225. "borderInlineEndWidth",
  23226. "borderInlineStart",
  23227. "borderInlineStartColor",
  23228. "borderInlineStartStyle",
  23229. "borderInlineStartWidth",
  23230. "borderInlineStyle",
  23231. "borderInlineWidth",
  23232. "borderLeft",
  23233. "borderLeftColor",
  23234. "borderLeftStyle",
  23235. "borderLeftWidth",
  23236. "borderRadius",
  23237. "borderRight",
  23238. "borderRightColor",
  23239. "borderRightStyle",
  23240. "borderRightWidth",
  23241. "borderSpacing",
  23242. "borderStartEndRadius",
  23243. "borderStartStartRadius",
  23244. "borderStyle",
  23245. "borderTop",
  23246. "borderTopColor",
  23247. "borderTopLeftRadius",
  23248. "borderTopRightRadius",
  23249. "borderTopStyle",
  23250. "borderTopWidth",
  23251. "borderWidth",
  23252. "bottom",
  23253. "bottomMargin",
  23254. "bound",
  23255. "boundElements",
  23256. "boundingClientRect",
  23257. "boundingHeight",
  23258. "boundingLeft",
  23259. "boundingTop",
  23260. "boundingWidth",
  23261. "bounds",
  23262. "boundsGeometry",
  23263. "box-decoration-break",
  23264. "box-shadow",
  23265. "box-sizing",
  23266. "boxDecorationBreak",
  23267. "boxShadow",
  23268. "boxSizing",
  23269. "brand",
  23270. "brands",
  23271. "break-after",
  23272. "break-before",
  23273. "break-inside",
  23274. "breakAfter",
  23275. "breakBefore",
  23276. "breakInside",
  23277. "broadcast",
  23278. "browserLanguage",
  23279. "btoa",
  23280. "bubbles",
  23281. "buffer",
  23282. "bufferData",
  23283. "bufferDepth",
  23284. "bufferSize",
  23285. "bufferSubData",
  23286. "buffered",
  23287. "bufferedAmount",
  23288. "bufferedAmountLowThreshold",
  23289. "buildID",
  23290. "buildNumber",
  23291. "button",
  23292. "buttonID",
  23293. "buttons",
  23294. "byteLength",
  23295. "byteOffset",
  23296. "bytesWritten",
  23297. "c",
  23298. "cache",
  23299. "caches",
  23300. "call",
  23301. "caller",
  23302. "canBeFormatted",
  23303. "canBeMounted",
  23304. "canBeShared",
  23305. "canHaveChildren",
  23306. "canHaveHTML",
  23307. "canInsertDTMF",
  23308. "canMakePayment",
  23309. "canPlayType",
  23310. "canPresent",
  23311. "canTrickleIceCandidates",
  23312. "cancel",
  23313. "cancelAndHoldAtTime",
  23314. "cancelAnimationFrame",
  23315. "cancelBubble",
  23316. "cancelIdleCallback",
  23317. "cancelScheduledValues",
  23318. "cancelVideoFrameCallback",
  23319. "cancelWatchAvailability",
  23320. "cancelable",
  23321. "candidate",
  23322. "canonicalUUID",
  23323. "canvas",
  23324. "capabilities",
  23325. "caption",
  23326. "caption-side",
  23327. "captionSide",
  23328. "capture",
  23329. "captureEvents",
  23330. "captureStackTrace",
  23331. "captureStream",
  23332. "caret-color",
  23333. "caretBidiLevel",
  23334. "caretColor",
  23335. "caretPositionFromPoint",
  23336. "caretRangeFromPoint",
  23337. "cast",
  23338. "catch",
  23339. "category",
  23340. "cbrt",
  23341. "cd",
  23342. "ceil",
  23343. "cellIndex",
  23344. "cellPadding",
  23345. "cellSpacing",
  23346. "cells",
  23347. "ch",
  23348. "chOff",
  23349. "chain",
  23350. "challenge",
  23351. "changeType",
  23352. "changedTouches",
  23353. "channel",
  23354. "channelCount",
  23355. "channelCountMode",
  23356. "channelInterpretation",
  23357. "char",
  23358. "charAt",
  23359. "charCode",
  23360. "charCodeAt",
  23361. "charIndex",
  23362. "charLength",
  23363. "characterData",
  23364. "characterDataOldValue",
  23365. "characterSet",
  23366. "characteristic",
  23367. "charging",
  23368. "chargingTime",
  23369. "charset",
  23370. "check",
  23371. "checkEnclosure",
  23372. "checkFramebufferStatus",
  23373. "checkIntersection",
  23374. "checkValidity",
  23375. "checked",
  23376. "childElementCount",
  23377. "childList",
  23378. "childNodes",
  23379. "children",
  23380. "chrome",
  23381. "ciphertext",
  23382. "cite",
  23383. "city",
  23384. "claimInterface",
  23385. "claimed",
  23386. "classList",
  23387. "className",
  23388. "classid",
  23389. "clear",
  23390. "clearAppBadge",
  23391. "clearAttributes",
  23392. "clearBufferfi",
  23393. "clearBufferfv",
  23394. "clearBufferiv",
  23395. "clearBufferuiv",
  23396. "clearColor",
  23397. "clearData",
  23398. "clearDepth",
  23399. "clearHalt",
  23400. "clearImmediate",
  23401. "clearInterval",
  23402. "clearLiveSeekableRange",
  23403. "clearMarks",
  23404. "clearMaxGCPauseAccumulator",
  23405. "clearMeasures",
  23406. "clearParameters",
  23407. "clearRect",
  23408. "clearResourceTimings",
  23409. "clearShadow",
  23410. "clearStencil",
  23411. "clearTimeout",
  23412. "clearWatch",
  23413. "click",
  23414. "clickCount",
  23415. "clientDataJSON",
  23416. "clientHeight",
  23417. "clientInformation",
  23418. "clientLeft",
  23419. "clientRect",
  23420. "clientRects",
  23421. "clientTop",
  23422. "clientWaitSync",
  23423. "clientWidth",
  23424. "clientX",
  23425. "clientY",
  23426. "clip",
  23427. "clip-path",
  23428. "clip-rule",
  23429. "clipBottom",
  23430. "clipLeft",
  23431. "clipPath",
  23432. "clipPathUnits",
  23433. "clipRight",
  23434. "clipRule",
  23435. "clipTop",
  23436. "clipboard",
  23437. "clipboardData",
  23438. "clone",
  23439. "cloneContents",
  23440. "cloneNode",
  23441. "cloneRange",
  23442. "close",
  23443. "closePath",
  23444. "closed",
  23445. "closest",
  23446. "clz",
  23447. "clz32",
  23448. "cm",
  23449. "cmp",
  23450. "code",
  23451. "codeBase",
  23452. "codePointAt",
  23453. "codeType",
  23454. "colSpan",
  23455. "collapse",
  23456. "collapseToEnd",
  23457. "collapseToStart",
  23458. "collapsed",
  23459. "collect",
  23460. "colno",
  23461. "color",
  23462. "color-adjust",
  23463. "color-interpolation",
  23464. "color-interpolation-filters",
  23465. "colorAdjust",
  23466. "colorDepth",
  23467. "colorInterpolation",
  23468. "colorInterpolationFilters",
  23469. "colorMask",
  23470. "colorType",
  23471. "cols",
  23472. "column-count",
  23473. "column-fill",
  23474. "column-gap",
  23475. "column-rule",
  23476. "column-rule-color",
  23477. "column-rule-style",
  23478. "column-rule-width",
  23479. "column-span",
  23480. "column-width",
  23481. "columnCount",
  23482. "columnFill",
  23483. "columnGap",
  23484. "columnNumber",
  23485. "columnRule",
  23486. "columnRuleColor",
  23487. "columnRuleStyle",
  23488. "columnRuleWidth",
  23489. "columnSpan",
  23490. "columnWidth",
  23491. "columns",
  23492. "command",
  23493. "commit",
  23494. "commitPreferences",
  23495. "commitStyles",
  23496. "commonAncestorContainer",
  23497. "compact",
  23498. "compareBoundaryPoints",
  23499. "compareDocumentPosition",
  23500. "compareEndPoints",
  23501. "compareExchange",
  23502. "compareNode",
  23503. "comparePoint",
  23504. "compatMode",
  23505. "compatible",
  23506. "compile",
  23507. "compileShader",
  23508. "compileStreaming",
  23509. "complete",
  23510. "component",
  23511. "componentFromPoint",
  23512. "composed",
  23513. "composedPath",
  23514. "composite",
  23515. "compositionEndOffset",
  23516. "compositionStartOffset",
  23517. "compressedTexImage2D",
  23518. "compressedTexImage3D",
  23519. "compressedTexSubImage2D",
  23520. "compressedTexSubImage3D",
  23521. "computedStyleMap",
  23522. "concat",
  23523. "conditionText",
  23524. "coneInnerAngle",
  23525. "coneOuterAngle",
  23526. "coneOuterGain",
  23527. "configurable",
  23528. "configuration",
  23529. "configurationName",
  23530. "configurationValue",
  23531. "configurations",
  23532. "confirm",
  23533. "confirmComposition",
  23534. "confirmSiteSpecificTrackingException",
  23535. "confirmWebWideTrackingException",
  23536. "connect",
  23537. "connectEnd",
  23538. "connectShark",
  23539. "connectStart",
  23540. "connected",
  23541. "connection",
  23542. "connectionList",
  23543. "connectionSpeed",
  23544. "connectionState",
  23545. "connections",
  23546. "console",
  23547. "consolidate",
  23548. "constraint",
  23549. "constrictionActive",
  23550. "construct",
  23551. "constructor",
  23552. "contactID",
  23553. "contain",
  23554. "containerId",
  23555. "containerName",
  23556. "containerSrc",
  23557. "containerType",
  23558. "contains",
  23559. "containsNode",
  23560. "content",
  23561. "contentBoxSize",
  23562. "contentDocument",
  23563. "contentEditable",
  23564. "contentHint",
  23565. "contentOverflow",
  23566. "contentRect",
  23567. "contentScriptType",
  23568. "contentStyleType",
  23569. "contentType",
  23570. "contentWindow",
  23571. "context",
  23572. "contextMenu",
  23573. "contextmenu",
  23574. "continue",
  23575. "continuePrimaryKey",
  23576. "continuous",
  23577. "control",
  23578. "controlTransferIn",
  23579. "controlTransferOut",
  23580. "controller",
  23581. "controls",
  23582. "controlsList",
  23583. "convertPointFromNode",
  23584. "convertQuadFromNode",
  23585. "convertRectFromNode",
  23586. "convertToBlob",
  23587. "convertToSpecifiedUnits",
  23588. "cookie",
  23589. "cookieEnabled",
  23590. "coords",
  23591. "copyBufferSubData",
  23592. "copyFromChannel",
  23593. "copyTexImage2D",
  23594. "copyTexSubImage2D",
  23595. "copyTexSubImage3D",
  23596. "copyToChannel",
  23597. "copyWithin",
  23598. "correspondingElement",
  23599. "correspondingUseElement",
  23600. "corruptedVideoFrames",
  23601. "cos",
  23602. "cosh",
  23603. "count",
  23604. "countReset",
  23605. "counter-increment",
  23606. "counter-reset",
  23607. "counter-set",
  23608. "counterIncrement",
  23609. "counterReset",
  23610. "counterSet",
  23611. "country",
  23612. "cpuClass",
  23613. "cpuSleepAllowed",
  23614. "create",
  23615. "createAnalyser",
  23616. "createAnswer",
  23617. "createAttribute",
  23618. "createAttributeNS",
  23619. "createBiquadFilter",
  23620. "createBuffer",
  23621. "createBufferSource",
  23622. "createCDATASection",
  23623. "createCSSStyleSheet",
  23624. "createCaption",
  23625. "createChannelMerger",
  23626. "createChannelSplitter",
  23627. "createComment",
  23628. "createConstantSource",
  23629. "createContextualFragment",
  23630. "createControlRange",
  23631. "createConvolver",
  23632. "createDTMFSender",
  23633. "createDataChannel",
  23634. "createDelay",
  23635. "createDelayNode",
  23636. "createDocument",
  23637. "createDocumentFragment",
  23638. "createDocumentType",
  23639. "createDynamicsCompressor",
  23640. "createElement",
  23641. "createElementNS",
  23642. "createEntityReference",
  23643. "createEvent",
  23644. "createEventObject",
  23645. "createExpression",
  23646. "createFramebuffer",
  23647. "createFunction",
  23648. "createGain",
  23649. "createGainNode",
  23650. "createHTML",
  23651. "createHTMLDocument",
  23652. "createIIRFilter",
  23653. "createImageBitmap",
  23654. "createImageData",
  23655. "createIndex",
  23656. "createJavaScriptNode",
  23657. "createLinearGradient",
  23658. "createMediaElementSource",
  23659. "createMediaKeys",
  23660. "createMediaStreamDestination",
  23661. "createMediaStreamSource",
  23662. "createMediaStreamTrackSource",
  23663. "createMutableFile",
  23664. "createNSResolver",
  23665. "createNodeIterator",
  23666. "createNotification",
  23667. "createObjectStore",
  23668. "createObjectURL",
  23669. "createOffer",
  23670. "createOscillator",
  23671. "createPanner",
  23672. "createPattern",
  23673. "createPeriodicWave",
  23674. "createPolicy",
  23675. "createPopup",
  23676. "createProcessingInstruction",
  23677. "createProgram",
  23678. "createQuery",
  23679. "createRadialGradient",
  23680. "createRange",
  23681. "createRangeCollection",
  23682. "createReader",
  23683. "createRenderbuffer",
  23684. "createSVGAngle",
  23685. "createSVGLength",
  23686. "createSVGMatrix",
  23687. "createSVGNumber",
  23688. "createSVGPathSegArcAbs",
  23689. "createSVGPathSegArcRel",
  23690. "createSVGPathSegClosePath",
  23691. "createSVGPathSegCurvetoCubicAbs",
  23692. "createSVGPathSegCurvetoCubicRel",
  23693. "createSVGPathSegCurvetoCubicSmoothAbs",
  23694. "createSVGPathSegCurvetoCubicSmoothRel",
  23695. "createSVGPathSegCurvetoQuadraticAbs",
  23696. "createSVGPathSegCurvetoQuadraticRel",
  23697. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  23698. "createSVGPathSegCurvetoQuadraticSmoothRel",
  23699. "createSVGPathSegLinetoAbs",
  23700. "createSVGPathSegLinetoHorizontalAbs",
  23701. "createSVGPathSegLinetoHorizontalRel",
  23702. "createSVGPathSegLinetoRel",
  23703. "createSVGPathSegLinetoVerticalAbs",
  23704. "createSVGPathSegLinetoVerticalRel",
  23705. "createSVGPathSegMovetoAbs",
  23706. "createSVGPathSegMovetoRel",
  23707. "createSVGPoint",
  23708. "createSVGRect",
  23709. "createSVGTransform",
  23710. "createSVGTransformFromMatrix",
  23711. "createSampler",
  23712. "createScript",
  23713. "createScriptProcessor",
  23714. "createScriptURL",
  23715. "createSession",
  23716. "createShader",
  23717. "createShadowRoot",
  23718. "createStereoPanner",
  23719. "createStyleSheet",
  23720. "createTBody",
  23721. "createTFoot",
  23722. "createTHead",
  23723. "createTextNode",
  23724. "createTextRange",
  23725. "createTexture",
  23726. "createTouch",
  23727. "createTouchList",
  23728. "createTransformFeedback",
  23729. "createTreeWalker",
  23730. "createVertexArray",
  23731. "createWaveShaper",
  23732. "creationTime",
  23733. "credentials",
  23734. "crossOrigin",
  23735. "crossOriginIsolated",
  23736. "crypto",
  23737. "csi",
  23738. "csp",
  23739. "cssFloat",
  23740. "cssRules",
  23741. "cssText",
  23742. "cssValueType",
  23743. "ctrlKey",
  23744. "ctrlLeft",
  23745. "cues",
  23746. "cullFace",
  23747. "currentDirection",
  23748. "currentLocalDescription",
  23749. "currentNode",
  23750. "currentPage",
  23751. "currentRect",
  23752. "currentRemoteDescription",
  23753. "currentScale",
  23754. "currentScript",
  23755. "currentSrc",
  23756. "currentState",
  23757. "currentStyle",
  23758. "currentTarget",
  23759. "currentTime",
  23760. "currentTranslate",
  23761. "currentView",
  23762. "cursor",
  23763. "curve",
  23764. "customElements",
  23765. "customError",
  23766. "cx",
  23767. "cy",
  23768. "d",
  23769. "data",
  23770. "dataFld",
  23771. "dataFormatAs",
  23772. "dataLoss",
  23773. "dataLossMessage",
  23774. "dataPageSize",
  23775. "dataSrc",
  23776. "dataTransfer",
  23777. "database",
  23778. "databases",
  23779. "dataset",
  23780. "dateTime",
  23781. "db",
  23782. "debug",
  23783. "debuggerEnabled",
  23784. "declare",
  23785. "decode",
  23786. "decodeAudioData",
  23787. "decodeURI",
  23788. "decodeURIComponent",
  23789. "decodedBodySize",
  23790. "decoding",
  23791. "decodingInfo",
  23792. "decrypt",
  23793. "default",
  23794. "defaultCharset",
  23795. "defaultChecked",
  23796. "defaultMuted",
  23797. "defaultPlaybackRate",
  23798. "defaultPolicy",
  23799. "defaultPrevented",
  23800. "defaultRequest",
  23801. "defaultSelected",
  23802. "defaultStatus",
  23803. "defaultURL",
  23804. "defaultValue",
  23805. "defaultView",
  23806. "defaultstatus",
  23807. "defer",
  23808. "define",
  23809. "defineMagicFunction",
  23810. "defineMagicVariable",
  23811. "defineProperties",
  23812. "defineProperty",
  23813. "deg",
  23814. "delay",
  23815. "delayTime",
  23816. "delegatesFocus",
  23817. "delete",
  23818. "deleteBuffer",
  23819. "deleteCaption",
  23820. "deleteCell",
  23821. "deleteContents",
  23822. "deleteData",
  23823. "deleteDatabase",
  23824. "deleteFramebuffer",
  23825. "deleteFromDocument",
  23826. "deleteIndex",
  23827. "deleteMedium",
  23828. "deleteObjectStore",
  23829. "deleteProgram",
  23830. "deleteProperty",
  23831. "deleteQuery",
  23832. "deleteRenderbuffer",
  23833. "deleteRow",
  23834. "deleteRule",
  23835. "deleteSampler",
  23836. "deleteShader",
  23837. "deleteSync",
  23838. "deleteTFoot",
  23839. "deleteTHead",
  23840. "deleteTexture",
  23841. "deleteTransformFeedback",
  23842. "deleteVertexArray",
  23843. "deliverChangeRecords",
  23844. "delivery",
  23845. "deliveryInfo",
  23846. "deliveryStatus",
  23847. "deliveryTimestamp",
  23848. "delta",
  23849. "deltaMode",
  23850. "deltaX",
  23851. "deltaY",
  23852. "deltaZ",
  23853. "dependentLocality",
  23854. "depthFar",
  23855. "depthFunc",
  23856. "depthMask",
  23857. "depthNear",
  23858. "depthRange",
  23859. "deref",
  23860. "deriveBits",
  23861. "deriveKey",
  23862. "description",
  23863. "deselectAll",
  23864. "designMode",
  23865. "desiredSize",
  23866. "destination",
  23867. "destinationURL",
  23868. "detach",
  23869. "detachEvent",
  23870. "detachShader",
  23871. "detail",
  23872. "details",
  23873. "detect",
  23874. "detune",
  23875. "device",
  23876. "deviceClass",
  23877. "deviceId",
  23878. "deviceMemory",
  23879. "devicePixelContentBoxSize",
  23880. "devicePixelRatio",
  23881. "deviceProtocol",
  23882. "deviceSubclass",
  23883. "deviceVersionMajor",
  23884. "deviceVersionMinor",
  23885. "deviceVersionSubminor",
  23886. "deviceXDPI",
  23887. "deviceYDPI",
  23888. "didTimeout",
  23889. "diffuseConstant",
  23890. "digest",
  23891. "dimensions",
  23892. "dir",
  23893. "dirName",
  23894. "direction",
  23895. "dirxml",
  23896. "disable",
  23897. "disablePictureInPicture",
  23898. "disableRemotePlayback",
  23899. "disableVertexAttribArray",
  23900. "disabled",
  23901. "dischargingTime",
  23902. "disconnect",
  23903. "disconnectShark",
  23904. "dispatchEvent",
  23905. "display",
  23906. "displayId",
  23907. "displayName",
  23908. "disposition",
  23909. "distanceModel",
  23910. "div",
  23911. "divisor",
  23912. "djsapi",
  23913. "djsproxy",
  23914. "doImport",
  23915. "doNotTrack",
  23916. "doScroll",
  23917. "doctype",
  23918. "document",
  23919. "documentElement",
  23920. "documentMode",
  23921. "documentURI",
  23922. "dolphin",
  23923. "dolphinGameCenter",
  23924. "dolphininfo",
  23925. "dolphinmeta",
  23926. "domComplete",
  23927. "domContentLoadedEventEnd",
  23928. "domContentLoadedEventStart",
  23929. "domInteractive",
  23930. "domLoading",
  23931. "domOverlayState",
  23932. "domain",
  23933. "domainLookupEnd",
  23934. "domainLookupStart",
  23935. "dominant-baseline",
  23936. "dominantBaseline",
  23937. "done",
  23938. "dopplerFactor",
  23939. "dotAll",
  23940. "downDegrees",
  23941. "downlink",
  23942. "download",
  23943. "downloadTotal",
  23944. "downloaded",
  23945. "dpcm",
  23946. "dpi",
  23947. "dppx",
  23948. "dragDrop",
  23949. "draggable",
  23950. "drawArrays",
  23951. "drawArraysInstanced",
  23952. "drawArraysInstancedANGLE",
  23953. "drawBuffers",
  23954. "drawCustomFocusRing",
  23955. "drawElements",
  23956. "drawElementsInstanced",
  23957. "drawElementsInstancedANGLE",
  23958. "drawFocusIfNeeded",
  23959. "drawImage",
  23960. "drawImageFromRect",
  23961. "drawRangeElements",
  23962. "drawSystemFocusRing",
  23963. "drawingBufferHeight",
  23964. "drawingBufferWidth",
  23965. "dropEffect",
  23966. "droppedVideoFrames",
  23967. "dropzone",
  23968. "dtmf",
  23969. "dump",
  23970. "dumpProfile",
  23971. "duplicate",
  23972. "durability",
  23973. "duration",
  23974. "dvname",
  23975. "dvnum",
  23976. "dx",
  23977. "dy",
  23978. "dynsrc",
  23979. "e",
  23980. "edgeMode",
  23981. "effect",
  23982. "effectAllowed",
  23983. "effectiveDirective",
  23984. "effectiveType",
  23985. "elapsedTime",
  23986. "element",
  23987. "elementFromPoint",
  23988. "elementTiming",
  23989. "elements",
  23990. "elementsFromPoint",
  23991. "elevation",
  23992. "ellipse",
  23993. "em",
  23994. "email",
  23995. "embeds",
  23996. "emma",
  23997. "empty",
  23998. "empty-cells",
  23999. "emptyCells",
  24000. "emptyHTML",
  24001. "emptyScript",
  24002. "emulatedPosition",
  24003. "enable",
  24004. "enableBackground",
  24005. "enableDelegations",
  24006. "enableStyleSheetsForSet",
  24007. "enableVertexAttribArray",
  24008. "enabled",
  24009. "enabledPlugin",
  24010. "encode",
  24011. "encodeInto",
  24012. "encodeURI",
  24013. "encodeURIComponent",
  24014. "encodedBodySize",
  24015. "encoding",
  24016. "encodingInfo",
  24017. "encrypt",
  24018. "enctype",
  24019. "end",
  24020. "endContainer",
  24021. "endElement",
  24022. "endElementAt",
  24023. "endOfStream",
  24024. "endOffset",
  24025. "endQuery",
  24026. "endTime",
  24027. "endTransformFeedback",
  24028. "ended",
  24029. "endpoint",
  24030. "endpointNumber",
  24031. "endpoints",
  24032. "endsWith",
  24033. "enterKeyHint",
  24034. "entities",
  24035. "entries",
  24036. "entryType",
  24037. "enumerable",
  24038. "enumerate",
  24039. "enumerateDevices",
  24040. "enumerateEditable",
  24041. "environmentBlendMode",
  24042. "equals",
  24043. "error",
  24044. "errorCode",
  24045. "errorDetail",
  24046. "errorText",
  24047. "escape",
  24048. "estimate",
  24049. "eval",
  24050. "evaluate",
  24051. "event",
  24052. "eventPhase",
  24053. "every",
  24054. "ex",
  24055. "exception",
  24056. "exchange",
  24057. "exec",
  24058. "execCommand",
  24059. "execCommandShowHelp",
  24060. "execScript",
  24061. "exitFullscreen",
  24062. "exitPictureInPicture",
  24063. "exitPointerLock",
  24064. "exitPresent",
  24065. "exp",
  24066. "expand",
  24067. "expandEntityReferences",
  24068. "expando",
  24069. "expansion",
  24070. "expiration",
  24071. "expirationTime",
  24072. "expires",
  24073. "expiryDate",
  24074. "explicitOriginalTarget",
  24075. "expm1",
  24076. "exponent",
  24077. "exponentialRampToValueAtTime",
  24078. "exportKey",
  24079. "exports",
  24080. "extend",
  24081. "extensions",
  24082. "extentNode",
  24083. "extentOffset",
  24084. "external",
  24085. "externalResourcesRequired",
  24086. "extractContents",
  24087. "extractable",
  24088. "eye",
  24089. "f",
  24090. "face",
  24091. "factoryReset",
  24092. "failureReason",
  24093. "fallback",
  24094. "family",
  24095. "familyName",
  24096. "farthestViewportElement",
  24097. "fastSeek",
  24098. "fatal",
  24099. "featureId",
  24100. "featurePolicy",
  24101. "featureSettings",
  24102. "features",
  24103. "fenceSync",
  24104. "fetch",
  24105. "fetchStart",
  24106. "fftSize",
  24107. "fgColor",
  24108. "fieldOfView",
  24109. "file",
  24110. "fileCreatedDate",
  24111. "fileHandle",
  24112. "fileModifiedDate",
  24113. "fileName",
  24114. "fileSize",
  24115. "fileUpdatedDate",
  24116. "filename",
  24117. "files",
  24118. "filesystem",
  24119. "fill",
  24120. "fill-opacity",
  24121. "fill-rule",
  24122. "fillLightMode",
  24123. "fillOpacity",
  24124. "fillRect",
  24125. "fillRule",
  24126. "fillStyle",
  24127. "fillText",
  24128. "filter",
  24129. "filterResX",
  24130. "filterResY",
  24131. "filterUnits",
  24132. "filters",
  24133. "finally",
  24134. "find",
  24135. "findIndex",
  24136. "findRule",
  24137. "findText",
  24138. "finish",
  24139. "finished",
  24140. "fireEvent",
  24141. "firesTouchEvents",
  24142. "firstChild",
  24143. "firstElementChild",
  24144. "firstPage",
  24145. "fixed",
  24146. "flags",
  24147. "flat",
  24148. "flatMap",
  24149. "flex",
  24150. "flex-basis",
  24151. "flex-direction",
  24152. "flex-flow",
  24153. "flex-grow",
  24154. "flex-shrink",
  24155. "flex-wrap",
  24156. "flexBasis",
  24157. "flexDirection",
  24158. "flexFlow",
  24159. "flexGrow",
  24160. "flexShrink",
  24161. "flexWrap",
  24162. "flipX",
  24163. "flipY",
  24164. "float",
  24165. "float32",
  24166. "float64",
  24167. "flood-color",
  24168. "flood-opacity",
  24169. "floodColor",
  24170. "floodOpacity",
  24171. "floor",
  24172. "flush",
  24173. "focus",
  24174. "focusNode",
  24175. "focusOffset",
  24176. "font",
  24177. "font-family",
  24178. "font-feature-settings",
  24179. "font-kerning",
  24180. "font-language-override",
  24181. "font-optical-sizing",
  24182. "font-size",
  24183. "font-size-adjust",
  24184. "font-stretch",
  24185. "font-style",
  24186. "font-synthesis",
  24187. "font-variant",
  24188. "font-variant-alternates",
  24189. "font-variant-caps",
  24190. "font-variant-east-asian",
  24191. "font-variant-ligatures",
  24192. "font-variant-numeric",
  24193. "font-variant-position",
  24194. "font-variation-settings",
  24195. "font-weight",
  24196. "fontFamily",
  24197. "fontFeatureSettings",
  24198. "fontKerning",
  24199. "fontLanguageOverride",
  24200. "fontOpticalSizing",
  24201. "fontSize",
  24202. "fontSizeAdjust",
  24203. "fontSmoothingEnabled",
  24204. "fontStretch",
  24205. "fontStyle",
  24206. "fontSynthesis",
  24207. "fontVariant",
  24208. "fontVariantAlternates",
  24209. "fontVariantCaps",
  24210. "fontVariantEastAsian",
  24211. "fontVariantLigatures",
  24212. "fontVariantNumeric",
  24213. "fontVariantPosition",
  24214. "fontVariationSettings",
  24215. "fontWeight",
  24216. "fontcolor",
  24217. "fontfaces",
  24218. "fonts",
  24219. "fontsize",
  24220. "for",
  24221. "forEach",
  24222. "force",
  24223. "forceRedraw",
  24224. "form",
  24225. "formAction",
  24226. "formData",
  24227. "formEnctype",
  24228. "formMethod",
  24229. "formNoValidate",
  24230. "formTarget",
  24231. "format",
  24232. "formatToParts",
  24233. "forms",
  24234. "forward",
  24235. "forwardX",
  24236. "forwardY",
  24237. "forwardZ",
  24238. "foundation",
  24239. "fr",
  24240. "fragmentDirective",
  24241. "frame",
  24242. "frameBorder",
  24243. "frameElement",
  24244. "frameSpacing",
  24245. "framebuffer",
  24246. "framebufferHeight",
  24247. "framebufferRenderbuffer",
  24248. "framebufferTexture2D",
  24249. "framebufferTextureLayer",
  24250. "framebufferWidth",
  24251. "frames",
  24252. "freeSpace",
  24253. "freeze",
  24254. "frequency",
  24255. "frequencyBinCount",
  24256. "from",
  24257. "fromCharCode",
  24258. "fromCodePoint",
  24259. "fromElement",
  24260. "fromEntries",
  24261. "fromFloat32Array",
  24262. "fromFloat64Array",
  24263. "fromMatrix",
  24264. "fromPoint",
  24265. "fromQuad",
  24266. "fromRect",
  24267. "frontFace",
  24268. "fround",
  24269. "fullPath",
  24270. "fullScreen",
  24271. "fullVersionList",
  24272. "fullscreen",
  24273. "fullscreenElement",
  24274. "fullscreenEnabled",
  24275. "fx",
  24276. "fy",
  24277. "gain",
  24278. "gamepad",
  24279. "gamma",
  24280. "gap",
  24281. "gatheringState",
  24282. "gatt",
  24283. "genderIdentity",
  24284. "generateCertificate",
  24285. "generateKey",
  24286. "generateMipmap",
  24287. "generateRequest",
  24288. "geolocation",
  24289. "gestureObject",
  24290. "get",
  24291. "getActiveAttrib",
  24292. "getActiveUniform",
  24293. "getActiveUniformBlockName",
  24294. "getActiveUniformBlockParameter",
  24295. "getActiveUniforms",
  24296. "getAdjacentText",
  24297. "getAll",
  24298. "getAllKeys",
  24299. "getAllResponseHeaders",
  24300. "getAllowlistForFeature",
  24301. "getAnimations",
  24302. "getAsFile",
  24303. "getAsString",
  24304. "getAttachedShaders",
  24305. "getAttribLocation",
  24306. "getAttribute",
  24307. "getAttributeNS",
  24308. "getAttributeNames",
  24309. "getAttributeNode",
  24310. "getAttributeNodeNS",
  24311. "getAttributeType",
  24312. "getAudioTracks",
  24313. "getAvailability",
  24314. "getBBox",
  24315. "getBattery",
  24316. "getBigInt64",
  24317. "getBigUint64",
  24318. "getBlob",
  24319. "getBookmark",
  24320. "getBoundingClientRect",
  24321. "getBounds",
  24322. "getBoxQuads",
  24323. "getBufferParameter",
  24324. "getBufferSubData",
  24325. "getByteFrequencyData",
  24326. "getByteTimeDomainData",
  24327. "getCSSCanvasContext",
  24328. "getCTM",
  24329. "getCandidateWindowClientRect",
  24330. "getCanonicalLocales",
  24331. "getCapabilities",
  24332. "getChannelData",
  24333. "getCharNumAtPosition",
  24334. "getCharacteristic",
  24335. "getCharacteristics",
  24336. "getClientExtensionResults",
  24337. "getClientRect",
  24338. "getClientRects",
  24339. "getCoalescedEvents",
  24340. "getCompositionAlternatives",
  24341. "getComputedStyle",
  24342. "getComputedTextLength",
  24343. "getComputedTiming",
  24344. "getConfiguration",
  24345. "getConstraints",
  24346. "getContext",
  24347. "getContextAttributes",
  24348. "getContributingSources",
  24349. "getCounterValue",
  24350. "getCueAsHTML",
  24351. "getCueById",
  24352. "getCurrentPosition",
  24353. "getCurrentTime",
  24354. "getData",
  24355. "getDatabaseNames",
  24356. "getDate",
  24357. "getDay",
  24358. "getDefaultComputedStyle",
  24359. "getDescriptor",
  24360. "getDescriptors",
  24361. "getDestinationInsertionPoints",
  24362. "getDevices",
  24363. "getDirectory",
  24364. "getDisplayMedia",
  24365. "getDistributedNodes",
  24366. "getEditable",
  24367. "getElementById",
  24368. "getElementsByClassName",
  24369. "getElementsByName",
  24370. "getElementsByTagName",
  24371. "getElementsByTagNameNS",
  24372. "getEnclosureList",
  24373. "getEndPositionOfChar",
  24374. "getEntries",
  24375. "getEntriesByName",
  24376. "getEntriesByType",
  24377. "getError",
  24378. "getExtension",
  24379. "getExtentOfChar",
  24380. "getEyeParameters",
  24381. "getFeature",
  24382. "getFile",
  24383. "getFiles",
  24384. "getFilesAndDirectories",
  24385. "getFingerprints",
  24386. "getFloat32",
  24387. "getFloat64",
  24388. "getFloatFrequencyData",
  24389. "getFloatTimeDomainData",
  24390. "getFloatValue",
  24391. "getFragDataLocation",
  24392. "getFrameData",
  24393. "getFramebufferAttachmentParameter",
  24394. "getFrequencyResponse",
  24395. "getFullYear",
  24396. "getGamepads",
  24397. "getHighEntropyValues",
  24398. "getHitTestResults",
  24399. "getHitTestResultsForTransientInput",
  24400. "getHours",
  24401. "getIdentityAssertion",
  24402. "getIds",
  24403. "getImageData",
  24404. "getIndexedParameter",
  24405. "getInstalledRelatedApps",
  24406. "getInt16",
  24407. "getInt32",
  24408. "getInt8",
  24409. "getInternalformatParameter",
  24410. "getIntersectionList",
  24411. "getItem",
  24412. "getItems",
  24413. "getKey",
  24414. "getKeyframes",
  24415. "getLayers",
  24416. "getLayoutMap",
  24417. "getLineDash",
  24418. "getLocalCandidates",
  24419. "getLocalParameters",
  24420. "getLocalStreams",
  24421. "getMarks",
  24422. "getMatchedCSSRules",
  24423. "getMaxGCPauseSinceClear",
  24424. "getMeasures",
  24425. "getMetadata",
  24426. "getMilliseconds",
  24427. "getMinutes",
  24428. "getModifierState",
  24429. "getMonth",
  24430. "getNamedItem",
  24431. "getNamedItemNS",
  24432. "getNativeFramebufferScaleFactor",
  24433. "getNotifications",
  24434. "getNotifier",
  24435. "getNumberOfChars",
  24436. "getOffsetReferenceSpace",
  24437. "getOutputTimestamp",
  24438. "getOverrideHistoryNavigationMode",
  24439. "getOverrideStyle",
  24440. "getOwnPropertyDescriptor",
  24441. "getOwnPropertyDescriptors",
  24442. "getOwnPropertyNames",
  24443. "getOwnPropertySymbols",
  24444. "getParameter",
  24445. "getParameters",
  24446. "getParent",
  24447. "getPathSegAtLength",
  24448. "getPhotoCapabilities",
  24449. "getPhotoSettings",
  24450. "getPointAtLength",
  24451. "getPose",
  24452. "getPredictedEvents",
  24453. "getPreference",
  24454. "getPreferenceDefault",
  24455. "getPresentationAttribute",
  24456. "getPreventDefault",
  24457. "getPrimaryService",
  24458. "getPrimaryServices",
  24459. "getProgramInfoLog",
  24460. "getProgramParameter",
  24461. "getPropertyCSSValue",
  24462. "getPropertyPriority",
  24463. "getPropertyShorthand",
  24464. "getPropertyType",
  24465. "getPropertyValue",
  24466. "getPrototypeOf",
  24467. "getQuery",
  24468. "getQueryParameter",
  24469. "getRGBColorValue",
  24470. "getRandomValues",
  24471. "getRangeAt",
  24472. "getReader",
  24473. "getReceivers",
  24474. "getRectValue",
  24475. "getRegistration",
  24476. "getRegistrations",
  24477. "getRemoteCandidates",
  24478. "getRemoteCertificates",
  24479. "getRemoteParameters",
  24480. "getRemoteStreams",
  24481. "getRenderbufferParameter",
  24482. "getResponseHeader",
  24483. "getRoot",
  24484. "getRootNode",
  24485. "getRotationOfChar",
  24486. "getSVGDocument",
  24487. "getSamplerParameter",
  24488. "getScreenCTM",
  24489. "getSeconds",
  24490. "getSelectedCandidatePair",
  24491. "getSelection",
  24492. "getSenders",
  24493. "getService",
  24494. "getSettings",
  24495. "getShaderInfoLog",
  24496. "getShaderParameter",
  24497. "getShaderPrecisionFormat",
  24498. "getShaderSource",
  24499. "getSimpleDuration",
  24500. "getSiteIcons",
  24501. "getSources",
  24502. "getSpeculativeParserUrls",
  24503. "getStartPositionOfChar",
  24504. "getStartTime",
  24505. "getState",
  24506. "getStats",
  24507. "getStatusForPolicy",
  24508. "getStorageUpdates",
  24509. "getStreamById",
  24510. "getStringValue",
  24511. "getSubStringLength",
  24512. "getSubscription",
  24513. "getSupportedConstraints",
  24514. "getSupportedExtensions",
  24515. "getSupportedFormats",
  24516. "getSyncParameter",
  24517. "getSynchronizationSources",
  24518. "getTags",
  24519. "getTargetRanges",
  24520. "getTexParameter",
  24521. "getTime",
  24522. "getTimezoneOffset",
  24523. "getTiming",
  24524. "getTotalLength",
  24525. "getTrackById",
  24526. "getTracks",
  24527. "getTransceivers",
  24528. "getTransform",
  24529. "getTransformFeedbackVarying",
  24530. "getTransformToElement",
  24531. "getTransports",
  24532. "getType",
  24533. "getTypeMapping",
  24534. "getUTCDate",
  24535. "getUTCDay",
  24536. "getUTCFullYear",
  24537. "getUTCHours",
  24538. "getUTCMilliseconds",
  24539. "getUTCMinutes",
  24540. "getUTCMonth",
  24541. "getUTCSeconds",
  24542. "getUint16",
  24543. "getUint32",
  24544. "getUint8",
  24545. "getUniform",
  24546. "getUniformBlockIndex",
  24547. "getUniformIndices",
  24548. "getUniformLocation",
  24549. "getUserMedia",
  24550. "getVRDisplays",
  24551. "getValues",
  24552. "getVarDate",
  24553. "getVariableValue",
  24554. "getVertexAttrib",
  24555. "getVertexAttribOffset",
  24556. "getVideoPlaybackQuality",
  24557. "getVideoTracks",
  24558. "getViewerPose",
  24559. "getViewport",
  24560. "getVoices",
  24561. "getWakeLockState",
  24562. "getWriter",
  24563. "getYear",
  24564. "givenName",
  24565. "global",
  24566. "globalAlpha",
  24567. "globalCompositeOperation",
  24568. "globalThis",
  24569. "glyphOrientationHorizontal",
  24570. "glyphOrientationVertical",
  24571. "glyphRef",
  24572. "go",
  24573. "grabFrame",
  24574. "grad",
  24575. "gradientTransform",
  24576. "gradientUnits",
  24577. "grammars",
  24578. "green",
  24579. "grid",
  24580. "grid-area",
  24581. "grid-auto-columns",
  24582. "grid-auto-flow",
  24583. "grid-auto-rows",
  24584. "grid-column",
  24585. "grid-column-end",
  24586. "grid-column-gap",
  24587. "grid-column-start",
  24588. "grid-gap",
  24589. "grid-row",
  24590. "grid-row-end",
  24591. "grid-row-gap",
  24592. "grid-row-start",
  24593. "grid-template",
  24594. "grid-template-areas",
  24595. "grid-template-columns",
  24596. "grid-template-rows",
  24597. "gridArea",
  24598. "gridAutoColumns",
  24599. "gridAutoFlow",
  24600. "gridAutoRows",
  24601. "gridColumn",
  24602. "gridColumnEnd",
  24603. "gridColumnGap",
  24604. "gridColumnStart",
  24605. "gridGap",
  24606. "gridRow",
  24607. "gridRowEnd",
  24608. "gridRowGap",
  24609. "gridRowStart",
  24610. "gridTemplate",
  24611. "gridTemplateAreas",
  24612. "gridTemplateColumns",
  24613. "gridTemplateRows",
  24614. "gripSpace",
  24615. "group",
  24616. "groupCollapsed",
  24617. "groupEnd",
  24618. "groupId",
  24619. "hadRecentInput",
  24620. "hand",
  24621. "handedness",
  24622. "hapticActuators",
  24623. "hardwareConcurrency",
  24624. "has",
  24625. "hasAttribute",
  24626. "hasAttributeNS",
  24627. "hasAttributes",
  24628. "hasBeenActive",
  24629. "hasChildNodes",
  24630. "hasComposition",
  24631. "hasEnrolledInstrument",
  24632. "hasExtension",
  24633. "hasExternalDisplay",
  24634. "hasFeature",
  24635. "hasFocus",
  24636. "hasInstance",
  24637. "hasLayout",
  24638. "hasOrientation",
  24639. "hasOwnProperty",
  24640. "hasPointerCapture",
  24641. "hasPosition",
  24642. "hasReading",
  24643. "hasStorageAccess",
  24644. "hash",
  24645. "head",
  24646. "headers",
  24647. "heading",
  24648. "height",
  24649. "hidden",
  24650. "hide",
  24651. "hideFocus",
  24652. "high",
  24653. "highWaterMark",
  24654. "hint",
  24655. "history",
  24656. "honorificPrefix",
  24657. "honorificSuffix",
  24658. "horizontalOverflow",
  24659. "host",
  24660. "hostCandidate",
  24661. "hostname",
  24662. "href",
  24663. "hrefTranslate",
  24664. "hreflang",
  24665. "hspace",
  24666. "html5TagCheckInerface",
  24667. "htmlFor",
  24668. "htmlText",
  24669. "httpEquiv",
  24670. "httpRequestStatusCode",
  24671. "hwTimestamp",
  24672. "hyphens",
  24673. "hypot",
  24674. "iccId",
  24675. "iceConnectionState",
  24676. "iceGatheringState",
  24677. "iceTransport",
  24678. "icon",
  24679. "iconURL",
  24680. "id",
  24681. "identifier",
  24682. "identity",
  24683. "idpLoginUrl",
  24684. "ignoreBOM",
  24685. "ignoreCase",
  24686. "ignoreDepthValues",
  24687. "image-orientation",
  24688. "image-rendering",
  24689. "imageHeight",
  24690. "imageOrientation",
  24691. "imageRendering",
  24692. "imageSizes",
  24693. "imageSmoothingEnabled",
  24694. "imageSmoothingQuality",
  24695. "imageSrcset",
  24696. "imageWidth",
  24697. "images",
  24698. "ime-mode",
  24699. "imeMode",
  24700. "implementation",
  24701. "importKey",
  24702. "importNode",
  24703. "importStylesheet",
  24704. "imports",
  24705. "impp",
  24706. "imul",
  24707. "in",
  24708. "in1",
  24709. "in2",
  24710. "inBandMetadataTrackDispatchType",
  24711. "inRange",
  24712. "includes",
  24713. "incremental",
  24714. "indeterminate",
  24715. "index",
  24716. "indexNames",
  24717. "indexOf",
  24718. "indexedDB",
  24719. "indicate",
  24720. "inert",
  24721. "inertiaDestinationX",
  24722. "inertiaDestinationY",
  24723. "info",
  24724. "init",
  24725. "initAnimationEvent",
  24726. "initBeforeLoadEvent",
  24727. "initClipboardEvent",
  24728. "initCloseEvent",
  24729. "initCommandEvent",
  24730. "initCompositionEvent",
  24731. "initCustomEvent",
  24732. "initData",
  24733. "initDataType",
  24734. "initDeviceMotionEvent",
  24735. "initDeviceOrientationEvent",
  24736. "initDragEvent",
  24737. "initErrorEvent",
  24738. "initEvent",
  24739. "initFocusEvent",
  24740. "initGestureEvent",
  24741. "initHashChangeEvent",
  24742. "initKeyEvent",
  24743. "initKeyboardEvent",
  24744. "initMSManipulationEvent",
  24745. "initMessageEvent",
  24746. "initMouseEvent",
  24747. "initMouseScrollEvent",
  24748. "initMouseWheelEvent",
  24749. "initMutationEvent",
  24750. "initNSMouseEvent",
  24751. "initOverflowEvent",
  24752. "initPageEvent",
  24753. "initPageTransitionEvent",
  24754. "initPointerEvent",
  24755. "initPopStateEvent",
  24756. "initProgressEvent",
  24757. "initScrollAreaEvent",
  24758. "initSimpleGestureEvent",
  24759. "initStorageEvent",
  24760. "initTextEvent",
  24761. "initTimeEvent",
  24762. "initTouchEvent",
  24763. "initTransitionEvent",
  24764. "initUIEvent",
  24765. "initWebKitAnimationEvent",
  24766. "initWebKitTransitionEvent",
  24767. "initWebKitWheelEvent",
  24768. "initWheelEvent",
  24769. "initialTime",
  24770. "initialize",
  24771. "initiatorType",
  24772. "inline-size",
  24773. "inlineSize",
  24774. "inlineVerticalFieldOfView",
  24775. "inner",
  24776. "innerHTML",
  24777. "innerHeight",
  24778. "innerText",
  24779. "innerWidth",
  24780. "input",
  24781. "inputBuffer",
  24782. "inputEncoding",
  24783. "inputMethod",
  24784. "inputMode",
  24785. "inputSource",
  24786. "inputSources",
  24787. "inputType",
  24788. "inputs",
  24789. "insertAdjacentElement",
  24790. "insertAdjacentHTML",
  24791. "insertAdjacentText",
  24792. "insertBefore",
  24793. "insertCell",
  24794. "insertDTMF",
  24795. "insertData",
  24796. "insertItemBefore",
  24797. "insertNode",
  24798. "insertRow",
  24799. "insertRule",
  24800. "inset",
  24801. "inset-block",
  24802. "inset-block-end",
  24803. "inset-block-start",
  24804. "inset-inline",
  24805. "inset-inline-end",
  24806. "inset-inline-start",
  24807. "insetBlock",
  24808. "insetBlockEnd",
  24809. "insetBlockStart",
  24810. "insetInline",
  24811. "insetInlineEnd",
  24812. "insetInlineStart",
  24813. "installing",
  24814. "instanceRoot",
  24815. "instantiate",
  24816. "instantiateStreaming",
  24817. "instruments",
  24818. "int16",
  24819. "int32",
  24820. "int8",
  24821. "integrity",
  24822. "interactionMode",
  24823. "intercept",
  24824. "interfaceClass",
  24825. "interfaceName",
  24826. "interfaceNumber",
  24827. "interfaceProtocol",
  24828. "interfaceSubclass",
  24829. "interfaces",
  24830. "interimResults",
  24831. "internalSubset",
  24832. "interpretation",
  24833. "intersectionRatio",
  24834. "intersectionRect",
  24835. "intersectsNode",
  24836. "interval",
  24837. "invalidIteratorState",
  24838. "invalidateFramebuffer",
  24839. "invalidateSubFramebuffer",
  24840. "inverse",
  24841. "invertSelf",
  24842. "is",
  24843. "is2D",
  24844. "isActive",
  24845. "isAlternate",
  24846. "isArray",
  24847. "isBingCurrentSearchDefault",
  24848. "isBuffer",
  24849. "isCandidateWindowVisible",
  24850. "isChar",
  24851. "isCollapsed",
  24852. "isComposing",
  24853. "isConcatSpreadable",
  24854. "isConnected",
  24855. "isContentEditable",
  24856. "isContentHandlerRegistered",
  24857. "isContextLost",
  24858. "isDefaultNamespace",
  24859. "isDirectory",
  24860. "isDisabled",
  24861. "isEnabled",
  24862. "isEqual",
  24863. "isEqualNode",
  24864. "isExtensible",
  24865. "isExternalCTAP2SecurityKeySupported",
  24866. "isFile",
  24867. "isFinite",
  24868. "isFramebuffer",
  24869. "isFrozen",
  24870. "isGenerator",
  24871. "isHTML",
  24872. "isHistoryNavigation",
  24873. "isId",
  24874. "isIdentity",
  24875. "isInjected",
  24876. "isInteger",
  24877. "isIntersecting",
  24878. "isLockFree",
  24879. "isMap",
  24880. "isMultiLine",
  24881. "isNaN",
  24882. "isOpen",
  24883. "isPointInFill",
  24884. "isPointInPath",
  24885. "isPointInRange",
  24886. "isPointInStroke",
  24887. "isPrefAlternate",
  24888. "isPresenting",
  24889. "isPrimary",
  24890. "isProgram",
  24891. "isPropertyImplicit",
  24892. "isProtocolHandlerRegistered",
  24893. "isPrototypeOf",
  24894. "isQuery",
  24895. "isRenderbuffer",
  24896. "isSafeInteger",
  24897. "isSameNode",
  24898. "isSampler",
  24899. "isScript",
  24900. "isScriptURL",
  24901. "isSealed",
  24902. "isSecureContext",
  24903. "isSessionSupported",
  24904. "isShader",
  24905. "isSupported",
  24906. "isSync",
  24907. "isTextEdit",
  24908. "isTexture",
  24909. "isTransformFeedback",
  24910. "isTrusted",
  24911. "isTypeSupported",
  24912. "isUserVerifyingPlatformAuthenticatorAvailable",
  24913. "isVertexArray",
  24914. "isView",
  24915. "isVisible",
  24916. "isochronousTransferIn",
  24917. "isochronousTransferOut",
  24918. "isolation",
  24919. "italics",
  24920. "item",
  24921. "itemId",
  24922. "itemProp",
  24923. "itemRef",
  24924. "itemScope",
  24925. "itemType",
  24926. "itemValue",
  24927. "items",
  24928. "iterateNext",
  24929. "iterationComposite",
  24930. "iterator",
  24931. "javaEnabled",
  24932. "jobTitle",
  24933. "join",
  24934. "json",
  24935. "justify-content",
  24936. "justify-items",
  24937. "justify-self",
  24938. "justifyContent",
  24939. "justifyItems",
  24940. "justifySelf",
  24941. "k1",
  24942. "k2",
  24943. "k3",
  24944. "k4",
  24945. "kHz",
  24946. "keepalive",
  24947. "kernelMatrix",
  24948. "kernelUnitLengthX",
  24949. "kernelUnitLengthY",
  24950. "kerning",
  24951. "key",
  24952. "keyCode",
  24953. "keyFor",
  24954. "keyIdentifier",
  24955. "keyLightEnabled",
  24956. "keyLocation",
  24957. "keyPath",
  24958. "keyStatuses",
  24959. "keySystem",
  24960. "keyText",
  24961. "keyUsage",
  24962. "keyboard",
  24963. "keys",
  24964. "keytype",
  24965. "kind",
  24966. "knee",
  24967. "label",
  24968. "labels",
  24969. "lang",
  24970. "language",
  24971. "languages",
  24972. "largeArcFlag",
  24973. "lastChild",
  24974. "lastElementChild",
  24975. "lastEventId",
  24976. "lastIndex",
  24977. "lastIndexOf",
  24978. "lastInputTime",
  24979. "lastMatch",
  24980. "lastMessageSubject",
  24981. "lastMessageType",
  24982. "lastModified",
  24983. "lastModifiedDate",
  24984. "lastPage",
  24985. "lastParen",
  24986. "lastState",
  24987. "lastStyleSheetSet",
  24988. "latitude",
  24989. "layerX",
  24990. "layerY",
  24991. "layoutFlow",
  24992. "layoutGrid",
  24993. "layoutGridChar",
  24994. "layoutGridLine",
  24995. "layoutGridMode",
  24996. "layoutGridType",
  24997. "lbound",
  24998. "left",
  24999. "leftContext",
  25000. "leftDegrees",
  25001. "leftMargin",
  25002. "leftProjectionMatrix",
  25003. "leftViewMatrix",
  25004. "length",
  25005. "lengthAdjust",
  25006. "lengthComputable",
  25007. "letter-spacing",
  25008. "letterSpacing",
  25009. "level",
  25010. "lighting-color",
  25011. "lightingColor",
  25012. "limitingConeAngle",
  25013. "line",
  25014. "line-break",
  25015. "line-height",
  25016. "lineAlign",
  25017. "lineBreak",
  25018. "lineCap",
  25019. "lineDashOffset",
  25020. "lineHeight",
  25021. "lineJoin",
  25022. "lineNumber",
  25023. "lineTo",
  25024. "lineWidth",
  25025. "linearAcceleration",
  25026. "linearRampToValueAtTime",
  25027. "linearVelocity",
  25028. "lineno",
  25029. "lines",
  25030. "link",
  25031. "linkColor",
  25032. "linkProgram",
  25033. "links",
  25034. "list",
  25035. "list-style",
  25036. "list-style-image",
  25037. "list-style-position",
  25038. "list-style-type",
  25039. "listStyle",
  25040. "listStyleImage",
  25041. "listStylePosition",
  25042. "listStyleType",
  25043. "listener",
  25044. "load",
  25045. "loadEventEnd",
  25046. "loadEventStart",
  25047. "loadTime",
  25048. "loadTimes",
  25049. "loaded",
  25050. "loading",
  25051. "localDescription",
  25052. "localName",
  25053. "localService",
  25054. "localStorage",
  25055. "locale",
  25056. "localeCompare",
  25057. "location",
  25058. "locationbar",
  25059. "lock",
  25060. "locked",
  25061. "lockedFile",
  25062. "locks",
  25063. "log",
  25064. "log10",
  25065. "log1p",
  25066. "log2",
  25067. "logicalXDPI",
  25068. "logicalYDPI",
  25069. "longDesc",
  25070. "longitude",
  25071. "lookupNamespaceURI",
  25072. "lookupPrefix",
  25073. "loop",
  25074. "loopEnd",
  25075. "loopStart",
  25076. "looping",
  25077. "low",
  25078. "lower",
  25079. "lowerBound",
  25080. "lowerOpen",
  25081. "lowsrc",
  25082. "m11",
  25083. "m12",
  25084. "m13",
  25085. "m14",
  25086. "m21",
  25087. "m22",
  25088. "m23",
  25089. "m24",
  25090. "m31",
  25091. "m32",
  25092. "m33",
  25093. "m34",
  25094. "m41",
  25095. "m42",
  25096. "m43",
  25097. "m44",
  25098. "makeXRCompatible",
  25099. "manifest",
  25100. "manufacturer",
  25101. "manufacturerName",
  25102. "map",
  25103. "mapping",
  25104. "margin",
  25105. "margin-block",
  25106. "margin-block-end",
  25107. "margin-block-start",
  25108. "margin-bottom",
  25109. "margin-inline",
  25110. "margin-inline-end",
  25111. "margin-inline-start",
  25112. "margin-left",
  25113. "margin-right",
  25114. "margin-top",
  25115. "marginBlock",
  25116. "marginBlockEnd",
  25117. "marginBlockStart",
  25118. "marginBottom",
  25119. "marginHeight",
  25120. "marginInline",
  25121. "marginInlineEnd",
  25122. "marginInlineStart",
  25123. "marginLeft",
  25124. "marginRight",
  25125. "marginTop",
  25126. "marginWidth",
  25127. "mark",
  25128. "marker",
  25129. "marker-end",
  25130. "marker-mid",
  25131. "marker-offset",
  25132. "marker-start",
  25133. "markerEnd",
  25134. "markerHeight",
  25135. "markerMid",
  25136. "markerOffset",
  25137. "markerStart",
  25138. "markerUnits",
  25139. "markerWidth",
  25140. "marks",
  25141. "mask",
  25142. "mask-clip",
  25143. "mask-composite",
  25144. "mask-image",
  25145. "mask-mode",
  25146. "mask-origin",
  25147. "mask-position",
  25148. "mask-position-x",
  25149. "mask-position-y",
  25150. "mask-repeat",
  25151. "mask-size",
  25152. "mask-type",
  25153. "maskClip",
  25154. "maskComposite",
  25155. "maskContentUnits",
  25156. "maskImage",
  25157. "maskMode",
  25158. "maskOrigin",
  25159. "maskPosition",
  25160. "maskPositionX",
  25161. "maskPositionY",
  25162. "maskRepeat",
  25163. "maskSize",
  25164. "maskType",
  25165. "maskUnits",
  25166. "match",
  25167. "matchAll",
  25168. "matchMedia",
  25169. "matchMedium",
  25170. "matches",
  25171. "matrix",
  25172. "matrixTransform",
  25173. "max",
  25174. "max-block-size",
  25175. "max-height",
  25176. "max-inline-size",
  25177. "max-width",
  25178. "maxActions",
  25179. "maxAlternatives",
  25180. "maxBlockSize",
  25181. "maxChannelCount",
  25182. "maxChannels",
  25183. "maxConnectionsPerServer",
  25184. "maxDecibels",
  25185. "maxDistance",
  25186. "maxHeight",
  25187. "maxInlineSize",
  25188. "maxLayers",
  25189. "maxLength",
  25190. "maxMessageSize",
  25191. "maxPacketLifeTime",
  25192. "maxRetransmits",
  25193. "maxTouchPoints",
  25194. "maxValue",
  25195. "maxWidth",
  25196. "measure",
  25197. "measureText",
  25198. "media",
  25199. "mediaCapabilities",
  25200. "mediaDevices",
  25201. "mediaElement",
  25202. "mediaGroup",
  25203. "mediaKeys",
  25204. "mediaSession",
  25205. "mediaStream",
  25206. "mediaText",
  25207. "meetOrSlice",
  25208. "memory",
  25209. "menubar",
  25210. "mergeAttributes",
  25211. "message",
  25212. "messageClass",
  25213. "messageHandlers",
  25214. "messageType",
  25215. "metaKey",
  25216. "metadata",
  25217. "method",
  25218. "methodDetails",
  25219. "methodName",
  25220. "mid",
  25221. "mimeType",
  25222. "mimeTypes",
  25223. "min",
  25224. "min-block-size",
  25225. "min-height",
  25226. "min-inline-size",
  25227. "min-width",
  25228. "minBlockSize",
  25229. "minDecibels",
  25230. "minHeight",
  25231. "minInlineSize",
  25232. "minLength",
  25233. "minValue",
  25234. "minWidth",
  25235. "miterLimit",
  25236. "mix-blend-mode",
  25237. "mixBlendMode",
  25238. "mm",
  25239. "mobile",
  25240. "mode",
  25241. "model",
  25242. "modify",
  25243. "mount",
  25244. "move",
  25245. "moveBy",
  25246. "moveEnd",
  25247. "moveFirst",
  25248. "moveFocusDown",
  25249. "moveFocusLeft",
  25250. "moveFocusRight",
  25251. "moveFocusUp",
  25252. "moveNext",
  25253. "moveRow",
  25254. "moveStart",
  25255. "moveTo",
  25256. "moveToBookmark",
  25257. "moveToElementText",
  25258. "moveToPoint",
  25259. "movementX",
  25260. "movementY",
  25261. "mozAdd",
  25262. "mozAnimationStartTime",
  25263. "mozAnon",
  25264. "mozApps",
  25265. "mozAudioCaptured",
  25266. "mozAudioChannelType",
  25267. "mozAutoplayEnabled",
  25268. "mozCancelAnimationFrame",
  25269. "mozCancelFullScreen",
  25270. "mozCancelRequestAnimationFrame",
  25271. "mozCaptureStream",
  25272. "mozCaptureStreamUntilEnded",
  25273. "mozClearDataAt",
  25274. "mozContact",
  25275. "mozContacts",
  25276. "mozCreateFileHandle",
  25277. "mozCurrentTransform",
  25278. "mozCurrentTransformInverse",
  25279. "mozCursor",
  25280. "mozDash",
  25281. "mozDashOffset",
  25282. "mozDecodedFrames",
  25283. "mozExitPointerLock",
  25284. "mozFillRule",
  25285. "mozFragmentEnd",
  25286. "mozFrameDelay",
  25287. "mozFullScreen",
  25288. "mozFullScreenElement",
  25289. "mozFullScreenEnabled",
  25290. "mozGetAll",
  25291. "mozGetAllKeys",
  25292. "mozGetAsFile",
  25293. "mozGetDataAt",
  25294. "mozGetMetadata",
  25295. "mozGetUserMedia",
  25296. "mozHasAudio",
  25297. "mozHasItem",
  25298. "mozHidden",
  25299. "mozImageSmoothingEnabled",
  25300. "mozIndexedDB",
  25301. "mozInnerScreenX",
  25302. "mozInnerScreenY",
  25303. "mozInputSource",
  25304. "mozIsTextField",
  25305. "mozItem",
  25306. "mozItemCount",
  25307. "mozItems",
  25308. "mozLength",
  25309. "mozLockOrientation",
  25310. "mozMatchesSelector",
  25311. "mozMovementX",
  25312. "mozMovementY",
  25313. "mozOpaque",
  25314. "mozOrientation",
  25315. "mozPaintCount",
  25316. "mozPaintedFrames",
  25317. "mozParsedFrames",
  25318. "mozPay",
  25319. "mozPointerLockElement",
  25320. "mozPresentedFrames",
  25321. "mozPreservesPitch",
  25322. "mozPressure",
  25323. "mozPrintCallback",
  25324. "mozRTCIceCandidate",
  25325. "mozRTCPeerConnection",
  25326. "mozRTCSessionDescription",
  25327. "mozRemove",
  25328. "mozRequestAnimationFrame",
  25329. "mozRequestFullScreen",
  25330. "mozRequestPointerLock",
  25331. "mozSetDataAt",
  25332. "mozSetImageElement",
  25333. "mozSourceNode",
  25334. "mozSrcObject",
  25335. "mozSystem",
  25336. "mozTCPSocket",
  25337. "mozTextStyle",
  25338. "mozTypesAt",
  25339. "mozUnlockOrientation",
  25340. "mozUserCancelled",
  25341. "mozVisibilityState",
  25342. "ms",
  25343. "msAnimation",
  25344. "msAnimationDelay",
  25345. "msAnimationDirection",
  25346. "msAnimationDuration",
  25347. "msAnimationFillMode",
  25348. "msAnimationIterationCount",
  25349. "msAnimationName",
  25350. "msAnimationPlayState",
  25351. "msAnimationStartTime",
  25352. "msAnimationTimingFunction",
  25353. "msBackfaceVisibility",
  25354. "msBlockProgression",
  25355. "msCSSOMElementFloatMetrics",
  25356. "msCaching",
  25357. "msCachingEnabled",
  25358. "msCancelRequestAnimationFrame",
  25359. "msCapsLockWarningOff",
  25360. "msClearImmediate",
  25361. "msClose",
  25362. "msContentZoomChaining",
  25363. "msContentZoomFactor",
  25364. "msContentZoomLimit",
  25365. "msContentZoomLimitMax",
  25366. "msContentZoomLimitMin",
  25367. "msContentZoomSnap",
  25368. "msContentZoomSnapPoints",
  25369. "msContentZoomSnapType",
  25370. "msContentZooming",
  25371. "msConvertURL",
  25372. "msCrypto",
  25373. "msDoNotTrack",
  25374. "msElementsFromPoint",
  25375. "msElementsFromRect",
  25376. "msExitFullscreen",
  25377. "msExtendedCode",
  25378. "msFillRule",
  25379. "msFirstPaint",
  25380. "msFlex",
  25381. "msFlexAlign",
  25382. "msFlexDirection",
  25383. "msFlexFlow",
  25384. "msFlexItemAlign",
  25385. "msFlexLinePack",
  25386. "msFlexNegative",
  25387. "msFlexOrder",
  25388. "msFlexPack",
  25389. "msFlexPositive",
  25390. "msFlexPreferredSize",
  25391. "msFlexWrap",
  25392. "msFlowFrom",
  25393. "msFlowInto",
  25394. "msFontFeatureSettings",
  25395. "msFullscreenElement",
  25396. "msFullscreenEnabled",
  25397. "msGetInputContext",
  25398. "msGetRegionContent",
  25399. "msGetUntransformedBounds",
  25400. "msGraphicsTrustStatus",
  25401. "msGridColumn",
  25402. "msGridColumnAlign",
  25403. "msGridColumnSpan",
  25404. "msGridColumns",
  25405. "msGridRow",
  25406. "msGridRowAlign",
  25407. "msGridRowSpan",
  25408. "msGridRows",
  25409. "msHidden",
  25410. "msHighContrastAdjust",
  25411. "msHyphenateLimitChars",
  25412. "msHyphenateLimitLines",
  25413. "msHyphenateLimitZone",
  25414. "msHyphens",
  25415. "msImageSmoothingEnabled",
  25416. "msImeAlign",
  25417. "msIndexedDB",
  25418. "msInterpolationMode",
  25419. "msIsStaticHTML",
  25420. "msKeySystem",
  25421. "msKeys",
  25422. "msLaunchUri",
  25423. "msLockOrientation",
  25424. "msManipulationViewsEnabled",
  25425. "msMatchMedia",
  25426. "msMatchesSelector",
  25427. "msMaxTouchPoints",
  25428. "msOrientation",
  25429. "msOverflowStyle",
  25430. "msPerspective",
  25431. "msPerspectiveOrigin",
  25432. "msPlayToDisabled",
  25433. "msPlayToPreferredSourceUri",
  25434. "msPlayToPrimary",
  25435. "msPointerEnabled",
  25436. "msRegionOverflow",
  25437. "msReleasePointerCapture",
  25438. "msRequestAnimationFrame",
  25439. "msRequestFullscreen",
  25440. "msSaveBlob",
  25441. "msSaveOrOpenBlob",
  25442. "msScrollChaining",
  25443. "msScrollLimit",
  25444. "msScrollLimitXMax",
  25445. "msScrollLimitXMin",
  25446. "msScrollLimitYMax",
  25447. "msScrollLimitYMin",
  25448. "msScrollRails",
  25449. "msScrollSnapPointsX",
  25450. "msScrollSnapPointsY",
  25451. "msScrollSnapType",
  25452. "msScrollSnapX",
  25453. "msScrollSnapY",
  25454. "msScrollTranslation",
  25455. "msSetImmediate",
  25456. "msSetMediaKeys",
  25457. "msSetPointerCapture",
  25458. "msTextCombineHorizontal",
  25459. "msTextSizeAdjust",
  25460. "msToBlob",
  25461. "msTouchAction",
  25462. "msTouchSelect",
  25463. "msTraceAsyncCallbackCompleted",
  25464. "msTraceAsyncCallbackStarting",
  25465. "msTraceAsyncOperationCompleted",
  25466. "msTraceAsyncOperationStarting",
  25467. "msTransform",
  25468. "msTransformOrigin",
  25469. "msTransformStyle",
  25470. "msTransition",
  25471. "msTransitionDelay",
  25472. "msTransitionDuration",
  25473. "msTransitionProperty",
  25474. "msTransitionTimingFunction",
  25475. "msUnlockOrientation",
  25476. "msUpdateAsyncCallbackRelation",
  25477. "msUserSelect",
  25478. "msVisibilityState",
  25479. "msWrapFlow",
  25480. "msWrapMargin",
  25481. "msWrapThrough",
  25482. "msWriteProfilerMark",
  25483. "msZoom",
  25484. "msZoomTo",
  25485. "mt",
  25486. "mul",
  25487. "multiEntry",
  25488. "multiSelectionObj",
  25489. "multiline",
  25490. "multiple",
  25491. "multiply",
  25492. "multiplySelf",
  25493. "mutableFile",
  25494. "muted",
  25495. "n",
  25496. "name",
  25497. "nameProp",
  25498. "namedItem",
  25499. "namedRecordset",
  25500. "names",
  25501. "namespaceURI",
  25502. "namespaces",
  25503. "naturalHeight",
  25504. "naturalWidth",
  25505. "navigate",
  25506. "navigation",
  25507. "navigationMode",
  25508. "navigationPreload",
  25509. "navigationStart",
  25510. "navigator",
  25511. "near",
  25512. "nearestViewportElement",
  25513. "negative",
  25514. "negotiated",
  25515. "netscape",
  25516. "networkState",
  25517. "newScale",
  25518. "newTranslate",
  25519. "newURL",
  25520. "newValue",
  25521. "newValueSpecifiedUnits",
  25522. "newVersion",
  25523. "newhome",
  25524. "next",
  25525. "nextElementSibling",
  25526. "nextHopProtocol",
  25527. "nextNode",
  25528. "nextPage",
  25529. "nextSibling",
  25530. "nickname",
  25531. "noHref",
  25532. "noModule",
  25533. "noResize",
  25534. "noShade",
  25535. "noValidate",
  25536. "noWrap",
  25537. "node",
  25538. "nodeName",
  25539. "nodeType",
  25540. "nodeValue",
  25541. "nonce",
  25542. "normalize",
  25543. "normalizedPathSegList",
  25544. "notationName",
  25545. "notations",
  25546. "note",
  25547. "noteGrainOn",
  25548. "noteOff",
  25549. "noteOn",
  25550. "notify",
  25551. "now",
  25552. "numOctaves",
  25553. "number",
  25554. "numberOfChannels",
  25555. "numberOfInputs",
  25556. "numberOfItems",
  25557. "numberOfOutputs",
  25558. "numberValue",
  25559. "oMatchesSelector",
  25560. "object",
  25561. "object-fit",
  25562. "object-position",
  25563. "objectFit",
  25564. "objectPosition",
  25565. "objectStore",
  25566. "objectStoreNames",
  25567. "objectType",
  25568. "observe",
  25569. "of",
  25570. "offscreenBuffering",
  25571. "offset",
  25572. "offset-anchor",
  25573. "offset-distance",
  25574. "offset-path",
  25575. "offset-rotate",
  25576. "offsetAnchor",
  25577. "offsetDistance",
  25578. "offsetHeight",
  25579. "offsetLeft",
  25580. "offsetNode",
  25581. "offsetParent",
  25582. "offsetPath",
  25583. "offsetRotate",
  25584. "offsetTop",
  25585. "offsetWidth",
  25586. "offsetX",
  25587. "offsetY",
  25588. "ok",
  25589. "oldURL",
  25590. "oldValue",
  25591. "oldVersion",
  25592. "olderShadowRoot",
  25593. "onLine",
  25594. "onabort",
  25595. "onabsolutedeviceorientation",
  25596. "onactivate",
  25597. "onactive",
  25598. "onaddsourcebuffer",
  25599. "onaddstream",
  25600. "onaddtrack",
  25601. "onafterprint",
  25602. "onafterscriptexecute",
  25603. "onafterupdate",
  25604. "onanimationcancel",
  25605. "onanimationend",
  25606. "onanimationiteration",
  25607. "onanimationstart",
  25608. "onappinstalled",
  25609. "onaudioend",
  25610. "onaudioprocess",
  25611. "onaudiostart",
  25612. "onautocomplete",
  25613. "onautocompleteerror",
  25614. "onauxclick",
  25615. "onbeforeactivate",
  25616. "onbeforecopy",
  25617. "onbeforecut",
  25618. "onbeforedeactivate",
  25619. "onbeforeeditfocus",
  25620. "onbeforeinstallprompt",
  25621. "onbeforepaste",
  25622. "onbeforeprint",
  25623. "onbeforescriptexecute",
  25624. "onbeforeunload",
  25625. "onbeforeupdate",
  25626. "onbeforexrselect",
  25627. "onbegin",
  25628. "onblocked",
  25629. "onblur",
  25630. "onbounce",
  25631. "onboundary",
  25632. "onbufferedamountlow",
  25633. "oncached",
  25634. "oncancel",
  25635. "oncandidatewindowhide",
  25636. "oncandidatewindowshow",
  25637. "oncandidatewindowupdate",
  25638. "oncanplay",
  25639. "oncanplaythrough",
  25640. "once",
  25641. "oncellchange",
  25642. "onchange",
  25643. "oncharacteristicvaluechanged",
  25644. "onchargingchange",
  25645. "onchargingtimechange",
  25646. "onchecking",
  25647. "onclick",
  25648. "onclose",
  25649. "onclosing",
  25650. "oncompassneedscalibration",
  25651. "oncomplete",
  25652. "onconnect",
  25653. "onconnecting",
  25654. "onconnectionavailable",
  25655. "onconnectionstatechange",
  25656. "oncontextmenu",
  25657. "oncontrollerchange",
  25658. "oncontrolselect",
  25659. "oncopy",
  25660. "oncuechange",
  25661. "oncut",
  25662. "ondataavailable",
  25663. "ondatachannel",
  25664. "ondatasetchanged",
  25665. "ondatasetcomplete",
  25666. "ondblclick",
  25667. "ondeactivate",
  25668. "ondevicechange",
  25669. "ondevicelight",
  25670. "ondevicemotion",
  25671. "ondeviceorientation",
  25672. "ondeviceorientationabsolute",
  25673. "ondeviceproximity",
  25674. "ondischargingtimechange",
  25675. "ondisconnect",
  25676. "ondisplay",
  25677. "ondownloading",
  25678. "ondrag",
  25679. "ondragend",
  25680. "ondragenter",
  25681. "ondragexit",
  25682. "ondragleave",
  25683. "ondragover",
  25684. "ondragstart",
  25685. "ondrop",
  25686. "ondurationchange",
  25687. "onemptied",
  25688. "onencrypted",
  25689. "onend",
  25690. "onended",
  25691. "onenter",
  25692. "onenterpictureinpicture",
  25693. "onerror",
  25694. "onerrorupdate",
  25695. "onexit",
  25696. "onfilterchange",
  25697. "onfinish",
  25698. "onfocus",
  25699. "onfocusin",
  25700. "onfocusout",
  25701. "onformdata",
  25702. "onfreeze",
  25703. "onfullscreenchange",
  25704. "onfullscreenerror",
  25705. "ongatheringstatechange",
  25706. "ongattserverdisconnected",
  25707. "ongesturechange",
  25708. "ongestureend",
  25709. "ongesturestart",
  25710. "ongotpointercapture",
  25711. "onhashchange",
  25712. "onhelp",
  25713. "onicecandidate",
  25714. "onicecandidateerror",
  25715. "oniceconnectionstatechange",
  25716. "onicegatheringstatechange",
  25717. "oninactive",
  25718. "oninput",
  25719. "oninputsourceschange",
  25720. "oninvalid",
  25721. "onkeydown",
  25722. "onkeypress",
  25723. "onkeystatuseschange",
  25724. "onkeyup",
  25725. "onlanguagechange",
  25726. "onlayoutcomplete",
  25727. "onleavepictureinpicture",
  25728. "onlevelchange",
  25729. "onload",
  25730. "onloadeddata",
  25731. "onloadedmetadata",
  25732. "onloadend",
  25733. "onloading",
  25734. "onloadingdone",
  25735. "onloadingerror",
  25736. "onloadstart",
  25737. "onlosecapture",
  25738. "onlostpointercapture",
  25739. "only",
  25740. "onmark",
  25741. "onmessage",
  25742. "onmessageerror",
  25743. "onmidimessage",
  25744. "onmousedown",
  25745. "onmouseenter",
  25746. "onmouseleave",
  25747. "onmousemove",
  25748. "onmouseout",
  25749. "onmouseover",
  25750. "onmouseup",
  25751. "onmousewheel",
  25752. "onmove",
  25753. "onmoveend",
  25754. "onmovestart",
  25755. "onmozfullscreenchange",
  25756. "onmozfullscreenerror",
  25757. "onmozorientationchange",
  25758. "onmozpointerlockchange",
  25759. "onmozpointerlockerror",
  25760. "onmscontentzoom",
  25761. "onmsfullscreenchange",
  25762. "onmsfullscreenerror",
  25763. "onmsgesturechange",
  25764. "onmsgesturedoubletap",
  25765. "onmsgestureend",
  25766. "onmsgesturehold",
  25767. "onmsgesturestart",
  25768. "onmsgesturetap",
  25769. "onmsgotpointercapture",
  25770. "onmsinertiastart",
  25771. "onmslostpointercapture",
  25772. "onmsmanipulationstatechanged",
  25773. "onmsneedkey",
  25774. "onmsorientationchange",
  25775. "onmspointercancel",
  25776. "onmspointerdown",
  25777. "onmspointerenter",
  25778. "onmspointerhover",
  25779. "onmspointerleave",
  25780. "onmspointermove",
  25781. "onmspointerout",
  25782. "onmspointerover",
  25783. "onmspointerup",
  25784. "onmssitemodejumplistitemremoved",
  25785. "onmsthumbnailclick",
  25786. "onmute",
  25787. "onnegotiationneeded",
  25788. "onnomatch",
  25789. "onnoupdate",
  25790. "onobsolete",
  25791. "onoffline",
  25792. "ononline",
  25793. "onopen",
  25794. "onorientationchange",
  25795. "onpagechange",
  25796. "onpagehide",
  25797. "onpageshow",
  25798. "onpaste",
  25799. "onpause",
  25800. "onpayerdetailchange",
  25801. "onpaymentmethodchange",
  25802. "onplay",
  25803. "onplaying",
  25804. "onpluginstreamstart",
  25805. "onpointercancel",
  25806. "onpointerdown",
  25807. "onpointerenter",
  25808. "onpointerleave",
  25809. "onpointerlockchange",
  25810. "onpointerlockerror",
  25811. "onpointermove",
  25812. "onpointerout",
  25813. "onpointerover",
  25814. "onpointerrawupdate",
  25815. "onpointerup",
  25816. "onpopstate",
  25817. "onprocessorerror",
  25818. "onprogress",
  25819. "onpropertychange",
  25820. "onratechange",
  25821. "onreading",
  25822. "onreadystatechange",
  25823. "onrejectionhandled",
  25824. "onrelease",
  25825. "onremove",
  25826. "onremovesourcebuffer",
  25827. "onremovestream",
  25828. "onremovetrack",
  25829. "onrepeat",
  25830. "onreset",
  25831. "onresize",
  25832. "onresizeend",
  25833. "onresizestart",
  25834. "onresourcetimingbufferfull",
  25835. "onresult",
  25836. "onresume",
  25837. "onrowenter",
  25838. "onrowexit",
  25839. "onrowsdelete",
  25840. "onrowsinserted",
  25841. "onscroll",
  25842. "onsearch",
  25843. "onsecuritypolicyviolation",
  25844. "onseeked",
  25845. "onseeking",
  25846. "onselect",
  25847. "onselectedcandidatepairchange",
  25848. "onselectend",
  25849. "onselectionchange",
  25850. "onselectstart",
  25851. "onshippingaddresschange",
  25852. "onshippingoptionchange",
  25853. "onshow",
  25854. "onsignalingstatechange",
  25855. "onsoundend",
  25856. "onsoundstart",
  25857. "onsourceclose",
  25858. "onsourceclosed",
  25859. "onsourceended",
  25860. "onsourceopen",
  25861. "onspeechend",
  25862. "onspeechstart",
  25863. "onsqueeze",
  25864. "onsqueezeend",
  25865. "onsqueezestart",
  25866. "onstalled",
  25867. "onstart",
  25868. "onstatechange",
  25869. "onstop",
  25870. "onstorage",
  25871. "onstoragecommit",
  25872. "onsubmit",
  25873. "onsuccess",
  25874. "onsuspend",
  25875. "onterminate",
  25876. "ontextinput",
  25877. "ontimeout",
  25878. "ontimeupdate",
  25879. "ontoggle",
  25880. "ontonechange",
  25881. "ontouchcancel",
  25882. "ontouchend",
  25883. "ontouchmove",
  25884. "ontouchstart",
  25885. "ontrack",
  25886. "ontransitioncancel",
  25887. "ontransitionend",
  25888. "ontransitionrun",
  25889. "ontransitionstart",
  25890. "onunhandledrejection",
  25891. "onunload",
  25892. "onunmute",
  25893. "onupdate",
  25894. "onupdateend",
  25895. "onupdatefound",
  25896. "onupdateready",
  25897. "onupdatestart",
  25898. "onupgradeneeded",
  25899. "onuserproximity",
  25900. "onversionchange",
  25901. "onvisibilitychange",
  25902. "onvoiceschanged",
  25903. "onvolumechange",
  25904. "onvrdisplayactivate",
  25905. "onvrdisplayconnect",
  25906. "onvrdisplaydeactivate",
  25907. "onvrdisplaydisconnect",
  25908. "onvrdisplaypresentchange",
  25909. "onwaiting",
  25910. "onwaitingforkey",
  25911. "onwarning",
  25912. "onwebkitanimationend",
  25913. "onwebkitanimationiteration",
  25914. "onwebkitanimationstart",
  25915. "onwebkitcurrentplaybacktargetiswirelesschanged",
  25916. "onwebkitfullscreenchange",
  25917. "onwebkitfullscreenerror",
  25918. "onwebkitkeyadded",
  25919. "onwebkitkeyerror",
  25920. "onwebkitkeymessage",
  25921. "onwebkitneedkey",
  25922. "onwebkitorientationchange",
  25923. "onwebkitplaybacktargetavailabilitychanged",
  25924. "onwebkitpointerlockchange",
  25925. "onwebkitpointerlockerror",
  25926. "onwebkitresourcetimingbufferfull",
  25927. "onwebkittransitionend",
  25928. "onwheel",
  25929. "onzoom",
  25930. "opacity",
  25931. "open",
  25932. "openCursor",
  25933. "openDatabase",
  25934. "openKeyCursor",
  25935. "opened",
  25936. "opener",
  25937. "opera",
  25938. "operationType",
  25939. "operator",
  25940. "opr",
  25941. "optimum",
  25942. "options",
  25943. "or",
  25944. "order",
  25945. "orderX",
  25946. "orderY",
  25947. "ordered",
  25948. "org",
  25949. "organization",
  25950. "orient",
  25951. "orientAngle",
  25952. "orientType",
  25953. "orientation",
  25954. "orientationX",
  25955. "orientationY",
  25956. "orientationZ",
  25957. "origin",
  25958. "originalPolicy",
  25959. "originalTarget",
  25960. "orphans",
  25961. "oscpu",
  25962. "outerHTML",
  25963. "outerHeight",
  25964. "outerText",
  25965. "outerWidth",
  25966. "outline",
  25967. "outline-color",
  25968. "outline-offset",
  25969. "outline-style",
  25970. "outline-width",
  25971. "outlineColor",
  25972. "outlineOffset",
  25973. "outlineStyle",
  25974. "outlineWidth",
  25975. "outputBuffer",
  25976. "outputChannelCount",
  25977. "outputLatency",
  25978. "outputs",
  25979. "overflow",
  25980. "overflow-anchor",
  25981. "overflow-block",
  25982. "overflow-inline",
  25983. "overflow-wrap",
  25984. "overflow-x",
  25985. "overflow-y",
  25986. "overflowAnchor",
  25987. "overflowBlock",
  25988. "overflowInline",
  25989. "overflowWrap",
  25990. "overflowX",
  25991. "overflowY",
  25992. "overrideMimeType",
  25993. "oversample",
  25994. "overscroll-behavior",
  25995. "overscroll-behavior-block",
  25996. "overscroll-behavior-inline",
  25997. "overscroll-behavior-x",
  25998. "overscroll-behavior-y",
  25999. "overscrollBehavior",
  26000. "overscrollBehaviorBlock",
  26001. "overscrollBehaviorInline",
  26002. "overscrollBehaviorX",
  26003. "overscrollBehaviorY",
  26004. "ownKeys",
  26005. "ownerDocument",
  26006. "ownerElement",
  26007. "ownerNode",
  26008. "ownerRule",
  26009. "ownerSVGElement",
  26010. "owningElement",
  26011. "p1",
  26012. "p2",
  26013. "p3",
  26014. "p4",
  26015. "packetSize",
  26016. "packets",
  26017. "pad",
  26018. "padEnd",
  26019. "padStart",
  26020. "padding",
  26021. "padding-block",
  26022. "padding-block-end",
  26023. "padding-block-start",
  26024. "padding-bottom",
  26025. "padding-inline",
  26026. "padding-inline-end",
  26027. "padding-inline-start",
  26028. "padding-left",
  26029. "padding-right",
  26030. "padding-top",
  26031. "paddingBlock",
  26032. "paddingBlockEnd",
  26033. "paddingBlockStart",
  26034. "paddingBottom",
  26035. "paddingInline",
  26036. "paddingInlineEnd",
  26037. "paddingInlineStart",
  26038. "paddingLeft",
  26039. "paddingRight",
  26040. "paddingTop",
  26041. "page",
  26042. "page-break-after",
  26043. "page-break-before",
  26044. "page-break-inside",
  26045. "pageBreakAfter",
  26046. "pageBreakBefore",
  26047. "pageBreakInside",
  26048. "pageCount",
  26049. "pageLeft",
  26050. "pageTop",
  26051. "pageX",
  26052. "pageXOffset",
  26053. "pageY",
  26054. "pageYOffset",
  26055. "pages",
  26056. "paint-order",
  26057. "paintOrder",
  26058. "paintRequests",
  26059. "paintType",
  26060. "paintWorklet",
  26061. "palette",
  26062. "pan",
  26063. "panningModel",
  26064. "parameterData",
  26065. "parameters",
  26066. "parent",
  26067. "parentElement",
  26068. "parentNode",
  26069. "parentRule",
  26070. "parentStyleSheet",
  26071. "parentTextEdit",
  26072. "parentWindow",
  26073. "parse",
  26074. "parseAll",
  26075. "parseFloat",
  26076. "parseFromString",
  26077. "parseInt",
  26078. "part",
  26079. "participants",
  26080. "passive",
  26081. "password",
  26082. "pasteHTML",
  26083. "path",
  26084. "pathLength",
  26085. "pathSegList",
  26086. "pathSegType",
  26087. "pathSegTypeAsLetter",
  26088. "pathname",
  26089. "pattern",
  26090. "patternContentUnits",
  26091. "patternMismatch",
  26092. "patternTransform",
  26093. "patternUnits",
  26094. "pause",
  26095. "pauseAnimations",
  26096. "pauseOnExit",
  26097. "pauseProfilers",
  26098. "pauseTransformFeedback",
  26099. "paused",
  26100. "payerEmail",
  26101. "payerName",
  26102. "payerPhone",
  26103. "paymentManager",
  26104. "pc",
  26105. "peerIdentity",
  26106. "pending",
  26107. "pendingLocalDescription",
  26108. "pendingRemoteDescription",
  26109. "percent",
  26110. "performance",
  26111. "periodicSync",
  26112. "permission",
  26113. "permissionState",
  26114. "permissions",
  26115. "persist",
  26116. "persisted",
  26117. "personalbar",
  26118. "perspective",
  26119. "perspective-origin",
  26120. "perspectiveOrigin",
  26121. "phone",
  26122. "phoneticFamilyName",
  26123. "phoneticGivenName",
  26124. "photo",
  26125. "pictureInPictureElement",
  26126. "pictureInPictureEnabled",
  26127. "pictureInPictureWindow",
  26128. "ping",
  26129. "pipeThrough",
  26130. "pipeTo",
  26131. "pitch",
  26132. "pixelBottom",
  26133. "pixelDepth",
  26134. "pixelHeight",
  26135. "pixelLeft",
  26136. "pixelRight",
  26137. "pixelStorei",
  26138. "pixelTop",
  26139. "pixelUnitToMillimeterX",
  26140. "pixelUnitToMillimeterY",
  26141. "pixelWidth",
  26142. "place-content",
  26143. "place-items",
  26144. "place-self",
  26145. "placeContent",
  26146. "placeItems",
  26147. "placeSelf",
  26148. "placeholder",
  26149. "platformVersion",
  26150. "platform",
  26151. "platforms",
  26152. "play",
  26153. "playEffect",
  26154. "playState",
  26155. "playbackRate",
  26156. "playbackState",
  26157. "playbackTime",
  26158. "played",
  26159. "playoutDelayHint",
  26160. "playsInline",
  26161. "plugins",
  26162. "pluginspage",
  26163. "pname",
  26164. "pointer-events",
  26165. "pointerBeforeReferenceNode",
  26166. "pointerEnabled",
  26167. "pointerEvents",
  26168. "pointerId",
  26169. "pointerLockElement",
  26170. "pointerType",
  26171. "points",
  26172. "pointsAtX",
  26173. "pointsAtY",
  26174. "pointsAtZ",
  26175. "polygonOffset",
  26176. "pop",
  26177. "populateMatrix",
  26178. "popupWindowFeatures",
  26179. "popupWindowName",
  26180. "popupWindowURI",
  26181. "port",
  26182. "port1",
  26183. "port2",
  26184. "ports",
  26185. "posBottom",
  26186. "posHeight",
  26187. "posLeft",
  26188. "posRight",
  26189. "posTop",
  26190. "posWidth",
  26191. "pose",
  26192. "position",
  26193. "positionAlign",
  26194. "positionX",
  26195. "positionY",
  26196. "positionZ",
  26197. "postError",
  26198. "postMessage",
  26199. "postalCode",
  26200. "poster",
  26201. "pow",
  26202. "powerEfficient",
  26203. "powerOff",
  26204. "preMultiplySelf",
  26205. "precision",
  26206. "preferredStyleSheetSet",
  26207. "preferredStylesheetSet",
  26208. "prefix",
  26209. "preload",
  26210. "prepend",
  26211. "presentation",
  26212. "preserveAlpha",
  26213. "preserveAspectRatio",
  26214. "preserveAspectRatioString",
  26215. "pressed",
  26216. "pressure",
  26217. "prevValue",
  26218. "preventDefault",
  26219. "preventExtensions",
  26220. "preventSilentAccess",
  26221. "previousElementSibling",
  26222. "previousNode",
  26223. "previousPage",
  26224. "previousRect",
  26225. "previousScale",
  26226. "previousSibling",
  26227. "previousTranslate",
  26228. "primaryKey",
  26229. "primitiveType",
  26230. "primitiveUnits",
  26231. "principals",
  26232. "print",
  26233. "priority",
  26234. "privateKey",
  26235. "probablySupportsContext",
  26236. "process",
  26237. "processIceMessage",
  26238. "processingEnd",
  26239. "processingStart",
  26240. "processorOptions",
  26241. "product",
  26242. "productId",
  26243. "productName",
  26244. "productSub",
  26245. "profile",
  26246. "profileEnd",
  26247. "profiles",
  26248. "projectionMatrix",
  26249. "promise",
  26250. "prompt",
  26251. "properties",
  26252. "propertyIsEnumerable",
  26253. "propertyName",
  26254. "protocol",
  26255. "protocolLong",
  26256. "prototype",
  26257. "provider",
  26258. "pseudoClass",
  26259. "pseudoElement",
  26260. "pt",
  26261. "publicId",
  26262. "publicKey",
  26263. "published",
  26264. "pulse",
  26265. "push",
  26266. "pushManager",
  26267. "pushNotification",
  26268. "pushState",
  26269. "put",
  26270. "putImageData",
  26271. "px",
  26272. "quadraticCurveTo",
  26273. "qualifier",
  26274. "quaternion",
  26275. "query",
  26276. "queryCommandEnabled",
  26277. "queryCommandIndeterm",
  26278. "queryCommandState",
  26279. "queryCommandSupported",
  26280. "queryCommandText",
  26281. "queryCommandValue",
  26282. "querySelector",
  26283. "querySelectorAll",
  26284. "queueMicrotask",
  26285. "quote",
  26286. "quotes",
  26287. "r",
  26288. "r1",
  26289. "r2",
  26290. "race",
  26291. "rad",
  26292. "radiogroup",
  26293. "radiusX",
  26294. "radiusY",
  26295. "random",
  26296. "range",
  26297. "rangeCount",
  26298. "rangeMax",
  26299. "rangeMin",
  26300. "rangeOffset",
  26301. "rangeOverflow",
  26302. "rangeParent",
  26303. "rangeUnderflow",
  26304. "rate",
  26305. "ratio",
  26306. "raw",
  26307. "rawId",
  26308. "read",
  26309. "readAsArrayBuffer",
  26310. "readAsBinaryString",
  26311. "readAsBlob",
  26312. "readAsDataURL",
  26313. "readAsText",
  26314. "readBuffer",
  26315. "readEntries",
  26316. "readOnly",
  26317. "readPixels",
  26318. "readReportRequested",
  26319. "readText",
  26320. "readValue",
  26321. "readable",
  26322. "ready",
  26323. "readyState",
  26324. "reason",
  26325. "reboot",
  26326. "receivedAlert",
  26327. "receiver",
  26328. "receivers",
  26329. "recipient",
  26330. "reconnect",
  26331. "recordNumber",
  26332. "recordsAvailable",
  26333. "recordset",
  26334. "rect",
  26335. "red",
  26336. "redEyeReduction",
  26337. "redirect",
  26338. "redirectCount",
  26339. "redirectEnd",
  26340. "redirectStart",
  26341. "redirected",
  26342. "reduce",
  26343. "reduceRight",
  26344. "reduction",
  26345. "refDistance",
  26346. "refX",
  26347. "refY",
  26348. "referenceNode",
  26349. "referenceSpace",
  26350. "referrer",
  26351. "referrerPolicy",
  26352. "refresh",
  26353. "region",
  26354. "regionAnchorX",
  26355. "regionAnchorY",
  26356. "regionId",
  26357. "regions",
  26358. "register",
  26359. "registerContentHandler",
  26360. "registerElement",
  26361. "registerProperty",
  26362. "registerProtocolHandler",
  26363. "reject",
  26364. "rel",
  26365. "relList",
  26366. "relatedAddress",
  26367. "relatedNode",
  26368. "relatedPort",
  26369. "relatedTarget",
  26370. "release",
  26371. "releaseCapture",
  26372. "releaseEvents",
  26373. "releaseInterface",
  26374. "releaseLock",
  26375. "releasePointerCapture",
  26376. "releaseShaderCompiler",
  26377. "reliable",
  26378. "reliableWrite",
  26379. "reload",
  26380. "rem",
  26381. "remainingSpace",
  26382. "remote",
  26383. "remoteDescription",
  26384. "remove",
  26385. "removeAllRanges",
  26386. "removeAttribute",
  26387. "removeAttributeNS",
  26388. "removeAttributeNode",
  26389. "removeBehavior",
  26390. "removeChild",
  26391. "removeCue",
  26392. "removeEventListener",
  26393. "removeFilter",
  26394. "removeImport",
  26395. "removeItem",
  26396. "removeListener",
  26397. "removeNamedItem",
  26398. "removeNamedItemNS",
  26399. "removeNode",
  26400. "removeParameter",
  26401. "removeProperty",
  26402. "removeRange",
  26403. "removeRegion",
  26404. "removeRule",
  26405. "removeSiteSpecificTrackingException",
  26406. "removeSourceBuffer",
  26407. "removeStream",
  26408. "removeTrack",
  26409. "removeVariable",
  26410. "removeWakeLockListener",
  26411. "removeWebWideTrackingException",
  26412. "removed",
  26413. "removedNodes",
  26414. "renderHeight",
  26415. "renderState",
  26416. "renderTime",
  26417. "renderWidth",
  26418. "renderbufferStorage",
  26419. "renderbufferStorageMultisample",
  26420. "renderedBuffer",
  26421. "renderingMode",
  26422. "renotify",
  26423. "repeat",
  26424. "replace",
  26425. "replaceAdjacentText",
  26426. "replaceAll",
  26427. "replaceChild",
  26428. "replaceChildren",
  26429. "replaceData",
  26430. "replaceId",
  26431. "replaceItem",
  26432. "replaceNode",
  26433. "replaceState",
  26434. "replaceSync",
  26435. "replaceTrack",
  26436. "replaceWholeText",
  26437. "replaceWith",
  26438. "reportValidity",
  26439. "request",
  26440. "requestAnimationFrame",
  26441. "requestAutocomplete",
  26442. "requestData",
  26443. "requestDevice",
  26444. "requestFrame",
  26445. "requestFullscreen",
  26446. "requestHitTestSource",
  26447. "requestHitTestSourceForTransientInput",
  26448. "requestId",
  26449. "requestIdleCallback",
  26450. "requestMIDIAccess",
  26451. "requestMediaKeySystemAccess",
  26452. "requestPermission",
  26453. "requestPictureInPicture",
  26454. "requestPointerLock",
  26455. "requestPresent",
  26456. "requestReferenceSpace",
  26457. "requestSession",
  26458. "requestStart",
  26459. "requestStorageAccess",
  26460. "requestSubmit",
  26461. "requestVideoFrameCallback",
  26462. "requestingWindow",
  26463. "requireInteraction",
  26464. "required",
  26465. "requiredExtensions",
  26466. "requiredFeatures",
  26467. "reset",
  26468. "resetPose",
  26469. "resetTransform",
  26470. "resize",
  26471. "resizeBy",
  26472. "resizeTo",
  26473. "resolve",
  26474. "response",
  26475. "responseBody",
  26476. "responseEnd",
  26477. "responseReady",
  26478. "responseStart",
  26479. "responseText",
  26480. "responseType",
  26481. "responseURL",
  26482. "responseXML",
  26483. "restartIce",
  26484. "restore",
  26485. "result",
  26486. "resultIndex",
  26487. "resultType",
  26488. "results",
  26489. "resume",
  26490. "resumeProfilers",
  26491. "resumeTransformFeedback",
  26492. "retry",
  26493. "returnValue",
  26494. "rev",
  26495. "reverse",
  26496. "reversed",
  26497. "revocable",
  26498. "revokeObjectURL",
  26499. "rgbColor",
  26500. "right",
  26501. "rightContext",
  26502. "rightDegrees",
  26503. "rightMargin",
  26504. "rightProjectionMatrix",
  26505. "rightViewMatrix",
  26506. "role",
  26507. "rolloffFactor",
  26508. "root",
  26509. "rootBounds",
  26510. "rootElement",
  26511. "rootMargin",
  26512. "rotate",
  26513. "rotateAxisAngle",
  26514. "rotateAxisAngleSelf",
  26515. "rotateFromVector",
  26516. "rotateFromVectorSelf",
  26517. "rotateSelf",
  26518. "rotation",
  26519. "rotationAngle",
  26520. "rotationRate",
  26521. "round",
  26522. "row-gap",
  26523. "rowGap",
  26524. "rowIndex",
  26525. "rowSpan",
  26526. "rows",
  26527. "rtcpTransport",
  26528. "rtt",
  26529. "ruby-align",
  26530. "ruby-position",
  26531. "rubyAlign",
  26532. "rubyOverhang",
  26533. "rubyPosition",
  26534. "rules",
  26535. "runtime",
  26536. "runtimeStyle",
  26537. "rx",
  26538. "ry",
  26539. "s",
  26540. "safari",
  26541. "sample",
  26542. "sampleCoverage",
  26543. "sampleRate",
  26544. "samplerParameterf",
  26545. "samplerParameteri",
  26546. "sandbox",
  26547. "save",
  26548. "saveData",
  26549. "scale",
  26550. "scale3d",
  26551. "scale3dSelf",
  26552. "scaleNonUniform",
  26553. "scaleNonUniformSelf",
  26554. "scaleSelf",
  26555. "scheme",
  26556. "scissor",
  26557. "scope",
  26558. "scopeName",
  26559. "scoped",
  26560. "screen",
  26561. "screenBrightness",
  26562. "screenEnabled",
  26563. "screenLeft",
  26564. "screenPixelToMillimeterX",
  26565. "screenPixelToMillimeterY",
  26566. "screenTop",
  26567. "screenX",
  26568. "screenY",
  26569. "scriptURL",
  26570. "scripts",
  26571. "scroll",
  26572. "scroll-behavior",
  26573. "scroll-margin",
  26574. "scroll-margin-block",
  26575. "scroll-margin-block-end",
  26576. "scroll-margin-block-start",
  26577. "scroll-margin-bottom",
  26578. "scroll-margin-inline",
  26579. "scroll-margin-inline-end",
  26580. "scroll-margin-inline-start",
  26581. "scroll-margin-left",
  26582. "scroll-margin-right",
  26583. "scroll-margin-top",
  26584. "scroll-padding",
  26585. "scroll-padding-block",
  26586. "scroll-padding-block-end",
  26587. "scroll-padding-block-start",
  26588. "scroll-padding-bottom",
  26589. "scroll-padding-inline",
  26590. "scroll-padding-inline-end",
  26591. "scroll-padding-inline-start",
  26592. "scroll-padding-left",
  26593. "scroll-padding-right",
  26594. "scroll-padding-top",
  26595. "scroll-snap-align",
  26596. "scroll-snap-type",
  26597. "scrollAmount",
  26598. "scrollBehavior",
  26599. "scrollBy",
  26600. "scrollByLines",
  26601. "scrollByPages",
  26602. "scrollDelay",
  26603. "scrollHeight",
  26604. "scrollIntoView",
  26605. "scrollIntoViewIfNeeded",
  26606. "scrollLeft",
  26607. "scrollLeftMax",
  26608. "scrollMargin",
  26609. "scrollMarginBlock",
  26610. "scrollMarginBlockEnd",
  26611. "scrollMarginBlockStart",
  26612. "scrollMarginBottom",
  26613. "scrollMarginInline",
  26614. "scrollMarginInlineEnd",
  26615. "scrollMarginInlineStart",
  26616. "scrollMarginLeft",
  26617. "scrollMarginRight",
  26618. "scrollMarginTop",
  26619. "scrollMaxX",
  26620. "scrollMaxY",
  26621. "scrollPadding",
  26622. "scrollPaddingBlock",
  26623. "scrollPaddingBlockEnd",
  26624. "scrollPaddingBlockStart",
  26625. "scrollPaddingBottom",
  26626. "scrollPaddingInline",
  26627. "scrollPaddingInlineEnd",
  26628. "scrollPaddingInlineStart",
  26629. "scrollPaddingLeft",
  26630. "scrollPaddingRight",
  26631. "scrollPaddingTop",
  26632. "scrollRestoration",
  26633. "scrollSnapAlign",
  26634. "scrollSnapType",
  26635. "scrollTo",
  26636. "scrollTop",
  26637. "scrollTopMax",
  26638. "scrollWidth",
  26639. "scrollX",
  26640. "scrollY",
  26641. "scrollbar-color",
  26642. "scrollbar-width",
  26643. "scrollbar3dLightColor",
  26644. "scrollbarArrowColor",
  26645. "scrollbarBaseColor",
  26646. "scrollbarColor",
  26647. "scrollbarDarkShadowColor",
  26648. "scrollbarFaceColor",
  26649. "scrollbarHighlightColor",
  26650. "scrollbarShadowColor",
  26651. "scrollbarTrackColor",
  26652. "scrollbarWidth",
  26653. "scrollbars",
  26654. "scrolling",
  26655. "scrollingElement",
  26656. "sctp",
  26657. "sctpCauseCode",
  26658. "sdp",
  26659. "sdpLineNumber",
  26660. "sdpMLineIndex",
  26661. "sdpMid",
  26662. "seal",
  26663. "search",
  26664. "searchBox",
  26665. "searchBoxJavaBridge_",
  26666. "searchParams",
  26667. "sectionRowIndex",
  26668. "secureConnectionStart",
  26669. "security",
  26670. "seed",
  26671. "seekToNextFrame",
  26672. "seekable",
  26673. "seeking",
  26674. "select",
  26675. "selectAllChildren",
  26676. "selectAlternateInterface",
  26677. "selectConfiguration",
  26678. "selectNode",
  26679. "selectNodeContents",
  26680. "selectNodes",
  26681. "selectSingleNode",
  26682. "selectSubString",
  26683. "selected",
  26684. "selectedIndex",
  26685. "selectedOptions",
  26686. "selectedStyleSheetSet",
  26687. "selectedStylesheetSet",
  26688. "selection",
  26689. "selectionDirection",
  26690. "selectionEnd",
  26691. "selectionStart",
  26692. "selector",
  26693. "selectorText",
  26694. "self",
  26695. "send",
  26696. "sendAsBinary",
  26697. "sendBeacon",
  26698. "sender",
  26699. "sentAlert",
  26700. "sentTimestamp",
  26701. "separator",
  26702. "serialNumber",
  26703. "serializeToString",
  26704. "serverTiming",
  26705. "service",
  26706. "serviceWorker",
  26707. "session",
  26708. "sessionId",
  26709. "sessionStorage",
  26710. "set",
  26711. "setActionHandler",
  26712. "setActive",
  26713. "setAlpha",
  26714. "setAppBadge",
  26715. "setAttribute",
  26716. "setAttributeNS",
  26717. "setAttributeNode",
  26718. "setAttributeNodeNS",
  26719. "setBaseAndExtent",
  26720. "setBigInt64",
  26721. "setBigUint64",
  26722. "setBingCurrentSearchDefault",
  26723. "setCapture",
  26724. "setCodecPreferences",
  26725. "setColor",
  26726. "setCompositeOperation",
  26727. "setConfiguration",
  26728. "setCurrentTime",
  26729. "setCustomValidity",
  26730. "setData",
  26731. "setDate",
  26732. "setDragImage",
  26733. "setEnd",
  26734. "setEndAfter",
  26735. "setEndBefore",
  26736. "setEndPoint",
  26737. "setFillColor",
  26738. "setFilterRes",
  26739. "setFloat32",
  26740. "setFloat64",
  26741. "setFloatValue",
  26742. "setFormValue",
  26743. "setFullYear",
  26744. "setHeaderValue",
  26745. "setHours",
  26746. "setIdentityProvider",
  26747. "setImmediate",
  26748. "setInt16",
  26749. "setInt32",
  26750. "setInt8",
  26751. "setInterval",
  26752. "setItem",
  26753. "setKeyframes",
  26754. "setLineCap",
  26755. "setLineDash",
  26756. "setLineJoin",
  26757. "setLineWidth",
  26758. "setLiveSeekableRange",
  26759. "setLocalDescription",
  26760. "setMatrix",
  26761. "setMatrixValue",
  26762. "setMediaKeys",
  26763. "setMilliseconds",
  26764. "setMinutes",
  26765. "setMiterLimit",
  26766. "setMonth",
  26767. "setNamedItem",
  26768. "setNamedItemNS",
  26769. "setNonUserCodeExceptions",
  26770. "setOrientToAngle",
  26771. "setOrientToAuto",
  26772. "setOrientation",
  26773. "setOverrideHistoryNavigationMode",
  26774. "setPaint",
  26775. "setParameter",
  26776. "setParameters",
  26777. "setPeriodicWave",
  26778. "setPointerCapture",
  26779. "setPosition",
  26780. "setPositionState",
  26781. "setPreference",
  26782. "setProperty",
  26783. "setPrototypeOf",
  26784. "setRGBColor",
  26785. "setRGBColorICCColor",
  26786. "setRadius",
  26787. "setRangeText",
  26788. "setRemoteDescription",
  26789. "setRequestHeader",
  26790. "setResizable",
  26791. "setResourceTimingBufferSize",
  26792. "setRotate",
  26793. "setScale",
  26794. "setSeconds",
  26795. "setSelectionRange",
  26796. "setServerCertificate",
  26797. "setShadow",
  26798. "setSinkId",
  26799. "setSkewX",
  26800. "setSkewY",
  26801. "setStart",
  26802. "setStartAfter",
  26803. "setStartBefore",
  26804. "setStdDeviation",
  26805. "setStreams",
  26806. "setStringValue",
  26807. "setStrokeColor",
  26808. "setSuggestResult",
  26809. "setTargetAtTime",
  26810. "setTargetValueAtTime",
  26811. "setTime",
  26812. "setTimeout",
  26813. "setTransform",
  26814. "setTranslate",
  26815. "setUTCDate",
  26816. "setUTCFullYear",
  26817. "setUTCHours",
  26818. "setUTCMilliseconds",
  26819. "setUTCMinutes",
  26820. "setUTCMonth",
  26821. "setUTCSeconds",
  26822. "setUint16",
  26823. "setUint32",
  26824. "setUint8",
  26825. "setUri",
  26826. "setValidity",
  26827. "setValueAtTime",
  26828. "setValueCurveAtTime",
  26829. "setVariable",
  26830. "setVelocity",
  26831. "setVersion",
  26832. "setYear",
  26833. "settingName",
  26834. "settingValue",
  26835. "sex",
  26836. "shaderSource",
  26837. "shadowBlur",
  26838. "shadowColor",
  26839. "shadowOffsetX",
  26840. "shadowOffsetY",
  26841. "shadowRoot",
  26842. "shape",
  26843. "shape-image-threshold",
  26844. "shape-margin",
  26845. "shape-outside",
  26846. "shape-rendering",
  26847. "shapeImageThreshold",
  26848. "shapeMargin",
  26849. "shapeOutside",
  26850. "shapeRendering",
  26851. "sheet",
  26852. "shift",
  26853. "shiftKey",
  26854. "shiftLeft",
  26855. "shippingAddress",
  26856. "shippingOption",
  26857. "shippingType",
  26858. "show",
  26859. "showHelp",
  26860. "showModal",
  26861. "showModalDialog",
  26862. "showModelessDialog",
  26863. "showNotification",
  26864. "sidebar",
  26865. "sign",
  26866. "signal",
  26867. "signalingState",
  26868. "signature",
  26869. "silent",
  26870. "sin",
  26871. "singleNodeValue",
  26872. "sinh",
  26873. "sinkId",
  26874. "sittingToStandingTransform",
  26875. "size",
  26876. "sizeToContent",
  26877. "sizeX",
  26878. "sizeZ",
  26879. "sizes",
  26880. "skewX",
  26881. "skewXSelf",
  26882. "skewY",
  26883. "skewYSelf",
  26884. "slice",
  26885. "slope",
  26886. "slot",
  26887. "small",
  26888. "smil",
  26889. "smooth",
  26890. "smoothingTimeConstant",
  26891. "snapToLines",
  26892. "snapshotItem",
  26893. "snapshotLength",
  26894. "some",
  26895. "sort",
  26896. "sortingCode",
  26897. "source",
  26898. "sourceBuffer",
  26899. "sourceBuffers",
  26900. "sourceCapabilities",
  26901. "sourceFile",
  26902. "sourceIndex",
  26903. "sources",
  26904. "spacing",
  26905. "span",
  26906. "speak",
  26907. "speakAs",
  26908. "speaking",
  26909. "species",
  26910. "specified",
  26911. "specularConstant",
  26912. "specularExponent",
  26913. "speechSynthesis",
  26914. "speed",
  26915. "speedOfSound",
  26916. "spellcheck",
  26917. "splice",
  26918. "split",
  26919. "splitText",
  26920. "spreadMethod",
  26921. "sqrt",
  26922. "src",
  26923. "srcElement",
  26924. "srcFilter",
  26925. "srcObject",
  26926. "srcUrn",
  26927. "srcdoc",
  26928. "srclang",
  26929. "srcset",
  26930. "stack",
  26931. "stackTraceLimit",
  26932. "stacktrace",
  26933. "stageParameters",
  26934. "standalone",
  26935. "standby",
  26936. "start",
  26937. "startContainer",
  26938. "startIce",
  26939. "startMessages",
  26940. "startNotifications",
  26941. "startOffset",
  26942. "startProfiling",
  26943. "startRendering",
  26944. "startShark",
  26945. "startTime",
  26946. "startsWith",
  26947. "state",
  26948. "status",
  26949. "statusCode",
  26950. "statusMessage",
  26951. "statusText",
  26952. "statusbar",
  26953. "stdDeviationX",
  26954. "stdDeviationY",
  26955. "stencilFunc",
  26956. "stencilFuncSeparate",
  26957. "stencilMask",
  26958. "stencilMaskSeparate",
  26959. "stencilOp",
  26960. "stencilOpSeparate",
  26961. "step",
  26962. "stepDown",
  26963. "stepMismatch",
  26964. "stepUp",
  26965. "sticky",
  26966. "stitchTiles",
  26967. "stop",
  26968. "stop-color",
  26969. "stop-opacity",
  26970. "stopColor",
  26971. "stopImmediatePropagation",
  26972. "stopNotifications",
  26973. "stopOpacity",
  26974. "stopProfiling",
  26975. "stopPropagation",
  26976. "stopShark",
  26977. "stopped",
  26978. "storage",
  26979. "storageArea",
  26980. "storageName",
  26981. "storageStatus",
  26982. "store",
  26983. "storeSiteSpecificTrackingException",
  26984. "storeWebWideTrackingException",
  26985. "stpVersion",
  26986. "stream",
  26987. "streams",
  26988. "stretch",
  26989. "strike",
  26990. "string",
  26991. "stringValue",
  26992. "stringify",
  26993. "stroke",
  26994. "stroke-dasharray",
  26995. "stroke-dashoffset",
  26996. "stroke-linecap",
  26997. "stroke-linejoin",
  26998. "stroke-miterlimit",
  26999. "stroke-opacity",
  27000. "stroke-width",
  27001. "strokeDasharray",
  27002. "strokeDashoffset",
  27003. "strokeLinecap",
  27004. "strokeLinejoin",
  27005. "strokeMiterlimit",
  27006. "strokeOpacity",
  27007. "strokeRect",
  27008. "strokeStyle",
  27009. "strokeText",
  27010. "strokeWidth",
  27011. "style",
  27012. "styleFloat",
  27013. "styleMap",
  27014. "styleMedia",
  27015. "styleSheet",
  27016. "styleSheetSets",
  27017. "styleSheets",
  27018. "sub",
  27019. "subarray",
  27020. "subject",
  27021. "submit",
  27022. "submitFrame",
  27023. "submitter",
  27024. "subscribe",
  27025. "substr",
  27026. "substring",
  27027. "substringData",
  27028. "subtle",
  27029. "subtree",
  27030. "suffix",
  27031. "suffixes",
  27032. "summary",
  27033. "sup",
  27034. "supported",
  27035. "supportedContentEncodings",
  27036. "supportedEntryTypes",
  27037. "supports",
  27038. "supportsSession",
  27039. "surfaceScale",
  27040. "surroundContents",
  27041. "suspend",
  27042. "suspendRedraw",
  27043. "swapCache",
  27044. "swapNode",
  27045. "sweepFlag",
  27046. "symbols",
  27047. "sync",
  27048. "sysexEnabled",
  27049. "system",
  27050. "systemCode",
  27051. "systemId",
  27052. "systemLanguage",
  27053. "systemXDPI",
  27054. "systemYDPI",
  27055. "tBodies",
  27056. "tFoot",
  27057. "tHead",
  27058. "tabIndex",
  27059. "table",
  27060. "table-layout",
  27061. "tableLayout",
  27062. "tableValues",
  27063. "tag",
  27064. "tagName",
  27065. "tagUrn",
  27066. "tags",
  27067. "taintEnabled",
  27068. "takePhoto",
  27069. "takeRecords",
  27070. "tan",
  27071. "tangentialPressure",
  27072. "tanh",
  27073. "target",
  27074. "targetElement",
  27075. "targetRayMode",
  27076. "targetRaySpace",
  27077. "targetTouches",
  27078. "targetX",
  27079. "targetY",
  27080. "tcpType",
  27081. "tee",
  27082. "tel",
  27083. "terminate",
  27084. "test",
  27085. "texImage2D",
  27086. "texImage3D",
  27087. "texParameterf",
  27088. "texParameteri",
  27089. "texStorage2D",
  27090. "texStorage3D",
  27091. "texSubImage2D",
  27092. "texSubImage3D",
  27093. "text",
  27094. "text-align",
  27095. "text-align-last",
  27096. "text-anchor",
  27097. "text-combine-upright",
  27098. "text-decoration",
  27099. "text-decoration-color",
  27100. "text-decoration-line",
  27101. "text-decoration-skip-ink",
  27102. "text-decoration-style",
  27103. "text-decoration-thickness",
  27104. "text-emphasis",
  27105. "text-emphasis-color",
  27106. "text-emphasis-position",
  27107. "text-emphasis-style",
  27108. "text-indent",
  27109. "text-justify",
  27110. "text-orientation",
  27111. "text-overflow",
  27112. "text-rendering",
  27113. "text-shadow",
  27114. "text-transform",
  27115. "text-underline-offset",
  27116. "text-underline-position",
  27117. "textAlign",
  27118. "textAlignLast",
  27119. "textAnchor",
  27120. "textAutospace",
  27121. "textBaseline",
  27122. "textCombineUpright",
  27123. "textContent",
  27124. "textDecoration",
  27125. "textDecorationBlink",
  27126. "textDecorationColor",
  27127. "textDecorationLine",
  27128. "textDecorationLineThrough",
  27129. "textDecorationNone",
  27130. "textDecorationOverline",
  27131. "textDecorationSkipInk",
  27132. "textDecorationStyle",
  27133. "textDecorationThickness",
  27134. "textDecorationUnderline",
  27135. "textEmphasis",
  27136. "textEmphasisColor",
  27137. "textEmphasisPosition",
  27138. "textEmphasisStyle",
  27139. "textIndent",
  27140. "textJustify",
  27141. "textJustifyTrim",
  27142. "textKashida",
  27143. "textKashidaSpace",
  27144. "textLength",
  27145. "textOrientation",
  27146. "textOverflow",
  27147. "textRendering",
  27148. "textShadow",
  27149. "textTracks",
  27150. "textTransform",
  27151. "textUnderlineOffset",
  27152. "textUnderlinePosition",
  27153. "then",
  27154. "threadId",
  27155. "threshold",
  27156. "thresholds",
  27157. "tiltX",
  27158. "tiltY",
  27159. "time",
  27160. "timeEnd",
  27161. "timeLog",
  27162. "timeOrigin",
  27163. "timeRemaining",
  27164. "timeStamp",
  27165. "timecode",
  27166. "timeline",
  27167. "timelineTime",
  27168. "timeout",
  27169. "timestamp",
  27170. "timestampOffset",
  27171. "timing",
  27172. "title",
  27173. "to",
  27174. "toArray",
  27175. "toBlob",
  27176. "toDataURL",
  27177. "toDateString",
  27178. "toElement",
  27179. "toExponential",
  27180. "toFixed",
  27181. "toFloat32Array",
  27182. "toFloat64Array",
  27183. "toGMTString",
  27184. "toISOString",
  27185. "toJSON",
  27186. "toLocaleDateString",
  27187. "toLocaleFormat",
  27188. "toLocaleLowerCase",
  27189. "toLocaleString",
  27190. "toLocaleTimeString",
  27191. "toLocaleUpperCase",
  27192. "toLowerCase",
  27193. "toMatrix",
  27194. "toMethod",
  27195. "toPrecision",
  27196. "toPrimitive",
  27197. "toSdp",
  27198. "toSource",
  27199. "toStaticHTML",
  27200. "toString",
  27201. "toStringTag",
  27202. "toSum",
  27203. "toTimeString",
  27204. "toUTCString",
  27205. "toUpperCase",
  27206. "toggle",
  27207. "toggleAttribute",
  27208. "toggleLongPressEnabled",
  27209. "tone",
  27210. "toneBuffer",
  27211. "tooLong",
  27212. "tooShort",
  27213. "toolbar",
  27214. "top",
  27215. "topMargin",
  27216. "total",
  27217. "totalFrameDelay",
  27218. "totalVideoFrames",
  27219. "touch-action",
  27220. "touchAction",
  27221. "touched",
  27222. "touches",
  27223. "trace",
  27224. "track",
  27225. "trackVisibility",
  27226. "transaction",
  27227. "transactions",
  27228. "transceiver",
  27229. "transferControlToOffscreen",
  27230. "transferFromImageBitmap",
  27231. "transferImageBitmap",
  27232. "transferIn",
  27233. "transferOut",
  27234. "transferSize",
  27235. "transferToImageBitmap",
  27236. "transform",
  27237. "transform-box",
  27238. "transform-origin",
  27239. "transform-style",
  27240. "transformBox",
  27241. "transformFeedbackVaryings",
  27242. "transformOrigin",
  27243. "transformPoint",
  27244. "transformString",
  27245. "transformStyle",
  27246. "transformToDocument",
  27247. "transformToFragment",
  27248. "transition",
  27249. "transition-delay",
  27250. "transition-duration",
  27251. "transition-property",
  27252. "transition-timing-function",
  27253. "transitionDelay",
  27254. "transitionDuration",
  27255. "transitionProperty",
  27256. "transitionTimingFunction",
  27257. "translate",
  27258. "translateSelf",
  27259. "translationX",
  27260. "translationY",
  27261. "transport",
  27262. "trim",
  27263. "trimEnd",
  27264. "trimLeft",
  27265. "trimRight",
  27266. "trimStart",
  27267. "trueSpeed",
  27268. "trunc",
  27269. "truncate",
  27270. "trustedTypes",
  27271. "turn",
  27272. "twist",
  27273. "type",
  27274. "typeDetail",
  27275. "typeMismatch",
  27276. "typeMustMatch",
  27277. "types",
  27278. "u2f",
  27279. "ubound",
  27280. "uint16",
  27281. "uint32",
  27282. "uint8",
  27283. "uint8Clamped",
  27284. "undefined",
  27285. "unescape",
  27286. "uneval",
  27287. "unicode",
  27288. "unicode-bidi",
  27289. "unicodeBidi",
  27290. "unicodeRange",
  27291. "uniform1f",
  27292. "uniform1fv",
  27293. "uniform1i",
  27294. "uniform1iv",
  27295. "uniform1ui",
  27296. "uniform1uiv",
  27297. "uniform2f",
  27298. "uniform2fv",
  27299. "uniform2i",
  27300. "uniform2iv",
  27301. "uniform2ui",
  27302. "uniform2uiv",
  27303. "uniform3f",
  27304. "uniform3fv",
  27305. "uniform3i",
  27306. "uniform3iv",
  27307. "uniform3ui",
  27308. "uniform3uiv",
  27309. "uniform4f",
  27310. "uniform4fv",
  27311. "uniform4i",
  27312. "uniform4iv",
  27313. "uniform4ui",
  27314. "uniform4uiv",
  27315. "uniformBlockBinding",
  27316. "uniformMatrix2fv",
  27317. "uniformMatrix2x3fv",
  27318. "uniformMatrix2x4fv",
  27319. "uniformMatrix3fv",
  27320. "uniformMatrix3x2fv",
  27321. "uniformMatrix3x4fv",
  27322. "uniformMatrix4fv",
  27323. "uniformMatrix4x2fv",
  27324. "uniformMatrix4x3fv",
  27325. "unique",
  27326. "uniqueID",
  27327. "uniqueNumber",
  27328. "unit",
  27329. "unitType",
  27330. "units",
  27331. "unloadEventEnd",
  27332. "unloadEventStart",
  27333. "unlock",
  27334. "unmount",
  27335. "unobserve",
  27336. "unpause",
  27337. "unpauseAnimations",
  27338. "unreadCount",
  27339. "unregister",
  27340. "unregisterContentHandler",
  27341. "unregisterProtocolHandler",
  27342. "unscopables",
  27343. "unselectable",
  27344. "unshift",
  27345. "unsubscribe",
  27346. "unsuspendRedraw",
  27347. "unsuspendRedrawAll",
  27348. "unwatch",
  27349. "unwrapKey",
  27350. "upDegrees",
  27351. "upX",
  27352. "upY",
  27353. "upZ",
  27354. "update",
  27355. "updateCommands",
  27356. "updateIce",
  27357. "updateInterval",
  27358. "updatePlaybackRate",
  27359. "updateRenderState",
  27360. "updateSettings",
  27361. "updateTiming",
  27362. "updateViaCache",
  27363. "updateWith",
  27364. "updated",
  27365. "updating",
  27366. "upgrade",
  27367. "upload",
  27368. "uploadTotal",
  27369. "uploaded",
  27370. "upper",
  27371. "upperBound",
  27372. "upperOpen",
  27373. "uri",
  27374. "url",
  27375. "urn",
  27376. "urns",
  27377. "usages",
  27378. "usb",
  27379. "usbVersionMajor",
  27380. "usbVersionMinor",
  27381. "usbVersionSubminor",
  27382. "useCurrentView",
  27383. "useMap",
  27384. "useProgram",
  27385. "usedSpace",
  27386. "user-select",
  27387. "userActivation",
  27388. "userAgent",
  27389. "userAgentData",
  27390. "userChoice",
  27391. "userHandle",
  27392. "userHint",
  27393. "userLanguage",
  27394. "userSelect",
  27395. "userVisibleOnly",
  27396. "username",
  27397. "usernameFragment",
  27398. "utterance",
  27399. "uuid",
  27400. "v8BreakIterator",
  27401. "vAlign",
  27402. "vLink",
  27403. "valid",
  27404. "validate",
  27405. "validateProgram",
  27406. "validationMessage",
  27407. "validity",
  27408. "value",
  27409. "valueAsDate",
  27410. "valueAsNumber",
  27411. "valueAsString",
  27412. "valueInSpecifiedUnits",
  27413. "valueMissing",
  27414. "valueOf",
  27415. "valueText",
  27416. "valueType",
  27417. "values",
  27418. "variable",
  27419. "variant",
  27420. "variationSettings",
  27421. "vector-effect",
  27422. "vectorEffect",
  27423. "velocityAngular",
  27424. "velocityExpansion",
  27425. "velocityX",
  27426. "velocityY",
  27427. "vendor",
  27428. "vendorId",
  27429. "vendorSub",
  27430. "verify",
  27431. "version",
  27432. "vertexAttrib1f",
  27433. "vertexAttrib1fv",
  27434. "vertexAttrib2f",
  27435. "vertexAttrib2fv",
  27436. "vertexAttrib3f",
  27437. "vertexAttrib3fv",
  27438. "vertexAttrib4f",
  27439. "vertexAttrib4fv",
  27440. "vertexAttribDivisor",
  27441. "vertexAttribDivisorANGLE",
  27442. "vertexAttribI4i",
  27443. "vertexAttribI4iv",
  27444. "vertexAttribI4ui",
  27445. "vertexAttribI4uiv",
  27446. "vertexAttribIPointer",
  27447. "vertexAttribPointer",
  27448. "vertical",
  27449. "vertical-align",
  27450. "verticalAlign",
  27451. "verticalOverflow",
  27452. "vh",
  27453. "vibrate",
  27454. "vibrationActuator",
  27455. "videoBitsPerSecond",
  27456. "videoHeight",
  27457. "videoTracks",
  27458. "videoWidth",
  27459. "view",
  27460. "viewBox",
  27461. "viewBoxString",
  27462. "viewTarget",
  27463. "viewTargetString",
  27464. "viewport",
  27465. "viewportAnchorX",
  27466. "viewportAnchorY",
  27467. "viewportElement",
  27468. "views",
  27469. "violatedDirective",
  27470. "visibility",
  27471. "visibilityState",
  27472. "visible",
  27473. "visualViewport",
  27474. "vlinkColor",
  27475. "vmax",
  27476. "vmin",
  27477. "voice",
  27478. "voiceURI",
  27479. "volume",
  27480. "vrml",
  27481. "vspace",
  27482. "vw",
  27483. "w",
  27484. "wait",
  27485. "waitSync",
  27486. "waiting",
  27487. "wake",
  27488. "wakeLock",
  27489. "wand",
  27490. "warn",
  27491. "wasClean",
  27492. "wasDiscarded",
  27493. "watch",
  27494. "watchAvailability",
  27495. "watchPosition",
  27496. "webdriver",
  27497. "webkitAddKey",
  27498. "webkitAlignContent",
  27499. "webkitAlignItems",
  27500. "webkitAlignSelf",
  27501. "webkitAnimation",
  27502. "webkitAnimationDelay",
  27503. "webkitAnimationDirection",
  27504. "webkitAnimationDuration",
  27505. "webkitAnimationFillMode",
  27506. "webkitAnimationIterationCount",
  27507. "webkitAnimationName",
  27508. "webkitAnimationPlayState",
  27509. "webkitAnimationTimingFunction",
  27510. "webkitAppearance",
  27511. "webkitAudioContext",
  27512. "webkitAudioDecodedByteCount",
  27513. "webkitAudioPannerNode",
  27514. "webkitBackfaceVisibility",
  27515. "webkitBackground",
  27516. "webkitBackgroundAttachment",
  27517. "webkitBackgroundClip",
  27518. "webkitBackgroundColor",
  27519. "webkitBackgroundImage",
  27520. "webkitBackgroundOrigin",
  27521. "webkitBackgroundPosition",
  27522. "webkitBackgroundPositionX",
  27523. "webkitBackgroundPositionY",
  27524. "webkitBackgroundRepeat",
  27525. "webkitBackgroundSize",
  27526. "webkitBackingStorePixelRatio",
  27527. "webkitBorderBottomLeftRadius",
  27528. "webkitBorderBottomRightRadius",
  27529. "webkitBorderImage",
  27530. "webkitBorderImageOutset",
  27531. "webkitBorderImageRepeat",
  27532. "webkitBorderImageSlice",
  27533. "webkitBorderImageSource",
  27534. "webkitBorderImageWidth",
  27535. "webkitBorderRadius",
  27536. "webkitBorderTopLeftRadius",
  27537. "webkitBorderTopRightRadius",
  27538. "webkitBoxAlign",
  27539. "webkitBoxDirection",
  27540. "webkitBoxFlex",
  27541. "webkitBoxOrdinalGroup",
  27542. "webkitBoxOrient",
  27543. "webkitBoxPack",
  27544. "webkitBoxShadow",
  27545. "webkitBoxSizing",
  27546. "webkitCancelAnimationFrame",
  27547. "webkitCancelFullScreen",
  27548. "webkitCancelKeyRequest",
  27549. "webkitCancelRequestAnimationFrame",
  27550. "webkitClearResourceTimings",
  27551. "webkitClosedCaptionsVisible",
  27552. "webkitConvertPointFromNodeToPage",
  27553. "webkitConvertPointFromPageToNode",
  27554. "webkitCreateShadowRoot",
  27555. "webkitCurrentFullScreenElement",
  27556. "webkitCurrentPlaybackTargetIsWireless",
  27557. "webkitDecodedFrameCount",
  27558. "webkitDirectionInvertedFromDevice",
  27559. "webkitDisplayingFullscreen",
  27560. "webkitDroppedFrameCount",
  27561. "webkitEnterFullScreen",
  27562. "webkitEnterFullscreen",
  27563. "webkitEntries",
  27564. "webkitExitFullScreen",
  27565. "webkitExitFullscreen",
  27566. "webkitExitPointerLock",
  27567. "webkitFilter",
  27568. "webkitFlex",
  27569. "webkitFlexBasis",
  27570. "webkitFlexDirection",
  27571. "webkitFlexFlow",
  27572. "webkitFlexGrow",
  27573. "webkitFlexShrink",
  27574. "webkitFlexWrap",
  27575. "webkitFullScreenKeyboardInputAllowed",
  27576. "webkitFullscreenElement",
  27577. "webkitFullscreenEnabled",
  27578. "webkitGenerateKeyRequest",
  27579. "webkitGetAsEntry",
  27580. "webkitGetDatabaseNames",
  27581. "webkitGetEntries",
  27582. "webkitGetEntriesByName",
  27583. "webkitGetEntriesByType",
  27584. "webkitGetFlowByName",
  27585. "webkitGetGamepads",
  27586. "webkitGetImageDataHD",
  27587. "webkitGetNamedFlows",
  27588. "webkitGetRegionFlowRanges",
  27589. "webkitGetUserMedia",
  27590. "webkitHasClosedCaptions",
  27591. "webkitHidden",
  27592. "webkitIDBCursor",
  27593. "webkitIDBDatabase",
  27594. "webkitIDBDatabaseError",
  27595. "webkitIDBDatabaseException",
  27596. "webkitIDBFactory",
  27597. "webkitIDBIndex",
  27598. "webkitIDBKeyRange",
  27599. "webkitIDBObjectStore",
  27600. "webkitIDBRequest",
  27601. "webkitIDBTransaction",
  27602. "webkitImageSmoothingEnabled",
  27603. "webkitIndexedDB",
  27604. "webkitInitMessageEvent",
  27605. "webkitIsFullScreen",
  27606. "webkitJustifyContent",
  27607. "webkitKeys",
  27608. "webkitLineClamp",
  27609. "webkitLineDashOffset",
  27610. "webkitLockOrientation",
  27611. "webkitMask",
  27612. "webkitMaskClip",
  27613. "webkitMaskComposite",
  27614. "webkitMaskImage",
  27615. "webkitMaskOrigin",
  27616. "webkitMaskPosition",
  27617. "webkitMaskPositionX",
  27618. "webkitMaskPositionY",
  27619. "webkitMaskRepeat",
  27620. "webkitMaskSize",
  27621. "webkitMatchesSelector",
  27622. "webkitMediaStream",
  27623. "webkitNotifications",
  27624. "webkitOfflineAudioContext",
  27625. "webkitOrder",
  27626. "webkitOrientation",
  27627. "webkitPeerConnection00",
  27628. "webkitPersistentStorage",
  27629. "webkitPerspective",
  27630. "webkitPerspectiveOrigin",
  27631. "webkitPointerLockElement",
  27632. "webkitPostMessage",
  27633. "webkitPreservesPitch",
  27634. "webkitPutImageDataHD",
  27635. "webkitRTCPeerConnection",
  27636. "webkitRegionOverset",
  27637. "webkitRelativePath",
  27638. "webkitRequestAnimationFrame",
  27639. "webkitRequestFileSystem",
  27640. "webkitRequestFullScreen",
  27641. "webkitRequestFullscreen",
  27642. "webkitRequestPointerLock",
  27643. "webkitResolveLocalFileSystemURL",
  27644. "webkitSetMediaKeys",
  27645. "webkitSetResourceTimingBufferSize",
  27646. "webkitShadowRoot",
  27647. "webkitShowPlaybackTargetPicker",
  27648. "webkitSlice",
  27649. "webkitSpeechGrammar",
  27650. "webkitSpeechGrammarList",
  27651. "webkitSpeechRecognition",
  27652. "webkitSpeechRecognitionError",
  27653. "webkitSpeechRecognitionEvent",
  27654. "webkitStorageInfo",
  27655. "webkitSupportsFullscreen",
  27656. "webkitTemporaryStorage",
  27657. "webkitTextFillColor",
  27658. "webkitTextSizeAdjust",
  27659. "webkitTextStroke",
  27660. "webkitTextStrokeColor",
  27661. "webkitTextStrokeWidth",
  27662. "webkitTransform",
  27663. "webkitTransformOrigin",
  27664. "webkitTransformStyle",
  27665. "webkitTransition",
  27666. "webkitTransitionDelay",
  27667. "webkitTransitionDuration",
  27668. "webkitTransitionProperty",
  27669. "webkitTransitionTimingFunction",
  27670. "webkitURL",
  27671. "webkitUnlockOrientation",
  27672. "webkitUserSelect",
  27673. "webkitVideoDecodedByteCount",
  27674. "webkitVisibilityState",
  27675. "webkitWirelessVideoPlaybackDisabled",
  27676. "webkitdirectory",
  27677. "webkitdropzone",
  27678. "webstore",
  27679. "weight",
  27680. "whatToShow",
  27681. "wheelDelta",
  27682. "wheelDeltaX",
  27683. "wheelDeltaY",
  27684. "whenDefined",
  27685. "which",
  27686. "white-space",
  27687. "whiteSpace",
  27688. "wholeText",
  27689. "widows",
  27690. "width",
  27691. "will-change",
  27692. "willChange",
  27693. "willValidate",
  27694. "window",
  27695. "withCredentials",
  27696. "word-break",
  27697. "word-spacing",
  27698. "word-wrap",
  27699. "wordBreak",
  27700. "wordSpacing",
  27701. "wordWrap",
  27702. "workerStart",
  27703. "wow64",
  27704. "wrap",
  27705. "wrapKey",
  27706. "writable",
  27707. "writableAuxiliaries",
  27708. "write",
  27709. "writeText",
  27710. "writeValue",
  27711. "writeWithoutResponse",
  27712. "writeln",
  27713. "writing-mode",
  27714. "writingMode",
  27715. "x",
  27716. "x1",
  27717. "x2",
  27718. "xChannelSelector",
  27719. "xmlEncoding",
  27720. "xmlStandalone",
  27721. "xmlVersion",
  27722. "xmlbase",
  27723. "xmllang",
  27724. "xmlspace",
  27725. "xor",
  27726. "xr",
  27727. "y",
  27728. "y1",
  27729. "y2",
  27730. "yChannelSelector",
  27731. "yandex",
  27732. "z",
  27733. "z-index",
  27734. "zIndex",
  27735. "zoom",
  27736. "zoomAndPan",
  27737. "zoomRectScreen",
  27738. ];
  27739. /***********************************************************************
  27740. A JavaScript tokenizer / parser / beautifier / compressor.
  27741. https://github.com/mishoo/UglifyJS2
  27742. -------------------------------- (C) ---------------------------------
  27743. Author: Mihai Bazon
  27744. <mihai.bazon@gmail.com>
  27745. http://mihai.bazon.net/blog
  27746. Distributed under the BSD license:
  27747. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  27748. Redistribution and use in source and binary forms, with or without
  27749. modification, are permitted provided that the following conditions
  27750. are met:
  27751. * Redistributions of source code must retain the above
  27752. copyright notice, this list of conditions and the following
  27753. disclaimer.
  27754. * Redistributions in binary form must reproduce the above
  27755. copyright notice, this list of conditions and the following
  27756. disclaimer in the documentation and/or other materials
  27757. provided with the distribution.
  27758. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  27759. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27760. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  27761. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  27762. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  27763. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27764. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27765. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27766. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  27767. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27768. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27769. SUCH DAMAGE.
  27770. ***********************************************************************/
  27771. function find_builtins(reserved) {
  27772. domprops.forEach(add);
  27773. // Compatibility fix for some standard defined globals not defined on every js environment
  27774. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  27775. var objects = {};
  27776. var global_ref = typeof global === "object" ? global : self;
  27777. new_globals.forEach(function (new_global) {
  27778. objects[new_global] = global_ref[new_global] || function() {};
  27779. });
  27780. [
  27781. "null",
  27782. "true",
  27783. "false",
  27784. "NaN",
  27785. "Infinity",
  27786. "-Infinity",
  27787. "undefined",
  27788. ].forEach(add);
  27789. [ Object, Array, Function, Number,
  27790. String, Boolean, Error, Math,
  27791. Date, RegExp, objects.Symbol, ArrayBuffer,
  27792. DataView, decodeURI, decodeURIComponent,
  27793. encodeURI, encodeURIComponent, eval, EvalError,
  27794. Float32Array, Float64Array, Int8Array, Int16Array,
  27795. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  27796. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  27797. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  27798. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  27799. objects.WeakMap, objects.WeakSet
  27800. ].forEach(function(ctor) {
  27801. Object.getOwnPropertyNames(ctor).map(add);
  27802. if (ctor.prototype) {
  27803. Object.getOwnPropertyNames(ctor.prototype).map(add);
  27804. }
  27805. });
  27806. function add(name) {
  27807. reserved.add(name);
  27808. }
  27809. }
  27810. function reserve_quoted_keys(ast, reserved) {
  27811. function add(name) {
  27812. push_uniq(reserved, name);
  27813. }
  27814. ast.walk(new TreeWalker(function(node) {
  27815. if (node instanceof AST_ObjectKeyVal && node.quote) {
  27816. add(node.key);
  27817. } else if (node instanceof AST_ObjectProperty && node.quote) {
  27818. add(node.key.name);
  27819. } else if (node instanceof AST_Sub) {
  27820. addStrings(node.property, add);
  27821. }
  27822. }));
  27823. }
  27824. function addStrings(node, add) {
  27825. node.walk(new TreeWalker(function(node) {
  27826. if (node instanceof AST_Sequence) {
  27827. addStrings(node.tail_node(), add);
  27828. } else if (node instanceof AST_String) {
  27829. add(node.value);
  27830. } else if (node instanceof AST_Conditional) {
  27831. addStrings(node.consequent, add);
  27832. addStrings(node.alternative, add);
  27833. }
  27834. return true;
  27835. }));
  27836. }
  27837. function mangle_private_properties(ast, options) {
  27838. var cprivate = -1;
  27839. var private_cache = new Map();
  27840. var nth_identifier = options.nth_identifier || base54;
  27841. ast = ast.transform(new TreeTransformer(function(node) {
  27842. if (
  27843. node instanceof AST_ClassPrivateProperty
  27844. || node instanceof AST_PrivateMethod
  27845. || node instanceof AST_PrivateGetter
  27846. || node instanceof AST_PrivateSetter
  27847. || node instanceof AST_PrivateIn
  27848. ) {
  27849. node.key.name = mangle_private(node.key.name);
  27850. } else if (node instanceof AST_DotHash) {
  27851. node.property = mangle_private(node.property);
  27852. }
  27853. }));
  27854. return ast;
  27855. function mangle_private(name) {
  27856. let mangled = private_cache.get(name);
  27857. if (!mangled) {
  27858. mangled = nth_identifier.get(++cprivate);
  27859. private_cache.set(name, mangled);
  27860. }
  27861. return mangled;
  27862. }
  27863. }
  27864. function find_annotated_props(ast) {
  27865. var annotated_props = new Set();
  27866. walk(ast, node => {
  27867. if (
  27868. node instanceof AST_ClassPrivateProperty
  27869. || node instanceof AST_PrivateMethod
  27870. || node instanceof AST_PrivateGetter
  27871. || node instanceof AST_PrivateSetter
  27872. || node instanceof AST_DotHash
  27873. ) ; else if (node instanceof AST_ObjectKeyVal) {
  27874. if (typeof node.key == "string" && has_annotation(node, _MANGLEPROP)) {
  27875. annotated_props.add(node.key);
  27876. }
  27877. } else if (node instanceof AST_ObjectProperty) {
  27878. // setter or getter, since KeyVal is handled above
  27879. if (has_annotation(node, _MANGLEPROP)) {
  27880. annotated_props.add(node.key.name);
  27881. }
  27882. } else if (node instanceof AST_Dot) {
  27883. if (has_annotation(node, _MANGLEPROP)) {
  27884. annotated_props.add(node.property);
  27885. }
  27886. } else if (node instanceof AST_Sub) {
  27887. if (node.property instanceof AST_String && has_annotation(node, _MANGLEPROP)) {
  27888. annotated_props.add(node.property.value);
  27889. }
  27890. }
  27891. });
  27892. return annotated_props;
  27893. }
  27894. function mangle_properties(ast, options, annotated_props = find_annotated_props(ast)) {
  27895. options = defaults(options, {
  27896. builtins: false,
  27897. cache: null,
  27898. debug: false,
  27899. keep_quoted: false,
  27900. nth_identifier: base54,
  27901. only_cache: false,
  27902. regex: null,
  27903. reserved: null,
  27904. undeclared: false,
  27905. only_annotated: false,
  27906. }, true);
  27907. var nth_identifier = options.nth_identifier;
  27908. var reserved_option = options.reserved;
  27909. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  27910. var reserved = new Set(reserved_option);
  27911. if (!options.builtins) find_builtins(reserved);
  27912. var cname = -1;
  27913. var cache;
  27914. if (options.cache) {
  27915. cache = options.cache.props;
  27916. } else {
  27917. cache = new Map();
  27918. }
  27919. var only_annotated = options.only_annotated;
  27920. var regex = options.regex && new RegExp(options.regex);
  27921. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  27922. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  27923. // the same as passing an empty string.
  27924. var debug = options.debug !== false;
  27925. var debug_name_suffix;
  27926. if (debug) {
  27927. debug_name_suffix = (options.debug === true ? "" : options.debug);
  27928. }
  27929. var names_to_mangle = new Set();
  27930. var unmangleable = new Set();
  27931. // Track each already-mangled name to prevent nth_identifier from generating
  27932. // the same name.
  27933. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  27934. var keep_quoted = !!options.keep_quoted;
  27935. // step 1: find candidates to mangle
  27936. ast.walk(new TreeWalker(function(node) {
  27937. if (
  27938. node instanceof AST_ClassPrivateProperty
  27939. || node instanceof AST_PrivateMethod
  27940. || node instanceof AST_PrivateGetter
  27941. || node instanceof AST_PrivateSetter
  27942. || node instanceof AST_DotHash
  27943. ) ; else if (node instanceof AST_ObjectKeyVal) {
  27944. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  27945. add(node.key);
  27946. }
  27947. } else if (node instanceof AST_ObjectProperty) {
  27948. // setter or getter, since KeyVal is handled above
  27949. if (!keep_quoted || !node.quote) {
  27950. add(node.key.name);
  27951. }
  27952. } else if (node instanceof AST_Dot) {
  27953. var declared = !!options.undeclared;
  27954. if (!declared) {
  27955. var root = node;
  27956. while (root.expression) {
  27957. root = root.expression;
  27958. }
  27959. declared = !(root.thedef && root.thedef.undeclared);
  27960. }
  27961. if (declared &&
  27962. (!keep_quoted || !node.quote)) {
  27963. add(node.property);
  27964. }
  27965. } else if (node instanceof AST_Sub) {
  27966. if (!keep_quoted) {
  27967. addStrings(node.property, add);
  27968. }
  27969. } else if (node instanceof AST_Call
  27970. && node.expression.print_to_string() == "Object.defineProperty") {
  27971. addStrings(node.args[1], add);
  27972. } else if (node instanceof AST_Binary && node.operator === "in") {
  27973. addStrings(node.left, add);
  27974. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  27975. add(node.value);
  27976. }
  27977. }));
  27978. // step 2: transform the tree, renaming properties
  27979. return ast.transform(new TreeTransformer(function(node) {
  27980. if (
  27981. node instanceof AST_ClassPrivateProperty
  27982. || node instanceof AST_PrivateMethod
  27983. || node instanceof AST_PrivateGetter
  27984. || node instanceof AST_PrivateSetter
  27985. || node instanceof AST_DotHash
  27986. ) ; else if (node instanceof AST_ObjectKeyVal) {
  27987. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  27988. node.key = mangle(node.key);
  27989. }
  27990. } else if (node instanceof AST_ObjectProperty) {
  27991. // setter, getter, method or class field
  27992. if (!keep_quoted || !node.quote) {
  27993. node.key.name = mangle(node.key.name);
  27994. }
  27995. } else if (node instanceof AST_Dot) {
  27996. if (!keep_quoted || !node.quote) {
  27997. node.property = mangle(node.property);
  27998. }
  27999. } else if (!keep_quoted && node instanceof AST_Sub) {
  28000. node.property = mangleStrings(node.property);
  28001. } else if (node instanceof AST_Call
  28002. && node.expression.print_to_string() == "Object.defineProperty") {
  28003. node.args[1] = mangleStrings(node.args[1]);
  28004. } else if (node instanceof AST_Binary && node.operator === "in") {
  28005. node.left = mangleStrings(node.left);
  28006. } else if (node instanceof AST_String && has_annotation(node, _KEY)) {
  28007. // Clear _KEY annotation to prevent double mangling
  28008. clear_annotation(node, _KEY);
  28009. node.value = mangle(node.value);
  28010. }
  28011. }));
  28012. // only function declarations after this line
  28013. function can_mangle(name) {
  28014. if (unmangleable.has(name)) return false;
  28015. if (reserved.has(name)) return false;
  28016. if (options.only_cache) {
  28017. return cache.has(name);
  28018. }
  28019. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  28020. return true;
  28021. }
  28022. function should_mangle(name) {
  28023. if (only_annotated && !annotated_props.has(name)) return false;
  28024. if (regex && !regex.test(name)) {
  28025. return annotated_props.has(name);
  28026. }
  28027. if (reserved.has(name)) return false;
  28028. return cache.has(name)
  28029. || names_to_mangle.has(name);
  28030. }
  28031. function add(name) {
  28032. if (can_mangle(name)) {
  28033. names_to_mangle.add(name);
  28034. }
  28035. if (!should_mangle(name)) {
  28036. unmangleable.add(name);
  28037. }
  28038. }
  28039. function mangle(name) {
  28040. if (!should_mangle(name)) {
  28041. return name;
  28042. }
  28043. var mangled = cache.get(name);
  28044. if (!mangled) {
  28045. if (debug) {
  28046. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  28047. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  28048. if (can_mangle(debug_mangled)) {
  28049. mangled = debug_mangled;
  28050. }
  28051. }
  28052. // either debug mode is off, or it is on and we could not use the mangled name
  28053. if (!mangled) {
  28054. do {
  28055. mangled = nth_identifier.get(++cname);
  28056. } while (!can_mangle(mangled));
  28057. }
  28058. cache.set(name, mangled);
  28059. }
  28060. return mangled;
  28061. }
  28062. function mangleStrings(node) {
  28063. return node.transform(new TreeTransformer(function(node) {
  28064. if (node instanceof AST_Sequence) {
  28065. var last = node.expressions.length - 1;
  28066. node.expressions[last] = mangleStrings(node.expressions[last]);
  28067. } else if (node instanceof AST_String) {
  28068. // Clear _KEY annotation to prevent double mangling
  28069. clear_annotation(node, _KEY);
  28070. node.value = mangle(node.value);
  28071. } else if (node instanceof AST_Conditional) {
  28072. node.consequent = mangleStrings(node.consequent);
  28073. node.alternative = mangleStrings(node.alternative);
  28074. }
  28075. return node;
  28076. }));
  28077. }
  28078. }
  28079. // to/from base64 functions
  28080. // Prefer built-in Buffer, if available, then use hack
  28081. // https://developer.mozilla.org/en-US/docs/Glossary/Base64#The_Unicode_Problem
  28082. var to_ascii = typeof Buffer !== "undefined"
  28083. ? (b64) => Buffer.from(b64, "base64").toString()
  28084. : (b64) => decodeURIComponent(escape(atob(b64)));
  28085. var to_base64 = typeof Buffer !== "undefined"
  28086. ? (str) => Buffer.from(str).toString("base64")
  28087. : (str) => btoa(unescape(encodeURIComponent(str)));
  28088. function read_source_map(code) {
  28089. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  28090. if (!match) {
  28091. console.warn("inline source map not found");
  28092. return null;
  28093. }
  28094. return to_ascii(match[2]);
  28095. }
  28096. function set_shorthand(name, options, keys) {
  28097. if (options[name]) {
  28098. keys.forEach(function(key) {
  28099. if (options[key]) {
  28100. if (typeof options[key] != "object") options[key] = {};
  28101. if (!(name in options[key])) options[key][name] = options[name];
  28102. }
  28103. });
  28104. }
  28105. }
  28106. function init_cache(cache) {
  28107. if (!cache) return;
  28108. if (!("props" in cache)) {
  28109. cache.props = new Map();
  28110. } else if (!(cache.props instanceof Map)) {
  28111. cache.props = map_from_object(cache.props);
  28112. }
  28113. }
  28114. function cache_to_json(cache) {
  28115. return {
  28116. props: map_to_object(cache.props)
  28117. };
  28118. }
  28119. function log_input(files, options, fs, debug_folder) {
  28120. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  28121. return;
  28122. }
  28123. try {
  28124. fs.mkdirSync(debug_folder);
  28125. } catch (e) {
  28126. if (e.code !== "EEXIST") throw e;
  28127. }
  28128. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  28129. options = options || {};
  28130. const options_str = JSON.stringify(options, (_key, thing) => {
  28131. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  28132. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  28133. return thing;
  28134. }, 4);
  28135. const files_str = (file) => {
  28136. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  28137. return JSON.stringify(file, null, 2);
  28138. } else if (typeof file === "object") {
  28139. return Object.keys(file)
  28140. .map((key) => key + ": " + files_str(file[key]))
  28141. .join("\n\n");
  28142. } else if (typeof file === "string") {
  28143. return "```\n" + file + "\n```";
  28144. } else {
  28145. return file; // What do?
  28146. }
  28147. };
  28148. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  28149. }
  28150. async function minify(files, options, _fs_module) {
  28151. if (
  28152. _fs_module
  28153. && typeof process === "object"
  28154. && process.env
  28155. && typeof process.env.TERSER_DEBUG_DIR === "string"
  28156. ) {
  28157. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  28158. }
  28159. options = defaults(options, {
  28160. compress: {},
  28161. ecma: undefined,
  28162. enclose: false,
  28163. ie8: false,
  28164. keep_classnames: undefined,
  28165. keep_fnames: false,
  28166. mangle: {},
  28167. module: false,
  28168. nameCache: null,
  28169. output: null,
  28170. format: null,
  28171. parse: {},
  28172. rename: undefined,
  28173. safari10: false,
  28174. sourceMap: false,
  28175. spidermonkey: false,
  28176. timings: false,
  28177. toplevel: false,
  28178. warnings: false,
  28179. wrap: false,
  28180. }, true);
  28181. var timings = options.timings && {
  28182. start: Date.now()
  28183. };
  28184. if (options.keep_classnames === undefined) {
  28185. options.keep_classnames = options.keep_fnames;
  28186. }
  28187. if (options.rename === undefined) {
  28188. options.rename = options.compress && options.mangle;
  28189. }
  28190. if (options.output && options.format) {
  28191. throw new Error("Please only specify either output or format option, preferrably format.");
  28192. }
  28193. options.format = options.format || options.output || {};
  28194. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  28195. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  28196. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  28197. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  28198. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  28199. set_shorthand("safari10", options, [ "mangle", "format" ]);
  28200. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  28201. set_shorthand("warnings", options, [ "compress" ]); // legacy
  28202. var quoted_props;
  28203. if (options.mangle) {
  28204. options.mangle = defaults(options.mangle, {
  28205. cache: options.nameCache && (options.nameCache.vars || {}),
  28206. eval: false,
  28207. ie8: false,
  28208. keep_classnames: false,
  28209. keep_fnames: false,
  28210. module: false,
  28211. nth_identifier: base54,
  28212. properties: false,
  28213. reserved: [],
  28214. safari10: false,
  28215. toplevel: false,
  28216. }, true);
  28217. if (options.mangle.properties) {
  28218. if (typeof options.mangle.properties != "object") {
  28219. options.mangle.properties = {};
  28220. }
  28221. if (options.mangle.properties.keep_quoted) {
  28222. quoted_props = options.mangle.properties.reserved;
  28223. if (!Array.isArray(quoted_props)) quoted_props = [];
  28224. options.mangle.properties.reserved = quoted_props;
  28225. }
  28226. if (options.nameCache && !("cache" in options.mangle.properties)) {
  28227. options.mangle.properties.cache = options.nameCache.props || {};
  28228. }
  28229. }
  28230. init_cache(options.mangle.cache);
  28231. init_cache(options.mangle.properties.cache);
  28232. }
  28233. if (options.sourceMap) {
  28234. options.sourceMap = defaults(options.sourceMap, {
  28235. asObject: false,
  28236. content: null,
  28237. filename: null,
  28238. includeSources: false,
  28239. root: null,
  28240. url: null,
  28241. }, true);
  28242. }
  28243. // -- Parse phase --
  28244. if (timings) timings.parse = Date.now();
  28245. var toplevel;
  28246. if (files instanceof AST_Toplevel) {
  28247. toplevel = files;
  28248. } else {
  28249. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  28250. files = [ files ];
  28251. }
  28252. options.parse = options.parse || {};
  28253. options.parse.toplevel = null;
  28254. if (options.parse.spidermonkey) {
  28255. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  28256. if (!toplevel) return files[name];
  28257. toplevel.body = toplevel.body.concat(files[name].body);
  28258. return toplevel;
  28259. }, null));
  28260. } else {
  28261. delete options.parse.spidermonkey;
  28262. for (var name in files) if (HOP(files, name)) {
  28263. options.parse.filename = name;
  28264. options.parse.toplevel = parse(files[name], options.parse);
  28265. if (options.sourceMap && options.sourceMap.content == "inline") {
  28266. if (Object.keys(files).length > 1)
  28267. throw new Error("inline source map only works with singular input");
  28268. options.sourceMap.content = read_source_map(files[name]);
  28269. }
  28270. }
  28271. }
  28272. toplevel = options.parse.toplevel;
  28273. }
  28274. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  28275. reserve_quoted_keys(toplevel, quoted_props);
  28276. }
  28277. var annotated_props;
  28278. if (options.mangle && options.mangle.properties) {
  28279. annotated_props = find_annotated_props(toplevel);
  28280. }
  28281. if (options.wrap) {
  28282. toplevel = toplevel.wrap_commonjs(options.wrap);
  28283. }
  28284. if (options.enclose) {
  28285. toplevel = toplevel.wrap_enclose(options.enclose);
  28286. }
  28287. if (timings) timings.rename = Date.now();
  28288. // -- Compress phase --
  28289. if (timings) timings.compress = Date.now();
  28290. if (options.compress) {
  28291. toplevel = new Compressor(options.compress, {
  28292. mangle_options: options.mangle
  28293. }).compress(toplevel);
  28294. }
  28295. // -- Mangle phase --
  28296. if (timings) timings.scope = Date.now();
  28297. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  28298. if (timings) timings.mangle = Date.now();
  28299. if (options.mangle) {
  28300. toplevel.compute_char_frequency(options.mangle);
  28301. toplevel.mangle_names(options.mangle);
  28302. toplevel = mangle_private_properties(toplevel, options.mangle);
  28303. }
  28304. if (timings) timings.properties = Date.now();
  28305. if (options.mangle && options.mangle.properties) {
  28306. toplevel = mangle_properties(toplevel, options.mangle.properties, annotated_props);
  28307. }
  28308. // Format phase
  28309. if (timings) timings.format = Date.now();
  28310. var result = {};
  28311. if (options.format.ast) {
  28312. result.ast = toplevel;
  28313. }
  28314. if (options.format.spidermonkey) {
  28315. result.ast = toplevel.to_mozilla_ast();
  28316. }
  28317. let format_options;
  28318. if (!HOP(options.format, "code") || options.format.code) {
  28319. // Make a shallow copy so that we can modify without mutating the user's input.
  28320. format_options = {...options.format};
  28321. if (!format_options.ast) {
  28322. // Destroy stuff to save RAM. (unless the deprecated `ast` option is on)
  28323. format_options._destroy_ast = true;
  28324. walk(toplevel, node => {
  28325. if (node instanceof AST_Scope) {
  28326. node.variables = undefined;
  28327. node.enclosed = undefined;
  28328. node.parent_scope = undefined;
  28329. }
  28330. if (node.block_scope) {
  28331. node.block_scope.variables = undefined;
  28332. node.block_scope.enclosed = undefined;
  28333. node.parent_scope = undefined;
  28334. }
  28335. });
  28336. }
  28337. if (options.sourceMap) {
  28338. if (options.sourceMap.includeSources && files instanceof AST_Toplevel) {
  28339. throw new Error("original source content unavailable");
  28340. }
  28341. format_options.source_map = await SourceMap({
  28342. file: options.sourceMap.filename,
  28343. orig: options.sourceMap.content,
  28344. root: options.sourceMap.root,
  28345. files: options.sourceMap.includeSources ? files : null,
  28346. });
  28347. }
  28348. delete format_options.ast;
  28349. delete format_options.code;
  28350. delete format_options.spidermonkey;
  28351. var stream = OutputStream(format_options);
  28352. toplevel.print(stream);
  28353. result.code = stream.get();
  28354. if (options.sourceMap) {
  28355. Object.defineProperty(result, "map", {
  28356. configurable: true,
  28357. enumerable: true,
  28358. get() {
  28359. const map = format_options.source_map.getEncoded();
  28360. return (result.map = options.sourceMap.asObject ? map : JSON.stringify(map));
  28361. },
  28362. set(value) {
  28363. Object.defineProperty(result, "map", {
  28364. value,
  28365. writable: true,
  28366. });
  28367. }
  28368. });
  28369. result.decoded_map = format_options.source_map.getDecoded();
  28370. if (options.sourceMap.url == "inline") {
  28371. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  28372. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  28373. } else if (options.sourceMap.url) {
  28374. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  28375. }
  28376. }
  28377. }
  28378. if (options.nameCache && options.mangle) {
  28379. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  28380. if (options.mangle.properties && options.mangle.properties.cache) {
  28381. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  28382. }
  28383. }
  28384. if (format_options && format_options.source_map) {
  28385. format_options.source_map.destroy();
  28386. }
  28387. if (timings) {
  28388. timings.end = Date.now();
  28389. result.timings = {
  28390. parse: 1e-3 * (timings.rename - timings.parse),
  28391. rename: 1e-3 * (timings.compress - timings.rename),
  28392. compress: 1e-3 * (timings.scope - timings.compress),
  28393. scope: 1e-3 * (timings.mangle - timings.scope),
  28394. mangle: 1e-3 * (timings.properties - timings.mangle),
  28395. properties: 1e-3 * (timings.format - timings.properties),
  28396. format: 1e-3 * (timings.end - timings.format),
  28397. total: 1e-3 * (timings.end - timings.start)
  28398. };
  28399. }
  28400. return result;
  28401. }
  28402. async function run_cli({ program, packageJson, fs, path }) {
  28403. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  28404. var files = {};
  28405. var options = {
  28406. compress: false,
  28407. mangle: false
  28408. };
  28409. const default_options = await _default_options();
  28410. program.version(packageJson.name + " " + packageJson.version);
  28411. program.parseArgv = program.parse;
  28412. program.parse = undefined;
  28413. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  28414. else if (process.argv.includes("options")) program.helpInformation = function() {
  28415. var text = [];
  28416. for (var option in default_options) {
  28417. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  28418. text.push(format_object(default_options[option]));
  28419. text.push("");
  28420. }
  28421. return text.join("\n");
  28422. };
  28423. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  28424. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  28425. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  28426. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  28427. program.option("-f, --format [options]", "Format options.", parse_js());
  28428. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  28429. program.option("-o, --output <file>", "Output file (default STDOUT).");
  28430. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  28431. program.option("--config-file <file>", "Read minify() options from JSON file.");
  28432. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  28433. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  28434. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  28435. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  28436. program.option("--keep-classnames", "Do not mangle/drop class names.");
  28437. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  28438. program.option("--module", "Input is an ES6 module");
  28439. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  28440. program.option("--rename", "Force symbol expansion.");
  28441. program.option("--no-rename", "Disable symbol expansion.");
  28442. program.option("--safari10", "Support non-standard Safari 10.");
  28443. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  28444. program.option("--timings", "Display operations run time on STDERR.");
  28445. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  28446. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  28447. program.arguments("[files...]").parseArgv(process.argv);
  28448. if (program.configFile) {
  28449. options = JSON.parse(read_file(program.configFile));
  28450. }
  28451. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  28452. fatal("ERROR: cannot write source map to STDOUT");
  28453. }
  28454. [
  28455. "compress",
  28456. "enclose",
  28457. "ie8",
  28458. "mangle",
  28459. "module",
  28460. "safari10",
  28461. "sourceMap",
  28462. "toplevel",
  28463. "wrap"
  28464. ].forEach(function(name) {
  28465. if (name in program) {
  28466. options[name] = program[name];
  28467. }
  28468. });
  28469. if ("ecma" in program) {
  28470. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  28471. const ecma = program.ecma | 0;
  28472. if (ecma > 5 && ecma < 2015)
  28473. options.ecma = ecma + 2009;
  28474. else
  28475. options.ecma = ecma;
  28476. }
  28477. if (program.format || program.beautify) {
  28478. const chosenOption = program.format || program.beautify;
  28479. options.format = typeof chosenOption === "object" ? chosenOption : {};
  28480. }
  28481. if (program.comments) {
  28482. if (typeof options.format != "object") options.format = {};
  28483. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  28484. }
  28485. if (program.define) {
  28486. if (typeof options.compress != "object") options.compress = {};
  28487. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  28488. for (var expr in program.define) {
  28489. options.compress.global_defs[expr] = program.define[expr];
  28490. }
  28491. }
  28492. if (program.keepClassnames) {
  28493. options.keep_classnames = true;
  28494. }
  28495. if (program.keepFnames) {
  28496. options.keep_fnames = true;
  28497. }
  28498. if (program.mangleProps) {
  28499. if (program.mangleProps.domprops) {
  28500. delete program.mangleProps.domprops;
  28501. } else {
  28502. if (typeof program.mangleProps != "object") program.mangleProps = {};
  28503. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  28504. }
  28505. if (typeof options.mangle != "object") options.mangle = {};
  28506. options.mangle.properties = program.mangleProps;
  28507. }
  28508. if (program.nameCache) {
  28509. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  28510. }
  28511. if (program.output == "ast") {
  28512. options.format = {
  28513. ast: true,
  28514. code: false
  28515. };
  28516. }
  28517. if (program.parse) {
  28518. if (!program.parse.acorn && !program.parse.spidermonkey) {
  28519. options.parse = program.parse;
  28520. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  28521. fatal("ERROR: inline source map only works with built-in parser");
  28522. }
  28523. }
  28524. if (~program.rawArgs.indexOf("--rename")) {
  28525. options.rename = true;
  28526. } else if (!program.rename) {
  28527. options.rename = false;
  28528. }
  28529. let convert_path = name => name;
  28530. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  28531. convert_path = function() {
  28532. var base = program.sourceMap.base;
  28533. delete options.sourceMap.base;
  28534. return function(name) {
  28535. return path.relative(base, name);
  28536. };
  28537. }();
  28538. }
  28539. let filesList;
  28540. if (options.files && options.files.length) {
  28541. filesList = options.files;
  28542. delete options.files;
  28543. } else if (program.args.length) {
  28544. filesList = program.args;
  28545. }
  28546. if (filesList) {
  28547. simple_glob(filesList).forEach(function(name) {
  28548. files[convert_path(name)] = read_file(name);
  28549. });
  28550. } else {
  28551. await new Promise((resolve) => {
  28552. var chunks = [];
  28553. process.stdin.setEncoding("utf8");
  28554. process.stdin.on("data", function(chunk) {
  28555. chunks.push(chunk);
  28556. }).on("end", function() {
  28557. files = [ chunks.join("") ];
  28558. resolve();
  28559. });
  28560. process.stdin.resume();
  28561. });
  28562. }
  28563. await run_cli();
  28564. function convert_ast(fn) {
  28565. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  28566. }
  28567. async function run_cli() {
  28568. var content = program.sourceMap && program.sourceMap.content;
  28569. if (content && content !== "inline") {
  28570. options.sourceMap.content = read_file(content, content);
  28571. }
  28572. if (program.timings) options.timings = true;
  28573. try {
  28574. if (program.parse) {
  28575. if (program.parse.acorn) {
  28576. files = convert_ast(function(toplevel, name) {
  28577. return require("acorn").parse(files[name], {
  28578. ecmaVersion: 2018,
  28579. locations: true,
  28580. program: toplevel,
  28581. sourceFile: name,
  28582. sourceType: options.module || program.parse.module ? "module" : "script"
  28583. });
  28584. });
  28585. } else if (program.parse.spidermonkey) {
  28586. files = convert_ast(function(toplevel, name) {
  28587. var obj = JSON.parse(files[name]);
  28588. if (!toplevel) return obj;
  28589. toplevel.body = toplevel.body.concat(obj.body);
  28590. return toplevel;
  28591. });
  28592. }
  28593. }
  28594. } catch (ex) {
  28595. fatal(ex);
  28596. }
  28597. let result;
  28598. try {
  28599. result = await minify(files, options, fs);
  28600. } catch (ex) {
  28601. if (ex.name == "SyntaxError") {
  28602. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  28603. var col = ex.col;
  28604. var lines = files[ex.filename].split(/\r?\n/);
  28605. var line = lines[ex.line - 1];
  28606. if (!line && !col) {
  28607. line = lines[ex.line - 2];
  28608. col = line.length;
  28609. }
  28610. if (line) {
  28611. var limit = 70;
  28612. if (col > limit) {
  28613. line = line.slice(col - limit);
  28614. col = limit;
  28615. }
  28616. print_error(line.slice(0, 80));
  28617. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  28618. }
  28619. }
  28620. if (ex.defs) {
  28621. print_error("Supported options:");
  28622. print_error(format_object(ex.defs));
  28623. }
  28624. fatal(ex);
  28625. return;
  28626. }
  28627. if (program.output == "ast") {
  28628. if (!options.compress && !options.mangle) {
  28629. result.ast.figure_out_scope({});
  28630. }
  28631. console.log(JSON.stringify(result.ast, function(key, value) {
  28632. if (value) switch (key) {
  28633. case "thedef":
  28634. return symdef(value);
  28635. case "enclosed":
  28636. return value.length ? value.map(symdef) : undefined;
  28637. case "variables":
  28638. case "globals":
  28639. return value.size ? collect_from_map(value, symdef) : undefined;
  28640. }
  28641. if (skip_keys.has(key)) return;
  28642. if (value instanceof AST_Token) return;
  28643. if (value instanceof Map) return;
  28644. if (value instanceof AST_Node) {
  28645. var result = {
  28646. _class: "AST_" + value.TYPE
  28647. };
  28648. if (value.block_scope) {
  28649. result.variables = value.block_scope.variables;
  28650. result.enclosed = value.block_scope.enclosed;
  28651. }
  28652. value.CTOR.PROPS.forEach(function(prop) {
  28653. if (prop !== "block_scope") {
  28654. result[prop] = value[prop];
  28655. }
  28656. });
  28657. return result;
  28658. }
  28659. return value;
  28660. }, 2));
  28661. } else if (program.output == "spidermonkey") {
  28662. try {
  28663. const minified = await minify(
  28664. result.code,
  28665. {
  28666. compress: false,
  28667. mangle: false,
  28668. format: {
  28669. ast: true,
  28670. code: false
  28671. }
  28672. },
  28673. fs
  28674. );
  28675. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  28676. } catch (ex) {
  28677. fatal(ex);
  28678. return;
  28679. }
  28680. } else if (program.output) {
  28681. fs.writeFileSync(program.output, result.code);
  28682. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  28683. fs.writeFileSync(program.output + ".map", result.map);
  28684. }
  28685. } else {
  28686. console.log(result.code);
  28687. }
  28688. if (program.nameCache) {
  28689. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  28690. }
  28691. if (result.timings) for (var phase in result.timings) {
  28692. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  28693. }
  28694. }
  28695. function fatal(message) {
  28696. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  28697. print_error(message);
  28698. process.exit(1);
  28699. }
  28700. // A file glob function that only supports "*" and "?" wildcards in the basename.
  28701. // Example: "foo/bar/*baz??.*.js"
  28702. // Argument `glob` may be a string or an array of strings.
  28703. // Returns an array of strings. Garbage in, garbage out.
  28704. function simple_glob(glob) {
  28705. if (Array.isArray(glob)) {
  28706. return [].concat.apply([], glob.map(simple_glob));
  28707. }
  28708. if (glob && glob.match(/[*?]/)) {
  28709. var dir = path.dirname(glob);
  28710. try {
  28711. var entries = fs.readdirSync(dir);
  28712. } catch (ex) {}
  28713. if (entries) {
  28714. var pattern = "^" + path.basename(glob)
  28715. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  28716. .replace(/\*/g, "[^/\\\\]*")
  28717. .replace(/\?/g, "[^/\\\\]") + "$";
  28718. var mod = process.platform === "win32" ? "i" : "";
  28719. var rx = new RegExp(pattern, mod);
  28720. var results = entries.filter(function(name) {
  28721. return rx.test(name);
  28722. }).map(function(name) {
  28723. return path.join(dir, name);
  28724. });
  28725. if (results.length) return results;
  28726. }
  28727. }
  28728. return [ glob ];
  28729. }
  28730. function read_file(path, default_value) {
  28731. try {
  28732. return fs.readFileSync(path, "utf8");
  28733. } catch (ex) {
  28734. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  28735. fatal(ex);
  28736. }
  28737. }
  28738. function parse_js(flag) {
  28739. return function(value, options) {
  28740. options = options || {};
  28741. try {
  28742. walk(parse(value, { expression: true }), node => {
  28743. if (node instanceof AST_Assign) {
  28744. var name = node.left.print_to_string();
  28745. var value = node.right;
  28746. if (flag) {
  28747. options[name] = value;
  28748. } else if (value instanceof AST_Array) {
  28749. options[name] = value.elements.map(to_string);
  28750. } else if (value instanceof AST_RegExp) {
  28751. value = value.value;
  28752. options[name] = new RegExp(value.source, value.flags);
  28753. } else {
  28754. options[name] = to_string(value);
  28755. }
  28756. return true;
  28757. }
  28758. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  28759. var name = node.print_to_string();
  28760. options[name] = true;
  28761. return true;
  28762. }
  28763. if (!(node instanceof AST_Sequence)) throw node;
  28764. function to_string(value) {
  28765. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  28766. quote_keys: true
  28767. });
  28768. }
  28769. });
  28770. } catch(ex) {
  28771. if (flag) {
  28772. fatal("Error parsing arguments for '" + flag + "': " + value);
  28773. } else {
  28774. options[value] = null;
  28775. }
  28776. }
  28777. return options;
  28778. };
  28779. }
  28780. function symdef(def) {
  28781. var ret = (1e6 + def.id) + " " + def.name;
  28782. if (def.mangled_name) ret += " " + def.mangled_name;
  28783. return ret;
  28784. }
  28785. function collect_from_map(map, callback) {
  28786. var result = [];
  28787. map.forEach(function (def) {
  28788. result.push(callback(def));
  28789. });
  28790. return result;
  28791. }
  28792. function format_object(obj) {
  28793. var lines = [];
  28794. var padding = "";
  28795. Object.keys(obj).map(function(name) {
  28796. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  28797. return [ name, JSON.stringify(obj[name]) ];
  28798. }).forEach(function(tokens) {
  28799. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  28800. });
  28801. return lines.join("\n");
  28802. }
  28803. function print_error(msg) {
  28804. process.stderr.write(msg);
  28805. process.stderr.write("\n");
  28806. }
  28807. function describe_ast() {
  28808. var out = OutputStream({ beautify: true });
  28809. function doitem(ctor) {
  28810. out.print("AST_" + ctor.TYPE);
  28811. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  28812. if (props.length > 0) {
  28813. out.space();
  28814. out.with_parens(function() {
  28815. props.forEach(function(prop, i) {
  28816. if (i) out.space();
  28817. out.print(prop);
  28818. });
  28819. });
  28820. }
  28821. if (ctor.documentation) {
  28822. out.space();
  28823. out.print_string(ctor.documentation);
  28824. }
  28825. if (ctor.SUBCLASSES.length > 0) {
  28826. out.space();
  28827. out.with_block(function() {
  28828. ctor.SUBCLASSES.forEach(function(ctor) {
  28829. out.indent();
  28830. doitem(ctor);
  28831. out.newline();
  28832. });
  28833. });
  28834. }
  28835. }
  28836. doitem(AST_Node);
  28837. return out + "\n";
  28838. }
  28839. }
  28840. async function _default_options() {
  28841. const defs = {};
  28842. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  28843. const options = infer_options({
  28844. [component]: {0: 0}
  28845. });
  28846. if (options) defs[component] = options;
  28847. });
  28848. return defs;
  28849. }
  28850. async function infer_options(options) {
  28851. try {
  28852. await minify("", options);
  28853. } catch (error) {
  28854. return error.defs;
  28855. }
  28856. }
  28857. exports._default_options = _default_options;
  28858. exports._run_cli = run_cli;
  28859. exports.minify = minify;
  28860. }));