bundle.min.js 930 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('source-map')) :
  3. typeof define === 'function' && define.amd ? define(['exports', 'source-map'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Terser = {}, global.sourceMap));
  5. }(this, (function (exports, MOZ_SourceMap) { 'use strict';
  6. function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  7. var MOZ_SourceMap__default = /*#__PURE__*/_interopDefaultLegacy(MOZ_SourceMap);
  8. /***********************************************************************
  9. A JavaScript tokenizer / parser / beautifier / compressor.
  10. https://github.com/mishoo/UglifyJS2
  11. -------------------------------- (C) ---------------------------------
  12. Author: Mihai Bazon
  13. <mihai.bazon@gmail.com>
  14. http://mihai.bazon.net/blog
  15. Distributed under the BSD license:
  16. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17. Redistribution and use in source and binary forms, with or without
  18. modification, are permitted provided that the following conditions
  19. are met:
  20. * Redistributions of source code must retain the above
  21. copyright notice, this list of conditions and the following
  22. disclaimer.
  23. * Redistributions in binary form must reproduce the above
  24. copyright notice, this list of conditions and the following
  25. disclaimer in the documentation and/or other materials
  26. provided with the distribution.
  27. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  28. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  30. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  31. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  32. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  33. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  34. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  35. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  36. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  37. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38. SUCH DAMAGE.
  39. ***********************************************************************/
  40. function characters(str) {
  41. return str.split("");
  42. }
  43. function member(name, array) {
  44. return array.includes(name);
  45. }
  46. class DefaultsError extends Error {
  47. constructor(msg, defs) {
  48. super();
  49. this.name = "DefaultsError";
  50. this.message = msg;
  51. this.defs = defs;
  52. }
  53. }
  54. function defaults(args, defs, croak) {
  55. if (args === true) {
  56. args = {};
  57. } else if (args != null && typeof args === "object") {
  58. args = {...args};
  59. }
  60. const ret = args || {};
  61. if (croak) for (const i in ret) if (HOP(ret, i) && !HOP(defs, i)) {
  62. throw new DefaultsError("`" + i + "` is not a supported option", defs);
  63. }
  64. for (const i in defs) if (HOP(defs, i)) {
  65. if (!args || !HOP(args, i)) {
  66. ret[i] = defs[i];
  67. } else if (i === "ecma") {
  68. let ecma = args[i] | 0;
  69. if (ecma > 5 && ecma < 2015) ecma += 2009;
  70. ret[i] = ecma;
  71. } else {
  72. ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
  73. }
  74. }
  75. return ret;
  76. }
  77. function noop() {}
  78. function return_false() { return false; }
  79. function return_true() { return true; }
  80. function return_this() { return this; }
  81. function return_null() { return null; }
  82. var MAP = (function() {
  83. function MAP(a, f, backwards) {
  84. var ret = [], top = [], i;
  85. function doit() {
  86. var val = f(a[i], i);
  87. var is_last = val instanceof Last;
  88. if (is_last) val = val.v;
  89. if (val instanceof AtTop) {
  90. val = val.v;
  91. if (val instanceof Splice) {
  92. top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
  93. } else {
  94. top.push(val);
  95. }
  96. } else if (val !== skip) {
  97. if (val instanceof Splice) {
  98. ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
  99. } else {
  100. ret.push(val);
  101. }
  102. }
  103. return is_last;
  104. }
  105. if (Array.isArray(a)) {
  106. if (backwards) {
  107. for (i = a.length; --i >= 0;) if (doit()) break;
  108. ret.reverse();
  109. top.reverse();
  110. } else {
  111. for (i = 0; i < a.length; ++i) if (doit()) break;
  112. }
  113. } else {
  114. for (i in a) if (HOP(a, i)) if (doit()) break;
  115. }
  116. return top.concat(ret);
  117. }
  118. MAP.at_top = function(val) { return new AtTop(val); };
  119. MAP.splice = function(val) { return new Splice(val); };
  120. MAP.last = function(val) { return new Last(val); };
  121. var skip = MAP.skip = {};
  122. function AtTop(val) { this.v = val; }
  123. function Splice(val) { this.v = val; }
  124. function Last(val) { this.v = val; }
  125. return MAP;
  126. })();
  127. function make_node(ctor, orig, props) {
  128. if (!props) props = {};
  129. if (orig) {
  130. if (!props.start) props.start = orig.start;
  131. if (!props.end) props.end = orig.end;
  132. }
  133. return new ctor(props);
  134. }
  135. function push_uniq(array, el) {
  136. if (!array.includes(el))
  137. array.push(el);
  138. }
  139. function string_template(text, props) {
  140. return text.replace(/{(.+?)}/g, function(str, p) {
  141. return props && props[p];
  142. });
  143. }
  144. function remove(array, el) {
  145. for (var i = array.length; --i >= 0;) {
  146. if (array[i] === el) array.splice(i, 1);
  147. }
  148. }
  149. function mergeSort(array, cmp) {
  150. if (array.length < 2) return array.slice();
  151. function merge(a, b) {
  152. var r = [], ai = 0, bi = 0, i = 0;
  153. while (ai < a.length && bi < b.length) {
  154. cmp(a[ai], b[bi]) <= 0
  155. ? r[i++] = a[ai++]
  156. : r[i++] = b[bi++];
  157. }
  158. if (ai < a.length) r.push.apply(r, a.slice(ai));
  159. if (bi < b.length) r.push.apply(r, b.slice(bi));
  160. return r;
  161. }
  162. function _ms(a) {
  163. if (a.length <= 1)
  164. return a;
  165. var m = Math.floor(a.length / 2), left = a.slice(0, m), right = a.slice(m);
  166. left = _ms(left);
  167. right = _ms(right);
  168. return merge(left, right);
  169. }
  170. return _ms(array);
  171. }
  172. function makePredicate(words) {
  173. if (!Array.isArray(words)) words = words.split(" ");
  174. return new Set(words.sort());
  175. }
  176. function map_add(map, key, value) {
  177. if (map.has(key)) {
  178. map.get(key).push(value);
  179. } else {
  180. map.set(key, [ value ]);
  181. }
  182. }
  183. function map_from_object(obj) {
  184. var map = new Map();
  185. for (var key in obj) {
  186. if (HOP(obj, key) && key.charAt(0) === "$") {
  187. map.set(key.substr(1), obj[key]);
  188. }
  189. }
  190. return map;
  191. }
  192. function map_to_object(map) {
  193. var obj = Object.create(null);
  194. map.forEach(function (value, key) {
  195. obj["$" + key] = value;
  196. });
  197. return obj;
  198. }
  199. function HOP(obj, prop) {
  200. return Object.prototype.hasOwnProperty.call(obj, prop);
  201. }
  202. function keep_name(keep_setting, name) {
  203. return keep_setting === true
  204. || (keep_setting instanceof RegExp && keep_setting.test(name));
  205. }
  206. var lineTerminatorEscape = {
  207. "\0": "0",
  208. "\n": "n",
  209. "\r": "r",
  210. "\u2028": "u2028",
  211. "\u2029": "u2029",
  212. };
  213. function regexp_source_fix(source) {
  214. // V8 does not escape line terminators in regexp patterns in node 12
  215. // We'll also remove literal \0
  216. return source.replace(/[\0\n\r\u2028\u2029]/g, function (match, offset) {
  217. var escaped = source[offset - 1] == "\\"
  218. && (source[offset - 2] != "\\"
  219. || /(?:^|[^\\])(?:\\{2})*$/.test(source.slice(0, offset - 1)));
  220. return (escaped ? "" : "\\") + lineTerminatorEscape[match];
  221. });
  222. }
  223. const all_flags = "gimuy";
  224. function sort_regexp_flags(flags) {
  225. const existing_flags = new Set(flags.split(""));
  226. let out = "";
  227. for (const flag of all_flags) {
  228. if (existing_flags.has(flag)) {
  229. out += flag;
  230. existing_flags.delete(flag);
  231. }
  232. }
  233. if (existing_flags.size) {
  234. // Flags Terser doesn't know about
  235. existing_flags.forEach(flag => { out += flag; });
  236. }
  237. return out;
  238. }
  239. function has_annotation(node, annotation) {
  240. return node._annotations & annotation;
  241. }
  242. function set_annotation(node, annotation) {
  243. node._annotations |= annotation;
  244. }
  245. /***********************************************************************
  246. A JavaScript tokenizer / parser / beautifier / compressor.
  247. https://github.com/mishoo/UglifyJS2
  248. -------------------------------- (C) ---------------------------------
  249. Author: Mihai Bazon
  250. <mihai.bazon@gmail.com>
  251. http://mihai.bazon.net/blog
  252. Distributed under the BSD license:
  253. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  254. Parser based on parse-js (http://marijn.haverbeke.nl/parse-js/).
  255. Redistribution and use in source and binary forms, with or without
  256. modification, are permitted provided that the following conditions
  257. are met:
  258. * Redistributions of source code must retain the above
  259. copyright notice, this list of conditions and the following
  260. disclaimer.
  261. * Redistributions in binary form must reproduce the above
  262. copyright notice, this list of conditions and the following
  263. disclaimer in the documentation and/or other materials
  264. provided with the distribution.
  265. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  266. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  267. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  268. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  269. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  270. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  271. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  272. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  273. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  274. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  275. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  276. SUCH DAMAGE.
  277. ***********************************************************************/
  278. var LATEST_RAW = ""; // Only used for numbers and template strings
  279. var LATEST_TEMPLATE_END = true;
  280. 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";
  281. var KEYWORDS_ATOM = "false null true";
  282. var RESERVED_WORDS = "enum import super this " + KEYWORDS_ATOM + " " + KEYWORDS;
  283. var ALL_RESERVED_WORDS = "implements interface package private protected public static " + RESERVED_WORDS;
  284. var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case yield await";
  285. KEYWORDS = makePredicate(KEYWORDS);
  286. RESERVED_WORDS = makePredicate(RESERVED_WORDS);
  287. KEYWORDS_BEFORE_EXPRESSION = makePredicate(KEYWORDS_BEFORE_EXPRESSION);
  288. KEYWORDS_ATOM = makePredicate(KEYWORDS_ATOM);
  289. ALL_RESERVED_WORDS = makePredicate(ALL_RESERVED_WORDS);
  290. var OPERATOR_CHARS = makePredicate(characters("+-*&%=<>!?|~^"));
  291. var RE_NUM_LITERAL = /[0-9a-f]/i;
  292. var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
  293. var RE_OCT_NUMBER = /^0[0-7]+$/;
  294. var RE_ES6_OCT_NUMBER = /^0o[0-7]+$/i;
  295. var RE_BIN_NUMBER = /^0b[01]+$/i;
  296. var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
  297. var RE_BIG_INT = /^(0[xob])?[0-9a-f]+n$/i;
  298. var OPERATORS = makePredicate([
  299. "in",
  300. "instanceof",
  301. "typeof",
  302. "new",
  303. "void",
  304. "delete",
  305. "++",
  306. "--",
  307. "+",
  308. "-",
  309. "!",
  310. "~",
  311. "&",
  312. "|",
  313. "^",
  314. "*",
  315. "**",
  316. "/",
  317. "%",
  318. ">>",
  319. "<<",
  320. ">>>",
  321. "<",
  322. ">",
  323. "<=",
  324. ">=",
  325. "==",
  326. "===",
  327. "!=",
  328. "!==",
  329. "?",
  330. "=",
  331. "+=",
  332. "-=",
  333. "||=",
  334. "&&=",
  335. "??=",
  336. "/=",
  337. "*=",
  338. "**=",
  339. "%=",
  340. ">>=",
  341. "<<=",
  342. ">>>=",
  343. "|=",
  344. "^=",
  345. "&=",
  346. "&&",
  347. "??",
  348. "||",
  349. ]);
  350. 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"));
  351. var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029"));
  352. var PUNC_AFTER_EXPRESSION = makePredicate(characters(";]),:"));
  353. var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:"));
  354. var PUNC_CHARS = makePredicate(characters("[]{}(),;:"));
  355. /* -----[ Tokenizer ]----- */
  356. // surrogate safe regexps adapted from https://github.com/mathiasbynens/unicode-8.0.0/tree/89b412d8a71ecca9ed593d9e9fa073ab64acfebe/Binary_Property
  357. var UNICODE = {
  358. 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]/,
  359. 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])+/,
  360. };
  361. function get_full_char(str, pos) {
  362. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  363. if (is_surrogate_pair_tail(str.charCodeAt(pos + 1))) {
  364. return str.charAt(pos) + str.charAt(pos + 1);
  365. }
  366. } else if (is_surrogate_pair_tail(str.charCodeAt(pos))) {
  367. if (is_surrogate_pair_head(str.charCodeAt(pos - 1))) {
  368. return str.charAt(pos - 1) + str.charAt(pos);
  369. }
  370. }
  371. return str.charAt(pos);
  372. }
  373. function get_full_char_code(str, pos) {
  374. // https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates
  375. if (is_surrogate_pair_head(str.charCodeAt(pos))) {
  376. return 0x10000 + (str.charCodeAt(pos) - 0xd800 << 10) + str.charCodeAt(pos + 1) - 0xdc00;
  377. }
  378. return str.charCodeAt(pos);
  379. }
  380. function get_full_char_length(str) {
  381. var surrogates = 0;
  382. for (var i = 0; i < str.length; i++) {
  383. if (is_surrogate_pair_head(str.charCodeAt(i)) && is_surrogate_pair_tail(str.charCodeAt(i + 1))) {
  384. surrogates++;
  385. i++;
  386. }
  387. }
  388. return str.length - surrogates;
  389. }
  390. function from_char_code(code) {
  391. // Based on https://github.com/mathiasbynens/String.fromCodePoint/blob/master/fromcodepoint.js
  392. if (code > 0xFFFF) {
  393. code -= 0x10000;
  394. return (String.fromCharCode((code >> 10) + 0xD800) +
  395. String.fromCharCode((code % 0x400) + 0xDC00));
  396. }
  397. return String.fromCharCode(code);
  398. }
  399. function is_surrogate_pair_head(code) {
  400. return code >= 0xd800 && code <= 0xdbff;
  401. }
  402. function is_surrogate_pair_tail(code) {
  403. return code >= 0xdc00 && code <= 0xdfff;
  404. }
  405. function is_digit(code) {
  406. return code >= 48 && code <= 57;
  407. }
  408. function is_identifier_start(ch) {
  409. return UNICODE.ID_Start.test(ch);
  410. }
  411. function is_identifier_char(ch) {
  412. return UNICODE.ID_Continue.test(ch);
  413. }
  414. const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
  415. function is_basic_identifier_string(str) {
  416. return BASIC_IDENT.test(str);
  417. }
  418. function is_identifier_string(str, allow_surrogates) {
  419. if (BASIC_IDENT.test(str)) {
  420. return true;
  421. }
  422. if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
  423. return false;
  424. }
  425. var match = UNICODE.ID_Start.exec(str);
  426. if (!match || match.index !== 0) {
  427. return false;
  428. }
  429. str = str.slice(match[0].length);
  430. if (!str) {
  431. return true;
  432. }
  433. match = UNICODE.ID_Continue.exec(str);
  434. return !!match && match[0].length === str.length;
  435. }
  436. function parse_js_number(num, allow_e = true) {
  437. if (!allow_e && num.includes("e")) {
  438. return NaN;
  439. }
  440. if (RE_HEX_NUMBER.test(num)) {
  441. return parseInt(num.substr(2), 16);
  442. } else if (RE_OCT_NUMBER.test(num)) {
  443. return parseInt(num.substr(1), 8);
  444. } else if (RE_ES6_OCT_NUMBER.test(num)) {
  445. return parseInt(num.substr(2), 8);
  446. } else if (RE_BIN_NUMBER.test(num)) {
  447. return parseInt(num.substr(2), 2);
  448. } else if (RE_DEC_NUMBER.test(num)) {
  449. return parseFloat(num);
  450. } else {
  451. var val = parseFloat(num);
  452. if (val == num) return val;
  453. }
  454. }
  455. class JS_Parse_Error extends Error {
  456. constructor(message, filename, line, col, pos) {
  457. super();
  458. this.name = "SyntaxError";
  459. this.message = message;
  460. this.filename = filename;
  461. this.line = line;
  462. this.col = col;
  463. this.pos = pos;
  464. }
  465. }
  466. function js_error(message, filename, line, col, pos) {
  467. throw new JS_Parse_Error(message, filename, line, col, pos);
  468. }
  469. function is_token(token, type, val) {
  470. return token.type == type && (val == null || token.value == val);
  471. }
  472. var EX_EOF = {};
  473. function tokenizer($TEXT, filename, html5_comments, shebang) {
  474. var S = {
  475. text : $TEXT,
  476. filename : filename,
  477. pos : 0,
  478. tokpos : 0,
  479. line : 1,
  480. tokline : 0,
  481. col : 0,
  482. tokcol : 0,
  483. newline_before : false,
  484. regex_allowed : false,
  485. brace_counter : 0,
  486. template_braces : [],
  487. comments_before : [],
  488. directives : {},
  489. directive_stack : []
  490. };
  491. function peek() { return get_full_char(S.text, S.pos); }
  492. // Used because parsing ?. involves a lookahead for a digit
  493. function is_option_chain_op() {
  494. const must_be_dot = S.text.charCodeAt(S.pos + 1) === 46;
  495. if (!must_be_dot) return false;
  496. const cannot_be_digit = S.text.charCodeAt(S.pos + 2);
  497. return cannot_be_digit < 48 || cannot_be_digit > 57;
  498. }
  499. function next(signal_eof, in_string) {
  500. var ch = get_full_char(S.text, S.pos++);
  501. if (signal_eof && !ch)
  502. throw EX_EOF;
  503. if (NEWLINE_CHARS.has(ch)) {
  504. S.newline_before = S.newline_before || !in_string;
  505. ++S.line;
  506. S.col = 0;
  507. if (ch == "\r" && peek() == "\n") {
  508. // treat a \r\n sequence as a single \n
  509. ++S.pos;
  510. ch = "\n";
  511. }
  512. } else {
  513. if (ch.length > 1) {
  514. ++S.pos;
  515. ++S.col;
  516. }
  517. ++S.col;
  518. }
  519. return ch;
  520. }
  521. function forward(i) {
  522. while (i--) next();
  523. }
  524. function looking_at(str) {
  525. return S.text.substr(S.pos, str.length) == str;
  526. }
  527. function find_eol() {
  528. var text = S.text;
  529. for (var i = S.pos, n = S.text.length; i < n; ++i) {
  530. var ch = text[i];
  531. if (NEWLINE_CHARS.has(ch))
  532. return i;
  533. }
  534. return -1;
  535. }
  536. function find(what, signal_eof) {
  537. var pos = S.text.indexOf(what, S.pos);
  538. if (signal_eof && pos == -1) throw EX_EOF;
  539. return pos;
  540. }
  541. function start_token() {
  542. S.tokline = S.line;
  543. S.tokcol = S.col;
  544. S.tokpos = S.pos;
  545. }
  546. var prev_was_dot = false;
  547. var previous_token = null;
  548. function token(type, value, is_comment) {
  549. S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX.has(value)) ||
  550. (type == "keyword" && KEYWORDS_BEFORE_EXPRESSION.has(value)) ||
  551. (type == "punc" && PUNC_BEFORE_EXPRESSION.has(value))) ||
  552. (type == "arrow");
  553. if (type == "punc" && (value == "." || value == "?.")) {
  554. prev_was_dot = true;
  555. } else if (!is_comment) {
  556. prev_was_dot = false;
  557. }
  558. const line = S.tokline;
  559. const col = S.tokcol;
  560. const pos = S.tokpos;
  561. const nlb = S.newline_before;
  562. const file = filename;
  563. let comments_before = [];
  564. let comments_after = [];
  565. if (!is_comment) {
  566. comments_before = S.comments_before;
  567. comments_after = S.comments_before = [];
  568. }
  569. S.newline_before = false;
  570. const tok = new AST_Token(type, value, line, col, pos, nlb, comments_before, comments_after, file);
  571. if (!is_comment) previous_token = tok;
  572. return tok;
  573. }
  574. function skip_whitespace() {
  575. while (WHITESPACE_CHARS.has(peek()))
  576. next();
  577. }
  578. function read_while(pred) {
  579. var ret = "", ch, i = 0;
  580. while ((ch = peek()) && pred(ch, i++))
  581. ret += next();
  582. return ret;
  583. }
  584. function parse_error(err) {
  585. js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
  586. }
  587. function read_num(prefix) {
  588. var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".", is_big_int = false, numeric_separator = false;
  589. var num = read_while(function(ch, i) {
  590. if (is_big_int) return false;
  591. var code = ch.charCodeAt(0);
  592. switch (code) {
  593. case 95: // _
  594. return (numeric_separator = true);
  595. case 98: case 66: // bB
  596. return (has_x = true); // Can occur in hex sequence, don't return false yet
  597. case 111: case 79: // oO
  598. case 120: case 88: // xX
  599. return has_x ? false : (has_x = true);
  600. case 101: case 69: // eE
  601. return has_x ? true : has_e ? false : (has_e = after_e = true);
  602. case 45: // -
  603. return after_e || (i == 0 && !prefix);
  604. case 43: // +
  605. return after_e;
  606. case (after_e = false, 46): // .
  607. return (!has_dot && !has_x && !has_e) ? (has_dot = true) : false;
  608. }
  609. if (ch === "n") {
  610. is_big_int = true;
  611. return true;
  612. }
  613. return RE_NUM_LITERAL.test(ch);
  614. });
  615. if (prefix) num = prefix + num;
  616. LATEST_RAW = num;
  617. if (RE_OCT_NUMBER.test(num) && next_token.has_directive("use strict")) {
  618. parse_error("Legacy octal literals are not allowed in strict mode");
  619. }
  620. if (numeric_separator) {
  621. if (num.endsWith("_")) {
  622. parse_error("Numeric separators are not allowed at the end of numeric literals");
  623. } else if (num.includes("__")) {
  624. parse_error("Only one underscore is allowed as numeric separator");
  625. }
  626. num = num.replace(/_/g, "");
  627. }
  628. if (num.endsWith("n")) {
  629. const without_n = num.slice(0, -1);
  630. const allow_e = RE_HEX_NUMBER.test(without_n);
  631. const valid = parse_js_number(without_n, allow_e);
  632. if (!has_dot && RE_BIG_INT.test(num) && !isNaN(valid))
  633. return token("big_int", without_n);
  634. parse_error("Invalid or unexpected token");
  635. }
  636. var valid = parse_js_number(num);
  637. if (!isNaN(valid)) {
  638. return token("num", valid);
  639. } else {
  640. parse_error("Invalid syntax: " + num);
  641. }
  642. }
  643. function is_octal(ch) {
  644. return ch >= "0" && ch <= "7";
  645. }
  646. function read_escaped_char(in_string, strict_hex, template_string) {
  647. var ch = next(true, in_string);
  648. switch (ch.charCodeAt(0)) {
  649. case 110 : return "\n";
  650. case 114 : return "\r";
  651. case 116 : return "\t";
  652. case 98 : return "\b";
  653. case 118 : return "\u000b"; // \v
  654. case 102 : return "\f";
  655. case 120 : return String.fromCharCode(hex_bytes(2, strict_hex)); // \x
  656. case 117 : // \u
  657. if (peek() == "{") {
  658. next(true);
  659. if (peek() === "}")
  660. parse_error("Expecting hex-character between {}");
  661. while (peek() == "0") next(true); // No significance
  662. var result, length = find("}", true) - S.pos;
  663. // Avoid 32 bit integer overflow (1 << 32 === 1)
  664. // We know first character isn't 0 and thus out of range anyway
  665. if (length > 6 || (result = hex_bytes(length, strict_hex)) > 0x10FFFF) {
  666. parse_error("Unicode reference out of bounds");
  667. }
  668. next(true);
  669. return from_char_code(result);
  670. }
  671. return String.fromCharCode(hex_bytes(4, strict_hex));
  672. case 10 : return ""; // newline
  673. case 13 : // \r
  674. if (peek() == "\n") { // DOS newline
  675. next(true, in_string);
  676. return "";
  677. }
  678. }
  679. if (is_octal(ch)) {
  680. if (template_string && strict_hex) {
  681. const represents_null_character = ch === "0" && !is_octal(peek());
  682. if (!represents_null_character) {
  683. parse_error("Octal escape sequences are not allowed in template strings");
  684. }
  685. }
  686. return read_octal_escape_sequence(ch, strict_hex);
  687. }
  688. return ch;
  689. }
  690. function read_octal_escape_sequence(ch, strict_octal) {
  691. // Read
  692. var p = peek();
  693. if (p >= "0" && p <= "7") {
  694. ch += next(true);
  695. if (ch[0] <= "3" && (p = peek()) >= "0" && p <= "7")
  696. ch += next(true);
  697. }
  698. // Parse
  699. if (ch === "0") return "\0";
  700. if (ch.length > 0 && next_token.has_directive("use strict") && strict_octal)
  701. parse_error("Legacy octal escape sequences are not allowed in strict mode");
  702. return String.fromCharCode(parseInt(ch, 8));
  703. }
  704. function hex_bytes(n, strict_hex) {
  705. var num = 0;
  706. for (; n > 0; --n) {
  707. if (!strict_hex && isNaN(parseInt(peek(), 16))) {
  708. return parseInt(num, 16) || "";
  709. }
  710. var digit = next(true);
  711. if (isNaN(parseInt(digit, 16)))
  712. parse_error("Invalid hex-character pattern in string");
  713. num += digit;
  714. }
  715. return parseInt(num, 16);
  716. }
  717. var read_string = with_eof_error("Unterminated string constant", function() {
  718. const start_pos = S.pos;
  719. var quote = next(), ret = [];
  720. for (;;) {
  721. var ch = next(true, true);
  722. if (ch == "\\") ch = read_escaped_char(true, true);
  723. else if (ch == "\r" || ch == "\n") parse_error("Unterminated string constant");
  724. else if (ch == quote) break;
  725. ret.push(ch);
  726. }
  727. var tok = token("string", ret.join(""));
  728. LATEST_RAW = S.text.slice(start_pos, S.pos);
  729. tok.quote = quote;
  730. return tok;
  731. });
  732. var read_template_characters = with_eof_error("Unterminated template", function(begin) {
  733. if (begin) {
  734. S.template_braces.push(S.brace_counter);
  735. }
  736. var content = "", raw = "", ch, tok;
  737. next(true, true);
  738. while ((ch = next(true, true)) != "`") {
  739. if (ch == "\r") {
  740. if (peek() == "\n") ++S.pos;
  741. ch = "\n";
  742. } else if (ch == "$" && peek() == "{") {
  743. next(true, true);
  744. S.brace_counter++;
  745. tok = token(begin ? "template_head" : "template_substitution", content);
  746. LATEST_RAW = raw;
  747. LATEST_TEMPLATE_END = false;
  748. return tok;
  749. }
  750. raw += ch;
  751. if (ch == "\\") {
  752. var tmp = S.pos;
  753. var prev_is_tag = previous_token && (previous_token.type === "name" || previous_token.type === "punc" && (previous_token.value === ")" || previous_token.value === "]"));
  754. ch = read_escaped_char(true, !prev_is_tag, true);
  755. raw += S.text.substr(tmp, S.pos - tmp);
  756. }
  757. content += ch;
  758. }
  759. S.template_braces.pop();
  760. tok = token(begin ? "template_head" : "template_substitution", content);
  761. LATEST_RAW = raw;
  762. LATEST_TEMPLATE_END = true;
  763. return tok;
  764. });
  765. function skip_line_comment(type) {
  766. var regex_allowed = S.regex_allowed;
  767. var i = find_eol(), ret;
  768. if (i == -1) {
  769. ret = S.text.substr(S.pos);
  770. S.pos = S.text.length;
  771. } else {
  772. ret = S.text.substring(S.pos, i);
  773. S.pos = i;
  774. }
  775. S.col = S.tokcol + (S.pos - S.tokpos);
  776. S.comments_before.push(token(type, ret, true));
  777. S.regex_allowed = regex_allowed;
  778. return next_token;
  779. }
  780. var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
  781. var regex_allowed = S.regex_allowed;
  782. var i = find("*/", true);
  783. var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
  784. // update stream position
  785. forward(get_full_char_length(text) /* text length doesn't count \r\n as 2 char while S.pos - i does */ + 2);
  786. S.comments_before.push(token("comment2", text, true));
  787. S.newline_before = S.newline_before || text.includes("\n");
  788. S.regex_allowed = regex_allowed;
  789. return next_token;
  790. });
  791. var read_name = with_eof_error("Unterminated identifier name", function() {
  792. var name = [], ch, escaped = false;
  793. var read_escaped_identifier_char = function() {
  794. escaped = true;
  795. next();
  796. if (peek() !== "u") {
  797. parse_error("Expecting UnicodeEscapeSequence -- uXXXX or u{XXXX}");
  798. }
  799. return read_escaped_char(false, true);
  800. };
  801. // Read first character (ID_Start)
  802. if ((ch = peek()) === "\\") {
  803. ch = read_escaped_identifier_char();
  804. if (!is_identifier_start(ch)) {
  805. parse_error("First identifier char is an invalid identifier char");
  806. }
  807. } else if (is_identifier_start(ch)) {
  808. next();
  809. } else {
  810. return "";
  811. }
  812. name.push(ch);
  813. // Read ID_Continue
  814. while ((ch = peek()) != null) {
  815. if ((ch = peek()) === "\\") {
  816. ch = read_escaped_identifier_char();
  817. if (!is_identifier_char(ch)) {
  818. parse_error("Invalid escaped identifier char");
  819. }
  820. } else {
  821. if (!is_identifier_char(ch)) {
  822. break;
  823. }
  824. next();
  825. }
  826. name.push(ch);
  827. }
  828. const name_str = name.join("");
  829. if (RESERVED_WORDS.has(name_str) && escaped) {
  830. parse_error("Escaped characters are not allowed in keywords");
  831. }
  832. return name_str;
  833. });
  834. var read_regexp = with_eof_error("Unterminated regular expression", function(source) {
  835. var prev_backslash = false, ch, in_class = false;
  836. while ((ch = next(true))) if (NEWLINE_CHARS.has(ch)) {
  837. parse_error("Unexpected line terminator");
  838. } else if (prev_backslash) {
  839. source += "\\" + ch;
  840. prev_backslash = false;
  841. } else if (ch == "[") {
  842. in_class = true;
  843. source += ch;
  844. } else if (ch == "]" && in_class) {
  845. in_class = false;
  846. source += ch;
  847. } else if (ch == "/" && !in_class) {
  848. break;
  849. } else if (ch == "\\") {
  850. prev_backslash = true;
  851. } else {
  852. source += ch;
  853. }
  854. const flags = read_name();
  855. return token("regexp", "/" + source + "/" + flags);
  856. });
  857. function read_operator(prefix) {
  858. function grow(op) {
  859. if (!peek()) return op;
  860. var bigger = op + peek();
  861. if (OPERATORS.has(bigger)) {
  862. next();
  863. return grow(bigger);
  864. } else {
  865. return op;
  866. }
  867. }
  868. return token("operator", grow(prefix || next()));
  869. }
  870. function handle_slash() {
  871. next();
  872. switch (peek()) {
  873. case "/":
  874. next();
  875. return skip_line_comment("comment1");
  876. case "*":
  877. next();
  878. return skip_multiline_comment();
  879. }
  880. return S.regex_allowed ? read_regexp("") : read_operator("/");
  881. }
  882. function handle_eq_sign() {
  883. next();
  884. if (peek() === ">") {
  885. next();
  886. return token("arrow", "=>");
  887. } else {
  888. return read_operator("=");
  889. }
  890. }
  891. function handle_dot() {
  892. next();
  893. if (is_digit(peek().charCodeAt(0))) {
  894. return read_num(".");
  895. }
  896. if (peek() === ".") {
  897. next(); // Consume second dot
  898. next(); // Consume third dot
  899. return token("expand", "...");
  900. }
  901. return token("punc", ".");
  902. }
  903. function read_word() {
  904. var word = read_name();
  905. if (prev_was_dot) return token("name", word);
  906. return KEYWORDS_ATOM.has(word) ? token("atom", word)
  907. : !KEYWORDS.has(word) ? token("name", word)
  908. : OPERATORS.has(word) ? token("operator", word)
  909. : token("keyword", word);
  910. }
  911. function read_private_word() {
  912. next();
  913. return token("privatename", read_name());
  914. }
  915. function with_eof_error(eof_error, cont) {
  916. return function(x) {
  917. try {
  918. return cont(x);
  919. } catch(ex) {
  920. if (ex === EX_EOF) parse_error(eof_error);
  921. else throw ex;
  922. }
  923. };
  924. }
  925. function next_token(force_regexp) {
  926. if (force_regexp != null)
  927. return read_regexp(force_regexp);
  928. if (shebang && S.pos == 0 && looking_at("#!")) {
  929. start_token();
  930. forward(2);
  931. skip_line_comment("comment5");
  932. }
  933. for (;;) {
  934. skip_whitespace();
  935. start_token();
  936. if (html5_comments) {
  937. if (looking_at("<!--")) {
  938. forward(4);
  939. skip_line_comment("comment3");
  940. continue;
  941. }
  942. if (looking_at("-->") && S.newline_before) {
  943. forward(3);
  944. skip_line_comment("comment4");
  945. continue;
  946. }
  947. }
  948. var ch = peek();
  949. if (!ch) return token("eof");
  950. var code = ch.charCodeAt(0);
  951. switch (code) {
  952. case 34: case 39: return read_string();
  953. case 46: return handle_dot();
  954. case 47: {
  955. var tok = handle_slash();
  956. if (tok === next_token) continue;
  957. return tok;
  958. }
  959. case 61: return handle_eq_sign();
  960. case 63: {
  961. if (!is_option_chain_op()) break; // Handled below
  962. next(); // ?
  963. next(); // .
  964. return token("punc", "?.");
  965. }
  966. case 96: return read_template_characters(true);
  967. case 123:
  968. S.brace_counter++;
  969. break;
  970. case 125:
  971. S.brace_counter--;
  972. if (S.template_braces.length > 0
  973. && S.template_braces[S.template_braces.length - 1] === S.brace_counter)
  974. return read_template_characters(false);
  975. break;
  976. }
  977. if (is_digit(code)) return read_num();
  978. if (PUNC_CHARS.has(ch)) return token("punc", next());
  979. if (OPERATOR_CHARS.has(ch)) return read_operator();
  980. if (code == 92 || is_identifier_start(ch)) return read_word();
  981. if (code == 35) return read_private_word();
  982. break;
  983. }
  984. parse_error("Unexpected character '" + ch + "'");
  985. }
  986. next_token.next = next;
  987. next_token.peek = peek;
  988. next_token.context = function(nc) {
  989. if (nc) S = nc;
  990. return S;
  991. };
  992. next_token.add_directive = function(directive) {
  993. S.directive_stack[S.directive_stack.length - 1].push(directive);
  994. if (S.directives[directive] === undefined) {
  995. S.directives[directive] = 1;
  996. } else {
  997. S.directives[directive]++;
  998. }
  999. };
  1000. next_token.push_directives_stack = function() {
  1001. S.directive_stack.push([]);
  1002. };
  1003. next_token.pop_directives_stack = function() {
  1004. var directives = S.directive_stack[S.directive_stack.length - 1];
  1005. for (var i = 0; i < directives.length; i++) {
  1006. S.directives[directives[i]]--;
  1007. }
  1008. S.directive_stack.pop();
  1009. };
  1010. next_token.has_directive = function(directive) {
  1011. return S.directives[directive] > 0;
  1012. };
  1013. return next_token;
  1014. }
  1015. /* -----[ Parser (constants) ]----- */
  1016. var UNARY_PREFIX = makePredicate([
  1017. "typeof",
  1018. "void",
  1019. "delete",
  1020. "--",
  1021. "++",
  1022. "!",
  1023. "~",
  1024. "-",
  1025. "+"
  1026. ]);
  1027. var UNARY_POSTFIX = makePredicate([ "--", "++" ]);
  1028. var ASSIGNMENT = makePredicate([ "=", "+=", "-=", "??=", "&&=", "||=", "/=", "*=", "**=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&=" ]);
  1029. var LOGICAL_ASSIGNMENT = makePredicate([ "??=", "&&=", "||=" ]);
  1030. var PRECEDENCE = (function(a, ret) {
  1031. for (var i = 0; i < a.length; ++i) {
  1032. var b = a[i];
  1033. for (var j = 0; j < b.length; ++j) {
  1034. ret[b[j]] = i + 1;
  1035. }
  1036. }
  1037. return ret;
  1038. })(
  1039. [
  1040. ["||"],
  1041. ["??"],
  1042. ["&&"],
  1043. ["|"],
  1044. ["^"],
  1045. ["&"],
  1046. ["==", "===", "!=", "!=="],
  1047. ["<", ">", "<=", ">=", "in", "instanceof"],
  1048. [">>", "<<", ">>>"],
  1049. ["+", "-"],
  1050. ["*", "/", "%"],
  1051. ["**"]
  1052. ],
  1053. {}
  1054. );
  1055. var ATOMIC_START_TOKEN = makePredicate([ "atom", "num", "big_int", "string", "regexp", "name" ]);
  1056. /* -----[ Parser ]----- */
  1057. function parse($TEXT, options) {
  1058. // maps start tokens to count of comments found outside of their parens
  1059. // Example: /* I count */ ( /* I don't */ foo() )
  1060. // Useful because comments_before property of call with parens outside
  1061. // contains both comments inside and outside these parens. Used to find the
  1062. const outer_comments_before_counts = new WeakMap();
  1063. options = defaults(options, {
  1064. bare_returns : false,
  1065. ecma : null, // Legacy
  1066. expression : false,
  1067. filename : null,
  1068. html5_comments : true,
  1069. module : false,
  1070. shebang : true,
  1071. strict : false,
  1072. toplevel : null,
  1073. }, true);
  1074. var S = {
  1075. input : (typeof $TEXT == "string"
  1076. ? tokenizer($TEXT, options.filename,
  1077. options.html5_comments, options.shebang)
  1078. : $TEXT),
  1079. token : null,
  1080. prev : null,
  1081. peeked : null,
  1082. in_function : 0,
  1083. in_async : -1,
  1084. in_generator : -1,
  1085. in_directives : true,
  1086. in_loop : 0,
  1087. labels : []
  1088. };
  1089. S.token = next();
  1090. function is(type, value) {
  1091. return is_token(S.token, type, value);
  1092. }
  1093. function peek() { return S.peeked || (S.peeked = S.input()); }
  1094. function next() {
  1095. S.prev = S.token;
  1096. if (!S.peeked) peek();
  1097. S.token = S.peeked;
  1098. S.peeked = null;
  1099. S.in_directives = S.in_directives && (
  1100. S.token.type == "string" || is("punc", ";")
  1101. );
  1102. return S.token;
  1103. }
  1104. function prev() {
  1105. return S.prev;
  1106. }
  1107. function croak(msg, line, col, pos) {
  1108. var ctx = S.input.context();
  1109. js_error(msg,
  1110. ctx.filename,
  1111. line != null ? line : ctx.tokline,
  1112. col != null ? col : ctx.tokcol,
  1113. pos != null ? pos : ctx.tokpos);
  1114. }
  1115. function token_error(token, msg) {
  1116. croak(msg, token.line, token.col);
  1117. }
  1118. function unexpected(token) {
  1119. if (token == null)
  1120. token = S.token;
  1121. token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
  1122. }
  1123. function expect_token(type, val) {
  1124. if (is(type, val)) {
  1125. return next();
  1126. }
  1127. token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
  1128. }
  1129. function expect(punc) { return expect_token("punc", punc); }
  1130. function has_newline_before(token) {
  1131. return token.nlb || !token.comments_before.every((comment) => !comment.nlb);
  1132. }
  1133. function can_insert_semicolon() {
  1134. return !options.strict
  1135. && (is("eof") || is("punc", "}") || has_newline_before(S.token));
  1136. }
  1137. function is_in_generator() {
  1138. return S.in_generator === S.in_function;
  1139. }
  1140. function is_in_async() {
  1141. return S.in_async === S.in_function;
  1142. }
  1143. function can_await() {
  1144. return (
  1145. S.in_async === S.in_function
  1146. || S.in_function === 0 && S.input.has_directive("use strict")
  1147. );
  1148. }
  1149. function semicolon(optional) {
  1150. if (is("punc", ";")) next();
  1151. else if (!optional && !can_insert_semicolon()) unexpected();
  1152. }
  1153. function parenthesised() {
  1154. expect("(");
  1155. var exp = expression(true);
  1156. expect(")");
  1157. return exp;
  1158. }
  1159. function embed_tokens(parser) {
  1160. return function _embed_tokens_wrapper(...args) {
  1161. const start = S.token;
  1162. const expr = parser(...args);
  1163. expr.start = start;
  1164. expr.end = prev();
  1165. return expr;
  1166. };
  1167. }
  1168. function handle_regexp() {
  1169. if (is("operator", "/") || is("operator", "/=")) {
  1170. S.peeked = null;
  1171. S.token = S.input(S.token.value.substr(1)); // force regexp
  1172. }
  1173. }
  1174. var statement = embed_tokens(function statement(is_export_default, is_for_body, is_if_body) {
  1175. handle_regexp();
  1176. switch (S.token.type) {
  1177. case "string":
  1178. if (S.in_directives) {
  1179. var token = peek();
  1180. if (!LATEST_RAW.includes("\\")
  1181. && (is_token(token, "punc", ";")
  1182. || is_token(token, "punc", "}")
  1183. || has_newline_before(token)
  1184. || is_token(token, "eof"))) {
  1185. S.input.add_directive(S.token.value);
  1186. } else {
  1187. S.in_directives = false;
  1188. }
  1189. }
  1190. var dir = S.in_directives, stat = simple_statement();
  1191. return dir && stat.body instanceof AST_String ? new AST_Directive(stat.body) : stat;
  1192. case "template_head":
  1193. case "num":
  1194. case "big_int":
  1195. case "regexp":
  1196. case "operator":
  1197. case "atom":
  1198. return simple_statement();
  1199. case "name":
  1200. if (S.token.value == "async" && is_token(peek(), "keyword", "function")) {
  1201. next();
  1202. next();
  1203. if (is_for_body) {
  1204. croak("functions are not allowed as the body of a loop");
  1205. }
  1206. return function_(AST_Defun, false, true, is_export_default);
  1207. }
  1208. if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
  1209. next();
  1210. var node = import_statement();
  1211. semicolon();
  1212. return node;
  1213. }
  1214. return is_token(peek(), "punc", ":")
  1215. ? labeled_statement()
  1216. : simple_statement();
  1217. case "punc":
  1218. switch (S.token.value) {
  1219. case "{":
  1220. return new AST_BlockStatement({
  1221. start : S.token,
  1222. body : block_(),
  1223. end : prev()
  1224. });
  1225. case "[":
  1226. case "(":
  1227. return simple_statement();
  1228. case ";":
  1229. S.in_directives = false;
  1230. next();
  1231. return new AST_EmptyStatement();
  1232. default:
  1233. unexpected();
  1234. }
  1235. case "keyword":
  1236. switch (S.token.value) {
  1237. case "break":
  1238. next();
  1239. return break_cont(AST_Break);
  1240. case "continue":
  1241. next();
  1242. return break_cont(AST_Continue);
  1243. case "debugger":
  1244. next();
  1245. semicolon();
  1246. return new AST_Debugger();
  1247. case "do":
  1248. next();
  1249. var body = in_loop(statement);
  1250. expect_token("keyword", "while");
  1251. var condition = parenthesised();
  1252. semicolon(true);
  1253. return new AST_Do({
  1254. body : body,
  1255. condition : condition
  1256. });
  1257. case "while":
  1258. next();
  1259. return new AST_While({
  1260. condition : parenthesised(),
  1261. body : in_loop(function() { return statement(false, true); })
  1262. });
  1263. case "for":
  1264. next();
  1265. return for_();
  1266. case "class":
  1267. next();
  1268. if (is_for_body) {
  1269. croak("classes are not allowed as the body of a loop");
  1270. }
  1271. if (is_if_body) {
  1272. croak("classes are not allowed as the body of an if");
  1273. }
  1274. return class_(AST_DefClass, is_export_default);
  1275. case "function":
  1276. next();
  1277. if (is_for_body) {
  1278. croak("functions are not allowed as the body of a loop");
  1279. }
  1280. return function_(AST_Defun, false, false, is_export_default);
  1281. case "if":
  1282. next();
  1283. return if_();
  1284. case "return":
  1285. if (S.in_function == 0 && !options.bare_returns)
  1286. croak("'return' outside of function");
  1287. next();
  1288. var value = null;
  1289. if (is("punc", ";")) {
  1290. next();
  1291. } else if (!can_insert_semicolon()) {
  1292. value = expression(true);
  1293. semicolon();
  1294. }
  1295. return new AST_Return({
  1296. value: value
  1297. });
  1298. case "switch":
  1299. next();
  1300. return new AST_Switch({
  1301. expression : parenthesised(),
  1302. body : in_loop(switch_body_)
  1303. });
  1304. case "throw":
  1305. next();
  1306. if (has_newline_before(S.token))
  1307. croak("Illegal newline after 'throw'");
  1308. var value = expression(true);
  1309. semicolon();
  1310. return new AST_Throw({
  1311. value: value
  1312. });
  1313. case "try":
  1314. next();
  1315. return try_();
  1316. case "var":
  1317. next();
  1318. var node = var_();
  1319. semicolon();
  1320. return node;
  1321. case "let":
  1322. next();
  1323. var node = let_();
  1324. semicolon();
  1325. return node;
  1326. case "const":
  1327. next();
  1328. var node = const_();
  1329. semicolon();
  1330. return node;
  1331. case "with":
  1332. if (S.input.has_directive("use strict")) {
  1333. croak("Strict mode may not include a with statement");
  1334. }
  1335. next();
  1336. return new AST_With({
  1337. expression : parenthesised(),
  1338. body : statement()
  1339. });
  1340. case "export":
  1341. if (!is_token(peek(), "punc", "(")) {
  1342. next();
  1343. var node = export_statement();
  1344. if (is("punc", ";")) semicolon();
  1345. return node;
  1346. }
  1347. }
  1348. }
  1349. unexpected();
  1350. });
  1351. function labeled_statement() {
  1352. var label = as_symbol(AST_Label);
  1353. if (label.name === "await" && is_in_async()) {
  1354. token_error(S.prev, "await cannot be used as label inside async function");
  1355. }
  1356. if (S.labels.some((l) => l.name === label.name)) {
  1357. // ECMA-262, 12.12: An ECMAScript program is considered
  1358. // syntactically incorrect if it contains a
  1359. // LabelledStatement that is enclosed by a
  1360. // LabelledStatement with the same Identifier as label.
  1361. croak("Label " + label.name + " defined twice");
  1362. }
  1363. expect(":");
  1364. S.labels.push(label);
  1365. var stat = statement();
  1366. S.labels.pop();
  1367. if (!(stat instanceof AST_IterationStatement)) {
  1368. // check for `continue` that refers to this label.
  1369. // those should be reported as syntax errors.
  1370. // https://github.com/mishoo/UglifyJS2/issues/287
  1371. label.references.forEach(function(ref) {
  1372. if (ref instanceof AST_Continue) {
  1373. ref = ref.label.start;
  1374. croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
  1375. ref.line, ref.col, ref.pos);
  1376. }
  1377. });
  1378. }
  1379. return new AST_LabeledStatement({ body: stat, label: label });
  1380. }
  1381. function simple_statement(tmp) {
  1382. return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
  1383. }
  1384. function break_cont(type) {
  1385. var label = null, ldef;
  1386. if (!can_insert_semicolon()) {
  1387. label = as_symbol(AST_LabelRef, true);
  1388. }
  1389. if (label != null) {
  1390. ldef = S.labels.find((l) => l.name === label.name);
  1391. if (!ldef)
  1392. croak("Undefined label " + label.name);
  1393. label.thedef = ldef;
  1394. } else if (S.in_loop == 0)
  1395. croak(type.TYPE + " not inside a loop or switch");
  1396. semicolon();
  1397. var stat = new type({ label: label });
  1398. if (ldef) ldef.references.push(stat);
  1399. return stat;
  1400. }
  1401. function for_() {
  1402. var for_await_error = "`for await` invalid in this context";
  1403. var await_tok = S.token;
  1404. if (await_tok.type == "name" && await_tok.value == "await") {
  1405. if (!can_await()) {
  1406. token_error(await_tok, for_await_error);
  1407. }
  1408. next();
  1409. } else {
  1410. await_tok = false;
  1411. }
  1412. expect("(");
  1413. var init = null;
  1414. if (!is("punc", ";")) {
  1415. init =
  1416. is("keyword", "var") ? (next(), var_(true)) :
  1417. is("keyword", "let") ? (next(), let_(true)) :
  1418. is("keyword", "const") ? (next(), const_(true)) :
  1419. expression(true, true);
  1420. var is_in = is("operator", "in");
  1421. var is_of = is("name", "of");
  1422. if (await_tok && !is_of) {
  1423. token_error(await_tok, for_await_error);
  1424. }
  1425. if (is_in || is_of) {
  1426. if (init instanceof AST_Definitions) {
  1427. if (init.definitions.length > 1)
  1428. token_error(init.start, "Only one variable declaration allowed in for..in loop");
  1429. } else if (!(is_assignable(init) || (init = to_destructuring(init)) instanceof AST_Destructuring)) {
  1430. token_error(init.start, "Invalid left-hand side in for..in loop");
  1431. }
  1432. next();
  1433. if (is_in) {
  1434. return for_in(init);
  1435. } else {
  1436. return for_of(init, !!await_tok);
  1437. }
  1438. }
  1439. } else if (await_tok) {
  1440. token_error(await_tok, for_await_error);
  1441. }
  1442. return regular_for(init);
  1443. }
  1444. function regular_for(init) {
  1445. expect(";");
  1446. var test = is("punc", ";") ? null : expression(true);
  1447. expect(";");
  1448. var step = is("punc", ")") ? null : expression(true);
  1449. expect(")");
  1450. return new AST_For({
  1451. init : init,
  1452. condition : test,
  1453. step : step,
  1454. body : in_loop(function() { return statement(false, true); })
  1455. });
  1456. }
  1457. function for_of(init, is_await) {
  1458. var lhs = init instanceof AST_Definitions ? init.definitions[0].name : null;
  1459. var obj = expression(true);
  1460. expect(")");
  1461. return new AST_ForOf({
  1462. await : is_await,
  1463. init : init,
  1464. name : lhs,
  1465. object : obj,
  1466. body : in_loop(function() { return statement(false, true); })
  1467. });
  1468. }
  1469. function for_in(init) {
  1470. var obj = expression(true);
  1471. expect(")");
  1472. return new AST_ForIn({
  1473. init : init,
  1474. object : obj,
  1475. body : in_loop(function() { return statement(false, true); })
  1476. });
  1477. }
  1478. var arrow_function = function(start, argnames, is_async) {
  1479. if (has_newline_before(S.token)) {
  1480. croak("Unexpected newline before arrow (=>)");
  1481. }
  1482. expect_token("arrow", "=>");
  1483. var body = _function_body(is("punc", "{"), false, is_async);
  1484. var end =
  1485. body instanceof Array && body.length ? body[body.length - 1].end :
  1486. body instanceof Array ? start :
  1487. body.end;
  1488. return new AST_Arrow({
  1489. start : start,
  1490. end : end,
  1491. async : is_async,
  1492. argnames : argnames,
  1493. body : body
  1494. });
  1495. };
  1496. var function_ = function(ctor, is_generator_property, is_async, is_export_default) {
  1497. var in_statement = ctor === AST_Defun;
  1498. var is_generator = is("operator", "*");
  1499. if (is_generator) {
  1500. next();
  1501. }
  1502. var name = is("name") ? as_symbol(in_statement ? AST_SymbolDefun : AST_SymbolLambda) : null;
  1503. if (in_statement && !name) {
  1504. if (is_export_default) {
  1505. ctor = AST_Function;
  1506. } else {
  1507. unexpected();
  1508. }
  1509. }
  1510. if (name && ctor !== AST_Accessor && !(name instanceof AST_SymbolDeclaration))
  1511. unexpected(prev());
  1512. var args = [];
  1513. var body = _function_body(true, is_generator || is_generator_property, is_async, name, args);
  1514. return new ctor({
  1515. start : args.start,
  1516. end : body.end,
  1517. is_generator: is_generator,
  1518. async : is_async,
  1519. name : name,
  1520. argnames: args,
  1521. body : body
  1522. });
  1523. };
  1524. class UsedParametersTracker {
  1525. constructor(is_parameter, strict, duplicates_ok = false) {
  1526. this.is_parameter = is_parameter;
  1527. this.duplicates_ok = duplicates_ok;
  1528. this.parameters = new Set();
  1529. this.duplicate = null;
  1530. this.default_assignment = false;
  1531. this.spread = false;
  1532. this.strict_mode = !!strict;
  1533. }
  1534. add_parameter(token) {
  1535. if (this.parameters.has(token.value)) {
  1536. if (this.duplicate === null) {
  1537. this.duplicate = token;
  1538. }
  1539. this.check_strict();
  1540. } else {
  1541. this.parameters.add(token.value);
  1542. if (this.is_parameter) {
  1543. switch (token.value) {
  1544. case "arguments":
  1545. case "eval":
  1546. case "yield":
  1547. if (this.strict_mode) {
  1548. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1549. }
  1550. break;
  1551. default:
  1552. if (RESERVED_WORDS.has(token.value)) {
  1553. unexpected();
  1554. }
  1555. }
  1556. }
  1557. }
  1558. }
  1559. mark_default_assignment(token) {
  1560. if (this.default_assignment === false) {
  1561. this.default_assignment = token;
  1562. }
  1563. }
  1564. mark_spread(token) {
  1565. if (this.spread === false) {
  1566. this.spread = token;
  1567. }
  1568. }
  1569. mark_strict_mode() {
  1570. this.strict_mode = true;
  1571. }
  1572. is_strict() {
  1573. return this.default_assignment !== false || this.spread !== false || this.strict_mode;
  1574. }
  1575. check_strict() {
  1576. if (this.is_strict() && this.duplicate !== null && !this.duplicates_ok) {
  1577. token_error(this.duplicate, "Parameter " + this.duplicate.value + " was used already");
  1578. }
  1579. }
  1580. }
  1581. function parameters(params) {
  1582. var used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1583. expect("(");
  1584. while (!is("punc", ")")) {
  1585. var param = parameter(used_parameters);
  1586. params.push(param);
  1587. if (!is("punc", ")")) {
  1588. expect(",");
  1589. }
  1590. if (param instanceof AST_Expansion) {
  1591. break;
  1592. }
  1593. }
  1594. next();
  1595. }
  1596. function parameter(used_parameters, symbol_type) {
  1597. var param;
  1598. var expand = false;
  1599. if (used_parameters === undefined) {
  1600. used_parameters = new UsedParametersTracker(true, S.input.has_directive("use strict"));
  1601. }
  1602. if (is("expand", "...")) {
  1603. expand = S.token;
  1604. used_parameters.mark_spread(S.token);
  1605. next();
  1606. }
  1607. param = binding_element(used_parameters, symbol_type);
  1608. if (is("operator", "=") && expand === false) {
  1609. used_parameters.mark_default_assignment(S.token);
  1610. next();
  1611. param = new AST_DefaultAssign({
  1612. start: param.start,
  1613. left: param,
  1614. operator: "=",
  1615. right: expression(false),
  1616. end: S.token
  1617. });
  1618. }
  1619. if (expand !== false) {
  1620. if (!is("punc", ")")) {
  1621. unexpected();
  1622. }
  1623. param = new AST_Expansion({
  1624. start: expand,
  1625. expression: param,
  1626. end: expand
  1627. });
  1628. }
  1629. used_parameters.check_strict();
  1630. return param;
  1631. }
  1632. function binding_element(used_parameters, symbol_type) {
  1633. var elements = [];
  1634. var first = true;
  1635. var is_expand = false;
  1636. var expand_token;
  1637. var first_token = S.token;
  1638. if (used_parameters === undefined) {
  1639. const strict = S.input.has_directive("use strict");
  1640. const duplicates_ok = symbol_type === AST_SymbolVar;
  1641. used_parameters = new UsedParametersTracker(false, strict, duplicates_ok);
  1642. }
  1643. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1644. if (is("punc", "[")) {
  1645. next();
  1646. while (!is("punc", "]")) {
  1647. if (first) {
  1648. first = false;
  1649. } else {
  1650. expect(",");
  1651. }
  1652. if (is("expand", "...")) {
  1653. is_expand = true;
  1654. expand_token = S.token;
  1655. used_parameters.mark_spread(S.token);
  1656. next();
  1657. }
  1658. if (is("punc")) {
  1659. switch (S.token.value) {
  1660. case ",":
  1661. elements.push(new AST_Hole({
  1662. start: S.token,
  1663. end: S.token
  1664. }));
  1665. continue;
  1666. case "]": // Trailing comma after last element
  1667. break;
  1668. case "[":
  1669. case "{":
  1670. elements.push(binding_element(used_parameters, symbol_type));
  1671. break;
  1672. default:
  1673. unexpected();
  1674. }
  1675. } else if (is("name")) {
  1676. used_parameters.add_parameter(S.token);
  1677. elements.push(as_symbol(symbol_type));
  1678. } else {
  1679. croak("Invalid function parameter");
  1680. }
  1681. if (is("operator", "=") && is_expand === false) {
  1682. used_parameters.mark_default_assignment(S.token);
  1683. next();
  1684. elements[elements.length - 1] = new AST_DefaultAssign({
  1685. start: elements[elements.length - 1].start,
  1686. left: elements[elements.length - 1],
  1687. operator: "=",
  1688. right: expression(false),
  1689. end: S.token
  1690. });
  1691. }
  1692. if (is_expand) {
  1693. if (!is("punc", "]")) {
  1694. croak("Rest element must be last element");
  1695. }
  1696. elements[elements.length - 1] = new AST_Expansion({
  1697. start: expand_token,
  1698. expression: elements[elements.length - 1],
  1699. end: expand_token
  1700. });
  1701. }
  1702. }
  1703. expect("]");
  1704. used_parameters.check_strict();
  1705. return new AST_Destructuring({
  1706. start: first_token,
  1707. names: elements,
  1708. is_array: true,
  1709. end: prev()
  1710. });
  1711. } else if (is("punc", "{")) {
  1712. next();
  1713. while (!is("punc", "}")) {
  1714. if (first) {
  1715. first = false;
  1716. } else {
  1717. expect(",");
  1718. }
  1719. if (is("expand", "...")) {
  1720. is_expand = true;
  1721. expand_token = S.token;
  1722. used_parameters.mark_spread(S.token);
  1723. next();
  1724. }
  1725. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1726. used_parameters.add_parameter(S.token);
  1727. var start = prev();
  1728. var value = as_symbol(symbol_type);
  1729. if (is_expand) {
  1730. elements.push(new AST_Expansion({
  1731. start: expand_token,
  1732. expression: value,
  1733. end: value.end,
  1734. }));
  1735. } else {
  1736. elements.push(new AST_ObjectKeyVal({
  1737. start: start,
  1738. key: value.name,
  1739. value: value,
  1740. end: value.end,
  1741. }));
  1742. }
  1743. } else if (is("punc", "}")) {
  1744. continue; // Allow trailing hole
  1745. } else {
  1746. var property_token = S.token;
  1747. var property = as_property_name();
  1748. if (property === null) {
  1749. unexpected(prev());
  1750. } else if (prev().type === "name" && !is("punc", ":")) {
  1751. elements.push(new AST_ObjectKeyVal({
  1752. start: prev(),
  1753. key: property,
  1754. value: new symbol_type({
  1755. start: prev(),
  1756. name: property,
  1757. end: prev()
  1758. }),
  1759. end: prev()
  1760. }));
  1761. } else {
  1762. expect(":");
  1763. elements.push(new AST_ObjectKeyVal({
  1764. start: property_token,
  1765. quote: property_token.quote,
  1766. key: property,
  1767. value: binding_element(used_parameters, symbol_type),
  1768. end: prev()
  1769. }));
  1770. }
  1771. }
  1772. if (is_expand) {
  1773. if (!is("punc", "}")) {
  1774. croak("Rest element must be last element");
  1775. }
  1776. } else if (is("operator", "=")) {
  1777. used_parameters.mark_default_assignment(S.token);
  1778. next();
  1779. elements[elements.length - 1].value = new AST_DefaultAssign({
  1780. start: elements[elements.length - 1].value.start,
  1781. left: elements[elements.length - 1].value,
  1782. operator: "=",
  1783. right: expression(false),
  1784. end: S.token
  1785. });
  1786. }
  1787. }
  1788. expect("}");
  1789. used_parameters.check_strict();
  1790. return new AST_Destructuring({
  1791. start: first_token,
  1792. names: elements,
  1793. is_array: false,
  1794. end: prev()
  1795. });
  1796. } else if (is("name")) {
  1797. used_parameters.add_parameter(S.token);
  1798. return as_symbol(symbol_type);
  1799. } else {
  1800. croak("Invalid function parameter");
  1801. }
  1802. }
  1803. function params_or_seq_(allow_arrows, maybe_sequence) {
  1804. var spread_token;
  1805. var invalid_sequence;
  1806. var trailing_comma;
  1807. var a = [];
  1808. expect("(");
  1809. while (!is("punc", ")")) {
  1810. if (spread_token) unexpected(spread_token);
  1811. if (is("expand", "...")) {
  1812. spread_token = S.token;
  1813. if (maybe_sequence) invalid_sequence = S.token;
  1814. next();
  1815. a.push(new AST_Expansion({
  1816. start: prev(),
  1817. expression: expression(),
  1818. end: S.token,
  1819. }));
  1820. } else {
  1821. a.push(expression());
  1822. }
  1823. if (!is("punc", ")")) {
  1824. expect(",");
  1825. if (is("punc", ")")) {
  1826. trailing_comma = prev();
  1827. if (maybe_sequence) invalid_sequence = trailing_comma;
  1828. }
  1829. }
  1830. }
  1831. expect(")");
  1832. if (allow_arrows && is("arrow", "=>")) {
  1833. if (spread_token && trailing_comma) unexpected(trailing_comma);
  1834. } else if (invalid_sequence) {
  1835. unexpected(invalid_sequence);
  1836. }
  1837. return a;
  1838. }
  1839. function _function_body(block, generator, is_async, name, args) {
  1840. var loop = S.in_loop;
  1841. var labels = S.labels;
  1842. var current_generator = S.in_generator;
  1843. var current_async = S.in_async;
  1844. ++S.in_function;
  1845. if (generator)
  1846. S.in_generator = S.in_function;
  1847. if (is_async)
  1848. S.in_async = S.in_function;
  1849. if (args) parameters(args);
  1850. if (block)
  1851. S.in_directives = true;
  1852. S.in_loop = 0;
  1853. S.labels = [];
  1854. if (block) {
  1855. S.input.push_directives_stack();
  1856. var a = block_();
  1857. if (name) _verify_symbol(name);
  1858. if (args) args.forEach(_verify_symbol);
  1859. S.input.pop_directives_stack();
  1860. } else {
  1861. var a = [new AST_Return({
  1862. start: S.token,
  1863. value: expression(false),
  1864. end: S.token
  1865. })];
  1866. }
  1867. --S.in_function;
  1868. S.in_loop = loop;
  1869. S.labels = labels;
  1870. S.in_generator = current_generator;
  1871. S.in_async = current_async;
  1872. return a;
  1873. }
  1874. function _await_expression() {
  1875. // Previous token must be "await" and not be interpreted as an identifier
  1876. if (!can_await()) {
  1877. croak("Unexpected await expression outside async function",
  1878. S.prev.line, S.prev.col, S.prev.pos);
  1879. }
  1880. // the await expression is parsed as a unary expression in Babel
  1881. return new AST_Await({
  1882. start: prev(),
  1883. end: S.token,
  1884. expression : maybe_unary(true),
  1885. });
  1886. }
  1887. function _yield_expression() {
  1888. // Previous token must be keyword yield and not be interpret as an identifier
  1889. if (!is_in_generator()) {
  1890. croak("Unexpected yield expression outside generator function",
  1891. S.prev.line, S.prev.col, S.prev.pos);
  1892. }
  1893. var start = S.token;
  1894. var star = false;
  1895. var has_expression = true;
  1896. // Attempt to get expression or star (and then the mandatory expression)
  1897. // behind yield on the same line.
  1898. //
  1899. // If nothing follows on the same line of the yieldExpression,
  1900. // it should default to the value `undefined` for yield to return.
  1901. // In that case, the `undefined` stored as `null` in ast.
  1902. //
  1903. // Note 1: It isn't allowed for yield* to close without an expression
  1904. // Note 2: If there is a nlb between yield and star, it is interpret as
  1905. // yield <explicit undefined> <inserted automatic semicolon> *
  1906. if (can_insert_semicolon() ||
  1907. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  1908. has_expression = false;
  1909. } else if (is("operator", "*")) {
  1910. star = true;
  1911. next();
  1912. }
  1913. return new AST_Yield({
  1914. start : start,
  1915. is_star : star,
  1916. expression : has_expression ? expression() : null,
  1917. end : prev()
  1918. });
  1919. }
  1920. function if_() {
  1921. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  1922. if (is("keyword", "else")) {
  1923. next();
  1924. belse = statement(false, false, true);
  1925. }
  1926. return new AST_If({
  1927. condition : cond,
  1928. body : body,
  1929. alternative : belse
  1930. });
  1931. }
  1932. function block_() {
  1933. expect("{");
  1934. var a = [];
  1935. while (!is("punc", "}")) {
  1936. if (is("eof")) unexpected();
  1937. a.push(statement());
  1938. }
  1939. next();
  1940. return a;
  1941. }
  1942. function switch_body_() {
  1943. expect("{");
  1944. var a = [], cur = null, branch = null, tmp;
  1945. while (!is("punc", "}")) {
  1946. if (is("eof")) unexpected();
  1947. if (is("keyword", "case")) {
  1948. if (branch) branch.end = prev();
  1949. cur = [];
  1950. branch = new AST_Case({
  1951. start : (tmp = S.token, next(), tmp),
  1952. expression : expression(true),
  1953. body : cur
  1954. });
  1955. a.push(branch);
  1956. expect(":");
  1957. } else if (is("keyword", "default")) {
  1958. if (branch) branch.end = prev();
  1959. cur = [];
  1960. branch = new AST_Default({
  1961. start : (tmp = S.token, next(), expect(":"), tmp),
  1962. body : cur
  1963. });
  1964. a.push(branch);
  1965. } else {
  1966. if (!cur) unexpected();
  1967. cur.push(statement());
  1968. }
  1969. }
  1970. if (branch) branch.end = prev();
  1971. next();
  1972. return a;
  1973. }
  1974. function try_() {
  1975. var body = block_(), bcatch = null, bfinally = null;
  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. function vardefs(no_in, kind) {
  2011. var a = [];
  2012. var def;
  2013. for (;;) {
  2014. var sym_type =
  2015. kind === "var" ? AST_SymbolVar :
  2016. kind === "const" ? AST_SymbolConst :
  2017. kind === "let" ? AST_SymbolLet : null;
  2018. if (is("punc", "{") || is("punc", "[")) {
  2019. def = new AST_VarDef({
  2020. start: S.token,
  2021. name: binding_element(undefined, sym_type),
  2022. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  2023. end: prev()
  2024. });
  2025. } else {
  2026. def = new AST_VarDef({
  2027. start : S.token,
  2028. name : as_symbol(sym_type),
  2029. value : is("operator", "=")
  2030. ? (next(), expression(false, no_in))
  2031. : !no_in && kind === "const"
  2032. ? croak("Missing initializer in const declaration") : null,
  2033. end : prev()
  2034. });
  2035. if (def.name.name == "import") croak("Unexpected token: import");
  2036. }
  2037. a.push(def);
  2038. if (!is("punc", ","))
  2039. break;
  2040. next();
  2041. }
  2042. return a;
  2043. }
  2044. var var_ = function(no_in) {
  2045. return new AST_Var({
  2046. start : prev(),
  2047. definitions : vardefs(no_in, "var"),
  2048. end : prev()
  2049. });
  2050. };
  2051. var let_ = function(no_in) {
  2052. return new AST_Let({
  2053. start : prev(),
  2054. definitions : vardefs(no_in, "let"),
  2055. end : prev()
  2056. });
  2057. };
  2058. var const_ = function(no_in) {
  2059. return new AST_Const({
  2060. start : prev(),
  2061. definitions : vardefs(no_in, "const"),
  2062. end : prev()
  2063. });
  2064. };
  2065. var new_ = function(allow_calls) {
  2066. var start = S.token;
  2067. expect_token("operator", "new");
  2068. if (is("punc", ".")) {
  2069. next();
  2070. expect_token("name", "target");
  2071. return subscripts(new AST_NewTarget({
  2072. start : start,
  2073. end : prev()
  2074. }), allow_calls);
  2075. }
  2076. var newexp = expr_atom(false), args;
  2077. if (is("punc", "(")) {
  2078. next();
  2079. args = expr_list(")", true);
  2080. } else {
  2081. args = [];
  2082. }
  2083. var call = new AST_New({
  2084. start : start,
  2085. expression : newexp,
  2086. args : args,
  2087. end : prev()
  2088. });
  2089. annotate(call);
  2090. return subscripts(call, allow_calls);
  2091. };
  2092. function as_atom_node() {
  2093. var tok = S.token, ret;
  2094. switch (tok.type) {
  2095. case "name":
  2096. ret = _make_symbol(AST_SymbolRef);
  2097. break;
  2098. case "num":
  2099. ret = new AST_Number({
  2100. start: tok,
  2101. end: tok,
  2102. value: tok.value,
  2103. raw: LATEST_RAW
  2104. });
  2105. break;
  2106. case "big_int":
  2107. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  2108. break;
  2109. case "string":
  2110. ret = new AST_String({
  2111. start : tok,
  2112. end : tok,
  2113. value : tok.value,
  2114. quote : tok.quote
  2115. });
  2116. break;
  2117. case "regexp":
  2118. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  2119. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  2120. break;
  2121. case "atom":
  2122. switch (tok.value) {
  2123. case "false":
  2124. ret = new AST_False({ start: tok, end: tok });
  2125. break;
  2126. case "true":
  2127. ret = new AST_True({ start: tok, end: tok });
  2128. break;
  2129. case "null":
  2130. ret = new AST_Null({ start: tok, end: tok });
  2131. break;
  2132. }
  2133. break;
  2134. }
  2135. next();
  2136. return ret;
  2137. }
  2138. function to_fun_args(ex, default_seen_above) {
  2139. var insert_default = function(ex, default_value) {
  2140. if (default_value) {
  2141. return new AST_DefaultAssign({
  2142. start: ex.start,
  2143. left: ex,
  2144. operator: "=",
  2145. right: default_value,
  2146. end: default_value.end
  2147. });
  2148. }
  2149. return ex;
  2150. };
  2151. if (ex instanceof AST_Object) {
  2152. return insert_default(new AST_Destructuring({
  2153. start: ex.start,
  2154. end: ex.end,
  2155. is_array: false,
  2156. names: ex.properties.map(prop => to_fun_args(prop))
  2157. }), default_seen_above);
  2158. } else if (ex instanceof AST_ObjectKeyVal) {
  2159. ex.value = to_fun_args(ex.value);
  2160. return insert_default(ex, default_seen_above);
  2161. } else if (ex instanceof AST_Hole) {
  2162. return ex;
  2163. } else if (ex instanceof AST_Destructuring) {
  2164. ex.names = ex.names.map(name => to_fun_args(name));
  2165. return insert_default(ex, default_seen_above);
  2166. } else if (ex instanceof AST_SymbolRef) {
  2167. return insert_default(new AST_SymbolFunarg({
  2168. name: ex.name,
  2169. start: ex.start,
  2170. end: ex.end
  2171. }), default_seen_above);
  2172. } else if (ex instanceof AST_Expansion) {
  2173. ex.expression = to_fun_args(ex.expression);
  2174. return insert_default(ex, default_seen_above);
  2175. } else if (ex instanceof AST_Array) {
  2176. return insert_default(new AST_Destructuring({
  2177. start: ex.start,
  2178. end: ex.end,
  2179. is_array: true,
  2180. names: ex.elements.map(elm => to_fun_args(elm))
  2181. }), default_seen_above);
  2182. } else if (ex instanceof AST_Assign) {
  2183. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2184. } else if (ex instanceof AST_DefaultAssign) {
  2185. ex.left = to_fun_args(ex.left);
  2186. return ex;
  2187. } else {
  2188. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2189. }
  2190. }
  2191. var expr_atom = function(allow_calls, allow_arrows) {
  2192. if (is("operator", "new")) {
  2193. return new_(allow_calls);
  2194. }
  2195. if (is("operator", "import")) {
  2196. return import_meta();
  2197. }
  2198. var start = S.token;
  2199. var peeked;
  2200. var async = is("name", "async")
  2201. && (peeked = peek()).value != "["
  2202. && peeked.type != "arrow"
  2203. && as_atom_node();
  2204. if (is("punc")) {
  2205. switch (S.token.value) {
  2206. case "(":
  2207. if (async && !allow_calls) break;
  2208. var exprs = params_or_seq_(allow_arrows, !async);
  2209. if (allow_arrows && is("arrow", "=>")) {
  2210. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2211. }
  2212. var ex = async ? new AST_Call({
  2213. expression: async,
  2214. args: exprs
  2215. }) : exprs.length == 1 ? exprs[0] : new AST_Sequence({
  2216. expressions: exprs
  2217. });
  2218. if (ex.start) {
  2219. const outer_comments_before = start.comments_before.length;
  2220. outer_comments_before_counts.set(start, outer_comments_before);
  2221. ex.start.comments_before.unshift(...start.comments_before);
  2222. start.comments_before = ex.start.comments_before;
  2223. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2224. var comment = start.comments_before[0];
  2225. if (!comment.nlb) {
  2226. comment.nlb = start.nlb;
  2227. start.nlb = false;
  2228. }
  2229. }
  2230. start.comments_after = ex.start.comments_after;
  2231. }
  2232. ex.start = start;
  2233. var end = prev();
  2234. if (ex.end) {
  2235. end.comments_before = ex.end.comments_before;
  2236. ex.end.comments_after.push(...end.comments_after);
  2237. end.comments_after = ex.end.comments_after;
  2238. }
  2239. ex.end = end;
  2240. if (ex instanceof AST_Call) annotate(ex);
  2241. return subscripts(ex, allow_calls);
  2242. case "[":
  2243. return subscripts(array_(), allow_calls);
  2244. case "{":
  2245. return subscripts(object_or_destructuring_(), allow_calls);
  2246. }
  2247. if (!async) unexpected();
  2248. }
  2249. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2250. var param = new AST_SymbolFunarg({
  2251. name: S.token.value,
  2252. start: start,
  2253. end: start,
  2254. });
  2255. next();
  2256. return arrow_function(start, [param], !!async);
  2257. }
  2258. if (is("keyword", "function")) {
  2259. next();
  2260. var func = function_(AST_Function, false, !!async);
  2261. func.start = start;
  2262. func.end = prev();
  2263. return subscripts(func, allow_calls);
  2264. }
  2265. if (async) return subscripts(async, allow_calls);
  2266. if (is("keyword", "class")) {
  2267. next();
  2268. var cls = class_(AST_ClassExpression);
  2269. cls.start = start;
  2270. cls.end = prev();
  2271. return subscripts(cls, allow_calls);
  2272. }
  2273. if (is("template_head")) {
  2274. return subscripts(template_string(), allow_calls);
  2275. }
  2276. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2277. return subscripts(as_atom_node(), allow_calls);
  2278. }
  2279. unexpected();
  2280. };
  2281. function template_string() {
  2282. var segments = [], start = S.token;
  2283. segments.push(new AST_TemplateSegment({
  2284. start: S.token,
  2285. raw: LATEST_RAW,
  2286. value: S.token.value,
  2287. end: S.token
  2288. }));
  2289. while (!LATEST_TEMPLATE_END) {
  2290. next();
  2291. handle_regexp();
  2292. segments.push(expression(true));
  2293. segments.push(new AST_TemplateSegment({
  2294. start: S.token,
  2295. raw: LATEST_RAW,
  2296. value: S.token.value,
  2297. end: S.token
  2298. }));
  2299. }
  2300. next();
  2301. return new AST_TemplateString({
  2302. start: start,
  2303. segments: segments,
  2304. end: S.token
  2305. });
  2306. }
  2307. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2308. var first = true, a = [];
  2309. while (!is("punc", closing)) {
  2310. if (first) first = false; else expect(",");
  2311. if (allow_trailing_comma && is("punc", closing)) break;
  2312. if (is("punc", ",") && allow_empty) {
  2313. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2314. } else if (is("expand", "...")) {
  2315. next();
  2316. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2317. } else {
  2318. a.push(expression(false));
  2319. }
  2320. }
  2321. next();
  2322. return a;
  2323. }
  2324. var array_ = embed_tokens(function() {
  2325. expect("[");
  2326. return new AST_Array({
  2327. elements: expr_list("]", !options.strict, true)
  2328. });
  2329. });
  2330. var create_accessor = embed_tokens((is_generator, is_async) => {
  2331. return function_(AST_Accessor, is_generator, is_async);
  2332. });
  2333. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2334. var start = S.token, first = true, a = [];
  2335. expect("{");
  2336. while (!is("punc", "}")) {
  2337. if (first) first = false; else expect(",");
  2338. if (!options.strict && is("punc", "}"))
  2339. // allow trailing comma
  2340. break;
  2341. start = S.token;
  2342. if (start.type == "expand") {
  2343. next();
  2344. a.push(new AST_Expansion({
  2345. start: start,
  2346. expression: expression(false),
  2347. end: prev(),
  2348. }));
  2349. continue;
  2350. }
  2351. var name = as_property_name();
  2352. var value;
  2353. // Check property and fetch value
  2354. if (!is("punc", ":")) {
  2355. var concise = concise_method_or_getset(name, start);
  2356. if (concise) {
  2357. a.push(concise);
  2358. continue;
  2359. }
  2360. value = new AST_SymbolRef({
  2361. start: prev(),
  2362. name: name,
  2363. end: prev()
  2364. });
  2365. } else if (name === null) {
  2366. unexpected(prev());
  2367. } else {
  2368. next(); // `:` - see first condition
  2369. value = expression(false);
  2370. }
  2371. // Check for default value and alter value accordingly if necessary
  2372. if (is("operator", "=")) {
  2373. next();
  2374. value = new AST_Assign({
  2375. start: start,
  2376. left: value,
  2377. operator: "=",
  2378. right: expression(false),
  2379. logical: false,
  2380. end: prev()
  2381. });
  2382. }
  2383. // Create property
  2384. a.push(new AST_ObjectKeyVal({
  2385. start: start,
  2386. quote: start.quote,
  2387. key: name instanceof AST_Node ? name : "" + name,
  2388. value: value,
  2389. end: prev()
  2390. }));
  2391. }
  2392. next();
  2393. return new AST_Object({ properties: a });
  2394. });
  2395. function class_(KindOfClass, is_export_default) {
  2396. var start, method, class_name, extends_, a = [];
  2397. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2398. S.input.add_directive("use strict");
  2399. if (S.token.type == "name" && S.token.value != "extends") {
  2400. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2401. }
  2402. if (KindOfClass === AST_DefClass && !class_name) {
  2403. if (is_export_default) {
  2404. KindOfClass = AST_ClassExpression;
  2405. } else {
  2406. unexpected();
  2407. }
  2408. }
  2409. if (S.token.value == "extends") {
  2410. next();
  2411. extends_ = expression(true);
  2412. }
  2413. expect("{");
  2414. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2415. while (!is("punc", "}")) {
  2416. start = S.token;
  2417. method = concise_method_or_getset(as_property_name(), start, true);
  2418. if (!method) { unexpected(); }
  2419. a.push(method);
  2420. while (is("punc", ";")) { next(); }
  2421. }
  2422. S.input.pop_directives_stack();
  2423. next();
  2424. return new KindOfClass({
  2425. start: start,
  2426. name: class_name,
  2427. extends: extends_,
  2428. properties: a,
  2429. end: prev(),
  2430. });
  2431. }
  2432. function concise_method_or_getset(name, start, is_class) {
  2433. const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
  2434. if (typeof name === "string" || typeof name === "number") {
  2435. return new SymbolClass({
  2436. start,
  2437. name: "" + name,
  2438. end: prev()
  2439. });
  2440. } else if (name === null) {
  2441. unexpected();
  2442. }
  2443. return name;
  2444. };
  2445. const is_not_method_start = () =>
  2446. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=");
  2447. var is_async = false;
  2448. var is_static = false;
  2449. var is_generator = false;
  2450. var is_private = false;
  2451. var accessor_type = null;
  2452. if (is_class && name === "static" && is_not_method_start()) {
  2453. is_static = true;
  2454. name = as_property_name();
  2455. }
  2456. if (name === "async" && is_not_method_start()) {
  2457. is_async = true;
  2458. name = as_property_name();
  2459. }
  2460. if (prev().type === "operator" && prev().value === "*") {
  2461. is_generator = true;
  2462. name = as_property_name();
  2463. }
  2464. if ((name === "get" || name === "set") && is_not_method_start()) {
  2465. accessor_type = name;
  2466. name = as_property_name();
  2467. }
  2468. if (prev().type === "privatename") {
  2469. is_private = true;
  2470. }
  2471. const property_token = prev();
  2472. if (accessor_type != null) {
  2473. if (!is_private) {
  2474. const AccessorClass = accessor_type === "get"
  2475. ? AST_ObjectGetter
  2476. : AST_ObjectSetter;
  2477. name = get_symbol_ast(name);
  2478. return new AccessorClass({
  2479. start,
  2480. static: is_static,
  2481. key: name,
  2482. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  2483. value: create_accessor(),
  2484. end: prev()
  2485. });
  2486. } else {
  2487. const AccessorClass = accessor_type === "get"
  2488. ? AST_PrivateGetter
  2489. : AST_PrivateSetter;
  2490. return new AccessorClass({
  2491. start,
  2492. static: is_static,
  2493. key: get_symbol_ast(name),
  2494. value: create_accessor(),
  2495. end: prev(),
  2496. });
  2497. }
  2498. }
  2499. if (is("punc", "(")) {
  2500. name = get_symbol_ast(name);
  2501. const AST_MethodVariant = is_private
  2502. ? AST_PrivateMethod
  2503. : AST_ConciseMethod;
  2504. var node = new AST_MethodVariant({
  2505. start : start,
  2506. static : is_static,
  2507. is_generator: is_generator,
  2508. async : is_async,
  2509. key : name,
  2510. quote : name instanceof AST_SymbolMethod ?
  2511. property_token.quote : undefined,
  2512. value : create_accessor(is_generator, is_async),
  2513. end : prev()
  2514. });
  2515. return node;
  2516. }
  2517. if (is_class) {
  2518. const key = get_symbol_ast(name, AST_SymbolClassProperty);
  2519. const quote = key instanceof AST_SymbolClassProperty
  2520. ? property_token.quote
  2521. : undefined;
  2522. const AST_ClassPropertyVariant = is_private
  2523. ? AST_ClassPrivateProperty
  2524. : AST_ClassProperty;
  2525. if (is("operator", "=")) {
  2526. next();
  2527. return new AST_ClassPropertyVariant({
  2528. start,
  2529. static: is_static,
  2530. quote,
  2531. key,
  2532. value: expression(false),
  2533. end: prev()
  2534. });
  2535. } else if (
  2536. is("name")
  2537. || is("privatename")
  2538. || is("operator", "*")
  2539. || is("punc", ";")
  2540. || is("punc", "}")
  2541. ) {
  2542. return new AST_ClassPropertyVariant({
  2543. start,
  2544. static: is_static,
  2545. quote,
  2546. key,
  2547. end: prev()
  2548. });
  2549. }
  2550. }
  2551. }
  2552. function maybe_import_assertion() {
  2553. if (is("name", "assert") && !has_newline_before(S.token)) {
  2554. next();
  2555. return object_or_destructuring_();
  2556. }
  2557. return null;
  2558. }
  2559. function import_statement() {
  2560. var start = prev();
  2561. var imported_name;
  2562. var imported_names;
  2563. if (is("name")) {
  2564. imported_name = as_symbol(AST_SymbolImport);
  2565. }
  2566. if (is("punc", ",")) {
  2567. next();
  2568. }
  2569. imported_names = map_names(true);
  2570. if (imported_names || imported_name) {
  2571. expect_token("name", "from");
  2572. }
  2573. var mod_str = S.token;
  2574. if (mod_str.type !== "string") {
  2575. unexpected();
  2576. }
  2577. next();
  2578. const assert_clause = maybe_import_assertion();
  2579. return new AST_Import({
  2580. start,
  2581. imported_name,
  2582. imported_names,
  2583. module_name: new AST_String({
  2584. start: mod_str,
  2585. value: mod_str.value,
  2586. quote: mod_str.quote,
  2587. end: mod_str,
  2588. }),
  2589. assert_clause,
  2590. end: S.token,
  2591. });
  2592. }
  2593. function import_meta() {
  2594. var start = S.token;
  2595. expect_token("operator", "import");
  2596. expect_token("punc", ".");
  2597. expect_token("name", "meta");
  2598. return subscripts(new AST_ImportMeta({
  2599. start: start,
  2600. end: prev()
  2601. }), false);
  2602. }
  2603. function map_name(is_import) {
  2604. function make_symbol(type) {
  2605. return new type({
  2606. name: as_property_name(),
  2607. start: prev(),
  2608. end: prev()
  2609. });
  2610. }
  2611. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2612. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2613. var start = S.token;
  2614. var foreign_name;
  2615. var name;
  2616. if (is_import) {
  2617. foreign_name = make_symbol(foreign_type);
  2618. } else {
  2619. name = make_symbol(type);
  2620. }
  2621. if (is("name", "as")) {
  2622. next(); // The "as" word
  2623. if (is_import) {
  2624. name = make_symbol(type);
  2625. } else {
  2626. foreign_name = make_symbol(foreign_type);
  2627. }
  2628. } else if (is_import) {
  2629. name = new type(foreign_name);
  2630. } else {
  2631. foreign_name = new foreign_type(name);
  2632. }
  2633. return new AST_NameMapping({
  2634. start: start,
  2635. foreign_name: foreign_name,
  2636. name: name,
  2637. end: prev(),
  2638. });
  2639. }
  2640. function map_nameAsterisk(is_import, name) {
  2641. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2642. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2643. var start = S.token;
  2644. var foreign_name;
  2645. var end = prev();
  2646. name = name || new type({
  2647. name: "*",
  2648. start: start,
  2649. end: end,
  2650. });
  2651. foreign_name = new foreign_type({
  2652. name: "*",
  2653. start: start,
  2654. end: end,
  2655. });
  2656. return new AST_NameMapping({
  2657. start: start,
  2658. foreign_name: foreign_name,
  2659. name: name,
  2660. end: end,
  2661. });
  2662. }
  2663. function map_names(is_import) {
  2664. var names;
  2665. if (is("punc", "{")) {
  2666. next();
  2667. names = [];
  2668. while (!is("punc", "}")) {
  2669. names.push(map_name(is_import));
  2670. if (is("punc", ",")) {
  2671. next();
  2672. }
  2673. }
  2674. next();
  2675. } else if (is("operator", "*")) {
  2676. var name;
  2677. next();
  2678. if (is_import && is("name", "as")) {
  2679. next(); // The "as" word
  2680. name = as_symbol(is_import ? AST_SymbolImport : AST_SymbolExportForeign);
  2681. }
  2682. names = [map_nameAsterisk(is_import, name)];
  2683. }
  2684. return names;
  2685. }
  2686. function export_statement() {
  2687. var start = S.token;
  2688. var is_default;
  2689. var exported_names;
  2690. if (is("keyword", "default")) {
  2691. is_default = true;
  2692. next();
  2693. } else if (exported_names = map_names(false)) {
  2694. if (is("name", "from")) {
  2695. next();
  2696. var mod_str = S.token;
  2697. if (mod_str.type !== "string") {
  2698. unexpected();
  2699. }
  2700. next();
  2701. const assert_clause = maybe_import_assertion();
  2702. return new AST_Export({
  2703. start: start,
  2704. is_default: is_default,
  2705. exported_names: exported_names,
  2706. module_name: new AST_String({
  2707. start: mod_str,
  2708. value: mod_str.value,
  2709. quote: mod_str.quote,
  2710. end: mod_str,
  2711. }),
  2712. end: prev(),
  2713. assert_clause
  2714. });
  2715. } else {
  2716. return new AST_Export({
  2717. start: start,
  2718. is_default: is_default,
  2719. exported_names: exported_names,
  2720. end: prev(),
  2721. });
  2722. }
  2723. }
  2724. var node;
  2725. var exported_value;
  2726. var exported_definition;
  2727. if (is("punc", "{")
  2728. || is_default
  2729. && (is("keyword", "class") || is("keyword", "function"))
  2730. && is_token(peek(), "punc")) {
  2731. exported_value = expression(false);
  2732. semicolon();
  2733. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2734. unexpected(node.start);
  2735. } else if (
  2736. node instanceof AST_Definitions
  2737. || node instanceof AST_Defun
  2738. || node instanceof AST_DefClass
  2739. ) {
  2740. exported_definition = node;
  2741. } else if (
  2742. node instanceof AST_ClassExpression
  2743. || node instanceof AST_Function
  2744. ) {
  2745. exported_value = node;
  2746. } else if (node instanceof AST_SimpleStatement) {
  2747. exported_value = node.body;
  2748. } else {
  2749. unexpected(node.start);
  2750. }
  2751. return new AST_Export({
  2752. start: start,
  2753. is_default: is_default,
  2754. exported_value: exported_value,
  2755. exported_definition: exported_definition,
  2756. end: prev(),
  2757. assert_clause: null
  2758. });
  2759. }
  2760. function as_property_name() {
  2761. var tmp = S.token;
  2762. switch (tmp.type) {
  2763. case "punc":
  2764. if (tmp.value === "[") {
  2765. next();
  2766. var ex = expression(false);
  2767. expect("]");
  2768. return ex;
  2769. } else unexpected(tmp);
  2770. case "operator":
  2771. if (tmp.value === "*") {
  2772. next();
  2773. return null;
  2774. }
  2775. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2776. unexpected(tmp);
  2777. }
  2778. /* falls through */
  2779. case "name":
  2780. case "privatename":
  2781. case "string":
  2782. case "num":
  2783. case "big_int":
  2784. case "keyword":
  2785. case "atom":
  2786. next();
  2787. return tmp.value;
  2788. default:
  2789. unexpected(tmp);
  2790. }
  2791. }
  2792. function as_name() {
  2793. var tmp = S.token;
  2794. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  2795. next();
  2796. return tmp.value;
  2797. }
  2798. function _make_symbol(type) {
  2799. var name = S.token.value;
  2800. return new (name == "this" ? AST_This :
  2801. name == "super" ? AST_Super :
  2802. type)({
  2803. name : String(name),
  2804. start : S.token,
  2805. end : S.token
  2806. });
  2807. }
  2808. function _verify_symbol(sym) {
  2809. var name = sym.name;
  2810. if (is_in_generator() && name == "yield") {
  2811. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2812. }
  2813. if (S.input.has_directive("use strict")) {
  2814. if (name == "yield") {
  2815. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2816. }
  2817. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2818. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2819. }
  2820. }
  2821. }
  2822. function as_symbol(type, noerror) {
  2823. if (!is("name")) {
  2824. if (!noerror) croak("Name expected");
  2825. return null;
  2826. }
  2827. var sym = _make_symbol(type);
  2828. _verify_symbol(sym);
  2829. next();
  2830. return sym;
  2831. }
  2832. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2833. function annotate(node) {
  2834. var start = node.start;
  2835. var comments = start.comments_before;
  2836. const comments_outside_parens = outer_comments_before_counts.get(start);
  2837. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2838. while (--i >= 0) {
  2839. var comment = comments[i];
  2840. if (/[@#]__/.test(comment.value)) {
  2841. if (/[@#]__PURE__/.test(comment.value)) {
  2842. set_annotation(node, _PURE);
  2843. break;
  2844. }
  2845. if (/[@#]__INLINE__/.test(comment.value)) {
  2846. set_annotation(node, _INLINE);
  2847. break;
  2848. }
  2849. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2850. set_annotation(node, _NOINLINE);
  2851. break;
  2852. }
  2853. }
  2854. }
  2855. }
  2856. var subscripts = function(expr, allow_calls, is_chain) {
  2857. var start = expr.start;
  2858. if (is("punc", ".")) {
  2859. next();
  2860. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2861. return subscripts(new AST_DotVariant({
  2862. start : start,
  2863. expression : expr,
  2864. optional : false,
  2865. property : as_name(),
  2866. end : prev()
  2867. }), allow_calls, is_chain);
  2868. }
  2869. if (is("punc", "[")) {
  2870. next();
  2871. var prop = expression(true);
  2872. expect("]");
  2873. return subscripts(new AST_Sub({
  2874. start : start,
  2875. expression : expr,
  2876. optional : false,
  2877. property : prop,
  2878. end : prev()
  2879. }), allow_calls, is_chain);
  2880. }
  2881. if (allow_calls && is("punc", "(")) {
  2882. next();
  2883. var call = new AST_Call({
  2884. start : start,
  2885. expression : expr,
  2886. optional : false,
  2887. args : call_args(),
  2888. end : prev()
  2889. });
  2890. annotate(call);
  2891. return subscripts(call, true, is_chain);
  2892. }
  2893. if (is("punc", "?.")) {
  2894. next();
  2895. let chain_contents;
  2896. if (allow_calls && is("punc", "(")) {
  2897. next();
  2898. const call = new AST_Call({
  2899. start,
  2900. optional: true,
  2901. expression: expr,
  2902. args: call_args(),
  2903. end: prev()
  2904. });
  2905. annotate(call);
  2906. chain_contents = subscripts(call, true, true);
  2907. } else if (is("name") || is("privatename")) {
  2908. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2909. chain_contents = subscripts(new AST_DotVariant({
  2910. start,
  2911. expression: expr,
  2912. optional: true,
  2913. property: as_name(),
  2914. end: prev()
  2915. }), allow_calls, true);
  2916. } else if (is("punc", "[")) {
  2917. next();
  2918. const property = expression(true);
  2919. expect("]");
  2920. chain_contents = subscripts(new AST_Sub({
  2921. start,
  2922. expression: expr,
  2923. optional: true,
  2924. property,
  2925. end: prev()
  2926. }), allow_calls, true);
  2927. }
  2928. if (!chain_contents) unexpected();
  2929. if (chain_contents instanceof AST_Chain) return chain_contents;
  2930. return new AST_Chain({
  2931. start,
  2932. expression: chain_contents,
  2933. end: prev()
  2934. });
  2935. }
  2936. if (is("template_head")) {
  2937. if (is_chain) {
  2938. // a?.b`c` is a syntax error
  2939. unexpected();
  2940. }
  2941. return subscripts(new AST_PrefixedTemplateString({
  2942. start: start,
  2943. prefix: expr,
  2944. template_string: template_string(),
  2945. end: prev()
  2946. }), allow_calls);
  2947. }
  2948. return expr;
  2949. };
  2950. function call_args() {
  2951. var args = [];
  2952. while (!is("punc", ")")) {
  2953. if (is("expand", "...")) {
  2954. next();
  2955. args.push(new AST_Expansion({
  2956. start: prev(),
  2957. expression: expression(false),
  2958. end: prev()
  2959. }));
  2960. } else {
  2961. args.push(expression(false));
  2962. }
  2963. if (!is("punc", ")")) {
  2964. expect(",");
  2965. }
  2966. }
  2967. next();
  2968. return args;
  2969. }
  2970. var maybe_unary = function(allow_calls, allow_arrows) {
  2971. var start = S.token;
  2972. if (start.type == "name" && start.value == "await" && can_await()) {
  2973. next();
  2974. return _await_expression();
  2975. }
  2976. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  2977. next();
  2978. handle_regexp();
  2979. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  2980. ex.start = start;
  2981. ex.end = prev();
  2982. return ex;
  2983. }
  2984. var val = expr_atom(allow_calls, allow_arrows);
  2985. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  2986. if (val instanceof AST_Arrow) unexpected();
  2987. val = make_unary(AST_UnaryPostfix, S.token, val);
  2988. val.start = start;
  2989. val.end = S.token;
  2990. next();
  2991. }
  2992. return val;
  2993. };
  2994. function make_unary(ctor, token, expr) {
  2995. var op = token.value;
  2996. switch (op) {
  2997. case "++":
  2998. case "--":
  2999. if (!is_assignable(expr))
  3000. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  3001. break;
  3002. case "delete":
  3003. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3004. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3005. break;
  3006. }
  3007. return new ctor({ operator: op, expression: expr });
  3008. }
  3009. var expr_op = function(left, min_prec, no_in) {
  3010. var op = is("operator") ? S.token.value : null;
  3011. if (op == "in" && no_in) op = null;
  3012. if (op == "**" && left instanceof AST_UnaryPrefix
  3013. /* unary token in front not allowed - parenthesis required */
  3014. && !is_token(left.start, "punc", "(")
  3015. && left.operator !== "--" && left.operator !== "++")
  3016. unexpected(left.start);
  3017. var prec = op != null ? PRECEDENCE[op] : null;
  3018. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3019. next();
  3020. var right = expr_op(maybe_unary(true), prec, no_in);
  3021. return expr_op(new AST_Binary({
  3022. start : left.start,
  3023. left : left,
  3024. operator : op,
  3025. right : right,
  3026. end : right.end
  3027. }), min_prec, no_in);
  3028. }
  3029. return left;
  3030. };
  3031. function expr_ops(no_in) {
  3032. return expr_op(maybe_unary(true, true), 0, no_in);
  3033. }
  3034. var maybe_conditional = function(no_in) {
  3035. var start = S.token;
  3036. var expr = expr_ops(no_in);
  3037. if (is("operator", "?")) {
  3038. next();
  3039. var yes = expression(false);
  3040. expect(":");
  3041. return new AST_Conditional({
  3042. start : start,
  3043. condition : expr,
  3044. consequent : yes,
  3045. alternative : expression(false, no_in),
  3046. end : prev()
  3047. });
  3048. }
  3049. return expr;
  3050. };
  3051. function is_assignable(expr) {
  3052. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3053. }
  3054. function to_destructuring(node) {
  3055. if (node instanceof AST_Object) {
  3056. node = new AST_Destructuring({
  3057. start: node.start,
  3058. names: node.properties.map(to_destructuring),
  3059. is_array: false,
  3060. end: node.end
  3061. });
  3062. } else if (node instanceof AST_Array) {
  3063. var names = [];
  3064. for (var i = 0; i < node.elements.length; i++) {
  3065. // Only allow expansion as last element
  3066. if (node.elements[i] instanceof AST_Expansion) {
  3067. if (i + 1 !== node.elements.length) {
  3068. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3069. }
  3070. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3071. }
  3072. names.push(to_destructuring(node.elements[i]));
  3073. }
  3074. node = new AST_Destructuring({
  3075. start: node.start,
  3076. names: names,
  3077. is_array: true,
  3078. end: node.end
  3079. });
  3080. } else if (node instanceof AST_ObjectProperty) {
  3081. node.value = to_destructuring(node.value);
  3082. } else if (node instanceof AST_Assign) {
  3083. node = new AST_DefaultAssign({
  3084. start: node.start,
  3085. left: node.left,
  3086. operator: "=",
  3087. right: node.right,
  3088. end: node.end
  3089. });
  3090. }
  3091. return node;
  3092. }
  3093. // In ES6, AssignmentExpression can also be an ArrowFunction
  3094. var maybe_assign = function(no_in) {
  3095. handle_regexp();
  3096. var start = S.token;
  3097. if (start.type == "name" && start.value == "yield") {
  3098. if (is_in_generator()) {
  3099. next();
  3100. return _yield_expression();
  3101. } else if (S.input.has_directive("use strict")) {
  3102. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3103. }
  3104. }
  3105. var left = maybe_conditional(no_in);
  3106. var val = S.token.value;
  3107. if (is("operator") && ASSIGNMENT.has(val)) {
  3108. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3109. next();
  3110. return new AST_Assign({
  3111. start : start,
  3112. left : left,
  3113. operator : val,
  3114. right : maybe_assign(no_in),
  3115. logical : LOGICAL_ASSIGNMENT.has(val),
  3116. end : prev()
  3117. });
  3118. }
  3119. croak("Invalid assignment");
  3120. }
  3121. return left;
  3122. };
  3123. var expression = function(commas, no_in) {
  3124. var start = S.token;
  3125. var exprs = [];
  3126. while (true) {
  3127. exprs.push(maybe_assign(no_in));
  3128. if (!commas || !is("punc", ",")) break;
  3129. next();
  3130. commas = true;
  3131. }
  3132. return exprs.length == 1 ? exprs[0] : new AST_Sequence({
  3133. start : start,
  3134. expressions : exprs,
  3135. end : peek()
  3136. });
  3137. };
  3138. function in_loop(cont) {
  3139. ++S.in_loop;
  3140. var ret = cont();
  3141. --S.in_loop;
  3142. return ret;
  3143. }
  3144. if (options.expression) {
  3145. return expression(true);
  3146. }
  3147. return (function parse_toplevel() {
  3148. var start = S.token;
  3149. var body = [];
  3150. S.input.push_directives_stack();
  3151. if (options.module) S.input.add_directive("use strict");
  3152. while (!is("eof")) {
  3153. body.push(statement());
  3154. }
  3155. S.input.pop_directives_stack();
  3156. var end = prev();
  3157. var toplevel = options.toplevel;
  3158. if (toplevel) {
  3159. toplevel.body = toplevel.body.concat(body);
  3160. toplevel.end = end;
  3161. } else {
  3162. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3163. }
  3164. return toplevel;
  3165. })();
  3166. }
  3167. /***********************************************************************
  3168. A JavaScript tokenizer / parser / beautifier / compressor.
  3169. https://github.com/mishoo/UglifyJS2
  3170. -------------------------------- (C) ---------------------------------
  3171. Author: Mihai Bazon
  3172. <mihai.bazon@gmail.com>
  3173. http://mihai.bazon.net/blog
  3174. Distributed under the BSD license:
  3175. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3176. Redistribution and use in source and binary forms, with or without
  3177. modification, are permitted provided that the following conditions
  3178. are met:
  3179. * Redistributions of source code must retain the above
  3180. copyright notice, this list of conditions and the following
  3181. disclaimer.
  3182. * Redistributions in binary form must reproduce the above
  3183. copyright notice, this list of conditions and the following
  3184. disclaimer in the documentation and/or other materials
  3185. provided with the distribution.
  3186. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3187. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3188. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3189. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3190. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3191. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3192. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3193. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3194. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3195. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3196. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3197. SUCH DAMAGE.
  3198. ***********************************************************************/
  3199. function DEFNODE(type, props, ctor, methods, base = AST_Node) {
  3200. if (!props) props = [];
  3201. else props = props.split(/\s+/);
  3202. var self_props = props;
  3203. if (base && base.PROPS)
  3204. props = props.concat(base.PROPS);
  3205. const proto = base && Object.create(base.prototype);
  3206. if (proto) {
  3207. ctor.prototype = proto;
  3208. ctor.BASE = base;
  3209. }
  3210. if (base) base.SUBCLASSES.push(ctor);
  3211. ctor.prototype.CTOR = ctor;
  3212. ctor.prototype.constructor = ctor;
  3213. ctor.PROPS = props || null;
  3214. ctor.SELF_PROPS = self_props;
  3215. ctor.SUBCLASSES = [];
  3216. if (type) {
  3217. ctor.prototype.TYPE = ctor.TYPE = type;
  3218. }
  3219. if (methods) for (let i in methods) if (HOP(methods, i)) {
  3220. if (i[0] === "$") {
  3221. ctor[i.substr(1)] = methods[i];
  3222. } else {
  3223. ctor.prototype[i] = methods[i];
  3224. }
  3225. }
  3226. ctor.DEFMETHOD = function(name, method) {
  3227. this.prototype[name] = method;
  3228. };
  3229. return ctor;
  3230. }
  3231. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  3232. const set_tok_flag = (tok, flag, truth) => {
  3233. if (truth) {
  3234. tok.flags |= flag;
  3235. } else {
  3236. tok.flags &= ~flag;
  3237. }
  3238. };
  3239. const TOK_FLAG_NLB = 0b0001;
  3240. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  3241. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  3242. class AST_Token {
  3243. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  3244. this.flags = (nlb ? 1 : 0);
  3245. this.type = type;
  3246. this.value = value;
  3247. this.line = line;
  3248. this.col = col;
  3249. this.pos = pos;
  3250. this.comments_before = comments_before;
  3251. this.comments_after = comments_after;
  3252. this.file = file;
  3253. Object.seal(this);
  3254. }
  3255. get nlb() {
  3256. return has_tok_flag(this, TOK_FLAG_NLB);
  3257. }
  3258. set nlb(new_nlb) {
  3259. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  3260. }
  3261. get quote() {
  3262. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  3263. ? ""
  3264. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  3265. }
  3266. set quote(quote_type) {
  3267. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  3268. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  3269. }
  3270. }
  3271. var AST_Node = DEFNODE("Node", "start end", function AST_Node(props) {
  3272. if (props) {
  3273. this.start = props.start;
  3274. this.end = props.end;
  3275. }
  3276. this.flags = 0;
  3277. }, {
  3278. _clone: function(deep) {
  3279. if (deep) {
  3280. var self = this.clone();
  3281. return self.transform(new TreeTransformer(function(node) {
  3282. if (node !== self) {
  3283. return node.clone(true);
  3284. }
  3285. }));
  3286. }
  3287. return new this.CTOR(this);
  3288. },
  3289. clone: function(deep) {
  3290. return this._clone(deep);
  3291. },
  3292. $documentation: "Base class of all AST nodes",
  3293. $propdoc: {
  3294. start: "[AST_Token] The first token of this node",
  3295. end: "[AST_Token] The last token of this node"
  3296. },
  3297. _walk: function(visitor) {
  3298. return visitor._visit(this);
  3299. },
  3300. walk: function(visitor) {
  3301. return this._walk(visitor); // not sure the indirection will be any help
  3302. },
  3303. _children_backwards: () => {}
  3304. }, null);
  3305. /* -----[ statements ]----- */
  3306. var AST_Statement = DEFNODE("Statement", null, function AST_Statement(props) {
  3307. if (props) {
  3308. this.start = props.start;
  3309. this.end = props.end;
  3310. }
  3311. this.flags = 0;
  3312. }, {
  3313. $documentation: "Base class of all statements",
  3314. });
  3315. var AST_Debugger = DEFNODE("Debugger", null, function AST_Debugger(props) {
  3316. if (props) {
  3317. this.start = props.start;
  3318. this.end = props.end;
  3319. }
  3320. this.flags = 0;
  3321. }, {
  3322. $documentation: "Represents a debugger statement",
  3323. }, AST_Statement);
  3324. var AST_Directive = DEFNODE("Directive", "value quote", function AST_Directive(props) {
  3325. if (props) {
  3326. this.value = props.value;
  3327. this.quote = props.quote;
  3328. this.start = props.start;
  3329. this.end = props.end;
  3330. }
  3331. this.flags = 0;
  3332. }, {
  3333. $documentation: "Represents a directive, like \"use strict\";",
  3334. $propdoc: {
  3335. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3336. quote: "[string] the original quote character"
  3337. },
  3338. }, AST_Statement);
  3339. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", function AST_SimpleStatement(props) {
  3340. if (props) {
  3341. this.body = props.body;
  3342. this.start = props.start;
  3343. this.end = props.end;
  3344. }
  3345. this.flags = 0;
  3346. }, {
  3347. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3348. $propdoc: {
  3349. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3350. },
  3351. _walk: function(visitor) {
  3352. return visitor._visit(this, function() {
  3353. this.body._walk(visitor);
  3354. });
  3355. },
  3356. _children_backwards(push) {
  3357. push(this.body);
  3358. }
  3359. }, AST_Statement);
  3360. function walk_body(node, visitor) {
  3361. const body = node.body;
  3362. for (var i = 0, len = body.length; i < len; i++) {
  3363. body[i]._walk(visitor);
  3364. }
  3365. }
  3366. function clone_block_scope(deep) {
  3367. var clone = this._clone(deep);
  3368. if (this.block_scope) {
  3369. clone.block_scope = this.block_scope.clone();
  3370. }
  3371. return clone;
  3372. }
  3373. var AST_Block = DEFNODE("Block", "body block_scope", function AST_Block(props) {
  3374. if (props) {
  3375. this.body = props.body;
  3376. this.block_scope = props.block_scope;
  3377. this.start = props.start;
  3378. this.end = props.end;
  3379. }
  3380. this.flags = 0;
  3381. }, {
  3382. $documentation: "A body of statements (usually braced)",
  3383. $propdoc: {
  3384. body: "[AST_Statement*] an array of statements",
  3385. block_scope: "[AST_Scope] the block scope"
  3386. },
  3387. _walk: function(visitor) {
  3388. return visitor._visit(this, function() {
  3389. walk_body(this, visitor);
  3390. });
  3391. },
  3392. _children_backwards(push) {
  3393. let i = this.body.length;
  3394. while (i--) push(this.body[i]);
  3395. },
  3396. clone: clone_block_scope
  3397. }, AST_Statement);
  3398. var AST_BlockStatement = DEFNODE("BlockStatement", null, function AST_BlockStatement(props) {
  3399. if (props) {
  3400. this.body = props.body;
  3401. this.block_scope = props.block_scope;
  3402. this.start = props.start;
  3403. this.end = props.end;
  3404. }
  3405. this.flags = 0;
  3406. }, {
  3407. $documentation: "A block statement",
  3408. }, AST_Block);
  3409. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, function AST_EmptyStatement(props) {
  3410. if (props) {
  3411. this.start = props.start;
  3412. this.end = props.end;
  3413. }
  3414. this.flags = 0;
  3415. }, {
  3416. $documentation: "The empty statement (empty block or simply a semicolon)"
  3417. }, AST_Statement);
  3418. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", function AST_StatementWithBody(props) {
  3419. if (props) {
  3420. this.body = props.body;
  3421. this.start = props.start;
  3422. this.end = props.end;
  3423. }
  3424. this.flags = 0;
  3425. }, {
  3426. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3427. $propdoc: {
  3428. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3429. }
  3430. }, AST_Statement);
  3431. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", function AST_LabeledStatement(props) {
  3432. if (props) {
  3433. this.label = props.label;
  3434. this.body = props.body;
  3435. this.start = props.start;
  3436. this.end = props.end;
  3437. }
  3438. this.flags = 0;
  3439. }, {
  3440. $documentation: "Statement with a label",
  3441. $propdoc: {
  3442. label: "[AST_Label] a label definition"
  3443. },
  3444. _walk: function(visitor) {
  3445. return visitor._visit(this, function() {
  3446. this.label._walk(visitor);
  3447. this.body._walk(visitor);
  3448. });
  3449. },
  3450. _children_backwards(push) {
  3451. push(this.body);
  3452. push(this.label);
  3453. },
  3454. clone: function(deep) {
  3455. var node = this._clone(deep);
  3456. if (deep) {
  3457. var label = node.label;
  3458. var def = this.label;
  3459. node.walk(new TreeWalker(function(node) {
  3460. if (node instanceof AST_LoopControl
  3461. && node.label && node.label.thedef === def) {
  3462. node.label.thedef = label;
  3463. label.references.push(node);
  3464. }
  3465. }));
  3466. }
  3467. return node;
  3468. }
  3469. }, AST_StatementWithBody);
  3470. var AST_IterationStatement = DEFNODE(
  3471. "IterationStatement",
  3472. "block_scope",
  3473. function AST_IterationStatement(props) {
  3474. if (props) {
  3475. this.block_scope = props.block_scope;
  3476. this.body = props.body;
  3477. this.start = props.start;
  3478. this.end = props.end;
  3479. }
  3480. this.flags = 0;
  3481. },
  3482. {
  3483. $documentation: "Internal class. All loops inherit from it.",
  3484. $propdoc: {
  3485. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3486. },
  3487. clone: clone_block_scope
  3488. },
  3489. AST_StatementWithBody
  3490. );
  3491. var AST_DWLoop = DEFNODE("DWLoop", "condition", function AST_DWLoop(props) {
  3492. if (props) {
  3493. this.condition = props.condition;
  3494. this.block_scope = props.block_scope;
  3495. this.body = props.body;
  3496. this.start = props.start;
  3497. this.end = props.end;
  3498. }
  3499. this.flags = 0;
  3500. }, {
  3501. $documentation: "Base class for do/while statements",
  3502. $propdoc: {
  3503. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3504. }
  3505. }, AST_IterationStatement);
  3506. var AST_Do = DEFNODE("Do", null, function AST_Do(props) {
  3507. if (props) {
  3508. this.condition = props.condition;
  3509. this.block_scope = props.block_scope;
  3510. this.body = props.body;
  3511. this.start = props.start;
  3512. this.end = props.end;
  3513. }
  3514. this.flags = 0;
  3515. }, {
  3516. $documentation: "A `do` statement",
  3517. _walk: function(visitor) {
  3518. return visitor._visit(this, function() {
  3519. this.body._walk(visitor);
  3520. this.condition._walk(visitor);
  3521. });
  3522. },
  3523. _children_backwards(push) {
  3524. push(this.condition);
  3525. push(this.body);
  3526. }
  3527. }, AST_DWLoop);
  3528. var AST_While = DEFNODE("While", null, function AST_While(props) {
  3529. if (props) {
  3530. this.condition = props.condition;
  3531. this.block_scope = props.block_scope;
  3532. this.body = props.body;
  3533. this.start = props.start;
  3534. this.end = props.end;
  3535. }
  3536. this.flags = 0;
  3537. }, {
  3538. $documentation: "A `while` statement",
  3539. _walk: function(visitor) {
  3540. return visitor._visit(this, function() {
  3541. this.condition._walk(visitor);
  3542. this.body._walk(visitor);
  3543. });
  3544. },
  3545. _children_backwards(push) {
  3546. push(this.body);
  3547. push(this.condition);
  3548. },
  3549. }, AST_DWLoop);
  3550. var AST_For = DEFNODE("For", "init condition step", function AST_For(props) {
  3551. if (props) {
  3552. this.init = props.init;
  3553. this.condition = props.condition;
  3554. this.step = props.step;
  3555. this.block_scope = props.block_scope;
  3556. this.body = props.body;
  3557. this.start = props.start;
  3558. this.end = props.end;
  3559. }
  3560. this.flags = 0;
  3561. }, {
  3562. $documentation: "A `for` statement",
  3563. $propdoc: {
  3564. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3565. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3566. step: "[AST_Node?] the `for` update clause, or null if empty"
  3567. },
  3568. _walk: function(visitor) {
  3569. return visitor._visit(this, function() {
  3570. if (this.init) this.init._walk(visitor);
  3571. if (this.condition) this.condition._walk(visitor);
  3572. if (this.step) this.step._walk(visitor);
  3573. this.body._walk(visitor);
  3574. });
  3575. },
  3576. _children_backwards(push) {
  3577. push(this.body);
  3578. if (this.step) push(this.step);
  3579. if (this.condition) push(this.condition);
  3580. if (this.init) push(this.init);
  3581. },
  3582. }, AST_IterationStatement);
  3583. var AST_ForIn = DEFNODE("ForIn", "init object", function AST_ForIn(props) {
  3584. if (props) {
  3585. this.init = props.init;
  3586. this.object = props.object;
  3587. this.block_scope = props.block_scope;
  3588. this.body = props.body;
  3589. this.start = props.start;
  3590. this.end = props.end;
  3591. }
  3592. this.flags = 0;
  3593. }, {
  3594. $documentation: "A `for ... in` statement",
  3595. $propdoc: {
  3596. init: "[AST_Node] the `for/in` initialization code",
  3597. object: "[AST_Node] the object that we're looping through"
  3598. },
  3599. _walk: function(visitor) {
  3600. return visitor._visit(this, function() {
  3601. this.init._walk(visitor);
  3602. this.object._walk(visitor);
  3603. this.body._walk(visitor);
  3604. });
  3605. },
  3606. _children_backwards(push) {
  3607. push(this.body);
  3608. if (this.object) push(this.object);
  3609. if (this.init) push(this.init);
  3610. },
  3611. }, AST_IterationStatement);
  3612. var AST_ForOf = DEFNODE("ForOf", "await", function AST_ForOf(props) {
  3613. if (props) {
  3614. this.await = props.await;
  3615. this.init = props.init;
  3616. this.object = props.object;
  3617. this.block_scope = props.block_scope;
  3618. this.body = props.body;
  3619. this.start = props.start;
  3620. this.end = props.end;
  3621. }
  3622. this.flags = 0;
  3623. }, {
  3624. $documentation: "A `for ... of` statement",
  3625. }, AST_ForIn);
  3626. var AST_With = DEFNODE("With", "expression", function AST_With(props) {
  3627. if (props) {
  3628. this.expression = props.expression;
  3629. this.body = props.body;
  3630. this.start = props.start;
  3631. this.end = props.end;
  3632. }
  3633. this.flags = 0;
  3634. }, {
  3635. $documentation: "A `with` statement",
  3636. $propdoc: {
  3637. expression: "[AST_Node] the `with` expression"
  3638. },
  3639. _walk: function(visitor) {
  3640. return visitor._visit(this, function() {
  3641. this.expression._walk(visitor);
  3642. this.body._walk(visitor);
  3643. });
  3644. },
  3645. _children_backwards(push) {
  3646. push(this.body);
  3647. push(this.expression);
  3648. },
  3649. }, AST_StatementWithBody);
  3650. /* -----[ scope and functions ]----- */
  3651. var AST_Scope = DEFNODE(
  3652. "Scope",
  3653. "variables functions uses_with uses_eval parent_scope enclosed cname",
  3654. function AST_Scope(props) {
  3655. if (props) {
  3656. this.variables = props.variables;
  3657. this.functions = props.functions;
  3658. this.uses_with = props.uses_with;
  3659. this.uses_eval = props.uses_eval;
  3660. this.parent_scope = props.parent_scope;
  3661. this.enclosed = props.enclosed;
  3662. this.cname = props.cname;
  3663. this.body = props.body;
  3664. this.block_scope = props.block_scope;
  3665. this.start = props.start;
  3666. this.end = props.end;
  3667. }
  3668. this.flags = 0;
  3669. },
  3670. {
  3671. $documentation: "Base class for all statements introducing a lexical scope",
  3672. $propdoc: {
  3673. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3674. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3675. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3676. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3677. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3678. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3679. },
  3680. get_defun_scope: function() {
  3681. var self = this;
  3682. while (self.is_block_scope()) {
  3683. self = self.parent_scope;
  3684. }
  3685. return self;
  3686. },
  3687. clone: function(deep, toplevel) {
  3688. var node = this._clone(deep);
  3689. if (deep && this.variables && toplevel && !this._block_scope) {
  3690. node.figure_out_scope({}, {
  3691. toplevel: toplevel,
  3692. parent_scope: this.parent_scope
  3693. });
  3694. } else {
  3695. if (this.variables) node.variables = new Map(this.variables);
  3696. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3697. if (this._block_scope) node._block_scope = this._block_scope;
  3698. }
  3699. return node;
  3700. },
  3701. pinned: function() {
  3702. return this.uses_eval || this.uses_with;
  3703. }
  3704. },
  3705. AST_Block
  3706. );
  3707. var AST_Toplevel = DEFNODE("Toplevel", "globals", function AST_Toplevel(props) {
  3708. if (props) {
  3709. this.globals = props.globals;
  3710. this.variables = props.variables;
  3711. this.functions = props.functions;
  3712. this.uses_with = props.uses_with;
  3713. this.uses_eval = props.uses_eval;
  3714. this.parent_scope = props.parent_scope;
  3715. this.enclosed = props.enclosed;
  3716. this.cname = props.cname;
  3717. this.body = props.body;
  3718. this.block_scope = props.block_scope;
  3719. this.start = props.start;
  3720. this.end = props.end;
  3721. }
  3722. this.flags = 0;
  3723. }, {
  3724. $documentation: "The toplevel scope",
  3725. $propdoc: {
  3726. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3727. },
  3728. wrap_commonjs: function(name) {
  3729. var body = this.body;
  3730. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3731. wrapped_tl = parse(wrapped_tl);
  3732. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3733. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3734. return MAP.splice(body);
  3735. }
  3736. }));
  3737. return wrapped_tl;
  3738. },
  3739. wrap_enclose: function(args_values) {
  3740. if (typeof args_values != "string") args_values = "";
  3741. var index = args_values.indexOf(":");
  3742. if (index < 0) index = args_values.length;
  3743. var body = this.body;
  3744. return parse([
  3745. "(function(",
  3746. args_values.slice(0, index),
  3747. '){"$ORIG"})(',
  3748. args_values.slice(index + 1),
  3749. ")"
  3750. ].join("")).transform(new TreeTransformer(function(node) {
  3751. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3752. return MAP.splice(body);
  3753. }
  3754. }));
  3755. }
  3756. }, AST_Scope);
  3757. var AST_Expansion = DEFNODE("Expansion", "expression", function AST_Expansion(props) {
  3758. if (props) {
  3759. this.expression = props.expression;
  3760. this.start = props.start;
  3761. this.end = props.end;
  3762. }
  3763. this.flags = 0;
  3764. }, {
  3765. $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",
  3766. $propdoc: {
  3767. expression: "[AST_Node] the thing to be expanded"
  3768. },
  3769. _walk: function(visitor) {
  3770. return visitor._visit(this, function() {
  3771. this.expression.walk(visitor);
  3772. });
  3773. },
  3774. _children_backwards(push) {
  3775. push(this.expression);
  3776. },
  3777. });
  3778. var AST_Lambda = DEFNODE(
  3779. "Lambda",
  3780. "name argnames uses_arguments is_generator async",
  3781. function AST_Lambda(props) {
  3782. if (props) {
  3783. this.name = props.name;
  3784. this.argnames = props.argnames;
  3785. this.uses_arguments = props.uses_arguments;
  3786. this.is_generator = props.is_generator;
  3787. this.async = props.async;
  3788. this.variables = props.variables;
  3789. this.functions = props.functions;
  3790. this.uses_with = props.uses_with;
  3791. this.uses_eval = props.uses_eval;
  3792. this.parent_scope = props.parent_scope;
  3793. this.enclosed = props.enclosed;
  3794. this.cname = props.cname;
  3795. this.body = props.body;
  3796. this.block_scope = props.block_scope;
  3797. this.start = props.start;
  3798. this.end = props.end;
  3799. }
  3800. this.flags = 0;
  3801. },
  3802. {
  3803. $documentation: "Base class for functions",
  3804. $propdoc: {
  3805. name: "[AST_SymbolDeclaration?] the name of this function",
  3806. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3807. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3808. is_generator: "[boolean] is this a generator method",
  3809. async: "[boolean] is this method async",
  3810. },
  3811. args_as_names: function () {
  3812. var out = [];
  3813. for (var i = 0; i < this.argnames.length; i++) {
  3814. if (this.argnames[i] instanceof AST_Destructuring) {
  3815. out.push(...this.argnames[i].all_symbols());
  3816. } else {
  3817. out.push(this.argnames[i]);
  3818. }
  3819. }
  3820. return out;
  3821. },
  3822. _walk: function(visitor) {
  3823. return visitor._visit(this, function() {
  3824. if (this.name) this.name._walk(visitor);
  3825. var argnames = this.argnames;
  3826. for (var i = 0, len = argnames.length; i < len; i++) {
  3827. argnames[i]._walk(visitor);
  3828. }
  3829. walk_body(this, visitor);
  3830. });
  3831. },
  3832. _children_backwards(push) {
  3833. let i = this.body.length;
  3834. while (i--) push(this.body[i]);
  3835. i = this.argnames.length;
  3836. while (i--) push(this.argnames[i]);
  3837. if (this.name) push(this.name);
  3838. },
  3839. is_braceless() {
  3840. return this.body[0] instanceof AST_Return && this.body[0].value;
  3841. },
  3842. // Default args and expansion don't count, so .argnames.length doesn't cut it
  3843. length_property() {
  3844. let length = 0;
  3845. for (const arg of this.argnames) {
  3846. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  3847. length++;
  3848. }
  3849. }
  3850. return length;
  3851. }
  3852. },
  3853. AST_Scope
  3854. );
  3855. var AST_Accessor = DEFNODE("Accessor", null, function AST_Accessor(props) {
  3856. if (props) {
  3857. this.name = props.name;
  3858. this.argnames = props.argnames;
  3859. this.uses_arguments = props.uses_arguments;
  3860. this.is_generator = props.is_generator;
  3861. this.async = props.async;
  3862. this.variables = props.variables;
  3863. this.functions = props.functions;
  3864. this.uses_with = props.uses_with;
  3865. this.uses_eval = props.uses_eval;
  3866. this.parent_scope = props.parent_scope;
  3867. this.enclosed = props.enclosed;
  3868. this.cname = props.cname;
  3869. this.body = props.body;
  3870. this.block_scope = props.block_scope;
  3871. this.start = props.start;
  3872. this.end = props.end;
  3873. }
  3874. this.flags = 0;
  3875. }, {
  3876. $documentation: "A setter/getter function. The `name` property is always null."
  3877. }, AST_Lambda);
  3878. var AST_Function = DEFNODE("Function", null, function AST_Function(props) {
  3879. if (props) {
  3880. this.name = props.name;
  3881. this.argnames = props.argnames;
  3882. this.uses_arguments = props.uses_arguments;
  3883. this.is_generator = props.is_generator;
  3884. this.async = props.async;
  3885. this.variables = props.variables;
  3886. this.functions = props.functions;
  3887. this.uses_with = props.uses_with;
  3888. this.uses_eval = props.uses_eval;
  3889. this.parent_scope = props.parent_scope;
  3890. this.enclosed = props.enclosed;
  3891. this.cname = props.cname;
  3892. this.body = props.body;
  3893. this.block_scope = props.block_scope;
  3894. this.start = props.start;
  3895. this.end = props.end;
  3896. }
  3897. this.flags = 0;
  3898. }, {
  3899. $documentation: "A function expression"
  3900. }, AST_Lambda);
  3901. var AST_Arrow = DEFNODE("Arrow", null, function AST_Arrow(props) {
  3902. if (props) {
  3903. this.name = props.name;
  3904. this.argnames = props.argnames;
  3905. this.uses_arguments = props.uses_arguments;
  3906. this.is_generator = props.is_generator;
  3907. this.async = props.async;
  3908. this.variables = props.variables;
  3909. this.functions = props.functions;
  3910. this.uses_with = props.uses_with;
  3911. this.uses_eval = props.uses_eval;
  3912. this.parent_scope = props.parent_scope;
  3913. this.enclosed = props.enclosed;
  3914. this.cname = props.cname;
  3915. this.body = props.body;
  3916. this.block_scope = props.block_scope;
  3917. this.start = props.start;
  3918. this.end = props.end;
  3919. }
  3920. this.flags = 0;
  3921. }, {
  3922. $documentation: "An ES6 Arrow function ((a) => b)"
  3923. }, AST_Lambda);
  3924. var AST_Defun = DEFNODE("Defun", null, function AST_Defun(props) {
  3925. if (props) {
  3926. this.name = props.name;
  3927. this.argnames = props.argnames;
  3928. this.uses_arguments = props.uses_arguments;
  3929. this.is_generator = props.is_generator;
  3930. this.async = props.async;
  3931. this.variables = props.variables;
  3932. this.functions = props.functions;
  3933. this.uses_with = props.uses_with;
  3934. this.uses_eval = props.uses_eval;
  3935. this.parent_scope = props.parent_scope;
  3936. this.enclosed = props.enclosed;
  3937. this.cname = props.cname;
  3938. this.body = props.body;
  3939. this.block_scope = props.block_scope;
  3940. this.start = props.start;
  3941. this.end = props.end;
  3942. }
  3943. this.flags = 0;
  3944. }, {
  3945. $documentation: "A function definition"
  3946. }, AST_Lambda);
  3947. /* -----[ DESTRUCTURING ]----- */
  3948. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", function AST_Destructuring(props) {
  3949. if (props) {
  3950. this.names = props.names;
  3951. this.is_array = props.is_array;
  3952. this.start = props.start;
  3953. this.end = props.end;
  3954. }
  3955. this.flags = 0;
  3956. }, {
  3957. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  3958. $propdoc: {
  3959. "names": "[AST_Node*] Array of properties or elements",
  3960. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  3961. },
  3962. _walk: function(visitor) {
  3963. return visitor._visit(this, function() {
  3964. this.names.forEach(function(name) {
  3965. name._walk(visitor);
  3966. });
  3967. });
  3968. },
  3969. _children_backwards(push) {
  3970. let i = this.names.length;
  3971. while (i--) push(this.names[i]);
  3972. },
  3973. all_symbols: function() {
  3974. var out = [];
  3975. this.walk(new TreeWalker(function (node) {
  3976. if (node instanceof AST_Symbol) {
  3977. out.push(node);
  3978. }
  3979. }));
  3980. return out;
  3981. }
  3982. });
  3983. var AST_PrefixedTemplateString = DEFNODE(
  3984. "PrefixedTemplateString",
  3985. "template_string prefix",
  3986. function AST_PrefixedTemplateString(props) {
  3987. if (props) {
  3988. this.template_string = props.template_string;
  3989. this.prefix = props.prefix;
  3990. this.start = props.start;
  3991. this.end = props.end;
  3992. }
  3993. this.flags = 0;
  3994. },
  3995. {
  3996. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  3997. $propdoc: {
  3998. template_string: "[AST_TemplateString] The template string",
  3999. prefix: "[AST_Node] The prefix, which will get called."
  4000. },
  4001. _walk: function(visitor) {
  4002. return visitor._visit(this, function () {
  4003. this.prefix._walk(visitor);
  4004. this.template_string._walk(visitor);
  4005. });
  4006. },
  4007. _children_backwards(push) {
  4008. push(this.template_string);
  4009. push(this.prefix);
  4010. },
  4011. }
  4012. );
  4013. var AST_TemplateString = DEFNODE("TemplateString", "segments", function AST_TemplateString(props) {
  4014. if (props) {
  4015. this.segments = props.segments;
  4016. this.start = props.start;
  4017. this.end = props.end;
  4018. }
  4019. this.flags = 0;
  4020. }, {
  4021. $documentation: "A template string literal",
  4022. $propdoc: {
  4023. 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."
  4024. },
  4025. _walk: function(visitor) {
  4026. return visitor._visit(this, function() {
  4027. this.segments.forEach(function(seg) {
  4028. seg._walk(visitor);
  4029. });
  4030. });
  4031. },
  4032. _children_backwards(push) {
  4033. let i = this.segments.length;
  4034. while (i--) push(this.segments[i]);
  4035. }
  4036. });
  4037. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", function AST_TemplateSegment(props) {
  4038. if (props) {
  4039. this.value = props.value;
  4040. this.raw = props.raw;
  4041. this.start = props.start;
  4042. this.end = props.end;
  4043. }
  4044. this.flags = 0;
  4045. }, {
  4046. $documentation: "A segment of a template string literal",
  4047. $propdoc: {
  4048. value: "Content of the segment",
  4049. raw: "Raw source of the segment",
  4050. }
  4051. });
  4052. /* -----[ JUMPS ]----- */
  4053. var AST_Jump = DEFNODE("Jump", null, function AST_Jump(props) {
  4054. if (props) {
  4055. this.start = props.start;
  4056. this.end = props.end;
  4057. }
  4058. this.flags = 0;
  4059. }, {
  4060. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  4061. }, AST_Statement);
  4062. var AST_Exit = DEFNODE("Exit", "value", function AST_Exit(props) {
  4063. if (props) {
  4064. this.value = props.value;
  4065. this.start = props.start;
  4066. this.end = props.end;
  4067. }
  4068. this.flags = 0;
  4069. }, {
  4070. $documentation: "Base class for “exits” (`return` and `throw`)",
  4071. $propdoc: {
  4072. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  4073. },
  4074. _walk: function(visitor) {
  4075. return visitor._visit(this, this.value && function() {
  4076. this.value._walk(visitor);
  4077. });
  4078. },
  4079. _children_backwards(push) {
  4080. if (this.value) push(this.value);
  4081. },
  4082. }, AST_Jump);
  4083. var AST_Return = DEFNODE("Return", null, function AST_Return(props) {
  4084. if (props) {
  4085. this.value = props.value;
  4086. this.start = props.start;
  4087. this.end = props.end;
  4088. }
  4089. this.flags = 0;
  4090. }, {
  4091. $documentation: "A `return` statement"
  4092. }, AST_Exit);
  4093. var AST_Throw = DEFNODE("Throw", null, function AST_Throw(props) {
  4094. if (props) {
  4095. this.value = props.value;
  4096. this.start = props.start;
  4097. this.end = props.end;
  4098. }
  4099. this.flags = 0;
  4100. }, {
  4101. $documentation: "A `throw` statement"
  4102. }, AST_Exit);
  4103. var AST_LoopControl = DEFNODE("LoopControl", "label", function AST_LoopControl(props) {
  4104. if (props) {
  4105. this.label = props.label;
  4106. this.start = props.start;
  4107. this.end = props.end;
  4108. }
  4109. this.flags = 0;
  4110. }, {
  4111. $documentation: "Base class for loop control statements (`break` and `continue`)",
  4112. $propdoc: {
  4113. label: "[AST_LabelRef?] the label, or null if none",
  4114. },
  4115. _walk: function(visitor) {
  4116. return visitor._visit(this, this.label && function() {
  4117. this.label._walk(visitor);
  4118. });
  4119. },
  4120. _children_backwards(push) {
  4121. if (this.label) push(this.label);
  4122. },
  4123. }, AST_Jump);
  4124. var AST_Break = DEFNODE("Break", null, function AST_Break(props) {
  4125. if (props) {
  4126. this.label = props.label;
  4127. this.start = props.start;
  4128. this.end = props.end;
  4129. }
  4130. this.flags = 0;
  4131. }, {
  4132. $documentation: "A `break` statement"
  4133. }, AST_LoopControl);
  4134. var AST_Continue = DEFNODE("Continue", null, function AST_Continue(props) {
  4135. if (props) {
  4136. this.label = props.label;
  4137. this.start = props.start;
  4138. this.end = props.end;
  4139. }
  4140. this.flags = 0;
  4141. }, {
  4142. $documentation: "A `continue` statement"
  4143. }, AST_LoopControl);
  4144. var AST_Await = DEFNODE("Await", "expression", function AST_Await(props) {
  4145. if (props) {
  4146. this.expression = props.expression;
  4147. this.start = props.start;
  4148. this.end = props.end;
  4149. }
  4150. this.flags = 0;
  4151. }, {
  4152. $documentation: "An `await` statement",
  4153. $propdoc: {
  4154. expression: "[AST_Node] the mandatory expression being awaited",
  4155. },
  4156. _walk: function(visitor) {
  4157. return visitor._visit(this, function() {
  4158. this.expression._walk(visitor);
  4159. });
  4160. },
  4161. _children_backwards(push) {
  4162. push(this.expression);
  4163. },
  4164. });
  4165. var AST_Yield = DEFNODE("Yield", "expression is_star", function AST_Yield(props) {
  4166. if (props) {
  4167. this.expression = props.expression;
  4168. this.is_star = props.is_star;
  4169. this.start = props.start;
  4170. this.end = props.end;
  4171. }
  4172. this.flags = 0;
  4173. }, {
  4174. $documentation: "A `yield` statement",
  4175. $propdoc: {
  4176. 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",
  4177. is_star: "[Boolean] Whether this is a yield or yield* statement"
  4178. },
  4179. _walk: function(visitor) {
  4180. return visitor._visit(this, this.expression && function() {
  4181. this.expression._walk(visitor);
  4182. });
  4183. },
  4184. _children_backwards(push) {
  4185. if (this.expression) push(this.expression);
  4186. }
  4187. });
  4188. /* -----[ IF ]----- */
  4189. var AST_If = DEFNODE("If", "condition alternative", function AST_If(props) {
  4190. if (props) {
  4191. this.condition = props.condition;
  4192. this.alternative = props.alternative;
  4193. this.body = props.body;
  4194. this.start = props.start;
  4195. this.end = props.end;
  4196. }
  4197. this.flags = 0;
  4198. }, {
  4199. $documentation: "A `if` statement",
  4200. $propdoc: {
  4201. condition: "[AST_Node] the `if` condition",
  4202. alternative: "[AST_Statement?] the `else` part, or null if not present"
  4203. },
  4204. _walk: function(visitor) {
  4205. return visitor._visit(this, function() {
  4206. this.condition._walk(visitor);
  4207. this.body._walk(visitor);
  4208. if (this.alternative) this.alternative._walk(visitor);
  4209. });
  4210. },
  4211. _children_backwards(push) {
  4212. if (this.alternative) {
  4213. push(this.alternative);
  4214. }
  4215. push(this.body);
  4216. push(this.condition);
  4217. }
  4218. }, AST_StatementWithBody);
  4219. /* -----[ SWITCH ]----- */
  4220. var AST_Switch = DEFNODE("Switch", "expression", function AST_Switch(props) {
  4221. if (props) {
  4222. this.expression = props.expression;
  4223. this.body = props.body;
  4224. this.block_scope = props.block_scope;
  4225. this.start = props.start;
  4226. this.end = props.end;
  4227. }
  4228. this.flags = 0;
  4229. }, {
  4230. $documentation: "A `switch` statement",
  4231. $propdoc: {
  4232. expression: "[AST_Node] the `switch` “discriminant”"
  4233. },
  4234. _walk: function(visitor) {
  4235. return visitor._visit(this, function() {
  4236. this.expression._walk(visitor);
  4237. walk_body(this, visitor);
  4238. });
  4239. },
  4240. _children_backwards(push) {
  4241. let i = this.body.length;
  4242. while (i--) push(this.body[i]);
  4243. push(this.expression);
  4244. }
  4245. }, AST_Block);
  4246. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, function AST_SwitchBranch(props) {
  4247. if (props) {
  4248. this.body = props.body;
  4249. this.block_scope = props.block_scope;
  4250. this.start = props.start;
  4251. this.end = props.end;
  4252. }
  4253. this.flags = 0;
  4254. }, {
  4255. $documentation: "Base class for `switch` branches",
  4256. }, AST_Block);
  4257. var AST_Default = DEFNODE("Default", null, function AST_Default(props) {
  4258. if (props) {
  4259. this.body = props.body;
  4260. this.block_scope = props.block_scope;
  4261. this.start = props.start;
  4262. this.end = props.end;
  4263. }
  4264. this.flags = 0;
  4265. }, {
  4266. $documentation: "A `default` switch branch",
  4267. }, AST_SwitchBranch);
  4268. var AST_Case = DEFNODE("Case", "expression", function AST_Case(props) {
  4269. if (props) {
  4270. this.expression = props.expression;
  4271. this.body = props.body;
  4272. this.block_scope = props.block_scope;
  4273. this.start = props.start;
  4274. this.end = props.end;
  4275. }
  4276. this.flags = 0;
  4277. }, {
  4278. $documentation: "A `case` switch branch",
  4279. $propdoc: {
  4280. expression: "[AST_Node] the `case` expression"
  4281. },
  4282. _walk: function(visitor) {
  4283. return visitor._visit(this, function() {
  4284. this.expression._walk(visitor);
  4285. walk_body(this, visitor);
  4286. });
  4287. },
  4288. _children_backwards(push) {
  4289. let i = this.body.length;
  4290. while (i--) push(this.body[i]);
  4291. push(this.expression);
  4292. },
  4293. }, AST_SwitchBranch);
  4294. /* -----[ EXCEPTIONS ]----- */
  4295. var AST_Try = DEFNODE("Try", "bcatch bfinally", function AST_Try(props) {
  4296. if (props) {
  4297. this.bcatch = props.bcatch;
  4298. this.bfinally = props.bfinally;
  4299. this.body = props.body;
  4300. this.block_scope = props.block_scope;
  4301. this.start = props.start;
  4302. this.end = props.end;
  4303. }
  4304. this.flags = 0;
  4305. }, {
  4306. $documentation: "A `try` statement",
  4307. $propdoc: {
  4308. bcatch: "[AST_Catch?] the catch block, or null if not present",
  4309. bfinally: "[AST_Finally?] the finally block, or null if not present"
  4310. },
  4311. _walk: function(visitor) {
  4312. return visitor._visit(this, function() {
  4313. walk_body(this, visitor);
  4314. if (this.bcatch) this.bcatch._walk(visitor);
  4315. if (this.bfinally) this.bfinally._walk(visitor);
  4316. });
  4317. },
  4318. _children_backwards(push) {
  4319. if (this.bfinally) push(this.bfinally);
  4320. if (this.bcatch) push(this.bcatch);
  4321. let i = this.body.length;
  4322. while (i--) push(this.body[i]);
  4323. },
  4324. }, AST_Block);
  4325. var AST_Catch = DEFNODE("Catch", "argname", function AST_Catch(props) {
  4326. if (props) {
  4327. this.argname = props.argname;
  4328. this.body = props.body;
  4329. this.block_scope = props.block_scope;
  4330. this.start = props.start;
  4331. this.end = props.end;
  4332. }
  4333. this.flags = 0;
  4334. }, {
  4335. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  4336. $propdoc: {
  4337. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  4338. },
  4339. _walk: function(visitor) {
  4340. return visitor._visit(this, function() {
  4341. if (this.argname) this.argname._walk(visitor);
  4342. walk_body(this, visitor);
  4343. });
  4344. },
  4345. _children_backwards(push) {
  4346. let i = this.body.length;
  4347. while (i--) push(this.body[i]);
  4348. if (this.argname) push(this.argname);
  4349. },
  4350. }, AST_Block);
  4351. var AST_Finally = DEFNODE("Finally", null, function AST_Finally(props) {
  4352. if (props) {
  4353. this.body = props.body;
  4354. this.block_scope = props.block_scope;
  4355. this.start = props.start;
  4356. this.end = props.end;
  4357. }
  4358. this.flags = 0;
  4359. }, {
  4360. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  4361. }, AST_Block);
  4362. /* -----[ VAR/CONST ]----- */
  4363. var AST_Definitions = DEFNODE("Definitions", "definitions", function AST_Definitions(props) {
  4364. if (props) {
  4365. this.definitions = props.definitions;
  4366. this.start = props.start;
  4367. this.end = props.end;
  4368. }
  4369. this.flags = 0;
  4370. }, {
  4371. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  4372. $propdoc: {
  4373. definitions: "[AST_VarDef*] array of variable definitions"
  4374. },
  4375. _walk: function(visitor) {
  4376. return visitor._visit(this, function() {
  4377. var definitions = this.definitions;
  4378. for (var i = 0, len = definitions.length; i < len; i++) {
  4379. definitions[i]._walk(visitor);
  4380. }
  4381. });
  4382. },
  4383. _children_backwards(push) {
  4384. let i = this.definitions.length;
  4385. while (i--) push(this.definitions[i]);
  4386. },
  4387. }, AST_Statement);
  4388. var AST_Var = DEFNODE("Var", null, function AST_Var(props) {
  4389. if (props) {
  4390. this.definitions = props.definitions;
  4391. this.start = props.start;
  4392. this.end = props.end;
  4393. }
  4394. this.flags = 0;
  4395. }, {
  4396. $documentation: "A `var` statement"
  4397. }, AST_Definitions);
  4398. var AST_Let = DEFNODE("Let", null, function AST_Let(props) {
  4399. if (props) {
  4400. this.definitions = props.definitions;
  4401. this.start = props.start;
  4402. this.end = props.end;
  4403. }
  4404. this.flags = 0;
  4405. }, {
  4406. $documentation: "A `let` statement"
  4407. }, AST_Definitions);
  4408. var AST_Const = DEFNODE("Const", null, function AST_Const(props) {
  4409. if (props) {
  4410. this.definitions = props.definitions;
  4411. this.start = props.start;
  4412. this.end = props.end;
  4413. }
  4414. this.flags = 0;
  4415. }, {
  4416. $documentation: "A `const` statement"
  4417. }, AST_Definitions);
  4418. var AST_VarDef = DEFNODE("VarDef", "name value", function AST_VarDef(props) {
  4419. if (props) {
  4420. this.name = props.name;
  4421. this.value = props.value;
  4422. this.start = props.start;
  4423. this.end = props.end;
  4424. }
  4425. this.flags = 0;
  4426. }, {
  4427. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  4428. $propdoc: {
  4429. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  4430. value: "[AST_Node?] initializer, or null of there's no initializer"
  4431. },
  4432. _walk: function(visitor) {
  4433. return visitor._visit(this, function() {
  4434. this.name._walk(visitor);
  4435. if (this.value) this.value._walk(visitor);
  4436. });
  4437. },
  4438. _children_backwards(push) {
  4439. if (this.value) push(this.value);
  4440. push(this.name);
  4441. },
  4442. });
  4443. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", function AST_NameMapping(props) {
  4444. if (props) {
  4445. this.foreign_name = props.foreign_name;
  4446. this.name = props.name;
  4447. this.start = props.start;
  4448. this.end = props.end;
  4449. }
  4450. this.flags = 0;
  4451. }, {
  4452. $documentation: "The part of the export/import statement that declare names from a module.",
  4453. $propdoc: {
  4454. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  4455. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  4456. },
  4457. _walk: function (visitor) {
  4458. return visitor._visit(this, function() {
  4459. this.foreign_name._walk(visitor);
  4460. this.name._walk(visitor);
  4461. });
  4462. },
  4463. _children_backwards(push) {
  4464. push(this.name);
  4465. push(this.foreign_name);
  4466. },
  4467. });
  4468. var AST_Import = DEFNODE(
  4469. "Import",
  4470. "imported_name imported_names module_name assert_clause",
  4471. function AST_Import(props) {
  4472. if (props) {
  4473. this.imported_name = props.imported_name;
  4474. this.imported_names = props.imported_names;
  4475. this.module_name = props.module_name;
  4476. this.assert_clause = props.assert_clause;
  4477. this.start = props.start;
  4478. this.end = props.end;
  4479. }
  4480. this.flags = 0;
  4481. },
  4482. {
  4483. $documentation: "An `import` statement",
  4484. $propdoc: {
  4485. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  4486. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  4487. module_name: "[AST_String] String literal describing where this module came from",
  4488. assert_clause: "[AST_Object?] The import assertion"
  4489. },
  4490. _walk: function(visitor) {
  4491. return visitor._visit(this, function() {
  4492. if (this.imported_name) {
  4493. this.imported_name._walk(visitor);
  4494. }
  4495. if (this.imported_names) {
  4496. this.imported_names.forEach(function(name_import) {
  4497. name_import._walk(visitor);
  4498. });
  4499. }
  4500. this.module_name._walk(visitor);
  4501. });
  4502. },
  4503. _children_backwards(push) {
  4504. push(this.module_name);
  4505. if (this.imported_names) {
  4506. let i = this.imported_names.length;
  4507. while (i--) push(this.imported_names[i]);
  4508. }
  4509. if (this.imported_name) push(this.imported_name);
  4510. },
  4511. }
  4512. );
  4513. var AST_ImportMeta = DEFNODE("ImportMeta", null, function AST_ImportMeta(props) {
  4514. if (props) {
  4515. this.start = props.start;
  4516. this.end = props.end;
  4517. }
  4518. this.flags = 0;
  4519. }, {
  4520. $documentation: "A reference to import.meta",
  4521. });
  4522. var AST_Export = DEFNODE(
  4523. "Export",
  4524. "exported_definition exported_value is_default exported_names module_name assert_clause",
  4525. function AST_Export(props) {
  4526. if (props) {
  4527. this.exported_definition = props.exported_definition;
  4528. this.exported_value = props.exported_value;
  4529. this.is_default = props.is_default;
  4530. this.exported_names = props.exported_names;
  4531. this.module_name = props.module_name;
  4532. this.assert_clause = props.assert_clause;
  4533. this.start = props.start;
  4534. this.end = props.end;
  4535. }
  4536. this.flags = 0;
  4537. },
  4538. {
  4539. $documentation: "An `export` statement",
  4540. $propdoc: {
  4541. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  4542. exported_value: "[AST_Node?] An exported value",
  4543. exported_names: "[AST_NameMapping*?] List of exported names",
  4544. module_name: "[AST_String?] Name of the file to load exports from",
  4545. is_default: "[Boolean] Whether this is the default exported value of this module",
  4546. assert_clause: "[AST_Object?] The import assertion"
  4547. },
  4548. _walk: function (visitor) {
  4549. return visitor._visit(this, function () {
  4550. if (this.exported_definition) {
  4551. this.exported_definition._walk(visitor);
  4552. }
  4553. if (this.exported_value) {
  4554. this.exported_value._walk(visitor);
  4555. }
  4556. if (this.exported_names) {
  4557. this.exported_names.forEach(function(name_export) {
  4558. name_export._walk(visitor);
  4559. });
  4560. }
  4561. if (this.module_name) {
  4562. this.module_name._walk(visitor);
  4563. }
  4564. });
  4565. },
  4566. _children_backwards(push) {
  4567. if (this.module_name) push(this.module_name);
  4568. if (this.exported_names) {
  4569. let i = this.exported_names.length;
  4570. while (i--) push(this.exported_names[i]);
  4571. }
  4572. if (this.exported_value) push(this.exported_value);
  4573. if (this.exported_definition) push(this.exported_definition);
  4574. }
  4575. },
  4576. AST_Statement
  4577. );
  4578. /* -----[ OTHER ]----- */
  4579. var AST_Call = DEFNODE(
  4580. "Call",
  4581. "expression args optional _annotations",
  4582. function AST_Call(props) {
  4583. if (props) {
  4584. this.expression = props.expression;
  4585. this.args = props.args;
  4586. this.optional = props.optional;
  4587. this._annotations = props._annotations;
  4588. this.start = props.start;
  4589. this.end = props.end;
  4590. this.initialize();
  4591. }
  4592. this.flags = 0;
  4593. },
  4594. {
  4595. $documentation: "A function call expression",
  4596. $propdoc: {
  4597. expression: "[AST_Node] expression to invoke as function",
  4598. args: "[AST_Node*] array of arguments",
  4599. optional: "[boolean] whether this is an optional call (IE ?.() )",
  4600. _annotations: "[number] bitfield containing information about the call"
  4601. },
  4602. initialize() {
  4603. if (this._annotations == null) this._annotations = 0;
  4604. },
  4605. _walk(visitor) {
  4606. return visitor._visit(this, function() {
  4607. var args = this.args;
  4608. for (var i = 0, len = args.length; i < len; i++) {
  4609. args[i]._walk(visitor);
  4610. }
  4611. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  4612. });
  4613. },
  4614. _children_backwards(push) {
  4615. let i = this.args.length;
  4616. while (i--) push(this.args[i]);
  4617. push(this.expression);
  4618. },
  4619. }
  4620. );
  4621. var AST_New = DEFNODE("New", null, function AST_New(props) {
  4622. if (props) {
  4623. this.expression = props.expression;
  4624. this.args = props.args;
  4625. this.optional = props.optional;
  4626. this._annotations = props._annotations;
  4627. this.start = props.start;
  4628. this.end = props.end;
  4629. this.initialize();
  4630. }
  4631. this.flags = 0;
  4632. }, {
  4633. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  4634. }, AST_Call);
  4635. var AST_Sequence = DEFNODE("Sequence", "expressions", function AST_Sequence(props) {
  4636. if (props) {
  4637. this.expressions = props.expressions;
  4638. this.start = props.start;
  4639. this.end = props.end;
  4640. }
  4641. this.flags = 0;
  4642. }, {
  4643. $documentation: "A sequence expression (comma-separated expressions)",
  4644. $propdoc: {
  4645. expressions: "[AST_Node*] array of expressions (at least two)"
  4646. },
  4647. _walk: function(visitor) {
  4648. return visitor._visit(this, function() {
  4649. this.expressions.forEach(function(node) {
  4650. node._walk(visitor);
  4651. });
  4652. });
  4653. },
  4654. _children_backwards(push) {
  4655. let i = this.expressions.length;
  4656. while (i--) push(this.expressions[i]);
  4657. },
  4658. });
  4659. var AST_PropAccess = DEFNODE(
  4660. "PropAccess",
  4661. "expression property optional",
  4662. function AST_PropAccess(props) {
  4663. if (props) {
  4664. this.expression = props.expression;
  4665. this.property = props.property;
  4666. this.optional = props.optional;
  4667. this.start = props.start;
  4668. this.end = props.end;
  4669. }
  4670. this.flags = 0;
  4671. },
  4672. {
  4673. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  4674. $propdoc: {
  4675. expression: "[AST_Node] the “container” expression",
  4676. 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",
  4677. optional: "[boolean] whether this is an optional property access (IE ?.)"
  4678. }
  4679. }
  4680. );
  4681. var AST_Dot = DEFNODE("Dot", "quote", function AST_Dot(props) {
  4682. if (props) {
  4683. this.quote = props.quote;
  4684. this.expression = props.expression;
  4685. this.property = props.property;
  4686. this.optional = props.optional;
  4687. this.start = props.start;
  4688. this.end = props.end;
  4689. }
  4690. this.flags = 0;
  4691. }, {
  4692. $documentation: "A dotted property access expression",
  4693. $propdoc: {
  4694. quote: "[string] the original quote character when transformed from AST_Sub",
  4695. },
  4696. _walk: function(visitor) {
  4697. return visitor._visit(this, function() {
  4698. this.expression._walk(visitor);
  4699. });
  4700. },
  4701. _children_backwards(push) {
  4702. push(this.expression);
  4703. },
  4704. }, AST_PropAccess);
  4705. var AST_DotHash = DEFNODE("DotHash", "", function AST_DotHash(props) {
  4706. if (props) {
  4707. this.expression = props.expression;
  4708. this.property = props.property;
  4709. this.optional = props.optional;
  4710. this.start = props.start;
  4711. this.end = props.end;
  4712. }
  4713. this.flags = 0;
  4714. }, {
  4715. $documentation: "A dotted property access to a private property",
  4716. _walk: function(visitor) {
  4717. return visitor._visit(this, function() {
  4718. this.expression._walk(visitor);
  4719. });
  4720. },
  4721. _children_backwards(push) {
  4722. push(this.expression);
  4723. },
  4724. }, AST_PropAccess);
  4725. var AST_Sub = DEFNODE("Sub", null, function AST_Sub(props) {
  4726. if (props) {
  4727. this.expression = props.expression;
  4728. this.property = props.property;
  4729. this.optional = props.optional;
  4730. this.start = props.start;
  4731. this.end = props.end;
  4732. }
  4733. this.flags = 0;
  4734. }, {
  4735. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4736. _walk: function(visitor) {
  4737. return visitor._visit(this, function() {
  4738. this.expression._walk(visitor);
  4739. this.property._walk(visitor);
  4740. });
  4741. },
  4742. _children_backwards(push) {
  4743. push(this.property);
  4744. push(this.expression);
  4745. },
  4746. }, AST_PropAccess);
  4747. var AST_Chain = DEFNODE("Chain", "expression", function AST_Chain(props) {
  4748. if (props) {
  4749. this.expression = props.expression;
  4750. this.start = props.start;
  4751. this.end = props.end;
  4752. }
  4753. this.flags = 0;
  4754. }, {
  4755. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4756. $propdoc: {
  4757. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  4758. },
  4759. _walk: function (visitor) {
  4760. return visitor._visit(this, function() {
  4761. this.expression._walk(visitor);
  4762. });
  4763. },
  4764. _children_backwards(push) {
  4765. push(this.expression);
  4766. },
  4767. });
  4768. var AST_Unary = DEFNODE("Unary", "operator expression", function AST_Unary(props) {
  4769. if (props) {
  4770. this.operator = props.operator;
  4771. this.expression = props.expression;
  4772. this.start = props.start;
  4773. this.end = props.end;
  4774. }
  4775. this.flags = 0;
  4776. }, {
  4777. $documentation: "Base class for unary expressions",
  4778. $propdoc: {
  4779. operator: "[string] the operator",
  4780. expression: "[AST_Node] expression that this unary operator applies to"
  4781. },
  4782. _walk: function(visitor) {
  4783. return visitor._visit(this, function() {
  4784. this.expression._walk(visitor);
  4785. });
  4786. },
  4787. _children_backwards(push) {
  4788. push(this.expression);
  4789. },
  4790. });
  4791. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, function AST_UnaryPrefix(props) {
  4792. if (props) {
  4793. this.operator = props.operator;
  4794. this.expression = props.expression;
  4795. this.start = props.start;
  4796. this.end = props.end;
  4797. }
  4798. this.flags = 0;
  4799. }, {
  4800. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4801. }, AST_Unary);
  4802. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, function AST_UnaryPostfix(props) {
  4803. if (props) {
  4804. this.operator = props.operator;
  4805. this.expression = props.expression;
  4806. this.start = props.start;
  4807. this.end = props.end;
  4808. }
  4809. this.flags = 0;
  4810. }, {
  4811. $documentation: "Unary postfix expression, i.e. `i++`"
  4812. }, AST_Unary);
  4813. var AST_Binary = DEFNODE("Binary", "operator left right", function AST_Binary(props) {
  4814. if (props) {
  4815. this.operator = props.operator;
  4816. this.left = props.left;
  4817. this.right = props.right;
  4818. this.start = props.start;
  4819. this.end = props.end;
  4820. }
  4821. this.flags = 0;
  4822. }, {
  4823. $documentation: "Binary expression, i.e. `a + b`",
  4824. $propdoc: {
  4825. left: "[AST_Node] left-hand side expression",
  4826. operator: "[string] the operator",
  4827. right: "[AST_Node] right-hand side expression"
  4828. },
  4829. _walk: function(visitor) {
  4830. return visitor._visit(this, function() {
  4831. this.left._walk(visitor);
  4832. this.right._walk(visitor);
  4833. });
  4834. },
  4835. _children_backwards(push) {
  4836. push(this.right);
  4837. push(this.left);
  4838. },
  4839. });
  4840. var AST_Conditional = DEFNODE(
  4841. "Conditional",
  4842. "condition consequent alternative",
  4843. function AST_Conditional(props) {
  4844. if (props) {
  4845. this.condition = props.condition;
  4846. this.consequent = props.consequent;
  4847. this.alternative = props.alternative;
  4848. this.start = props.start;
  4849. this.end = props.end;
  4850. }
  4851. this.flags = 0;
  4852. },
  4853. {
  4854. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  4855. $propdoc: {
  4856. condition: "[AST_Node]",
  4857. consequent: "[AST_Node]",
  4858. alternative: "[AST_Node]"
  4859. },
  4860. _walk: function(visitor) {
  4861. return visitor._visit(this, function() {
  4862. this.condition._walk(visitor);
  4863. this.consequent._walk(visitor);
  4864. this.alternative._walk(visitor);
  4865. });
  4866. },
  4867. _children_backwards(push) {
  4868. push(this.alternative);
  4869. push(this.consequent);
  4870. push(this.condition);
  4871. },
  4872. }
  4873. );
  4874. var AST_Assign = DEFNODE("Assign", "logical", function AST_Assign(props) {
  4875. if (props) {
  4876. this.logical = props.logical;
  4877. this.operator = props.operator;
  4878. this.left = props.left;
  4879. this.right = props.right;
  4880. this.start = props.start;
  4881. this.end = props.end;
  4882. }
  4883. this.flags = 0;
  4884. }, {
  4885. $documentation: "An assignment expression — `a = b + 5`",
  4886. $propdoc: {
  4887. logical: "Whether it's a logical assignment"
  4888. }
  4889. }, AST_Binary);
  4890. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, function AST_DefaultAssign(props) {
  4891. if (props) {
  4892. this.operator = props.operator;
  4893. this.left = props.left;
  4894. this.right = props.right;
  4895. this.start = props.start;
  4896. this.end = props.end;
  4897. }
  4898. this.flags = 0;
  4899. }, {
  4900. $documentation: "A default assignment expression like in `(a = 3) => a`"
  4901. }, AST_Binary);
  4902. /* -----[ LITERALS ]----- */
  4903. var AST_Array = DEFNODE("Array", "elements", function AST_Array(props) {
  4904. if (props) {
  4905. this.elements = props.elements;
  4906. this.start = props.start;
  4907. this.end = props.end;
  4908. }
  4909. this.flags = 0;
  4910. }, {
  4911. $documentation: "An array literal",
  4912. $propdoc: {
  4913. elements: "[AST_Node*] array of elements"
  4914. },
  4915. _walk: function(visitor) {
  4916. return visitor._visit(this, function() {
  4917. var elements = this.elements;
  4918. for (var i = 0, len = elements.length; i < len; i++) {
  4919. elements[i]._walk(visitor);
  4920. }
  4921. });
  4922. },
  4923. _children_backwards(push) {
  4924. let i = this.elements.length;
  4925. while (i--) push(this.elements[i]);
  4926. },
  4927. });
  4928. var AST_Object = DEFNODE("Object", "properties", function AST_Object(props) {
  4929. if (props) {
  4930. this.properties = props.properties;
  4931. this.start = props.start;
  4932. this.end = props.end;
  4933. }
  4934. this.flags = 0;
  4935. }, {
  4936. $documentation: "An object literal",
  4937. $propdoc: {
  4938. properties: "[AST_ObjectProperty*] array of properties"
  4939. },
  4940. _walk: function(visitor) {
  4941. return visitor._visit(this, function() {
  4942. var properties = this.properties;
  4943. for (var i = 0, len = properties.length; i < len; i++) {
  4944. properties[i]._walk(visitor);
  4945. }
  4946. });
  4947. },
  4948. _children_backwards(push) {
  4949. let i = this.properties.length;
  4950. while (i--) push(this.properties[i]);
  4951. },
  4952. });
  4953. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", function AST_ObjectProperty(props) {
  4954. if (props) {
  4955. this.key = props.key;
  4956. this.value = props.value;
  4957. this.start = props.start;
  4958. this.end = props.end;
  4959. }
  4960. this.flags = 0;
  4961. }, {
  4962. $documentation: "Base class for literal object properties",
  4963. $propdoc: {
  4964. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  4965. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  4966. },
  4967. _walk: function(visitor) {
  4968. return visitor._visit(this, function() {
  4969. if (this.key instanceof AST_Node)
  4970. this.key._walk(visitor);
  4971. this.value._walk(visitor);
  4972. });
  4973. },
  4974. _children_backwards(push) {
  4975. push(this.value);
  4976. if (this.key instanceof AST_Node) push(this.key);
  4977. }
  4978. });
  4979. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", function AST_ObjectKeyVal(props) {
  4980. if (props) {
  4981. this.quote = props.quote;
  4982. this.key = props.key;
  4983. this.value = props.value;
  4984. this.start = props.start;
  4985. this.end = props.end;
  4986. }
  4987. this.flags = 0;
  4988. }, {
  4989. $documentation: "A key: value object property",
  4990. $propdoc: {
  4991. quote: "[string] the original quote character"
  4992. },
  4993. computed_key() {
  4994. return this.key instanceof AST_Node;
  4995. }
  4996. }, AST_ObjectProperty);
  4997. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", function AST_PrivateSetter(props) {
  4998. if (props) {
  4999. this.static = props.static;
  5000. this.key = props.key;
  5001. this.value = props.value;
  5002. this.start = props.start;
  5003. this.end = props.end;
  5004. }
  5005. this.flags = 0;
  5006. }, {
  5007. $propdoc: {
  5008. static: "[boolean] whether this is a static private setter"
  5009. },
  5010. $documentation: "A private setter property",
  5011. computed_key() {
  5012. return false;
  5013. }
  5014. }, AST_ObjectProperty);
  5015. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", function AST_PrivateGetter(props) {
  5016. if (props) {
  5017. this.static = props.static;
  5018. this.key = props.key;
  5019. this.value = props.value;
  5020. this.start = props.start;
  5021. this.end = props.end;
  5022. }
  5023. this.flags = 0;
  5024. }, {
  5025. $propdoc: {
  5026. static: "[boolean] whether this is a static private getter"
  5027. },
  5028. $documentation: "A private getter property",
  5029. computed_key() {
  5030. return false;
  5031. }
  5032. }, AST_ObjectProperty);
  5033. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", function AST_ObjectSetter(props) {
  5034. if (props) {
  5035. this.quote = props.quote;
  5036. this.static = props.static;
  5037. this.key = props.key;
  5038. this.value = props.value;
  5039. this.start = props.start;
  5040. this.end = props.end;
  5041. }
  5042. this.flags = 0;
  5043. }, {
  5044. $propdoc: {
  5045. quote: "[string|undefined] the original quote character, if any",
  5046. static: "[boolean] whether this is a static setter (classes only)"
  5047. },
  5048. $documentation: "An object setter property",
  5049. computed_key() {
  5050. return !(this.key instanceof AST_SymbolMethod);
  5051. }
  5052. }, AST_ObjectProperty);
  5053. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", function AST_ObjectGetter(props) {
  5054. if (props) {
  5055. this.quote = props.quote;
  5056. this.static = props.static;
  5057. this.key = props.key;
  5058. this.value = props.value;
  5059. this.start = props.start;
  5060. this.end = props.end;
  5061. }
  5062. this.flags = 0;
  5063. }, {
  5064. $propdoc: {
  5065. quote: "[string|undefined] the original quote character, if any",
  5066. static: "[boolean] whether this is a static getter (classes only)"
  5067. },
  5068. $documentation: "An object getter property",
  5069. computed_key() {
  5070. return !(this.key instanceof AST_SymbolMethod);
  5071. }
  5072. }, AST_ObjectProperty);
  5073. var AST_ConciseMethod = DEFNODE(
  5074. "ConciseMethod",
  5075. "quote static is_generator async",
  5076. function AST_ConciseMethod(props) {
  5077. if (props) {
  5078. this.quote = props.quote;
  5079. this.static = props.static;
  5080. this.is_generator = props.is_generator;
  5081. this.async = props.async;
  5082. this.key = props.key;
  5083. this.value = props.value;
  5084. this.start = props.start;
  5085. this.end = props.end;
  5086. }
  5087. this.flags = 0;
  5088. },
  5089. {
  5090. $propdoc: {
  5091. quote: "[string|undefined] the original quote character, if any",
  5092. static: "[boolean] is this method static (classes only)",
  5093. is_generator: "[boolean] is this a generator method",
  5094. async: "[boolean] is this method async",
  5095. },
  5096. $documentation: "An ES6 concise method inside an object or class",
  5097. computed_key() {
  5098. return !(this.key instanceof AST_SymbolMethod);
  5099. }
  5100. },
  5101. AST_ObjectProperty
  5102. );
  5103. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", function AST_PrivateMethod(props) {
  5104. if (props) {
  5105. this.quote = props.quote;
  5106. this.static = props.static;
  5107. this.is_generator = props.is_generator;
  5108. this.async = props.async;
  5109. this.key = props.key;
  5110. this.value = props.value;
  5111. this.start = props.start;
  5112. this.end = props.end;
  5113. }
  5114. this.flags = 0;
  5115. }, {
  5116. $documentation: "A private class method inside a class",
  5117. }, AST_ConciseMethod);
  5118. var AST_Class = DEFNODE("Class", "name extends properties", function AST_Class(props) {
  5119. if (props) {
  5120. this.name = props.name;
  5121. this.extends = props.extends;
  5122. this.properties = props.properties;
  5123. this.variables = props.variables;
  5124. this.functions = props.functions;
  5125. this.uses_with = props.uses_with;
  5126. this.uses_eval = props.uses_eval;
  5127. this.parent_scope = props.parent_scope;
  5128. this.enclosed = props.enclosed;
  5129. this.cname = props.cname;
  5130. this.body = props.body;
  5131. this.block_scope = props.block_scope;
  5132. this.start = props.start;
  5133. this.end = props.end;
  5134. }
  5135. this.flags = 0;
  5136. }, {
  5137. $propdoc: {
  5138. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  5139. extends: "[AST_Node]? optional parent class",
  5140. properties: "[AST_ObjectProperty*] array of properties"
  5141. },
  5142. $documentation: "An ES6 class",
  5143. _walk: function(visitor) {
  5144. return visitor._visit(this, function() {
  5145. if (this.name) {
  5146. this.name._walk(visitor);
  5147. }
  5148. if (this.extends) {
  5149. this.extends._walk(visitor);
  5150. }
  5151. this.properties.forEach((prop) => prop._walk(visitor));
  5152. });
  5153. },
  5154. _children_backwards(push) {
  5155. let i = this.properties.length;
  5156. while (i--) push(this.properties[i]);
  5157. if (this.extends) push(this.extends);
  5158. if (this.name) push(this.name);
  5159. },
  5160. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  5161. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", function AST_ClassProperty(props) {
  5162. if (props) {
  5163. this.static = props.static;
  5164. this.quote = props.quote;
  5165. this.key = props.key;
  5166. this.value = props.value;
  5167. this.start = props.start;
  5168. this.end = props.end;
  5169. }
  5170. this.flags = 0;
  5171. }, {
  5172. $documentation: "A class property",
  5173. $propdoc: {
  5174. static: "[boolean] whether this is a static key",
  5175. quote: "[string] which quote is being used"
  5176. },
  5177. _walk: function(visitor) {
  5178. return visitor._visit(this, function() {
  5179. if (this.key instanceof AST_Node)
  5180. this.key._walk(visitor);
  5181. if (this.value instanceof AST_Node)
  5182. this.value._walk(visitor);
  5183. });
  5184. },
  5185. _children_backwards(push) {
  5186. if (this.value instanceof AST_Node) push(this.value);
  5187. if (this.key instanceof AST_Node) push(this.key);
  5188. },
  5189. computed_key() {
  5190. return !(this.key instanceof AST_SymbolClassProperty);
  5191. }
  5192. }, AST_ObjectProperty);
  5193. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", function AST_ClassPrivateProperty(props) {
  5194. if (props) {
  5195. this.static = props.static;
  5196. this.quote = props.quote;
  5197. this.key = props.key;
  5198. this.value = props.value;
  5199. this.start = props.start;
  5200. this.end = props.end;
  5201. }
  5202. this.flags = 0;
  5203. }, {
  5204. $documentation: "A class property for a private property",
  5205. }, AST_ClassProperty);
  5206. var AST_DefClass = DEFNODE("DefClass", null, function AST_DefClass(props) {
  5207. if (props) {
  5208. this.name = props.name;
  5209. this.extends = props.extends;
  5210. this.properties = props.properties;
  5211. this.variables = props.variables;
  5212. this.functions = props.functions;
  5213. this.uses_with = props.uses_with;
  5214. this.uses_eval = props.uses_eval;
  5215. this.parent_scope = props.parent_scope;
  5216. this.enclosed = props.enclosed;
  5217. this.cname = props.cname;
  5218. this.body = props.body;
  5219. this.block_scope = props.block_scope;
  5220. this.start = props.start;
  5221. this.end = props.end;
  5222. }
  5223. this.flags = 0;
  5224. }, {
  5225. $documentation: "A class definition",
  5226. }, AST_Class);
  5227. var AST_ClassExpression = DEFNODE("ClassExpression", null, function AST_ClassExpression(props) {
  5228. if (props) {
  5229. this.name = props.name;
  5230. this.extends = props.extends;
  5231. this.properties = props.properties;
  5232. this.variables = props.variables;
  5233. this.functions = props.functions;
  5234. this.uses_with = props.uses_with;
  5235. this.uses_eval = props.uses_eval;
  5236. this.parent_scope = props.parent_scope;
  5237. this.enclosed = props.enclosed;
  5238. this.cname = props.cname;
  5239. this.body = props.body;
  5240. this.block_scope = props.block_scope;
  5241. this.start = props.start;
  5242. this.end = props.end;
  5243. }
  5244. this.flags = 0;
  5245. }, {
  5246. $documentation: "A class expression."
  5247. }, AST_Class);
  5248. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", function AST_Symbol(props) {
  5249. if (props) {
  5250. this.scope = props.scope;
  5251. this.name = props.name;
  5252. this.thedef = props.thedef;
  5253. this.start = props.start;
  5254. this.end = props.end;
  5255. }
  5256. this.flags = 0;
  5257. }, {
  5258. $propdoc: {
  5259. name: "[string] name of this symbol",
  5260. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  5261. thedef: "[SymbolDef/S] the definition of this symbol"
  5262. },
  5263. $documentation: "Base class for all symbols"
  5264. });
  5265. var AST_NewTarget = DEFNODE("NewTarget", null, function AST_NewTarget(props) {
  5266. if (props) {
  5267. this.start = props.start;
  5268. this.end = props.end;
  5269. }
  5270. this.flags = 0;
  5271. }, {
  5272. $documentation: "A reference to new.target"
  5273. });
  5274. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", function AST_SymbolDeclaration(props) {
  5275. if (props) {
  5276. this.init = props.init;
  5277. this.scope = props.scope;
  5278. this.name = props.name;
  5279. this.thedef = props.thedef;
  5280. this.start = props.start;
  5281. this.end = props.end;
  5282. }
  5283. this.flags = 0;
  5284. }, {
  5285. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  5286. }, AST_Symbol);
  5287. var AST_SymbolVar = DEFNODE("SymbolVar", null, function AST_SymbolVar(props) {
  5288. if (props) {
  5289. this.init = props.init;
  5290. this.scope = props.scope;
  5291. this.name = props.name;
  5292. this.thedef = props.thedef;
  5293. this.start = props.start;
  5294. this.end = props.end;
  5295. }
  5296. this.flags = 0;
  5297. }, {
  5298. $documentation: "Symbol defining a variable",
  5299. }, AST_SymbolDeclaration);
  5300. var AST_SymbolBlockDeclaration = DEFNODE(
  5301. "SymbolBlockDeclaration",
  5302. null,
  5303. function AST_SymbolBlockDeclaration(props) {
  5304. if (props) {
  5305. this.init = props.init;
  5306. this.scope = props.scope;
  5307. this.name = props.name;
  5308. this.thedef = props.thedef;
  5309. this.start = props.start;
  5310. this.end = props.end;
  5311. }
  5312. this.flags = 0;
  5313. },
  5314. {
  5315. $documentation: "Base class for block-scoped declaration symbols"
  5316. },
  5317. AST_SymbolDeclaration
  5318. );
  5319. var AST_SymbolConst = DEFNODE("SymbolConst", null, function AST_SymbolConst(props) {
  5320. if (props) {
  5321. this.init = props.init;
  5322. this.scope = props.scope;
  5323. this.name = props.name;
  5324. this.thedef = props.thedef;
  5325. this.start = props.start;
  5326. this.end = props.end;
  5327. }
  5328. this.flags = 0;
  5329. }, {
  5330. $documentation: "A constant declaration"
  5331. }, AST_SymbolBlockDeclaration);
  5332. var AST_SymbolLet = DEFNODE("SymbolLet", null, function AST_SymbolLet(props) {
  5333. if (props) {
  5334. this.init = props.init;
  5335. this.scope = props.scope;
  5336. this.name = props.name;
  5337. this.thedef = props.thedef;
  5338. this.start = props.start;
  5339. this.end = props.end;
  5340. }
  5341. this.flags = 0;
  5342. }, {
  5343. $documentation: "A block-scoped `let` declaration"
  5344. }, AST_SymbolBlockDeclaration);
  5345. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, function AST_SymbolFunarg(props) {
  5346. if (props) {
  5347. this.init = props.init;
  5348. this.scope = props.scope;
  5349. this.name = props.name;
  5350. this.thedef = props.thedef;
  5351. this.start = props.start;
  5352. this.end = props.end;
  5353. }
  5354. this.flags = 0;
  5355. }, {
  5356. $documentation: "Symbol naming a function argument",
  5357. }, AST_SymbolVar);
  5358. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, function AST_SymbolDefun(props) {
  5359. if (props) {
  5360. this.init = props.init;
  5361. this.scope = props.scope;
  5362. this.name = props.name;
  5363. this.thedef = props.thedef;
  5364. this.start = props.start;
  5365. this.end = props.end;
  5366. }
  5367. this.flags = 0;
  5368. }, {
  5369. $documentation: "Symbol defining a function",
  5370. }, AST_SymbolDeclaration);
  5371. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, function AST_SymbolMethod(props) {
  5372. if (props) {
  5373. this.scope = props.scope;
  5374. this.name = props.name;
  5375. this.thedef = props.thedef;
  5376. this.start = props.start;
  5377. this.end = props.end;
  5378. }
  5379. this.flags = 0;
  5380. }, {
  5381. $documentation: "Symbol in an object defining a method",
  5382. }, AST_Symbol);
  5383. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, function AST_SymbolClassProperty(props) {
  5384. if (props) {
  5385. this.scope = props.scope;
  5386. this.name = props.name;
  5387. this.thedef = props.thedef;
  5388. this.start = props.start;
  5389. this.end = props.end;
  5390. }
  5391. this.flags = 0;
  5392. }, {
  5393. $documentation: "Symbol for a class property",
  5394. }, AST_Symbol);
  5395. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, function AST_SymbolLambda(props) {
  5396. if (props) {
  5397. this.init = props.init;
  5398. this.scope = props.scope;
  5399. this.name = props.name;
  5400. this.thedef = props.thedef;
  5401. this.start = props.start;
  5402. this.end = props.end;
  5403. }
  5404. this.flags = 0;
  5405. }, {
  5406. $documentation: "Symbol naming a function expression",
  5407. }, AST_SymbolDeclaration);
  5408. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, function AST_SymbolDefClass(props) {
  5409. if (props) {
  5410. this.init = props.init;
  5411. this.scope = props.scope;
  5412. this.name = props.name;
  5413. this.thedef = props.thedef;
  5414. this.start = props.start;
  5415. this.end = props.end;
  5416. }
  5417. this.flags = 0;
  5418. }, {
  5419. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  5420. }, AST_SymbolBlockDeclaration);
  5421. var AST_SymbolClass = DEFNODE("SymbolClass", null, function AST_SymbolClass(props) {
  5422. if (props) {
  5423. this.init = props.init;
  5424. this.scope = props.scope;
  5425. this.name = props.name;
  5426. this.thedef = props.thedef;
  5427. this.start = props.start;
  5428. this.end = props.end;
  5429. }
  5430. this.flags = 0;
  5431. }, {
  5432. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  5433. }, AST_SymbolDeclaration);
  5434. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, function AST_SymbolCatch(props) {
  5435. if (props) {
  5436. this.init = props.init;
  5437. this.scope = props.scope;
  5438. this.name = props.name;
  5439. this.thedef = props.thedef;
  5440. this.start = props.start;
  5441. this.end = props.end;
  5442. }
  5443. this.flags = 0;
  5444. }, {
  5445. $documentation: "Symbol naming the exception in catch",
  5446. }, AST_SymbolBlockDeclaration);
  5447. var AST_SymbolImport = DEFNODE("SymbolImport", null, function AST_SymbolImport(props) {
  5448. if (props) {
  5449. this.init = props.init;
  5450. this.scope = props.scope;
  5451. this.name = props.name;
  5452. this.thedef = props.thedef;
  5453. this.start = props.start;
  5454. this.end = props.end;
  5455. }
  5456. this.flags = 0;
  5457. }, {
  5458. $documentation: "Symbol referring to an imported name",
  5459. }, AST_SymbolBlockDeclaration);
  5460. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, function AST_SymbolImportForeign(props) {
  5461. if (props) {
  5462. this.scope = props.scope;
  5463. this.name = props.name;
  5464. this.thedef = props.thedef;
  5465. this.start = props.start;
  5466. this.end = props.end;
  5467. }
  5468. this.flags = 0;
  5469. }, {
  5470. $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",
  5471. }, AST_Symbol);
  5472. var AST_Label = DEFNODE("Label", "references", function AST_Label(props) {
  5473. if (props) {
  5474. this.references = props.references;
  5475. this.scope = props.scope;
  5476. this.name = props.name;
  5477. this.thedef = props.thedef;
  5478. this.start = props.start;
  5479. this.end = props.end;
  5480. this.initialize();
  5481. }
  5482. this.flags = 0;
  5483. }, {
  5484. $documentation: "Symbol naming a label (declaration)",
  5485. $propdoc: {
  5486. references: "[AST_LoopControl*] a list of nodes referring to this label"
  5487. },
  5488. initialize: function() {
  5489. this.references = [];
  5490. this.thedef = this;
  5491. }
  5492. }, AST_Symbol);
  5493. var AST_SymbolRef = DEFNODE("SymbolRef", null, function AST_SymbolRef(props) {
  5494. if (props) {
  5495. this.scope = props.scope;
  5496. this.name = props.name;
  5497. this.thedef = props.thedef;
  5498. this.start = props.start;
  5499. this.end = props.end;
  5500. }
  5501. this.flags = 0;
  5502. }, {
  5503. $documentation: "Reference to some symbol (not definition/declaration)",
  5504. }, AST_Symbol);
  5505. var AST_SymbolExport = DEFNODE("SymbolExport", null, function AST_SymbolExport(props) {
  5506. if (props) {
  5507. this.scope = props.scope;
  5508. this.name = props.name;
  5509. this.thedef = props.thedef;
  5510. this.start = props.start;
  5511. this.end = props.end;
  5512. }
  5513. this.flags = 0;
  5514. }, {
  5515. $documentation: "Symbol referring to a name to export",
  5516. }, AST_SymbolRef);
  5517. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, function AST_SymbolExportForeign(props) {
  5518. if (props) {
  5519. this.scope = props.scope;
  5520. this.name = props.name;
  5521. this.thedef = props.thedef;
  5522. this.start = props.start;
  5523. this.end = props.end;
  5524. }
  5525. this.flags = 0;
  5526. }, {
  5527. $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",
  5528. }, AST_Symbol);
  5529. var AST_LabelRef = DEFNODE("LabelRef", null, function AST_LabelRef(props) {
  5530. if (props) {
  5531. this.scope = props.scope;
  5532. this.name = props.name;
  5533. this.thedef = props.thedef;
  5534. this.start = props.start;
  5535. this.end = props.end;
  5536. }
  5537. this.flags = 0;
  5538. }, {
  5539. $documentation: "Reference to a label symbol",
  5540. }, AST_Symbol);
  5541. var AST_This = DEFNODE("This", null, function AST_This(props) {
  5542. if (props) {
  5543. this.scope = props.scope;
  5544. this.name = props.name;
  5545. this.thedef = props.thedef;
  5546. this.start = props.start;
  5547. this.end = props.end;
  5548. }
  5549. this.flags = 0;
  5550. }, {
  5551. $documentation: "The `this` symbol",
  5552. }, AST_Symbol);
  5553. var AST_Super = DEFNODE("Super", null, function AST_Super(props) {
  5554. if (props) {
  5555. this.scope = props.scope;
  5556. this.name = props.name;
  5557. this.thedef = props.thedef;
  5558. this.start = props.start;
  5559. this.end = props.end;
  5560. }
  5561. this.flags = 0;
  5562. }, {
  5563. $documentation: "The `super` symbol",
  5564. }, AST_This);
  5565. var AST_Constant = DEFNODE("Constant", null, function AST_Constant(props) {
  5566. if (props) {
  5567. this.start = props.start;
  5568. this.end = props.end;
  5569. }
  5570. this.flags = 0;
  5571. }, {
  5572. $documentation: "Base class for all constants",
  5573. getValue: function() {
  5574. return this.value;
  5575. }
  5576. });
  5577. var AST_String = DEFNODE("String", "value quote", function AST_String(props) {
  5578. if (props) {
  5579. this.value = props.value;
  5580. this.quote = props.quote;
  5581. this.start = props.start;
  5582. this.end = props.end;
  5583. }
  5584. this.flags = 0;
  5585. }, {
  5586. $documentation: "A string literal",
  5587. $propdoc: {
  5588. value: "[string] the contents of this string",
  5589. quote: "[string] the original quote character"
  5590. }
  5591. }, AST_Constant);
  5592. var AST_Number = DEFNODE("Number", "value raw", function AST_Number(props) {
  5593. if (props) {
  5594. this.value = props.value;
  5595. this.raw = props.raw;
  5596. this.start = props.start;
  5597. this.end = props.end;
  5598. }
  5599. this.flags = 0;
  5600. }, {
  5601. $documentation: "A number literal",
  5602. $propdoc: {
  5603. value: "[number] the numeric value",
  5604. raw: "[string] numeric value as string"
  5605. }
  5606. }, AST_Constant);
  5607. var AST_BigInt = DEFNODE("BigInt", "value", function AST_BigInt(props) {
  5608. if (props) {
  5609. this.value = props.value;
  5610. this.start = props.start;
  5611. this.end = props.end;
  5612. }
  5613. this.flags = 0;
  5614. }, {
  5615. $documentation: "A big int literal",
  5616. $propdoc: {
  5617. value: "[string] big int value"
  5618. }
  5619. }, AST_Constant);
  5620. var AST_RegExp = DEFNODE("RegExp", "value", function AST_RegExp(props) {
  5621. if (props) {
  5622. this.value = props.value;
  5623. this.start = props.start;
  5624. this.end = props.end;
  5625. }
  5626. this.flags = 0;
  5627. }, {
  5628. $documentation: "A regexp literal",
  5629. $propdoc: {
  5630. value: "[RegExp] the actual regexp",
  5631. }
  5632. }, AST_Constant);
  5633. var AST_Atom = DEFNODE("Atom", null, function AST_Atom(props) {
  5634. if (props) {
  5635. this.start = props.start;
  5636. this.end = props.end;
  5637. }
  5638. this.flags = 0;
  5639. }, {
  5640. $documentation: "Base class for atoms",
  5641. }, AST_Constant);
  5642. var AST_Null = DEFNODE("Null", null, function AST_Null(props) {
  5643. if (props) {
  5644. this.start = props.start;
  5645. this.end = props.end;
  5646. }
  5647. this.flags = 0;
  5648. }, {
  5649. $documentation: "The `null` atom",
  5650. value: null
  5651. }, AST_Atom);
  5652. var AST_NaN = DEFNODE("NaN", null, function AST_NaN(props) {
  5653. if (props) {
  5654. this.start = props.start;
  5655. this.end = props.end;
  5656. }
  5657. this.flags = 0;
  5658. }, {
  5659. $documentation: "The impossible value",
  5660. value: 0/0
  5661. }, AST_Atom);
  5662. var AST_Undefined = DEFNODE("Undefined", null, function AST_Undefined(props) {
  5663. if (props) {
  5664. this.start = props.start;
  5665. this.end = props.end;
  5666. }
  5667. this.flags = 0;
  5668. }, {
  5669. $documentation: "The `undefined` value",
  5670. value: (function() {}())
  5671. }, AST_Atom);
  5672. var AST_Hole = DEFNODE("Hole", null, function AST_Hole(props) {
  5673. if (props) {
  5674. this.start = props.start;
  5675. this.end = props.end;
  5676. }
  5677. this.flags = 0;
  5678. }, {
  5679. $documentation: "A hole in an array",
  5680. value: (function() {}())
  5681. }, AST_Atom);
  5682. var AST_Infinity = DEFNODE("Infinity", null, function AST_Infinity(props) {
  5683. if (props) {
  5684. this.start = props.start;
  5685. this.end = props.end;
  5686. }
  5687. this.flags = 0;
  5688. }, {
  5689. $documentation: "The `Infinity` value",
  5690. value: 1/0
  5691. }, AST_Atom);
  5692. var AST_Boolean = DEFNODE("Boolean", null, function AST_Boolean(props) {
  5693. if (props) {
  5694. this.start = props.start;
  5695. this.end = props.end;
  5696. }
  5697. this.flags = 0;
  5698. }, {
  5699. $documentation: "Base class for booleans",
  5700. }, AST_Atom);
  5701. var AST_False = DEFNODE("False", null, function AST_False(props) {
  5702. if (props) {
  5703. this.start = props.start;
  5704. this.end = props.end;
  5705. }
  5706. this.flags = 0;
  5707. }, {
  5708. $documentation: "The `false` atom",
  5709. value: false
  5710. }, AST_Boolean);
  5711. var AST_True = DEFNODE("True", null, function AST_True(props) {
  5712. if (props) {
  5713. this.start = props.start;
  5714. this.end = props.end;
  5715. }
  5716. this.flags = 0;
  5717. }, {
  5718. $documentation: "The `true` atom",
  5719. value: true
  5720. }, AST_Boolean);
  5721. /* -----[ Walk function ]---- */
  5722. /**
  5723. * Walk nodes in depth-first search fashion.
  5724. * Callback can return `walk_abort` symbol to stop iteration.
  5725. * It can also return `true` to stop iteration just for child nodes.
  5726. * Iteration can be stopped and continued by passing the `to_visit` argument,
  5727. * which is given to the callback in the second argument.
  5728. **/
  5729. function walk(node, cb, to_visit = [node]) {
  5730. const push = to_visit.push.bind(to_visit);
  5731. while (to_visit.length) {
  5732. const node = to_visit.pop();
  5733. const ret = cb(node, to_visit);
  5734. if (ret) {
  5735. if (ret === walk_abort) return true;
  5736. continue;
  5737. }
  5738. node._children_backwards(push);
  5739. }
  5740. return false;
  5741. }
  5742. /**
  5743. * Walks an AST node and its children.
  5744. *
  5745. * {cb} can return `walk_abort` to interrupt the walk.
  5746. *
  5747. * @param node
  5748. * @param cb {(node, info: { parent: (nth) => any }) => (boolean | undefined)}
  5749. *
  5750. * @returns {boolean} whether the walk was aborted
  5751. *
  5752. * @example
  5753. * const found_some_cond = walk_parent(my_ast_node, (node, { parent }) => {
  5754. * if (some_cond(node, parent())) return walk_abort
  5755. * });
  5756. */
  5757. function walk_parent(node, cb, initial_stack) {
  5758. const to_visit = [node];
  5759. const push = to_visit.push.bind(to_visit);
  5760. const stack = initial_stack ? initial_stack.slice() : [];
  5761. const parent_pop_indices = [];
  5762. let current;
  5763. const info = {
  5764. parent: (n = 0) => {
  5765. if (n === -1) {
  5766. return current;
  5767. }
  5768. // [ p1 p0 ] [ 1 0 ]
  5769. if (initial_stack && n >= stack.length) {
  5770. n -= stack.length;
  5771. return initial_stack[
  5772. initial_stack.length - (n + 1)
  5773. ];
  5774. }
  5775. return stack[stack.length - (1 + n)];
  5776. },
  5777. };
  5778. while (to_visit.length) {
  5779. current = to_visit.pop();
  5780. while (
  5781. parent_pop_indices.length &&
  5782. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  5783. ) {
  5784. stack.pop();
  5785. parent_pop_indices.pop();
  5786. }
  5787. const ret = cb(current, info);
  5788. if (ret) {
  5789. if (ret === walk_abort) return true;
  5790. continue;
  5791. }
  5792. const visit_length = to_visit.length;
  5793. current._children_backwards(push);
  5794. // Push only if we're going to traverse the children
  5795. if (to_visit.length > visit_length) {
  5796. stack.push(current);
  5797. parent_pop_indices.push(visit_length - 1);
  5798. }
  5799. }
  5800. return false;
  5801. }
  5802. const walk_abort = Symbol("abort walk");
  5803. /* -----[ TreeWalker ]----- */
  5804. class TreeWalker {
  5805. constructor(callback) {
  5806. this.visit = callback;
  5807. this.stack = [];
  5808. this.directives = Object.create(null);
  5809. }
  5810. _visit(node, descend) {
  5811. this.push(node);
  5812. var ret = this.visit(node, descend ? function() {
  5813. descend.call(node);
  5814. } : noop);
  5815. if (!ret && descend) {
  5816. descend.call(node);
  5817. }
  5818. this.pop();
  5819. return ret;
  5820. }
  5821. parent(n) {
  5822. return this.stack[this.stack.length - 2 - (n || 0)];
  5823. }
  5824. push(node) {
  5825. if (node instanceof AST_Lambda) {
  5826. this.directives = Object.create(this.directives);
  5827. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  5828. this.directives[node.value] = node;
  5829. } else if (node instanceof AST_Class) {
  5830. this.directives = Object.create(this.directives);
  5831. if (!this.directives["use strict"]) {
  5832. this.directives["use strict"] = node;
  5833. }
  5834. }
  5835. this.stack.push(node);
  5836. }
  5837. pop() {
  5838. var node = this.stack.pop();
  5839. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  5840. this.directives = Object.getPrototypeOf(this.directives);
  5841. }
  5842. }
  5843. self() {
  5844. return this.stack[this.stack.length - 1];
  5845. }
  5846. find_parent(type) {
  5847. var stack = this.stack;
  5848. for (var i = stack.length; --i >= 0;) {
  5849. var x = stack[i];
  5850. if (x instanceof type) return x;
  5851. }
  5852. }
  5853. find_scope() {
  5854. for (let i = 0;;i++) {
  5855. const p = this.parent(i);
  5856. if (p instanceof AST_Toplevel) return p;
  5857. if (p instanceof AST_Lambda) return p;
  5858. if (p.block_scope) return p.block_scope;
  5859. }
  5860. }
  5861. has_directive(type) {
  5862. var dir = this.directives[type];
  5863. if (dir) return dir;
  5864. var node = this.stack[this.stack.length - 1];
  5865. if (node instanceof AST_Scope && node.body) {
  5866. for (var i = 0; i < node.body.length; ++i) {
  5867. var st = node.body[i];
  5868. if (!(st instanceof AST_Directive)) break;
  5869. if (st.value == type) return st;
  5870. }
  5871. }
  5872. }
  5873. loopcontrol_target(node) {
  5874. var stack = this.stack;
  5875. if (node.label) for (var i = stack.length; --i >= 0;) {
  5876. var x = stack[i];
  5877. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  5878. return x.body;
  5879. } else for (var i = stack.length; --i >= 0;) {
  5880. var x = stack[i];
  5881. if (x instanceof AST_IterationStatement
  5882. || node instanceof AST_Break && x instanceof AST_Switch)
  5883. return x;
  5884. }
  5885. }
  5886. }
  5887. // Tree transformer helpers.
  5888. class TreeTransformer extends TreeWalker {
  5889. constructor(before, after) {
  5890. super();
  5891. this.before = before;
  5892. this.after = after;
  5893. }
  5894. }
  5895. const _PURE = 0b00000001;
  5896. const _INLINE = 0b00000010;
  5897. const _NOINLINE = 0b00000100;
  5898. /***********************************************************************
  5899. A JavaScript tokenizer / parser / beautifier / compressor.
  5900. https://github.com/mishoo/UglifyJS2
  5901. -------------------------------- (C) ---------------------------------
  5902. Author: Mihai Bazon
  5903. <mihai.bazon@gmail.com>
  5904. http://mihai.bazon.net/blog
  5905. Distributed under the BSD license:
  5906. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  5907. Redistribution and use in source and binary forms, with or without
  5908. modification, are permitted provided that the following conditions
  5909. are met:
  5910. * Redistributions of source code must retain the above
  5911. copyright notice, this list of conditions and the following
  5912. disclaimer.
  5913. * Redistributions in binary form must reproduce the above
  5914. copyright notice, this list of conditions and the following
  5915. disclaimer in the documentation and/or other materials
  5916. provided with the distribution.
  5917. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  5918. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5919. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  5920. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  5921. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  5922. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  5923. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  5924. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  5925. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  5926. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  5927. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5928. SUCH DAMAGE.
  5929. ***********************************************************************/
  5930. function def_transform(node, descend) {
  5931. node.DEFMETHOD("transform", function(tw, in_list) {
  5932. let transformed = undefined;
  5933. tw.push(this);
  5934. if (tw.before) transformed = tw.before(this, descend, in_list);
  5935. if (transformed === undefined) {
  5936. transformed = this;
  5937. descend(transformed, tw);
  5938. if (tw.after) {
  5939. const after_ret = tw.after(transformed, in_list);
  5940. if (after_ret !== undefined) transformed = after_ret;
  5941. }
  5942. }
  5943. tw.pop();
  5944. return transformed;
  5945. });
  5946. }
  5947. function do_list(list, tw) {
  5948. return MAP(list, function(node) {
  5949. return node.transform(tw, true);
  5950. });
  5951. }
  5952. def_transform(AST_Node, noop);
  5953. def_transform(AST_LabeledStatement, function(self, tw) {
  5954. self.label = self.label.transform(tw);
  5955. self.body = self.body.transform(tw);
  5956. });
  5957. def_transform(AST_SimpleStatement, function(self, tw) {
  5958. self.body = self.body.transform(tw);
  5959. });
  5960. def_transform(AST_Block, function(self, tw) {
  5961. self.body = do_list(self.body, tw);
  5962. });
  5963. def_transform(AST_Do, function(self, tw) {
  5964. self.body = self.body.transform(tw);
  5965. self.condition = self.condition.transform(tw);
  5966. });
  5967. def_transform(AST_While, function(self, tw) {
  5968. self.condition = self.condition.transform(tw);
  5969. self.body = self.body.transform(tw);
  5970. });
  5971. def_transform(AST_For, function(self, tw) {
  5972. if (self.init) self.init = self.init.transform(tw);
  5973. if (self.condition) self.condition = self.condition.transform(tw);
  5974. if (self.step) self.step = self.step.transform(tw);
  5975. self.body = self.body.transform(tw);
  5976. });
  5977. def_transform(AST_ForIn, function(self, tw) {
  5978. self.init = self.init.transform(tw);
  5979. self.object = self.object.transform(tw);
  5980. self.body = self.body.transform(tw);
  5981. });
  5982. def_transform(AST_With, function(self, tw) {
  5983. self.expression = self.expression.transform(tw);
  5984. self.body = self.body.transform(tw);
  5985. });
  5986. def_transform(AST_Exit, function(self, tw) {
  5987. if (self.value) self.value = self.value.transform(tw);
  5988. });
  5989. def_transform(AST_LoopControl, function(self, tw) {
  5990. if (self.label) self.label = self.label.transform(tw);
  5991. });
  5992. def_transform(AST_If, function(self, tw) {
  5993. self.condition = self.condition.transform(tw);
  5994. self.body = self.body.transform(tw);
  5995. if (self.alternative) self.alternative = self.alternative.transform(tw);
  5996. });
  5997. def_transform(AST_Switch, function(self, tw) {
  5998. self.expression = self.expression.transform(tw);
  5999. self.body = do_list(self.body, tw);
  6000. });
  6001. def_transform(AST_Case, function(self, tw) {
  6002. self.expression = self.expression.transform(tw);
  6003. self.body = do_list(self.body, tw);
  6004. });
  6005. def_transform(AST_Try, function(self, tw) {
  6006. self.body = do_list(self.body, tw);
  6007. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  6008. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  6009. });
  6010. def_transform(AST_Catch, function(self, tw) {
  6011. if (self.argname) self.argname = self.argname.transform(tw);
  6012. self.body = do_list(self.body, tw);
  6013. });
  6014. def_transform(AST_Definitions, function(self, tw) {
  6015. self.definitions = do_list(self.definitions, tw);
  6016. });
  6017. def_transform(AST_VarDef, function(self, tw) {
  6018. self.name = self.name.transform(tw);
  6019. if (self.value) self.value = self.value.transform(tw);
  6020. });
  6021. def_transform(AST_Destructuring, function(self, tw) {
  6022. self.names = do_list(self.names, tw);
  6023. });
  6024. def_transform(AST_Lambda, function(self, tw) {
  6025. if (self.name) self.name = self.name.transform(tw);
  6026. self.argnames = do_list(self.argnames, tw);
  6027. if (self.body instanceof AST_Node) {
  6028. self.body = self.body.transform(tw);
  6029. } else {
  6030. self.body = do_list(self.body, tw);
  6031. }
  6032. });
  6033. def_transform(AST_Call, function(self, tw) {
  6034. self.expression = self.expression.transform(tw);
  6035. self.args = do_list(self.args, tw);
  6036. });
  6037. def_transform(AST_Sequence, function(self, tw) {
  6038. const result = do_list(self.expressions, tw);
  6039. self.expressions = result.length
  6040. ? result
  6041. : [new AST_Number({ value: 0 })];
  6042. });
  6043. def_transform(AST_PropAccess, function(self, tw) {
  6044. self.expression = self.expression.transform(tw);
  6045. });
  6046. def_transform(AST_Sub, function(self, tw) {
  6047. self.expression = self.expression.transform(tw);
  6048. self.property = self.property.transform(tw);
  6049. });
  6050. def_transform(AST_Chain, function(self, tw) {
  6051. self.expression = self.expression.transform(tw);
  6052. });
  6053. def_transform(AST_Yield, function(self, tw) {
  6054. if (self.expression) self.expression = self.expression.transform(tw);
  6055. });
  6056. def_transform(AST_Await, function(self, tw) {
  6057. self.expression = self.expression.transform(tw);
  6058. });
  6059. def_transform(AST_Unary, function(self, tw) {
  6060. self.expression = self.expression.transform(tw);
  6061. });
  6062. def_transform(AST_Binary, function(self, tw) {
  6063. self.left = self.left.transform(tw);
  6064. self.right = self.right.transform(tw);
  6065. });
  6066. def_transform(AST_Conditional, function(self, tw) {
  6067. self.condition = self.condition.transform(tw);
  6068. self.consequent = self.consequent.transform(tw);
  6069. self.alternative = self.alternative.transform(tw);
  6070. });
  6071. def_transform(AST_Array, function(self, tw) {
  6072. self.elements = do_list(self.elements, tw);
  6073. });
  6074. def_transform(AST_Object, function(self, tw) {
  6075. self.properties = do_list(self.properties, tw);
  6076. });
  6077. def_transform(AST_ObjectProperty, function(self, tw) {
  6078. if (self.key instanceof AST_Node) {
  6079. self.key = self.key.transform(tw);
  6080. }
  6081. if (self.value) self.value = self.value.transform(tw);
  6082. });
  6083. def_transform(AST_Class, function(self, tw) {
  6084. if (self.name) self.name = self.name.transform(tw);
  6085. if (self.extends) self.extends = self.extends.transform(tw);
  6086. self.properties = do_list(self.properties, tw);
  6087. });
  6088. def_transform(AST_Expansion, function(self, tw) {
  6089. self.expression = self.expression.transform(tw);
  6090. });
  6091. def_transform(AST_NameMapping, function(self, tw) {
  6092. self.foreign_name = self.foreign_name.transform(tw);
  6093. self.name = self.name.transform(tw);
  6094. });
  6095. def_transform(AST_Import, function(self, tw) {
  6096. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  6097. if (self.imported_names) do_list(self.imported_names, tw);
  6098. self.module_name = self.module_name.transform(tw);
  6099. });
  6100. def_transform(AST_Export, function(self, tw) {
  6101. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  6102. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  6103. if (self.exported_names) do_list(self.exported_names, tw);
  6104. if (self.module_name) self.module_name = self.module_name.transform(tw);
  6105. });
  6106. def_transform(AST_TemplateString, function(self, tw) {
  6107. self.segments = do_list(self.segments, tw);
  6108. });
  6109. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  6110. self.prefix = self.prefix.transform(tw);
  6111. self.template_string = self.template_string.transform(tw);
  6112. });
  6113. /***********************************************************************
  6114. A JavaScript tokenizer / parser / beautifier / compressor.
  6115. https://github.com/mishoo/UglifyJS2
  6116. -------------------------------- (C) ---------------------------------
  6117. Author: Mihai Bazon
  6118. <mihai.bazon@gmail.com>
  6119. http://mihai.bazon.net/blog
  6120. Distributed under the BSD license:
  6121. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6122. Redistribution and use in source and binary forms, with or without
  6123. modification, are permitted provided that the following conditions
  6124. are met:
  6125. * Redistributions of source code must retain the above
  6126. copyright notice, this list of conditions and the following
  6127. disclaimer.
  6128. * Redistributions in binary form must reproduce the above
  6129. copyright notice, this list of conditions and the following
  6130. disclaimer in the documentation and/or other materials
  6131. provided with the distribution.
  6132. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6133. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6134. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6135. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6136. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6137. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6138. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6139. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6140. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6141. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6142. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6143. SUCH DAMAGE.
  6144. ***********************************************************************/
  6145. (function() {
  6146. var normalize_directives = function(body) {
  6147. var in_directive = true;
  6148. for (var i = 0; i < body.length; i++) {
  6149. if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  6150. body[i] = new AST_Directive({
  6151. start: body[i].start,
  6152. end: body[i].end,
  6153. value: body[i].body.value
  6154. });
  6155. } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
  6156. in_directive = false;
  6157. }
  6158. }
  6159. return body;
  6160. };
  6161. const assert_clause_from_moz = (assertions) => {
  6162. if (assertions && assertions.length > 0) {
  6163. return new AST_Object({
  6164. start: my_start_token(assertions),
  6165. end: my_end_token(assertions),
  6166. properties: assertions.map((assertion_kv) =>
  6167. new AST_ObjectKeyVal({
  6168. start: my_start_token(assertion_kv),
  6169. end: my_end_token(assertion_kv),
  6170. key: assertion_kv.key.name || assertion_kv.key.value,
  6171. value: from_moz(assertion_kv.value)
  6172. })
  6173. )
  6174. });
  6175. }
  6176. return null;
  6177. };
  6178. var MOZ_TO_ME = {
  6179. Program: function(M) {
  6180. return new AST_Toplevel({
  6181. start: my_start_token(M),
  6182. end: my_end_token(M),
  6183. body: normalize_directives(M.body.map(from_moz))
  6184. });
  6185. },
  6186. ArrayPattern: function(M) {
  6187. return new AST_Destructuring({
  6188. start: my_start_token(M),
  6189. end: my_end_token(M),
  6190. names: M.elements.map(function(elm) {
  6191. if (elm === null) {
  6192. return new AST_Hole();
  6193. }
  6194. return from_moz(elm);
  6195. }),
  6196. is_array: true
  6197. });
  6198. },
  6199. ObjectPattern: function(M) {
  6200. return new AST_Destructuring({
  6201. start: my_start_token(M),
  6202. end: my_end_token(M),
  6203. names: M.properties.map(from_moz),
  6204. is_array: false
  6205. });
  6206. },
  6207. AssignmentPattern: function(M) {
  6208. return new AST_DefaultAssign({
  6209. start: my_start_token(M),
  6210. end: my_end_token(M),
  6211. left: from_moz(M.left),
  6212. operator: "=",
  6213. right: from_moz(M.right)
  6214. });
  6215. },
  6216. SpreadElement: function(M) {
  6217. return new AST_Expansion({
  6218. start: my_start_token(M),
  6219. end: my_end_token(M),
  6220. expression: from_moz(M.argument)
  6221. });
  6222. },
  6223. RestElement: function(M) {
  6224. return new AST_Expansion({
  6225. start: my_start_token(M),
  6226. end: my_end_token(M),
  6227. expression: from_moz(M.argument)
  6228. });
  6229. },
  6230. TemplateElement: function(M) {
  6231. return new AST_TemplateSegment({
  6232. start: my_start_token(M),
  6233. end: my_end_token(M),
  6234. value: M.value.cooked,
  6235. raw: M.value.raw
  6236. });
  6237. },
  6238. TemplateLiteral: function(M) {
  6239. var segments = [];
  6240. for (var i = 0; i < M.quasis.length; i++) {
  6241. segments.push(from_moz(M.quasis[i]));
  6242. if (M.expressions[i]) {
  6243. segments.push(from_moz(M.expressions[i]));
  6244. }
  6245. }
  6246. return new AST_TemplateString({
  6247. start: my_start_token(M),
  6248. end: my_end_token(M),
  6249. segments: segments
  6250. });
  6251. },
  6252. TaggedTemplateExpression: function(M) {
  6253. return new AST_PrefixedTemplateString({
  6254. start: my_start_token(M),
  6255. end: my_end_token(M),
  6256. template_string: from_moz(M.quasi),
  6257. prefix: from_moz(M.tag)
  6258. });
  6259. },
  6260. FunctionDeclaration: function(M) {
  6261. return new AST_Defun({
  6262. start: my_start_token(M),
  6263. end: my_end_token(M),
  6264. name: from_moz(M.id),
  6265. argnames: M.params.map(from_moz),
  6266. is_generator: M.generator,
  6267. async: M.async,
  6268. body: normalize_directives(from_moz(M.body).body)
  6269. });
  6270. },
  6271. FunctionExpression: function(M) {
  6272. return new AST_Function({
  6273. start: my_start_token(M),
  6274. end: my_end_token(M),
  6275. name: from_moz(M.id),
  6276. argnames: M.params.map(from_moz),
  6277. is_generator: M.generator,
  6278. async: M.async,
  6279. body: normalize_directives(from_moz(M.body).body)
  6280. });
  6281. },
  6282. ArrowFunctionExpression: function(M) {
  6283. const body = M.body.type === "BlockStatement"
  6284. ? from_moz(M.body).body
  6285. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  6286. return new AST_Arrow({
  6287. start: my_start_token(M),
  6288. end: my_end_token(M),
  6289. argnames: M.params.map(from_moz),
  6290. body,
  6291. async: M.async,
  6292. });
  6293. },
  6294. ExpressionStatement: function(M) {
  6295. return new AST_SimpleStatement({
  6296. start: my_start_token(M),
  6297. end: my_end_token(M),
  6298. body: from_moz(M.expression)
  6299. });
  6300. },
  6301. TryStatement: function(M) {
  6302. var handlers = M.handlers || [M.handler];
  6303. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  6304. throw new Error("Multiple catch clauses are not supported.");
  6305. }
  6306. return new AST_Try({
  6307. start : my_start_token(M),
  6308. end : my_end_token(M),
  6309. body : from_moz(M.block).body,
  6310. bcatch : from_moz(handlers[0]),
  6311. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  6312. });
  6313. },
  6314. Property: function(M) {
  6315. var key = M.key;
  6316. var args = {
  6317. start : my_start_token(key || M.value),
  6318. end : my_end_token(M.value),
  6319. key : key.type == "Identifier" ? key.name : key.value,
  6320. value : from_moz(M.value)
  6321. };
  6322. if (M.computed) {
  6323. args.key = from_moz(M.key);
  6324. }
  6325. if (M.method) {
  6326. args.is_generator = M.value.generator;
  6327. args.async = M.value.async;
  6328. if (!M.computed) {
  6329. args.key = new AST_SymbolMethod({ name: args.key });
  6330. } else {
  6331. args.key = from_moz(M.key);
  6332. }
  6333. return new AST_ConciseMethod(args);
  6334. }
  6335. if (M.kind == "init") {
  6336. if (key.type != "Identifier" && key.type != "Literal") {
  6337. args.key = from_moz(key);
  6338. }
  6339. return new AST_ObjectKeyVal(args);
  6340. }
  6341. if (typeof args.key === "string" || typeof args.key === "number") {
  6342. args.key = new AST_SymbolMethod({
  6343. name: args.key
  6344. });
  6345. }
  6346. args.value = new AST_Accessor(args.value);
  6347. if (M.kind == "get") return new AST_ObjectGetter(args);
  6348. if (M.kind == "set") return new AST_ObjectSetter(args);
  6349. if (M.kind == "method") {
  6350. args.async = M.value.async;
  6351. args.is_generator = M.value.generator;
  6352. args.quote = M.computed ? "\"" : null;
  6353. return new AST_ConciseMethod(args);
  6354. }
  6355. },
  6356. MethodDefinition: function(M) {
  6357. var args = {
  6358. start : my_start_token(M),
  6359. end : my_end_token(M),
  6360. key : M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value }),
  6361. value : from_moz(M.value),
  6362. static : M.static,
  6363. };
  6364. if (M.kind == "get") {
  6365. return new AST_ObjectGetter(args);
  6366. }
  6367. if (M.kind == "set") {
  6368. return new AST_ObjectSetter(args);
  6369. }
  6370. args.is_generator = M.value.generator;
  6371. args.async = M.value.async;
  6372. return new AST_ConciseMethod(args);
  6373. },
  6374. FieldDefinition: function(M) {
  6375. let key;
  6376. if (M.computed) {
  6377. key = from_moz(M.key);
  6378. } else {
  6379. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  6380. key = from_moz(M.key);
  6381. }
  6382. return new AST_ClassProperty({
  6383. start : my_start_token(M),
  6384. end : my_end_token(M),
  6385. key,
  6386. value : from_moz(M.value),
  6387. static : M.static,
  6388. });
  6389. },
  6390. PropertyDefinition: function(M) {
  6391. let key;
  6392. if (M.computed) {
  6393. key = from_moz(M.key);
  6394. } else {
  6395. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in PropertyDefinition");
  6396. key = from_moz(M.key);
  6397. }
  6398. return new AST_ClassProperty({
  6399. start : my_start_token(M),
  6400. end : my_end_token(M),
  6401. key,
  6402. value : from_moz(M.value),
  6403. static : M.static,
  6404. });
  6405. },
  6406. ArrayExpression: function(M) {
  6407. return new AST_Array({
  6408. start : my_start_token(M),
  6409. end : my_end_token(M),
  6410. elements : M.elements.map(function(elem) {
  6411. return elem === null ? new AST_Hole() : from_moz(elem);
  6412. })
  6413. });
  6414. },
  6415. ObjectExpression: function(M) {
  6416. return new AST_Object({
  6417. start : my_start_token(M),
  6418. end : my_end_token(M),
  6419. properties : M.properties.map(function(prop) {
  6420. if (prop.type === "SpreadElement") {
  6421. return from_moz(prop);
  6422. }
  6423. prop.type = "Property";
  6424. return from_moz(prop);
  6425. })
  6426. });
  6427. },
  6428. SequenceExpression: function(M) {
  6429. return new AST_Sequence({
  6430. start : my_start_token(M),
  6431. end : my_end_token(M),
  6432. expressions: M.expressions.map(from_moz)
  6433. });
  6434. },
  6435. MemberExpression: function(M) {
  6436. return new (M.computed ? AST_Sub : AST_Dot)({
  6437. start : my_start_token(M),
  6438. end : my_end_token(M),
  6439. property : M.computed ? from_moz(M.property) : M.property.name,
  6440. expression : from_moz(M.object),
  6441. optional : M.optional || false
  6442. });
  6443. },
  6444. ChainExpression: function(M) {
  6445. return new AST_Chain({
  6446. start : my_start_token(M),
  6447. end : my_end_token(M),
  6448. expression : from_moz(M.expression)
  6449. });
  6450. },
  6451. SwitchCase: function(M) {
  6452. return new (M.test ? AST_Case : AST_Default)({
  6453. start : my_start_token(M),
  6454. end : my_end_token(M),
  6455. expression : from_moz(M.test),
  6456. body : M.consequent.map(from_moz)
  6457. });
  6458. },
  6459. VariableDeclaration: function(M) {
  6460. return new (M.kind === "const" ? AST_Const :
  6461. M.kind === "let" ? AST_Let : AST_Var)({
  6462. start : my_start_token(M),
  6463. end : my_end_token(M),
  6464. definitions : M.declarations.map(from_moz)
  6465. });
  6466. },
  6467. ImportDeclaration: function(M) {
  6468. var imported_name = null;
  6469. var imported_names = null;
  6470. M.specifiers.forEach(function (specifier) {
  6471. if (specifier.type === "ImportSpecifier") {
  6472. if (!imported_names) { imported_names = []; }
  6473. imported_names.push(new AST_NameMapping({
  6474. start: my_start_token(specifier),
  6475. end: my_end_token(specifier),
  6476. foreign_name: from_moz(specifier.imported),
  6477. name: from_moz(specifier.local)
  6478. }));
  6479. } else if (specifier.type === "ImportDefaultSpecifier") {
  6480. imported_name = from_moz(specifier.local);
  6481. } else if (specifier.type === "ImportNamespaceSpecifier") {
  6482. if (!imported_names) { imported_names = []; }
  6483. imported_names.push(new AST_NameMapping({
  6484. start: my_start_token(specifier),
  6485. end: my_end_token(specifier),
  6486. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  6487. name: from_moz(specifier.local)
  6488. }));
  6489. }
  6490. });
  6491. return new AST_Import({
  6492. start : my_start_token(M),
  6493. end : my_end_token(M),
  6494. imported_name: imported_name,
  6495. imported_names : imported_names,
  6496. module_name : from_moz(M.source),
  6497. assert_clause: assert_clause_from_moz(M.assertions)
  6498. });
  6499. },
  6500. ExportAllDeclaration: function(M) {
  6501. return new AST_Export({
  6502. start: my_start_token(M),
  6503. end: my_end_token(M),
  6504. exported_names: [
  6505. new AST_NameMapping({
  6506. name: new AST_SymbolExportForeign({ name: "*" }),
  6507. foreign_name: new AST_SymbolExportForeign({ name: "*" })
  6508. })
  6509. ],
  6510. module_name: from_moz(M.source),
  6511. assert_clause: assert_clause_from_moz(M.assertions)
  6512. });
  6513. },
  6514. ExportNamedDeclaration: function(M) {
  6515. return new AST_Export({
  6516. start: my_start_token(M),
  6517. end: my_end_token(M),
  6518. exported_definition: from_moz(M.declaration),
  6519. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(function (specifier) {
  6520. return new AST_NameMapping({
  6521. foreign_name: from_moz(specifier.exported),
  6522. name: from_moz(specifier.local)
  6523. });
  6524. }) : null,
  6525. module_name: from_moz(M.source),
  6526. assert_clause: assert_clause_from_moz(M.assertions)
  6527. });
  6528. },
  6529. ExportDefaultDeclaration: function(M) {
  6530. return new AST_Export({
  6531. start: my_start_token(M),
  6532. end: my_end_token(M),
  6533. exported_value: from_moz(M.declaration),
  6534. is_default: true
  6535. });
  6536. },
  6537. Literal: function(M) {
  6538. var val = M.value, args = {
  6539. start : my_start_token(M),
  6540. end : my_end_token(M)
  6541. };
  6542. var rx = M.regex;
  6543. if (rx && rx.pattern) {
  6544. // RegExpLiteral as per ESTree AST spec
  6545. args.value = {
  6546. source: rx.pattern,
  6547. flags: rx.flags
  6548. };
  6549. return new AST_RegExp(args);
  6550. } else if (rx) {
  6551. // support legacy RegExp
  6552. const rx_source = M.raw || val;
  6553. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  6554. if (!match) throw new Error("Invalid regex source " + rx_source);
  6555. const [_, source, flags] = match;
  6556. args.value = { source, flags };
  6557. return new AST_RegExp(args);
  6558. }
  6559. if (val === null) return new AST_Null(args);
  6560. switch (typeof val) {
  6561. case "string":
  6562. args.value = val;
  6563. return new AST_String(args);
  6564. case "number":
  6565. args.value = val;
  6566. args.raw = M.raw || val.toString();
  6567. return new AST_Number(args);
  6568. case "boolean":
  6569. return new (val ? AST_True : AST_False)(args);
  6570. }
  6571. },
  6572. MetaProperty: function(M) {
  6573. if (M.meta.name === "new" && M.property.name === "target") {
  6574. return new AST_NewTarget({
  6575. start: my_start_token(M),
  6576. end: my_end_token(M)
  6577. });
  6578. } else if (M.meta.name === "import" && M.property.name === "meta") {
  6579. return new AST_ImportMeta({
  6580. start: my_start_token(M),
  6581. end: my_end_token(M)
  6582. });
  6583. }
  6584. },
  6585. Identifier: function(M) {
  6586. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  6587. return new ( p.type == "LabeledStatement" ? AST_Label
  6588. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  6589. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  6590. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  6591. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  6592. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  6593. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  6594. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  6595. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  6596. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  6597. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  6598. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  6599. : p.type == "CatchClause" ? AST_SymbolCatch
  6600. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  6601. : AST_SymbolRef)({
  6602. start : my_start_token(M),
  6603. end : my_end_token(M),
  6604. name : M.name
  6605. });
  6606. },
  6607. BigIntLiteral(M) {
  6608. return new AST_BigInt({
  6609. start : my_start_token(M),
  6610. end : my_end_token(M),
  6611. value : M.value
  6612. });
  6613. },
  6614. EmptyStatement: function(M) {
  6615. return new AST_EmptyStatement({
  6616. start: my_start_token(M),
  6617. end: my_end_token(M)
  6618. });
  6619. },
  6620. BlockStatement: function(M) {
  6621. return new AST_BlockStatement({
  6622. start: my_start_token(M),
  6623. end: my_end_token(M),
  6624. body: M.body.map(from_moz)
  6625. });
  6626. },
  6627. IfStatement: function(M) {
  6628. return new AST_If({
  6629. start: my_start_token(M),
  6630. end: my_end_token(M),
  6631. condition: from_moz(M.test),
  6632. body: from_moz(M.consequent),
  6633. alternative: from_moz(M.alternate)
  6634. });
  6635. },
  6636. LabeledStatement: function(M) {
  6637. return new AST_LabeledStatement({
  6638. start: my_start_token(M),
  6639. end: my_end_token(M),
  6640. label: from_moz(M.label),
  6641. body: from_moz(M.body)
  6642. });
  6643. },
  6644. BreakStatement: function(M) {
  6645. return new AST_Break({
  6646. start: my_start_token(M),
  6647. end: my_end_token(M),
  6648. label: from_moz(M.label)
  6649. });
  6650. },
  6651. ContinueStatement: function(M) {
  6652. return new AST_Continue({
  6653. start: my_start_token(M),
  6654. end: my_end_token(M),
  6655. label: from_moz(M.label)
  6656. });
  6657. },
  6658. WithStatement: function(M) {
  6659. return new AST_With({
  6660. start: my_start_token(M),
  6661. end: my_end_token(M),
  6662. expression: from_moz(M.object),
  6663. body: from_moz(M.body)
  6664. });
  6665. },
  6666. SwitchStatement: function(M) {
  6667. return new AST_Switch({
  6668. start: my_start_token(M),
  6669. end: my_end_token(M),
  6670. expression: from_moz(M.discriminant),
  6671. body: M.cases.map(from_moz)
  6672. });
  6673. },
  6674. ReturnStatement: function(M) {
  6675. return new AST_Return({
  6676. start: my_start_token(M),
  6677. end: my_end_token(M),
  6678. value: from_moz(M.argument)
  6679. });
  6680. },
  6681. ThrowStatement: function(M) {
  6682. return new AST_Throw({
  6683. start: my_start_token(M),
  6684. end: my_end_token(M),
  6685. value: from_moz(M.argument)
  6686. });
  6687. },
  6688. WhileStatement: function(M) {
  6689. return new AST_While({
  6690. start: my_start_token(M),
  6691. end: my_end_token(M),
  6692. condition: from_moz(M.test),
  6693. body: from_moz(M.body)
  6694. });
  6695. },
  6696. DoWhileStatement: function(M) {
  6697. return new AST_Do({
  6698. start: my_start_token(M),
  6699. end: my_end_token(M),
  6700. condition: from_moz(M.test),
  6701. body: from_moz(M.body)
  6702. });
  6703. },
  6704. ForStatement: function(M) {
  6705. return new AST_For({
  6706. start: my_start_token(M),
  6707. end: my_end_token(M),
  6708. init: from_moz(M.init),
  6709. condition: from_moz(M.test),
  6710. step: from_moz(M.update),
  6711. body: from_moz(M.body)
  6712. });
  6713. },
  6714. ForInStatement: function(M) {
  6715. return new AST_ForIn({
  6716. start: my_start_token(M),
  6717. end: my_end_token(M),
  6718. init: from_moz(M.left),
  6719. object: from_moz(M.right),
  6720. body: from_moz(M.body)
  6721. });
  6722. },
  6723. ForOfStatement: function(M) {
  6724. return new AST_ForOf({
  6725. start: my_start_token(M),
  6726. end: my_end_token(M),
  6727. init: from_moz(M.left),
  6728. object: from_moz(M.right),
  6729. body: from_moz(M.body),
  6730. await: M.await
  6731. });
  6732. },
  6733. AwaitExpression: function(M) {
  6734. return new AST_Await({
  6735. start: my_start_token(M),
  6736. end: my_end_token(M),
  6737. expression: from_moz(M.argument)
  6738. });
  6739. },
  6740. YieldExpression: function(M) {
  6741. return new AST_Yield({
  6742. start: my_start_token(M),
  6743. end: my_end_token(M),
  6744. expression: from_moz(M.argument),
  6745. is_star: M.delegate
  6746. });
  6747. },
  6748. DebuggerStatement: function(M) {
  6749. return new AST_Debugger({
  6750. start: my_start_token(M),
  6751. end: my_end_token(M)
  6752. });
  6753. },
  6754. VariableDeclarator: function(M) {
  6755. return new AST_VarDef({
  6756. start: my_start_token(M),
  6757. end: my_end_token(M),
  6758. name: from_moz(M.id),
  6759. value: from_moz(M.init)
  6760. });
  6761. },
  6762. CatchClause: function(M) {
  6763. return new AST_Catch({
  6764. start: my_start_token(M),
  6765. end: my_end_token(M),
  6766. argname: from_moz(M.param),
  6767. body: from_moz(M.body).body
  6768. });
  6769. },
  6770. ThisExpression: function(M) {
  6771. return new AST_This({
  6772. start: my_start_token(M),
  6773. end: my_end_token(M)
  6774. });
  6775. },
  6776. Super: function(M) {
  6777. return new AST_Super({
  6778. start: my_start_token(M),
  6779. end: my_end_token(M)
  6780. });
  6781. },
  6782. BinaryExpression: function(M) {
  6783. return new AST_Binary({
  6784. start: my_start_token(M),
  6785. end: my_end_token(M),
  6786. operator: M.operator,
  6787. left: from_moz(M.left),
  6788. right: from_moz(M.right)
  6789. });
  6790. },
  6791. LogicalExpression: function(M) {
  6792. return new AST_Binary({
  6793. start: my_start_token(M),
  6794. end: my_end_token(M),
  6795. operator: M.operator,
  6796. left: from_moz(M.left),
  6797. right: from_moz(M.right)
  6798. });
  6799. },
  6800. AssignmentExpression: function(M) {
  6801. return new AST_Assign({
  6802. start: my_start_token(M),
  6803. end: my_end_token(M),
  6804. operator: M.operator,
  6805. left: from_moz(M.left),
  6806. right: from_moz(M.right)
  6807. });
  6808. },
  6809. ConditionalExpression: function(M) {
  6810. return new AST_Conditional({
  6811. start: my_start_token(M),
  6812. end: my_end_token(M),
  6813. condition: from_moz(M.test),
  6814. consequent: from_moz(M.consequent),
  6815. alternative: from_moz(M.alternate)
  6816. });
  6817. },
  6818. NewExpression: function(M) {
  6819. return new AST_New({
  6820. start: my_start_token(M),
  6821. end: my_end_token(M),
  6822. expression: from_moz(M.callee),
  6823. args: M.arguments.map(from_moz)
  6824. });
  6825. },
  6826. CallExpression: function(M) {
  6827. return new AST_Call({
  6828. start: my_start_token(M),
  6829. end: my_end_token(M),
  6830. expression: from_moz(M.callee),
  6831. optional: M.optional,
  6832. args: M.arguments.map(from_moz)
  6833. });
  6834. }
  6835. };
  6836. MOZ_TO_ME.UpdateExpression =
  6837. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  6838. var prefix = "prefix" in M ? M.prefix
  6839. : M.type == "UnaryExpression" ? true : false;
  6840. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  6841. start : my_start_token(M),
  6842. end : my_end_token(M),
  6843. operator : M.operator,
  6844. expression : from_moz(M.argument)
  6845. });
  6846. };
  6847. MOZ_TO_ME.ClassDeclaration =
  6848. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  6849. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  6850. start : my_start_token(M),
  6851. end : my_end_token(M),
  6852. name : from_moz(M.id),
  6853. extends : from_moz(M.superClass),
  6854. properties: M.body.body.map(from_moz)
  6855. });
  6856. };
  6857. def_to_moz(AST_EmptyStatement, function To_Moz_EmptyStatement() {
  6858. return {
  6859. type: "EmptyStatement"
  6860. };
  6861. });
  6862. def_to_moz(AST_BlockStatement, function To_Moz_BlockStatement(M) {
  6863. return {
  6864. type: "BlockStatement",
  6865. body: M.body.map(to_moz)
  6866. };
  6867. });
  6868. def_to_moz(AST_If, function To_Moz_IfStatement(M) {
  6869. return {
  6870. type: "IfStatement",
  6871. test: to_moz(M.condition),
  6872. consequent: to_moz(M.body),
  6873. alternate: to_moz(M.alternative)
  6874. };
  6875. });
  6876. def_to_moz(AST_LabeledStatement, function To_Moz_LabeledStatement(M) {
  6877. return {
  6878. type: "LabeledStatement",
  6879. label: to_moz(M.label),
  6880. body: to_moz(M.body)
  6881. };
  6882. });
  6883. def_to_moz(AST_Break, function To_Moz_BreakStatement(M) {
  6884. return {
  6885. type: "BreakStatement",
  6886. label: to_moz(M.label)
  6887. };
  6888. });
  6889. def_to_moz(AST_Continue, function To_Moz_ContinueStatement(M) {
  6890. return {
  6891. type: "ContinueStatement",
  6892. label: to_moz(M.label)
  6893. };
  6894. });
  6895. def_to_moz(AST_With, function To_Moz_WithStatement(M) {
  6896. return {
  6897. type: "WithStatement",
  6898. object: to_moz(M.expression),
  6899. body: to_moz(M.body)
  6900. };
  6901. });
  6902. def_to_moz(AST_Switch, function To_Moz_SwitchStatement(M) {
  6903. return {
  6904. type: "SwitchStatement",
  6905. discriminant: to_moz(M.expression),
  6906. cases: M.body.map(to_moz)
  6907. };
  6908. });
  6909. def_to_moz(AST_Return, function To_Moz_ReturnStatement(M) {
  6910. return {
  6911. type: "ReturnStatement",
  6912. argument: to_moz(M.value)
  6913. };
  6914. });
  6915. def_to_moz(AST_Throw, function To_Moz_ThrowStatement(M) {
  6916. return {
  6917. type: "ThrowStatement",
  6918. argument: to_moz(M.value)
  6919. };
  6920. });
  6921. def_to_moz(AST_While, function To_Moz_WhileStatement(M) {
  6922. return {
  6923. type: "WhileStatement",
  6924. test: to_moz(M.condition),
  6925. body: to_moz(M.body)
  6926. };
  6927. });
  6928. def_to_moz(AST_Do, function To_Moz_DoWhileStatement(M) {
  6929. return {
  6930. type: "DoWhileStatement",
  6931. test: to_moz(M.condition),
  6932. body: to_moz(M.body)
  6933. };
  6934. });
  6935. def_to_moz(AST_For, function To_Moz_ForStatement(M) {
  6936. return {
  6937. type: "ForStatement",
  6938. init: to_moz(M.init),
  6939. test: to_moz(M.condition),
  6940. update: to_moz(M.step),
  6941. body: to_moz(M.body)
  6942. };
  6943. });
  6944. def_to_moz(AST_ForIn, function To_Moz_ForInStatement(M) {
  6945. return {
  6946. type: "ForInStatement",
  6947. left: to_moz(M.init),
  6948. right: to_moz(M.object),
  6949. body: to_moz(M.body)
  6950. };
  6951. });
  6952. def_to_moz(AST_ForOf, function To_Moz_ForOfStatement(M) {
  6953. return {
  6954. type: "ForOfStatement",
  6955. left: to_moz(M.init),
  6956. right: to_moz(M.object),
  6957. body: to_moz(M.body),
  6958. await: M.await
  6959. };
  6960. });
  6961. def_to_moz(AST_Await, function To_Moz_AwaitExpression(M) {
  6962. return {
  6963. type: "AwaitExpression",
  6964. argument: to_moz(M.expression)
  6965. };
  6966. });
  6967. def_to_moz(AST_Yield, function To_Moz_YieldExpression(M) {
  6968. return {
  6969. type: "YieldExpression",
  6970. argument: to_moz(M.expression),
  6971. delegate: M.is_star
  6972. };
  6973. });
  6974. def_to_moz(AST_Debugger, function To_Moz_DebuggerStatement() {
  6975. return {
  6976. type: "DebuggerStatement"
  6977. };
  6978. });
  6979. def_to_moz(AST_VarDef, function To_Moz_VariableDeclarator(M) {
  6980. return {
  6981. type: "VariableDeclarator",
  6982. id: to_moz(M.name),
  6983. init: to_moz(M.value)
  6984. };
  6985. });
  6986. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  6987. return {
  6988. type: "CatchClause",
  6989. param: to_moz(M.argname),
  6990. body: to_moz_block(M)
  6991. };
  6992. });
  6993. def_to_moz(AST_This, function To_Moz_ThisExpression() {
  6994. return {
  6995. type: "ThisExpression"
  6996. };
  6997. });
  6998. def_to_moz(AST_Super, function To_Moz_Super() {
  6999. return {
  7000. type: "Super"
  7001. };
  7002. });
  7003. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7004. return {
  7005. type: "BinaryExpression",
  7006. operator: M.operator,
  7007. left: to_moz(M.left),
  7008. right: to_moz(M.right)
  7009. };
  7010. });
  7011. def_to_moz(AST_Binary, function To_Moz_LogicalExpression(M) {
  7012. return {
  7013. type: "LogicalExpression",
  7014. operator: M.operator,
  7015. left: to_moz(M.left),
  7016. right: to_moz(M.right)
  7017. };
  7018. });
  7019. def_to_moz(AST_Assign, function To_Moz_AssignmentExpression(M) {
  7020. return {
  7021. type: "AssignmentExpression",
  7022. operator: M.operator,
  7023. left: to_moz(M.left),
  7024. right: to_moz(M.right)
  7025. };
  7026. });
  7027. def_to_moz(AST_Conditional, function To_Moz_ConditionalExpression(M) {
  7028. return {
  7029. type: "ConditionalExpression",
  7030. test: to_moz(M.condition),
  7031. consequent: to_moz(M.consequent),
  7032. alternate: to_moz(M.alternative)
  7033. };
  7034. });
  7035. def_to_moz(AST_New, function To_Moz_NewExpression(M) {
  7036. return {
  7037. type: "NewExpression",
  7038. callee: to_moz(M.expression),
  7039. arguments: M.args.map(to_moz)
  7040. };
  7041. });
  7042. def_to_moz(AST_Call, function To_Moz_CallExpression(M) {
  7043. return {
  7044. type: "CallExpression",
  7045. callee: to_moz(M.expression),
  7046. optional: M.optional,
  7047. arguments: M.args.map(to_moz)
  7048. };
  7049. });
  7050. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  7051. return to_moz_scope("Program", M);
  7052. });
  7053. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  7054. return {
  7055. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  7056. argument: to_moz(M.expression)
  7057. };
  7058. });
  7059. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  7060. return {
  7061. type: "TaggedTemplateExpression",
  7062. tag: to_moz(M.prefix),
  7063. quasi: to_moz(M.template_string)
  7064. };
  7065. });
  7066. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  7067. var quasis = [];
  7068. var expressions = [];
  7069. for (var i = 0; i < M.segments.length; i++) {
  7070. if (i % 2 !== 0) {
  7071. expressions.push(to_moz(M.segments[i]));
  7072. } else {
  7073. quasis.push({
  7074. type: "TemplateElement",
  7075. value: {
  7076. raw: M.segments[i].raw,
  7077. cooked: M.segments[i].value
  7078. },
  7079. tail: i === M.segments.length - 1
  7080. });
  7081. }
  7082. }
  7083. return {
  7084. type: "TemplateLiteral",
  7085. quasis: quasis,
  7086. expressions: expressions
  7087. };
  7088. });
  7089. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  7090. return {
  7091. type: "FunctionDeclaration",
  7092. id: to_moz(M.name),
  7093. params: M.argnames.map(to_moz),
  7094. generator: M.is_generator,
  7095. async: M.async,
  7096. body: to_moz_scope("BlockStatement", M)
  7097. };
  7098. });
  7099. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  7100. var is_generator = parent.is_generator !== undefined ?
  7101. parent.is_generator : M.is_generator;
  7102. return {
  7103. type: "FunctionExpression",
  7104. id: to_moz(M.name),
  7105. params: M.argnames.map(to_moz),
  7106. generator: is_generator,
  7107. async: M.async,
  7108. body: to_moz_scope("BlockStatement", M)
  7109. };
  7110. });
  7111. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  7112. var body = {
  7113. type: "BlockStatement",
  7114. body: M.body.map(to_moz)
  7115. };
  7116. return {
  7117. type: "ArrowFunctionExpression",
  7118. params: M.argnames.map(to_moz),
  7119. async: M.async,
  7120. body: body
  7121. };
  7122. });
  7123. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  7124. if (M.is_array) {
  7125. return {
  7126. type: "ArrayPattern",
  7127. elements: M.names.map(to_moz)
  7128. };
  7129. }
  7130. return {
  7131. type: "ObjectPattern",
  7132. properties: M.names.map(to_moz)
  7133. };
  7134. });
  7135. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  7136. return {
  7137. type: "ExpressionStatement",
  7138. expression: {
  7139. type: "Literal",
  7140. value: M.value,
  7141. raw: M.print_to_string()
  7142. },
  7143. directive: M.value
  7144. };
  7145. });
  7146. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  7147. return {
  7148. type: "ExpressionStatement",
  7149. expression: to_moz(M.body)
  7150. };
  7151. });
  7152. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  7153. return {
  7154. type: "SwitchCase",
  7155. test: to_moz(M.expression),
  7156. consequent: M.body.map(to_moz)
  7157. };
  7158. });
  7159. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  7160. return {
  7161. type: "TryStatement",
  7162. block: to_moz_block(M),
  7163. handler: to_moz(M.bcatch),
  7164. guardedHandlers: [],
  7165. finalizer: to_moz(M.bfinally)
  7166. };
  7167. });
  7168. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  7169. return {
  7170. type: "CatchClause",
  7171. param: to_moz(M.argname),
  7172. guard: null,
  7173. body: to_moz_block(M)
  7174. };
  7175. });
  7176. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  7177. return {
  7178. type: "VariableDeclaration",
  7179. kind:
  7180. M instanceof AST_Const ? "const" :
  7181. M instanceof AST_Let ? "let" : "var",
  7182. declarations: M.definitions.map(to_moz)
  7183. };
  7184. });
  7185. const assert_clause_to_moz = assert_clause => {
  7186. const assertions = [];
  7187. if (assert_clause) {
  7188. for (const { key, value } of assert_clause.properties) {
  7189. const key_moz = is_basic_identifier_string(key)
  7190. ? { type: "Identifier", name: key }
  7191. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  7192. assertions.push({
  7193. type: "ImportAttribute",
  7194. key: key_moz,
  7195. value: to_moz(value)
  7196. });
  7197. }
  7198. }
  7199. return assertions;
  7200. };
  7201. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  7202. if (M.exported_names) {
  7203. if (M.exported_names[0].name.name === "*") {
  7204. return {
  7205. type: "ExportAllDeclaration",
  7206. source: to_moz(M.module_name),
  7207. assertions: assert_clause_to_moz(M.assert_clause)
  7208. };
  7209. }
  7210. return {
  7211. type: "ExportNamedDeclaration",
  7212. specifiers: M.exported_names.map(function (name_mapping) {
  7213. return {
  7214. type: "ExportSpecifier",
  7215. exported: to_moz(name_mapping.foreign_name),
  7216. local: to_moz(name_mapping.name)
  7217. };
  7218. }),
  7219. declaration: to_moz(M.exported_definition),
  7220. source: to_moz(M.module_name),
  7221. assertions: assert_clause_to_moz(M.assert_clause)
  7222. };
  7223. }
  7224. return {
  7225. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  7226. declaration: to_moz(M.exported_value || M.exported_definition)
  7227. };
  7228. });
  7229. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  7230. var specifiers = [];
  7231. if (M.imported_name) {
  7232. specifiers.push({
  7233. type: "ImportDefaultSpecifier",
  7234. local: to_moz(M.imported_name)
  7235. });
  7236. }
  7237. if (M.imported_names && M.imported_names[0].foreign_name.name === "*") {
  7238. specifiers.push({
  7239. type: "ImportNamespaceSpecifier",
  7240. local: to_moz(M.imported_names[0].name)
  7241. });
  7242. } else if (M.imported_names) {
  7243. M.imported_names.forEach(function(name_mapping) {
  7244. specifiers.push({
  7245. type: "ImportSpecifier",
  7246. local: to_moz(name_mapping.name),
  7247. imported: to_moz(name_mapping.foreign_name)
  7248. });
  7249. });
  7250. }
  7251. return {
  7252. type: "ImportDeclaration",
  7253. specifiers: specifiers,
  7254. source: to_moz(M.module_name),
  7255. assertions: assert_clause_to_moz(M.assert_clause)
  7256. };
  7257. });
  7258. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  7259. return {
  7260. type: "MetaProperty",
  7261. meta: {
  7262. type: "Identifier",
  7263. name: "import"
  7264. },
  7265. property: {
  7266. type: "Identifier",
  7267. name: "meta"
  7268. }
  7269. };
  7270. });
  7271. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  7272. return {
  7273. type: "SequenceExpression",
  7274. expressions: M.expressions.map(to_moz)
  7275. };
  7276. });
  7277. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  7278. return {
  7279. type: "MemberExpression",
  7280. object: to_moz(M.expression),
  7281. computed: false,
  7282. property: {
  7283. type: "PrivateIdentifier",
  7284. name: M.property
  7285. },
  7286. optional: M.optional
  7287. };
  7288. });
  7289. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  7290. var isComputed = M instanceof AST_Sub;
  7291. return {
  7292. type: "MemberExpression",
  7293. object: to_moz(M.expression),
  7294. computed: isComputed,
  7295. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  7296. optional: M.optional
  7297. };
  7298. });
  7299. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  7300. return {
  7301. type: "ChainExpression",
  7302. expression: to_moz(M.expression)
  7303. };
  7304. });
  7305. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  7306. return {
  7307. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  7308. operator: M.operator,
  7309. prefix: M instanceof AST_UnaryPrefix,
  7310. argument: to_moz(M.expression)
  7311. };
  7312. });
  7313. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  7314. if (M.operator == "=" && to_moz_in_destructuring()) {
  7315. return {
  7316. type: "AssignmentPattern",
  7317. left: to_moz(M.left),
  7318. right: to_moz(M.right)
  7319. };
  7320. }
  7321. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  7322. ? "LogicalExpression"
  7323. : "BinaryExpression";
  7324. return {
  7325. type,
  7326. left: to_moz(M.left),
  7327. operator: M.operator,
  7328. right: to_moz(M.right)
  7329. };
  7330. });
  7331. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  7332. return {
  7333. type: "ArrayExpression",
  7334. elements: M.elements.map(to_moz)
  7335. };
  7336. });
  7337. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  7338. return {
  7339. type: "ObjectExpression",
  7340. properties: M.properties.map(to_moz)
  7341. };
  7342. });
  7343. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  7344. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  7345. type: "Identifier",
  7346. value: M.key
  7347. };
  7348. if (typeof M.key === "number") {
  7349. key = {
  7350. type: "Literal",
  7351. value: Number(M.key)
  7352. };
  7353. }
  7354. if (typeof M.key === "string") {
  7355. key = {
  7356. type: "Identifier",
  7357. name: M.key
  7358. };
  7359. }
  7360. var kind;
  7361. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  7362. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  7363. if (M instanceof AST_ObjectKeyVal) {
  7364. kind = "init";
  7365. computed = !string_or_num;
  7366. } else
  7367. if (M instanceof AST_ObjectGetter) {
  7368. kind = "get";
  7369. } else
  7370. if (M instanceof AST_ObjectSetter) {
  7371. kind = "set";
  7372. }
  7373. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  7374. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  7375. return {
  7376. type: "MethodDefinition",
  7377. computed: false,
  7378. kind: kind,
  7379. static: M.static,
  7380. key: {
  7381. type: "PrivateIdentifier",
  7382. name: M.key.name
  7383. },
  7384. value: to_moz(M.value)
  7385. };
  7386. }
  7387. if (M instanceof AST_ClassPrivateProperty) {
  7388. return {
  7389. type: "PropertyDefinition",
  7390. key: {
  7391. type: "PrivateIdentifier",
  7392. name: M.key.name
  7393. },
  7394. value: to_moz(M.value),
  7395. computed: false,
  7396. static: M.static
  7397. };
  7398. }
  7399. if (M instanceof AST_ClassProperty) {
  7400. return {
  7401. type: "PropertyDefinition",
  7402. key,
  7403. value: to_moz(M.value),
  7404. computed,
  7405. static: M.static
  7406. };
  7407. }
  7408. if (parent instanceof AST_Class) {
  7409. return {
  7410. type: "MethodDefinition",
  7411. computed: computed,
  7412. kind: kind,
  7413. static: M.static,
  7414. key: to_moz(M.key),
  7415. value: to_moz(M.value)
  7416. };
  7417. }
  7418. return {
  7419. type: "Property",
  7420. computed: computed,
  7421. kind: kind,
  7422. key: key,
  7423. value: to_moz(M.value)
  7424. };
  7425. });
  7426. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  7427. if (parent instanceof AST_Object) {
  7428. return {
  7429. type: "Property",
  7430. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7431. kind: "init",
  7432. method: true,
  7433. shorthand: false,
  7434. key: to_moz(M.key),
  7435. value: to_moz(M.value)
  7436. };
  7437. }
  7438. const key = M instanceof AST_PrivateMethod
  7439. ? {
  7440. type: "PrivateIdentifier",
  7441. name: M.key.name
  7442. }
  7443. : to_moz(M.key);
  7444. return {
  7445. type: "MethodDefinition",
  7446. kind: M.key === "constructor" ? "constructor" : "method",
  7447. key,
  7448. value: to_moz(M.value),
  7449. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  7450. static: M.static,
  7451. };
  7452. });
  7453. def_to_moz(AST_Class, function To_Moz_Class(M) {
  7454. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  7455. return {
  7456. type: type,
  7457. superClass: to_moz(M.extends),
  7458. id: M.name ? to_moz(M.name) : null,
  7459. body: {
  7460. type: "ClassBody",
  7461. body: M.properties.map(to_moz)
  7462. }
  7463. };
  7464. });
  7465. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  7466. return {
  7467. type: "MetaProperty",
  7468. meta: {
  7469. type: "Identifier",
  7470. name: "new"
  7471. },
  7472. property: {
  7473. type: "Identifier",
  7474. name: "target"
  7475. }
  7476. };
  7477. });
  7478. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  7479. if (M instanceof AST_SymbolMethod && parent.quote) {
  7480. return {
  7481. type: "Literal",
  7482. value: M.name
  7483. };
  7484. }
  7485. var def = M.definition();
  7486. return {
  7487. type: "Identifier",
  7488. name: def ? def.mangled_name || def.name : M.name
  7489. };
  7490. });
  7491. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  7492. const pattern = M.value.source;
  7493. const flags = M.value.flags;
  7494. return {
  7495. type: "Literal",
  7496. value: null,
  7497. raw: M.print_to_string(),
  7498. regex: { pattern, flags }
  7499. };
  7500. });
  7501. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  7502. var value = M.value;
  7503. return {
  7504. type: "Literal",
  7505. value: value,
  7506. raw: M.raw || M.print_to_string()
  7507. };
  7508. });
  7509. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  7510. return {
  7511. type: "Identifier",
  7512. name: String(M.value)
  7513. };
  7514. });
  7515. def_to_moz(AST_BigInt, M => ({
  7516. type: "BigIntLiteral",
  7517. value: M.value
  7518. }));
  7519. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7520. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  7521. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  7522. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  7523. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  7524. /* -----[ tools ]----- */
  7525. function my_start_token(moznode) {
  7526. var loc = moznode.loc, start = loc && loc.start;
  7527. var range = moznode.range;
  7528. return new AST_Token(
  7529. "",
  7530. "",
  7531. start && start.line || 0,
  7532. start && start.column || 0,
  7533. range ? range [0] : moznode.start,
  7534. false,
  7535. [],
  7536. [],
  7537. loc && loc.source,
  7538. );
  7539. }
  7540. function my_end_token(moznode) {
  7541. var loc = moznode.loc, end = loc && loc.end;
  7542. var range = moznode.range;
  7543. return new AST_Token(
  7544. "",
  7545. "",
  7546. end && end.line || 0,
  7547. end && end.column || 0,
  7548. range ? range [0] : moznode.end,
  7549. false,
  7550. [],
  7551. [],
  7552. loc && loc.source,
  7553. );
  7554. }
  7555. var FROM_MOZ_STACK = null;
  7556. function from_moz(node) {
  7557. FROM_MOZ_STACK.push(node);
  7558. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  7559. FROM_MOZ_STACK.pop();
  7560. return ret;
  7561. }
  7562. AST_Node.from_mozilla_ast = function(node) {
  7563. var save_stack = FROM_MOZ_STACK;
  7564. FROM_MOZ_STACK = [];
  7565. var ast = from_moz(node);
  7566. FROM_MOZ_STACK = save_stack;
  7567. return ast;
  7568. };
  7569. function set_moz_loc(mynode, moznode) {
  7570. var start = mynode.start;
  7571. var end = mynode.end;
  7572. if (!(start && end)) {
  7573. return moznode;
  7574. }
  7575. if (start.pos != null && end.endpos != null) {
  7576. moznode.range = [start.pos, end.endpos];
  7577. }
  7578. if (start.line) {
  7579. moznode.loc = {
  7580. start: {line: start.line, column: start.col},
  7581. end: end.endline ? {line: end.endline, column: end.endcol} : null
  7582. };
  7583. if (start.file) {
  7584. moznode.loc.source = start.file;
  7585. }
  7586. }
  7587. return moznode;
  7588. }
  7589. function def_to_moz(mytype, handler) {
  7590. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  7591. return set_moz_loc(this, handler(this, parent));
  7592. });
  7593. }
  7594. var TO_MOZ_STACK = null;
  7595. function to_moz(node) {
  7596. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  7597. TO_MOZ_STACK.push(node);
  7598. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  7599. TO_MOZ_STACK.pop();
  7600. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  7601. return ast;
  7602. }
  7603. function to_moz_in_destructuring() {
  7604. var i = TO_MOZ_STACK.length;
  7605. while (i--) {
  7606. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  7607. return true;
  7608. }
  7609. }
  7610. return false;
  7611. }
  7612. function to_moz_block(node) {
  7613. return {
  7614. type: "BlockStatement",
  7615. body: node.body.map(to_moz)
  7616. };
  7617. }
  7618. function to_moz_scope(type, node) {
  7619. var body = node.body.map(to_moz);
  7620. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  7621. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  7622. }
  7623. return {
  7624. type: type,
  7625. body: body
  7626. };
  7627. }
  7628. })();
  7629. // return true if the node at the top of the stack (that means the
  7630. // innermost node in the current output) is lexically the first in
  7631. // a statement.
  7632. function first_in_statement(stack) {
  7633. let node = stack.parent(-1);
  7634. for (let i = 0, p; p = stack.parent(i); i++) {
  7635. if (p instanceof AST_Statement && p.body === node)
  7636. return true;
  7637. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  7638. (p.TYPE === "Call" && p.expression === node) ||
  7639. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  7640. (p instanceof AST_Dot && p.expression === node) ||
  7641. (p instanceof AST_Sub && p.expression === node) ||
  7642. (p instanceof AST_Conditional && p.condition === node) ||
  7643. (p instanceof AST_Binary && p.left === node) ||
  7644. (p instanceof AST_UnaryPostfix && p.expression === node)
  7645. ) {
  7646. node = p;
  7647. } else {
  7648. return false;
  7649. }
  7650. }
  7651. }
  7652. // Returns whether the leftmost item in the expression is an object
  7653. function left_is_object(node) {
  7654. if (node instanceof AST_Object) return true;
  7655. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  7656. if (node.TYPE === "Call") return left_is_object(node.expression);
  7657. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  7658. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  7659. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  7660. if (node instanceof AST_Binary) return left_is_object(node.left);
  7661. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  7662. return false;
  7663. }
  7664. /***********************************************************************
  7665. A JavaScript tokenizer / parser / beautifier / compressor.
  7666. https://github.com/mishoo/UglifyJS2
  7667. -------------------------------- (C) ---------------------------------
  7668. Author: Mihai Bazon
  7669. <mihai.bazon@gmail.com>
  7670. http://mihai.bazon.net/blog
  7671. Distributed under the BSD license:
  7672. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  7673. Redistribution and use in source and binary forms, with or without
  7674. modification, are permitted provided that the following conditions
  7675. are met:
  7676. * Redistributions of source code must retain the above
  7677. copyright notice, this list of conditions and the following
  7678. disclaimer.
  7679. * Redistributions in binary form must reproduce the above
  7680. copyright notice, this list of conditions and the following
  7681. disclaimer in the documentation and/or other materials
  7682. provided with the distribution.
  7683. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  7684. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7685. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  7686. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  7687. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  7688. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  7689. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  7690. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  7691. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  7692. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  7693. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  7694. SUCH DAMAGE.
  7695. ***********************************************************************/
  7696. const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
  7697. const CODE_LINE_BREAK = 10;
  7698. const CODE_SPACE = 32;
  7699. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/g;
  7700. function is_some_comments(comment) {
  7701. // multiline comment
  7702. return (
  7703. (comment.type === "comment2" || comment.type === "comment1")
  7704. && /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
  7705. );
  7706. }
  7707. class Rope {
  7708. constructor() {
  7709. this.committed = "";
  7710. this.current = "";
  7711. }
  7712. append(str) {
  7713. this.current += str;
  7714. }
  7715. insertAt(char, index) {
  7716. const { committed, current } = this;
  7717. if (index < committed.length) {
  7718. this.committed = committed.slice(0, index) + char + committed.slice(index);
  7719. } else if (index === committed.length) {
  7720. this.committed += char;
  7721. } else {
  7722. index -= committed.length;
  7723. this.committed += current.slice(0, index) + char;
  7724. this.current = current.slice(index);
  7725. }
  7726. }
  7727. charAt(index) {
  7728. const { committed } = this;
  7729. if (index < committed.length) return committed[index];
  7730. return this.current[index - committed.length];
  7731. }
  7732. curLength() {
  7733. return this.current.length;
  7734. }
  7735. length() {
  7736. return this.committed.length + this.current.length;
  7737. }
  7738. toString() {
  7739. return this.committed + this.current;
  7740. }
  7741. }
  7742. function OutputStream(options) {
  7743. var readonly = !options;
  7744. options = defaults(options, {
  7745. ascii_only : false,
  7746. beautify : false,
  7747. braces : false,
  7748. comments : "some",
  7749. ecma : 5,
  7750. ie8 : false,
  7751. indent_level : 4,
  7752. indent_start : 0,
  7753. inline_script : true,
  7754. keep_numbers : false,
  7755. keep_quoted_props : false,
  7756. max_line_len : false,
  7757. preamble : null,
  7758. preserve_annotations : false,
  7759. quote_keys : false,
  7760. quote_style : 0,
  7761. safari10 : false,
  7762. semicolons : true,
  7763. shebang : true,
  7764. shorthand : undefined,
  7765. source_map : null,
  7766. webkit : false,
  7767. width : 80,
  7768. wrap_iife : false,
  7769. wrap_func_args : true,
  7770. }, true);
  7771. if (options.shorthand === undefined)
  7772. options.shorthand = options.ecma > 5;
  7773. // Convert comment option to RegExp if neccessary and set up comments filter
  7774. var comment_filter = return_false; // Default case, throw all comments away
  7775. if (options.comments) {
  7776. let comments = options.comments;
  7777. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  7778. var regex_pos = options.comments.lastIndexOf("/");
  7779. comments = new RegExp(
  7780. options.comments.substr(1, regex_pos - 1),
  7781. options.comments.substr(regex_pos + 1)
  7782. );
  7783. }
  7784. if (comments instanceof RegExp) {
  7785. comment_filter = function(comment) {
  7786. return comment.type != "comment5" && comments.test(comment.value);
  7787. };
  7788. } else if (typeof comments === "function") {
  7789. comment_filter = function(comment) {
  7790. return comment.type != "comment5" && comments(this, comment);
  7791. };
  7792. } else if (comments === "some") {
  7793. comment_filter = is_some_comments;
  7794. } else { // NOTE includes "all" option
  7795. comment_filter = return_true;
  7796. }
  7797. }
  7798. var indentation = 0;
  7799. var current_col = 0;
  7800. var current_line = 1;
  7801. var current_pos = 0;
  7802. var OUTPUT = new Rope();
  7803. let printed_comments = new Set();
  7804. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  7805. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  7806. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  7807. var code = get_full_char_code(ch, 0).toString(16);
  7808. return "\\u{" + code + "}";
  7809. });
  7810. }
  7811. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  7812. var code = ch.charCodeAt(0).toString(16);
  7813. if (code.length <= 2 && !identifier) {
  7814. while (code.length < 2) code = "0" + code;
  7815. return "\\x" + code;
  7816. } else {
  7817. while (code.length < 4) code = "0" + code;
  7818. return "\\u" + code;
  7819. }
  7820. });
  7821. } : function(str) {
  7822. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  7823. if (lone) {
  7824. return "\\u" + lone.charCodeAt(0).toString(16);
  7825. }
  7826. return match;
  7827. });
  7828. };
  7829. function make_string(str, quote) {
  7830. var dq = 0, sq = 0;
  7831. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  7832. function(s, i) {
  7833. switch (s) {
  7834. case '"': ++dq; return '"';
  7835. case "'": ++sq; return "'";
  7836. case "\\": return "\\\\";
  7837. case "\n": return "\\n";
  7838. case "\r": return "\\r";
  7839. case "\t": return "\\t";
  7840. case "\b": return "\\b";
  7841. case "\f": return "\\f";
  7842. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  7843. case "\u2028": return "\\u2028";
  7844. case "\u2029": return "\\u2029";
  7845. case "\ufeff": return "\\ufeff";
  7846. case "\0":
  7847. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  7848. }
  7849. return s;
  7850. });
  7851. function quote_single() {
  7852. return "'" + str.replace(/\x27/g, "\\'") + "'";
  7853. }
  7854. function quote_double() {
  7855. return '"' + str.replace(/\x22/g, '\\"') + '"';
  7856. }
  7857. function quote_template() {
  7858. return "`" + str.replace(/`/g, "\\`") + "`";
  7859. }
  7860. str = to_utf8(str);
  7861. if (quote === "`") return quote_template();
  7862. switch (options.quote_style) {
  7863. case 1:
  7864. return quote_single();
  7865. case 2:
  7866. return quote_double();
  7867. case 3:
  7868. return quote == "'" ? quote_single() : quote_double();
  7869. default:
  7870. return dq > sq ? quote_single() : quote_double();
  7871. }
  7872. }
  7873. function encode_string(str, quote) {
  7874. var ret = make_string(str, quote);
  7875. if (options.inline_script) {
  7876. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  7877. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  7878. ret = ret.replace(/--\x3e/g, "--\\x3e");
  7879. }
  7880. return ret;
  7881. }
  7882. function make_name(name) {
  7883. name = name.toString();
  7884. name = to_utf8(name, true);
  7885. return name;
  7886. }
  7887. function make_indent(back) {
  7888. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  7889. }
  7890. /* -----[ beautification/minification ]----- */
  7891. var has_parens = false;
  7892. var might_need_space = false;
  7893. var might_need_semicolon = false;
  7894. var might_add_newline = 0;
  7895. var need_newline_indented = false;
  7896. var need_space = false;
  7897. var newline_insert = -1;
  7898. var last = "";
  7899. var mapping_token, mapping_name, mappings = options.source_map && [];
  7900. var do_add_mapping = mappings ? function() {
  7901. mappings.forEach(function(mapping) {
  7902. try {
  7903. let { name, token } = mapping;
  7904. if (token.type == "name" || token.type === "privatename") {
  7905. name = token.value;
  7906. } else if (name instanceof AST_Symbol) {
  7907. name = token.type === "string" ? token.value : name.name;
  7908. }
  7909. options.source_map.add(
  7910. mapping.token.file,
  7911. mapping.line, mapping.col,
  7912. mapping.token.line, mapping.token.col,
  7913. is_basic_identifier_string(name) ? name : undefined
  7914. );
  7915. } catch(ex) {
  7916. // Ignore bad mapping
  7917. }
  7918. });
  7919. mappings = [];
  7920. } : noop;
  7921. var ensure_line_len = options.max_line_len ? function() {
  7922. if (current_col > options.max_line_len) {
  7923. if (might_add_newline) {
  7924. OUTPUT.insertAt("\n", might_add_newline);
  7925. const curLength = OUTPUT.curLength();
  7926. if (mappings) {
  7927. var delta = curLength - current_col;
  7928. mappings.forEach(function(mapping) {
  7929. mapping.line++;
  7930. mapping.col += delta;
  7931. });
  7932. }
  7933. current_line++;
  7934. current_pos++;
  7935. current_col = curLength;
  7936. }
  7937. }
  7938. if (might_add_newline) {
  7939. might_add_newline = 0;
  7940. do_add_mapping();
  7941. }
  7942. } : noop;
  7943. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  7944. function print(str) {
  7945. str = String(str);
  7946. var ch = get_full_char(str, 0);
  7947. if (need_newline_indented && ch) {
  7948. need_newline_indented = false;
  7949. if (ch !== "\n") {
  7950. print("\n");
  7951. indent();
  7952. }
  7953. }
  7954. if (need_space && ch) {
  7955. need_space = false;
  7956. if (!/[\s;})]/.test(ch)) {
  7957. space();
  7958. }
  7959. }
  7960. newline_insert = -1;
  7961. var prev = last.charAt(last.length - 1);
  7962. if (might_need_semicolon) {
  7963. might_need_semicolon = false;
  7964. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  7965. if (options.semicolons || requireSemicolonChars.has(ch)) {
  7966. OUTPUT.append(";");
  7967. current_col++;
  7968. current_pos++;
  7969. } else {
  7970. ensure_line_len();
  7971. if (current_col > 0) {
  7972. OUTPUT.append("\n");
  7973. current_pos++;
  7974. current_line++;
  7975. current_col = 0;
  7976. }
  7977. if (/^\s+$/.test(str)) {
  7978. // reset the semicolon flag, since we didn't print one
  7979. // now and might still have to later
  7980. might_need_semicolon = true;
  7981. }
  7982. }
  7983. if (!options.beautify)
  7984. might_need_space = false;
  7985. }
  7986. }
  7987. if (might_need_space) {
  7988. if ((is_identifier_char(prev)
  7989. && (is_identifier_char(ch) || ch == "\\"))
  7990. || (ch == "/" && ch == prev)
  7991. || ((ch == "+" || ch == "-") && ch == last)
  7992. ) {
  7993. OUTPUT.append(" ");
  7994. current_col++;
  7995. current_pos++;
  7996. }
  7997. might_need_space = false;
  7998. }
  7999. if (mapping_token) {
  8000. mappings.push({
  8001. token: mapping_token,
  8002. name: mapping_name,
  8003. line: current_line,
  8004. col: current_col
  8005. });
  8006. mapping_token = false;
  8007. if (!might_add_newline) do_add_mapping();
  8008. }
  8009. OUTPUT.append(str);
  8010. has_parens = str[str.length - 1] == "(";
  8011. current_pos += str.length;
  8012. var a = str.split(/\r?\n/), n = a.length - 1;
  8013. current_line += n;
  8014. current_col += a[0].length;
  8015. if (n > 0) {
  8016. ensure_line_len();
  8017. current_col = a[n].length;
  8018. }
  8019. last = str;
  8020. }
  8021. var star = function() {
  8022. print("*");
  8023. };
  8024. var space = options.beautify ? function() {
  8025. print(" ");
  8026. } : function() {
  8027. might_need_space = true;
  8028. };
  8029. var indent = options.beautify ? function(half) {
  8030. if (options.beautify) {
  8031. print(make_indent(half ? 0.5 : 0));
  8032. }
  8033. } : noop;
  8034. var with_indent = options.beautify ? function(col, cont) {
  8035. if (col === true) col = next_indent();
  8036. var save_indentation = indentation;
  8037. indentation = col;
  8038. var ret = cont();
  8039. indentation = save_indentation;
  8040. return ret;
  8041. } : function(col, cont) { return cont(); };
  8042. var newline = options.beautify ? function() {
  8043. if (newline_insert < 0) return print("\n");
  8044. if (OUTPUT.charAt(newline_insert) != "\n") {
  8045. OUTPUT.insertAt("\n", newline_insert);
  8046. current_pos++;
  8047. current_line++;
  8048. }
  8049. newline_insert++;
  8050. } : options.max_line_len ? function() {
  8051. ensure_line_len();
  8052. might_add_newline = OUTPUT.length();
  8053. } : noop;
  8054. var semicolon = options.beautify ? function() {
  8055. print(";");
  8056. } : function() {
  8057. might_need_semicolon = true;
  8058. };
  8059. function force_semicolon() {
  8060. might_need_semicolon = false;
  8061. print(";");
  8062. }
  8063. function next_indent() {
  8064. return indentation + options.indent_level;
  8065. }
  8066. function with_block(cont) {
  8067. var ret;
  8068. print("{");
  8069. newline();
  8070. with_indent(next_indent(), function() {
  8071. ret = cont();
  8072. });
  8073. indent();
  8074. print("}");
  8075. return ret;
  8076. }
  8077. function with_parens(cont) {
  8078. print("(");
  8079. //XXX: still nice to have that for argument lists
  8080. //var ret = with_indent(current_col, cont);
  8081. var ret = cont();
  8082. print(")");
  8083. return ret;
  8084. }
  8085. function with_square(cont) {
  8086. print("[");
  8087. //var ret = with_indent(current_col, cont);
  8088. var ret = cont();
  8089. print("]");
  8090. return ret;
  8091. }
  8092. function comma() {
  8093. print(",");
  8094. space();
  8095. }
  8096. function colon() {
  8097. print(":");
  8098. space();
  8099. }
  8100. var add_mapping = mappings ? function(token, name) {
  8101. mapping_token = token;
  8102. mapping_name = name;
  8103. } : noop;
  8104. function get() {
  8105. if (might_add_newline) {
  8106. ensure_line_len();
  8107. }
  8108. return OUTPUT.toString();
  8109. }
  8110. function has_nlb() {
  8111. const output = OUTPUT.toString();
  8112. let n = output.length - 1;
  8113. while (n >= 0) {
  8114. const code = output.charCodeAt(n);
  8115. if (code === CODE_LINE_BREAK) {
  8116. return true;
  8117. }
  8118. if (code !== CODE_SPACE) {
  8119. return false;
  8120. }
  8121. n--;
  8122. }
  8123. return true;
  8124. }
  8125. function filter_comment(comment) {
  8126. if (!options.preserve_annotations) {
  8127. comment = comment.replace(r_annotation, " ");
  8128. }
  8129. if (/^\s*$/.test(comment)) {
  8130. return "";
  8131. }
  8132. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  8133. }
  8134. function prepend_comments(node) {
  8135. var self = this;
  8136. var start = node.start;
  8137. if (!start) return;
  8138. var printed_comments = self.printed_comments;
  8139. // There cannot be a newline between return and its value.
  8140. const return_with_value = node instanceof AST_Exit && node.value;
  8141. if (
  8142. start.comments_before
  8143. && printed_comments.has(start.comments_before)
  8144. ) {
  8145. if (return_with_value) {
  8146. start.comments_before = [];
  8147. } else {
  8148. return;
  8149. }
  8150. }
  8151. var comments = start.comments_before;
  8152. if (!comments) {
  8153. comments = start.comments_before = [];
  8154. }
  8155. printed_comments.add(comments);
  8156. if (return_with_value) {
  8157. var tw = new TreeWalker(function(node) {
  8158. var parent = tw.parent();
  8159. if (parent instanceof AST_Exit
  8160. || parent instanceof AST_Binary && parent.left === node
  8161. || parent.TYPE == "Call" && parent.expression === node
  8162. || parent instanceof AST_Conditional && parent.condition === node
  8163. || parent instanceof AST_Dot && parent.expression === node
  8164. || parent instanceof AST_Sequence && parent.expressions[0] === node
  8165. || parent instanceof AST_Sub && parent.expression === node
  8166. || parent instanceof AST_UnaryPostfix) {
  8167. if (!node.start) return;
  8168. var text = node.start.comments_before;
  8169. if (text && !printed_comments.has(text)) {
  8170. printed_comments.add(text);
  8171. comments = comments.concat(text);
  8172. }
  8173. } else {
  8174. return true;
  8175. }
  8176. });
  8177. tw.push(node);
  8178. node.value.walk(tw);
  8179. }
  8180. if (current_pos == 0) {
  8181. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  8182. && !printed_comments.has(comments[0])) {
  8183. print("#!" + comments.shift().value + "\n");
  8184. indent();
  8185. }
  8186. var preamble = options.preamble;
  8187. if (preamble) {
  8188. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  8189. }
  8190. }
  8191. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  8192. if (comments.length == 0) return;
  8193. var last_nlb = has_nlb();
  8194. comments.forEach(function(c, i) {
  8195. printed_comments.add(c);
  8196. if (!last_nlb) {
  8197. if (c.nlb) {
  8198. print("\n");
  8199. indent();
  8200. last_nlb = true;
  8201. } else if (i > 0) {
  8202. space();
  8203. }
  8204. }
  8205. if (/comment[134]/.test(c.type)) {
  8206. var value = filter_comment(c.value);
  8207. if (value) {
  8208. print("//" + value + "\n");
  8209. indent();
  8210. }
  8211. last_nlb = true;
  8212. } else if (c.type == "comment2") {
  8213. var value = filter_comment(c.value);
  8214. if (value) {
  8215. print("/*" + value + "*/");
  8216. }
  8217. last_nlb = false;
  8218. }
  8219. });
  8220. if (!last_nlb) {
  8221. if (start.nlb) {
  8222. print("\n");
  8223. indent();
  8224. } else {
  8225. space();
  8226. }
  8227. }
  8228. }
  8229. function append_comments(node, tail) {
  8230. var self = this;
  8231. var token = node.end;
  8232. if (!token) return;
  8233. var printed_comments = self.printed_comments;
  8234. var comments = token[tail ? "comments_before" : "comments_after"];
  8235. if (!comments || printed_comments.has(comments)) return;
  8236. if (!(node instanceof AST_Statement || comments.every((c) =>
  8237. !/comment[134]/.test(c.type)
  8238. ))) return;
  8239. printed_comments.add(comments);
  8240. var insert = OUTPUT.length();
  8241. comments.filter(comment_filter, node).forEach(function(c, i) {
  8242. if (printed_comments.has(c)) return;
  8243. printed_comments.add(c);
  8244. need_space = false;
  8245. if (need_newline_indented) {
  8246. print("\n");
  8247. indent();
  8248. need_newline_indented = false;
  8249. } else if (c.nlb && (i > 0 || !has_nlb())) {
  8250. print("\n");
  8251. indent();
  8252. } else if (i > 0 || !tail) {
  8253. space();
  8254. }
  8255. if (/comment[134]/.test(c.type)) {
  8256. const value = filter_comment(c.value);
  8257. if (value) {
  8258. print("//" + value);
  8259. }
  8260. need_newline_indented = true;
  8261. } else if (c.type == "comment2") {
  8262. const value = filter_comment(c.value);
  8263. if (value) {
  8264. print("/*" + value + "*/");
  8265. }
  8266. need_space = true;
  8267. }
  8268. });
  8269. if (OUTPUT.length() > insert) newline_insert = insert;
  8270. }
  8271. var stack = [];
  8272. return {
  8273. get : get,
  8274. toString : get,
  8275. indent : indent,
  8276. in_directive : false,
  8277. use_asm : null,
  8278. active_scope : null,
  8279. indentation : function() { return indentation; },
  8280. current_width : function() { return current_col - indentation; },
  8281. should_break : function() { return options.width && this.current_width() >= options.width; },
  8282. has_parens : function() { return has_parens; },
  8283. newline : newline,
  8284. print : print,
  8285. star : star,
  8286. space : space,
  8287. comma : comma,
  8288. colon : colon,
  8289. last : function() { return last; },
  8290. semicolon : semicolon,
  8291. force_semicolon : force_semicolon,
  8292. to_utf8 : to_utf8,
  8293. print_name : function(name) { print(make_name(name)); },
  8294. print_string : function(str, quote, escape_directive) {
  8295. var encoded = encode_string(str, quote);
  8296. if (escape_directive === true && !encoded.includes("\\")) {
  8297. // Insert semicolons to break directive prologue
  8298. if (!EXPECT_DIRECTIVE.test(OUTPUT.toString())) {
  8299. force_semicolon();
  8300. }
  8301. force_semicolon();
  8302. }
  8303. print(encoded);
  8304. },
  8305. print_template_string_chars: function(str) {
  8306. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  8307. return print(encoded.substr(1, encoded.length - 2));
  8308. },
  8309. encode_string : encode_string,
  8310. next_indent : next_indent,
  8311. with_indent : with_indent,
  8312. with_block : with_block,
  8313. with_parens : with_parens,
  8314. with_square : with_square,
  8315. add_mapping : add_mapping,
  8316. option : function(opt) { return options[opt]; },
  8317. printed_comments: printed_comments,
  8318. prepend_comments: readonly ? noop : prepend_comments,
  8319. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  8320. line : function() { return current_line; },
  8321. col : function() { return current_col; },
  8322. pos : function() { return current_pos; },
  8323. push_node : function(node) { stack.push(node); },
  8324. pop_node : function() { return stack.pop(); },
  8325. parent : function(n) {
  8326. return stack[stack.length - 2 - (n || 0)];
  8327. }
  8328. };
  8329. }
  8330. /* -----[ code generators ]----- */
  8331. (function() {
  8332. /* -----[ utils ]----- */
  8333. function DEFPRINT(nodetype, generator) {
  8334. nodetype.DEFMETHOD("_codegen", generator);
  8335. }
  8336. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  8337. var self = this, generator = self._codegen;
  8338. if (self instanceof AST_Scope) {
  8339. output.active_scope = self;
  8340. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  8341. output.use_asm = output.active_scope;
  8342. }
  8343. function doit() {
  8344. output.prepend_comments(self);
  8345. self.add_source_map(output);
  8346. generator(self, output);
  8347. output.append_comments(self);
  8348. }
  8349. output.push_node(self);
  8350. if (force_parens || self.needs_parens(output)) {
  8351. output.with_parens(doit);
  8352. } else {
  8353. doit();
  8354. }
  8355. output.pop_node();
  8356. if (self === output.use_asm) {
  8357. output.use_asm = null;
  8358. }
  8359. });
  8360. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  8361. AST_Node.DEFMETHOD("print_to_string", function(options) {
  8362. var output = OutputStream(options);
  8363. this.print(output);
  8364. return output.get();
  8365. });
  8366. /* -----[ PARENTHESES ]----- */
  8367. function PARENS(nodetype, func) {
  8368. if (Array.isArray(nodetype)) {
  8369. nodetype.forEach(function(nodetype) {
  8370. PARENS(nodetype, func);
  8371. });
  8372. } else {
  8373. nodetype.DEFMETHOD("needs_parens", func);
  8374. }
  8375. }
  8376. PARENS(AST_Node, return_false);
  8377. // a function expression needs parens around it when it's provably
  8378. // the first token to appear in a statement.
  8379. PARENS(AST_Function, function(output) {
  8380. if (!output.has_parens() && first_in_statement(output)) {
  8381. return true;
  8382. }
  8383. if (output.option("webkit")) {
  8384. var p = output.parent();
  8385. if (p instanceof AST_PropAccess && p.expression === this) {
  8386. return true;
  8387. }
  8388. }
  8389. if (output.option("wrap_iife")) {
  8390. var p = output.parent();
  8391. if (p instanceof AST_Call && p.expression === this) {
  8392. return true;
  8393. }
  8394. }
  8395. if (output.option("wrap_func_args")) {
  8396. var p = output.parent();
  8397. if (p instanceof AST_Call && p.args.includes(this)) {
  8398. return true;
  8399. }
  8400. }
  8401. return false;
  8402. });
  8403. PARENS(AST_Arrow, function(output) {
  8404. var p = output.parent();
  8405. if (
  8406. output.option("wrap_func_args")
  8407. && p instanceof AST_Call
  8408. && p.args.includes(this)
  8409. ) {
  8410. return true;
  8411. }
  8412. return p instanceof AST_PropAccess && p.expression === this;
  8413. });
  8414. // same goes for an object literal (as in AST_Function), because
  8415. // otherwise {...} would be interpreted as a block of code.
  8416. PARENS(AST_Object, function(output) {
  8417. return !output.has_parens() && first_in_statement(output);
  8418. });
  8419. PARENS(AST_ClassExpression, first_in_statement);
  8420. PARENS(AST_Unary, function(output) {
  8421. var p = output.parent();
  8422. return p instanceof AST_PropAccess && p.expression === this
  8423. || p instanceof AST_Call && p.expression === this
  8424. || p instanceof AST_Binary
  8425. && p.operator === "**"
  8426. && this instanceof AST_UnaryPrefix
  8427. && p.left === this
  8428. && this.operator !== "++"
  8429. && this.operator !== "--";
  8430. });
  8431. PARENS(AST_Await, function(output) {
  8432. var p = output.parent();
  8433. return p instanceof AST_PropAccess && p.expression === this
  8434. || p instanceof AST_Call && p.expression === this
  8435. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  8436. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  8437. });
  8438. PARENS(AST_Sequence, function(output) {
  8439. var p = output.parent();
  8440. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  8441. || p instanceof AST_Unary // !(foo, bar, baz)
  8442. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  8443. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  8444. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  8445. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  8446. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  8447. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  8448. * ==> 20 (side effect, set a := 10 and b := 20) */
  8449. || p instanceof AST_Arrow // x => (x, x)
  8450. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  8451. || p instanceof AST_Expansion // [...(a, b)]
  8452. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  8453. || p instanceof AST_Yield // yield (foo, bar)
  8454. || p instanceof AST_Export // export default (foo, bar)
  8455. ;
  8456. });
  8457. PARENS(AST_Binary, function(output) {
  8458. var p = output.parent();
  8459. // (foo && bar)()
  8460. if (p instanceof AST_Call && p.expression === this)
  8461. return true;
  8462. // typeof (foo && bar)
  8463. if (p instanceof AST_Unary)
  8464. return true;
  8465. // (foo && bar)["prop"], (foo && bar).prop
  8466. if (p instanceof AST_PropAccess && p.expression === this)
  8467. return true;
  8468. // this deals with precedence: 3 * (2 + 1)
  8469. if (p instanceof AST_Binary) {
  8470. const po = p.operator;
  8471. const so = this.operator;
  8472. if (so === "??" && (po === "||" || po === "&&")) {
  8473. return true;
  8474. }
  8475. if (po === "??" && (so === "||" || so === "&&")) {
  8476. return true;
  8477. }
  8478. const pp = PRECEDENCE[po];
  8479. const sp = PRECEDENCE[so];
  8480. if (pp > sp
  8481. || (pp == sp
  8482. && (this === p.right || po == "**"))) {
  8483. return true;
  8484. }
  8485. }
  8486. });
  8487. PARENS(AST_Yield, function(output) {
  8488. var p = output.parent();
  8489. // (yield 1) + (yield 2)
  8490. // a = yield 3
  8491. if (p instanceof AST_Binary && p.operator !== "=")
  8492. return true;
  8493. // (yield 1)()
  8494. // new (yield 1)()
  8495. if (p instanceof AST_Call && p.expression === this)
  8496. return true;
  8497. // (yield 1) ? yield 2 : yield 3
  8498. if (p instanceof AST_Conditional && p.condition === this)
  8499. return true;
  8500. // -(yield 4)
  8501. if (p instanceof AST_Unary)
  8502. return true;
  8503. // (yield x).foo
  8504. // (yield x)['foo']
  8505. if (p instanceof AST_PropAccess && p.expression === this)
  8506. return true;
  8507. });
  8508. PARENS(AST_PropAccess, function(output) {
  8509. var p = output.parent();
  8510. if (p instanceof AST_New && p.expression === this) {
  8511. // i.e. new (foo.bar().baz)
  8512. //
  8513. // if there's one call into this subtree, then we need
  8514. // parens around it too, otherwise the call will be
  8515. // interpreted as passing the arguments to the upper New
  8516. // expression.
  8517. return walk(this, node => {
  8518. if (node instanceof AST_Scope) return true;
  8519. if (node instanceof AST_Call) {
  8520. return walk_abort; // makes walk() return true.
  8521. }
  8522. });
  8523. }
  8524. });
  8525. PARENS(AST_Call, function(output) {
  8526. var p = output.parent(), p1;
  8527. if (p instanceof AST_New && p.expression === this
  8528. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  8529. return true;
  8530. // workaround for Safari bug.
  8531. // https://bugs.webkit.org/show_bug.cgi?id=123506
  8532. return this.expression instanceof AST_Function
  8533. && p instanceof AST_PropAccess
  8534. && p.expression === this
  8535. && (p1 = output.parent(1)) instanceof AST_Assign
  8536. && p1.left === p;
  8537. });
  8538. PARENS(AST_New, function(output) {
  8539. var p = output.parent();
  8540. if (this.args.length === 0
  8541. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  8542. || p instanceof AST_Call && p.expression === this
  8543. || p instanceof AST_PrefixedTemplateString && p.prefix === this)) // (new foo)(bar)
  8544. return true;
  8545. });
  8546. PARENS(AST_Number, function(output) {
  8547. var p = output.parent();
  8548. if (p instanceof AST_PropAccess && p.expression === this) {
  8549. var value = this.getValue();
  8550. if (value < 0 || /^0/.test(make_num(value))) {
  8551. return true;
  8552. }
  8553. }
  8554. });
  8555. PARENS(AST_BigInt, function(output) {
  8556. var p = output.parent();
  8557. if (p instanceof AST_PropAccess && p.expression === this) {
  8558. var value = this.getValue();
  8559. if (value.startsWith("-")) {
  8560. return true;
  8561. }
  8562. }
  8563. });
  8564. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  8565. var p = output.parent();
  8566. // !(a = false) → true
  8567. if (p instanceof AST_Unary)
  8568. return true;
  8569. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  8570. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  8571. return true;
  8572. // (a = func)() —or— new (a = Object)()
  8573. if (p instanceof AST_Call && p.expression === this)
  8574. return true;
  8575. // (a = foo) ? bar : baz
  8576. if (p instanceof AST_Conditional && p.condition === this)
  8577. return true;
  8578. // (a = foo)["prop"] —or— (a = foo).prop
  8579. if (p instanceof AST_PropAccess && p.expression === this)
  8580. return true;
  8581. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  8582. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  8583. return true;
  8584. });
  8585. /* -----[ PRINTERS ]----- */
  8586. DEFPRINT(AST_Directive, function(self, output) {
  8587. output.print_string(self.value, self.quote);
  8588. output.semicolon();
  8589. });
  8590. DEFPRINT(AST_Expansion, function (self, output) {
  8591. output.print("...");
  8592. self.expression.print(output);
  8593. });
  8594. DEFPRINT(AST_Destructuring, function (self, output) {
  8595. output.print(self.is_array ? "[" : "{");
  8596. var len = self.names.length;
  8597. self.names.forEach(function (name, i) {
  8598. if (i > 0) output.comma();
  8599. name.print(output);
  8600. // If the final element is a hole, we need to make sure it
  8601. // doesn't look like a trailing comma, by inserting an actual
  8602. // trailing comma.
  8603. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  8604. });
  8605. output.print(self.is_array ? "]" : "}");
  8606. });
  8607. DEFPRINT(AST_Debugger, function(self, output) {
  8608. output.print("debugger");
  8609. output.semicolon();
  8610. });
  8611. /* -----[ statements ]----- */
  8612. function display_body(body, is_toplevel, output, allow_directives) {
  8613. var last = body.length - 1;
  8614. output.in_directive = allow_directives;
  8615. body.forEach(function(stmt, i) {
  8616. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  8617. stmt instanceof AST_EmptyStatement ||
  8618. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  8619. )) {
  8620. output.in_directive = false;
  8621. }
  8622. if (!(stmt instanceof AST_EmptyStatement)) {
  8623. output.indent();
  8624. stmt.print(output);
  8625. if (!(i == last && is_toplevel)) {
  8626. output.newline();
  8627. if (is_toplevel) output.newline();
  8628. }
  8629. }
  8630. if (output.in_directive === true &&
  8631. stmt instanceof AST_SimpleStatement &&
  8632. stmt.body instanceof AST_String
  8633. ) {
  8634. output.in_directive = false;
  8635. }
  8636. });
  8637. output.in_directive = false;
  8638. }
  8639. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  8640. force_statement(this.body, output);
  8641. });
  8642. DEFPRINT(AST_Statement, function(self, output) {
  8643. self.body.print(output);
  8644. output.semicolon();
  8645. });
  8646. DEFPRINT(AST_Toplevel, function(self, output) {
  8647. display_body(self.body, true, output, true);
  8648. output.print("");
  8649. });
  8650. DEFPRINT(AST_LabeledStatement, function(self, output) {
  8651. self.label.print(output);
  8652. output.colon();
  8653. self.body.print(output);
  8654. });
  8655. DEFPRINT(AST_SimpleStatement, function(self, output) {
  8656. self.body.print(output);
  8657. output.semicolon();
  8658. });
  8659. function print_braced_empty(self, output) {
  8660. output.print("{");
  8661. output.with_indent(output.next_indent(), function() {
  8662. output.append_comments(self, true);
  8663. });
  8664. output.print("}");
  8665. }
  8666. function print_braced(self, output, allow_directives) {
  8667. if (self.body.length > 0) {
  8668. output.with_block(function() {
  8669. display_body(self.body, false, output, allow_directives);
  8670. });
  8671. } else print_braced_empty(self, output);
  8672. }
  8673. DEFPRINT(AST_BlockStatement, function(self, output) {
  8674. print_braced(self, output);
  8675. });
  8676. DEFPRINT(AST_EmptyStatement, function(self, output) {
  8677. output.semicolon();
  8678. });
  8679. DEFPRINT(AST_Do, function(self, output) {
  8680. output.print("do");
  8681. output.space();
  8682. make_block(self.body, output);
  8683. output.space();
  8684. output.print("while");
  8685. output.space();
  8686. output.with_parens(function() {
  8687. self.condition.print(output);
  8688. });
  8689. output.semicolon();
  8690. });
  8691. DEFPRINT(AST_While, function(self, output) {
  8692. output.print("while");
  8693. output.space();
  8694. output.with_parens(function() {
  8695. self.condition.print(output);
  8696. });
  8697. output.space();
  8698. self._do_print_body(output);
  8699. });
  8700. DEFPRINT(AST_For, function(self, output) {
  8701. output.print("for");
  8702. output.space();
  8703. output.with_parens(function() {
  8704. if (self.init) {
  8705. if (self.init instanceof AST_Definitions) {
  8706. self.init.print(output);
  8707. } else {
  8708. parenthesize_for_noin(self.init, output, true);
  8709. }
  8710. output.print(";");
  8711. output.space();
  8712. } else {
  8713. output.print(";");
  8714. }
  8715. if (self.condition) {
  8716. self.condition.print(output);
  8717. output.print(";");
  8718. output.space();
  8719. } else {
  8720. output.print(";");
  8721. }
  8722. if (self.step) {
  8723. self.step.print(output);
  8724. }
  8725. });
  8726. output.space();
  8727. self._do_print_body(output);
  8728. });
  8729. DEFPRINT(AST_ForIn, function(self, output) {
  8730. output.print("for");
  8731. if (self.await) {
  8732. output.space();
  8733. output.print("await");
  8734. }
  8735. output.space();
  8736. output.with_parens(function() {
  8737. self.init.print(output);
  8738. output.space();
  8739. output.print(self instanceof AST_ForOf ? "of" : "in");
  8740. output.space();
  8741. self.object.print(output);
  8742. });
  8743. output.space();
  8744. self._do_print_body(output);
  8745. });
  8746. DEFPRINT(AST_With, function(self, output) {
  8747. output.print("with");
  8748. output.space();
  8749. output.with_parens(function() {
  8750. self.expression.print(output);
  8751. });
  8752. output.space();
  8753. self._do_print_body(output);
  8754. });
  8755. /* -----[ functions ]----- */
  8756. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  8757. var self = this;
  8758. if (!nokeyword) {
  8759. if (self.async) {
  8760. output.print("async");
  8761. output.space();
  8762. }
  8763. output.print("function");
  8764. if (self.is_generator) {
  8765. output.star();
  8766. }
  8767. if (self.name) {
  8768. output.space();
  8769. }
  8770. }
  8771. if (self.name instanceof AST_Symbol) {
  8772. self.name.print(output);
  8773. } else if (nokeyword && self.name instanceof AST_Node) {
  8774. output.with_square(function() {
  8775. self.name.print(output); // Computed method name
  8776. });
  8777. }
  8778. output.with_parens(function() {
  8779. self.argnames.forEach(function(arg, i) {
  8780. if (i) output.comma();
  8781. arg.print(output);
  8782. });
  8783. });
  8784. output.space();
  8785. print_braced(self, output, true);
  8786. });
  8787. DEFPRINT(AST_Lambda, function(self, output) {
  8788. self._do_print(output);
  8789. });
  8790. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  8791. var tag = self.prefix;
  8792. var parenthesize_tag = tag instanceof AST_Lambda
  8793. || tag instanceof AST_Binary
  8794. || tag instanceof AST_Conditional
  8795. || tag instanceof AST_Sequence
  8796. || tag instanceof AST_Unary
  8797. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  8798. if (parenthesize_tag) output.print("(");
  8799. self.prefix.print(output);
  8800. if (parenthesize_tag) output.print(")");
  8801. self.template_string.print(output);
  8802. });
  8803. DEFPRINT(AST_TemplateString, function(self, output) {
  8804. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  8805. output.print("`");
  8806. for (var i = 0; i < self.segments.length; i++) {
  8807. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  8808. output.print("${");
  8809. self.segments[i].print(output);
  8810. output.print("}");
  8811. } else if (is_tagged) {
  8812. output.print(self.segments[i].raw);
  8813. } else {
  8814. output.print_template_string_chars(self.segments[i].value);
  8815. }
  8816. }
  8817. output.print("`");
  8818. });
  8819. DEFPRINT(AST_TemplateSegment, function(self, output) {
  8820. output.print_template_string_chars(self.value);
  8821. });
  8822. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  8823. var self = this;
  8824. var parent = output.parent();
  8825. var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
  8826. parent instanceof AST_Unary ||
  8827. (parent instanceof AST_Call && self === parent.expression);
  8828. if (needs_parens) { output.print("("); }
  8829. if (self.async) {
  8830. output.print("async");
  8831. output.space();
  8832. }
  8833. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  8834. self.argnames[0].print(output);
  8835. } else {
  8836. output.with_parens(function() {
  8837. self.argnames.forEach(function(arg, i) {
  8838. if (i) output.comma();
  8839. arg.print(output);
  8840. });
  8841. });
  8842. }
  8843. output.space();
  8844. output.print("=>");
  8845. output.space();
  8846. const first_statement = self.body[0];
  8847. if (
  8848. self.body.length === 1
  8849. && first_statement instanceof AST_Return
  8850. ) {
  8851. const returned = first_statement.value;
  8852. if (!returned) {
  8853. output.print("{}");
  8854. } else if (left_is_object(returned)) {
  8855. output.print("(");
  8856. returned.print(output);
  8857. output.print(")");
  8858. } else {
  8859. returned.print(output);
  8860. }
  8861. } else {
  8862. print_braced(self, output);
  8863. }
  8864. if (needs_parens) { output.print(")"); }
  8865. });
  8866. /* -----[ exits ]----- */
  8867. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  8868. output.print(kind);
  8869. if (this.value) {
  8870. output.space();
  8871. const comments = this.value.start.comments_before;
  8872. if (comments && comments.length && !output.printed_comments.has(comments)) {
  8873. output.print("(");
  8874. this.value.print(output);
  8875. output.print(")");
  8876. } else {
  8877. this.value.print(output);
  8878. }
  8879. }
  8880. output.semicolon();
  8881. });
  8882. DEFPRINT(AST_Return, function(self, output) {
  8883. self._do_print(output, "return");
  8884. });
  8885. DEFPRINT(AST_Throw, function(self, output) {
  8886. self._do_print(output, "throw");
  8887. });
  8888. /* -----[ yield ]----- */
  8889. DEFPRINT(AST_Yield, function(self, output) {
  8890. var star = self.is_star ? "*" : "";
  8891. output.print("yield" + star);
  8892. if (self.expression) {
  8893. output.space();
  8894. self.expression.print(output);
  8895. }
  8896. });
  8897. DEFPRINT(AST_Await, function(self, output) {
  8898. output.print("await");
  8899. output.space();
  8900. var e = self.expression;
  8901. var parens = !(
  8902. e instanceof AST_Call
  8903. || e instanceof AST_SymbolRef
  8904. || e instanceof AST_PropAccess
  8905. || e instanceof AST_Unary
  8906. || e instanceof AST_Constant
  8907. || e instanceof AST_Await
  8908. || e instanceof AST_Object
  8909. );
  8910. if (parens) output.print("(");
  8911. self.expression.print(output);
  8912. if (parens) output.print(")");
  8913. });
  8914. /* -----[ loop control ]----- */
  8915. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  8916. output.print(kind);
  8917. if (this.label) {
  8918. output.space();
  8919. this.label.print(output);
  8920. }
  8921. output.semicolon();
  8922. });
  8923. DEFPRINT(AST_Break, function(self, output) {
  8924. self._do_print(output, "break");
  8925. });
  8926. DEFPRINT(AST_Continue, function(self, output) {
  8927. self._do_print(output, "continue");
  8928. });
  8929. /* -----[ if ]----- */
  8930. function make_then(self, output) {
  8931. var b = self.body;
  8932. if (output.option("braces")
  8933. || output.option("ie8") && b instanceof AST_Do)
  8934. return make_block(b, output);
  8935. // The squeezer replaces "block"-s that contain only a single
  8936. // statement with the statement itself; technically, the AST
  8937. // is correct, but this can create problems when we output an
  8938. // IF having an ELSE clause where the THEN clause ends in an
  8939. // IF *without* an ELSE block (then the outer ELSE would refer
  8940. // to the inner IF). This function checks for this case and
  8941. // adds the block braces if needed.
  8942. if (!b) return output.force_semicolon();
  8943. while (true) {
  8944. if (b instanceof AST_If) {
  8945. if (!b.alternative) {
  8946. make_block(self.body, output);
  8947. return;
  8948. }
  8949. b = b.alternative;
  8950. } else if (b instanceof AST_StatementWithBody) {
  8951. b = b.body;
  8952. } else break;
  8953. }
  8954. force_statement(self.body, output);
  8955. }
  8956. DEFPRINT(AST_If, function(self, output) {
  8957. output.print("if");
  8958. output.space();
  8959. output.with_parens(function() {
  8960. self.condition.print(output);
  8961. });
  8962. output.space();
  8963. if (self.alternative) {
  8964. make_then(self, output);
  8965. output.space();
  8966. output.print("else");
  8967. output.space();
  8968. if (self.alternative instanceof AST_If)
  8969. self.alternative.print(output);
  8970. else
  8971. force_statement(self.alternative, output);
  8972. } else {
  8973. self._do_print_body(output);
  8974. }
  8975. });
  8976. /* -----[ switch ]----- */
  8977. DEFPRINT(AST_Switch, function(self, output) {
  8978. output.print("switch");
  8979. output.space();
  8980. output.with_parens(function() {
  8981. self.expression.print(output);
  8982. });
  8983. output.space();
  8984. var last = self.body.length - 1;
  8985. if (last < 0) print_braced_empty(self, output);
  8986. else output.with_block(function() {
  8987. self.body.forEach(function(branch, i) {
  8988. output.indent(true);
  8989. branch.print(output);
  8990. if (i < last && branch.body.length > 0)
  8991. output.newline();
  8992. });
  8993. });
  8994. });
  8995. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  8996. output.newline();
  8997. this.body.forEach(function(stmt) {
  8998. output.indent();
  8999. stmt.print(output);
  9000. output.newline();
  9001. });
  9002. });
  9003. DEFPRINT(AST_Default, function(self, output) {
  9004. output.print("default:");
  9005. self._do_print_body(output);
  9006. });
  9007. DEFPRINT(AST_Case, function(self, output) {
  9008. output.print("case");
  9009. output.space();
  9010. self.expression.print(output);
  9011. output.print(":");
  9012. self._do_print_body(output);
  9013. });
  9014. /* -----[ exceptions ]----- */
  9015. DEFPRINT(AST_Try, function(self, output) {
  9016. output.print("try");
  9017. output.space();
  9018. print_braced(self, output);
  9019. if (self.bcatch) {
  9020. output.space();
  9021. self.bcatch.print(output);
  9022. }
  9023. if (self.bfinally) {
  9024. output.space();
  9025. self.bfinally.print(output);
  9026. }
  9027. });
  9028. DEFPRINT(AST_Catch, function(self, output) {
  9029. output.print("catch");
  9030. if (self.argname) {
  9031. output.space();
  9032. output.with_parens(function() {
  9033. self.argname.print(output);
  9034. });
  9035. }
  9036. output.space();
  9037. print_braced(self, output);
  9038. });
  9039. DEFPRINT(AST_Finally, function(self, output) {
  9040. output.print("finally");
  9041. output.space();
  9042. print_braced(self, output);
  9043. });
  9044. /* -----[ var/const ]----- */
  9045. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  9046. output.print(kind);
  9047. output.space();
  9048. this.definitions.forEach(function(def, i) {
  9049. if (i) output.comma();
  9050. def.print(output);
  9051. });
  9052. var p = output.parent();
  9053. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  9054. var output_semicolon = !in_for || p && p.init !== this;
  9055. if (output_semicolon)
  9056. output.semicolon();
  9057. });
  9058. DEFPRINT(AST_Let, function(self, output) {
  9059. self._do_print(output, "let");
  9060. });
  9061. DEFPRINT(AST_Var, function(self, output) {
  9062. self._do_print(output, "var");
  9063. });
  9064. DEFPRINT(AST_Const, function(self, output) {
  9065. self._do_print(output, "const");
  9066. });
  9067. DEFPRINT(AST_Import, function(self, output) {
  9068. output.print("import");
  9069. output.space();
  9070. if (self.imported_name) {
  9071. self.imported_name.print(output);
  9072. }
  9073. if (self.imported_name && self.imported_names) {
  9074. output.print(",");
  9075. output.space();
  9076. }
  9077. if (self.imported_names) {
  9078. if (self.imported_names.length === 1 && self.imported_names[0].foreign_name.name === "*") {
  9079. self.imported_names[0].print(output);
  9080. } else {
  9081. output.print("{");
  9082. self.imported_names.forEach(function (name_import, i) {
  9083. output.space();
  9084. name_import.print(output);
  9085. if (i < self.imported_names.length - 1) {
  9086. output.print(",");
  9087. }
  9088. });
  9089. output.space();
  9090. output.print("}");
  9091. }
  9092. }
  9093. if (self.imported_name || self.imported_names) {
  9094. output.space();
  9095. output.print("from");
  9096. output.space();
  9097. }
  9098. self.module_name.print(output);
  9099. if (self.assert_clause) {
  9100. output.print("assert");
  9101. self.assert_clause.print(output);
  9102. }
  9103. output.semicolon();
  9104. });
  9105. DEFPRINT(AST_ImportMeta, function(self, output) {
  9106. output.print("import.meta");
  9107. });
  9108. DEFPRINT(AST_NameMapping, function(self, output) {
  9109. var is_import = output.parent() instanceof AST_Import;
  9110. var definition = self.name.definition();
  9111. var names_are_different =
  9112. (definition && definition.mangled_name || self.name.name) !==
  9113. self.foreign_name.name;
  9114. if (names_are_different) {
  9115. if (is_import) {
  9116. output.print(self.foreign_name.name);
  9117. } else {
  9118. self.name.print(output);
  9119. }
  9120. output.space();
  9121. output.print("as");
  9122. output.space();
  9123. if (is_import) {
  9124. self.name.print(output);
  9125. } else {
  9126. output.print(self.foreign_name.name);
  9127. }
  9128. } else {
  9129. self.name.print(output);
  9130. }
  9131. });
  9132. DEFPRINT(AST_Export, function(self, output) {
  9133. output.print("export");
  9134. output.space();
  9135. if (self.is_default) {
  9136. output.print("default");
  9137. output.space();
  9138. }
  9139. if (self.exported_names) {
  9140. if (self.exported_names.length === 1 && self.exported_names[0].name.name === "*") {
  9141. self.exported_names[0].print(output);
  9142. } else {
  9143. output.print("{");
  9144. self.exported_names.forEach(function(name_export, i) {
  9145. output.space();
  9146. name_export.print(output);
  9147. if (i < self.exported_names.length - 1) {
  9148. output.print(",");
  9149. }
  9150. });
  9151. output.space();
  9152. output.print("}");
  9153. }
  9154. } else if (self.exported_value) {
  9155. self.exported_value.print(output);
  9156. } else if (self.exported_definition) {
  9157. self.exported_definition.print(output);
  9158. if (self.exported_definition instanceof AST_Definitions) return;
  9159. }
  9160. if (self.module_name) {
  9161. output.space();
  9162. output.print("from");
  9163. output.space();
  9164. self.module_name.print(output);
  9165. }
  9166. if (self.assert_clause) {
  9167. output.print("assert");
  9168. self.assert_clause.print(output);
  9169. }
  9170. if (self.exported_value
  9171. && !(self.exported_value instanceof AST_Defun ||
  9172. self.exported_value instanceof AST_Function ||
  9173. self.exported_value instanceof AST_Class)
  9174. || self.module_name
  9175. || self.exported_names
  9176. ) {
  9177. output.semicolon();
  9178. }
  9179. });
  9180. function parenthesize_for_noin(node, output, noin) {
  9181. var parens = false;
  9182. // need to take some precautions here:
  9183. // https://github.com/mishoo/UglifyJS2/issues/60
  9184. if (noin) {
  9185. parens = walk(node, node => {
  9186. // Don't go into scopes -- except arrow functions:
  9187. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  9188. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  9189. return true;
  9190. }
  9191. if (node instanceof AST_Binary && node.operator == "in") {
  9192. return walk_abort; // makes walk() return true
  9193. }
  9194. });
  9195. }
  9196. node.print(output, parens);
  9197. }
  9198. DEFPRINT(AST_VarDef, function(self, output) {
  9199. self.name.print(output);
  9200. if (self.value) {
  9201. output.space();
  9202. output.print("=");
  9203. output.space();
  9204. var p = output.parent(1);
  9205. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  9206. parenthesize_for_noin(self.value, output, noin);
  9207. }
  9208. });
  9209. /* -----[ other expressions ]----- */
  9210. DEFPRINT(AST_Call, function(self, output) {
  9211. self.expression.print(output);
  9212. if (self instanceof AST_New && self.args.length === 0)
  9213. return;
  9214. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  9215. output.add_mapping(self.start);
  9216. }
  9217. if (self.optional) output.print("?.");
  9218. output.with_parens(function() {
  9219. self.args.forEach(function(expr, i) {
  9220. if (i) output.comma();
  9221. expr.print(output);
  9222. });
  9223. });
  9224. });
  9225. DEFPRINT(AST_New, function(self, output) {
  9226. output.print("new");
  9227. output.space();
  9228. AST_Call.prototype._codegen(self, output);
  9229. });
  9230. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  9231. this.expressions.forEach(function(node, index) {
  9232. if (index > 0) {
  9233. output.comma();
  9234. if (output.should_break()) {
  9235. output.newline();
  9236. output.indent();
  9237. }
  9238. }
  9239. node.print(output);
  9240. });
  9241. });
  9242. DEFPRINT(AST_Sequence, function(self, output) {
  9243. self._do_print(output);
  9244. // var p = output.parent();
  9245. // if (p instanceof AST_Statement) {
  9246. // output.with_indent(output.next_indent(), function(){
  9247. // self._do_print(output);
  9248. // });
  9249. // } else {
  9250. // self._do_print(output);
  9251. // }
  9252. });
  9253. DEFPRINT(AST_Dot, function(self, output) {
  9254. var expr = self.expression;
  9255. expr.print(output);
  9256. var prop = self.property;
  9257. var print_computed = ALL_RESERVED_WORDS.has(prop)
  9258. ? output.option("ie8")
  9259. : !is_identifier_string(
  9260. prop,
  9261. output.option("ecma") >= 2015 || output.option("safari10")
  9262. );
  9263. if (self.optional) output.print("?.");
  9264. if (print_computed) {
  9265. output.print("[");
  9266. output.add_mapping(self.end);
  9267. output.print_string(prop);
  9268. output.print("]");
  9269. } else {
  9270. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  9271. if (!/[xa-f.)]/i.test(output.last())) {
  9272. output.print(".");
  9273. }
  9274. }
  9275. if (!self.optional) output.print(".");
  9276. // the name after dot would be mapped about here.
  9277. output.add_mapping(self.end);
  9278. output.print_name(prop);
  9279. }
  9280. });
  9281. DEFPRINT(AST_DotHash, function(self, output) {
  9282. var expr = self.expression;
  9283. expr.print(output);
  9284. var prop = self.property;
  9285. if (self.optional) output.print("?");
  9286. output.print(".#");
  9287. output.add_mapping(self.end);
  9288. output.print_name(prop);
  9289. });
  9290. DEFPRINT(AST_Sub, function(self, output) {
  9291. self.expression.print(output);
  9292. if (self.optional) output.print("?.");
  9293. output.print("[");
  9294. self.property.print(output);
  9295. output.print("]");
  9296. });
  9297. DEFPRINT(AST_Chain, function(self, output) {
  9298. self.expression.print(output);
  9299. });
  9300. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  9301. var op = self.operator;
  9302. output.print(op);
  9303. if (/^[a-z]/i.test(op)
  9304. || (/[+-]$/.test(op)
  9305. && self.expression instanceof AST_UnaryPrefix
  9306. && /^[+-]/.test(self.expression.operator))) {
  9307. output.space();
  9308. }
  9309. self.expression.print(output);
  9310. });
  9311. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  9312. self.expression.print(output);
  9313. output.print(self.operator);
  9314. });
  9315. DEFPRINT(AST_Binary, function(self, output) {
  9316. var op = self.operator;
  9317. self.left.print(output);
  9318. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  9319. && self.left instanceof AST_UnaryPostfix
  9320. && self.left.operator == "--") {
  9321. // space is mandatory to avoid outputting -->
  9322. output.print(" ");
  9323. } else {
  9324. // the space is optional depending on "beautify"
  9325. output.space();
  9326. }
  9327. output.print(op);
  9328. if ((op == "<" || op == "<<")
  9329. && self.right instanceof AST_UnaryPrefix
  9330. && self.right.operator == "!"
  9331. && self.right.expression instanceof AST_UnaryPrefix
  9332. && self.right.expression.operator == "--") {
  9333. // space is mandatory to avoid outputting <!--
  9334. output.print(" ");
  9335. } else {
  9336. // the space is optional depending on "beautify"
  9337. output.space();
  9338. }
  9339. self.right.print(output);
  9340. });
  9341. DEFPRINT(AST_Conditional, function(self, output) {
  9342. self.condition.print(output);
  9343. output.space();
  9344. output.print("?");
  9345. output.space();
  9346. self.consequent.print(output);
  9347. output.space();
  9348. output.colon();
  9349. self.alternative.print(output);
  9350. });
  9351. /* -----[ literals ]----- */
  9352. DEFPRINT(AST_Array, function(self, output) {
  9353. output.with_square(function() {
  9354. var a = self.elements, len = a.length;
  9355. if (len > 0) output.space();
  9356. a.forEach(function(exp, i) {
  9357. if (i) output.comma();
  9358. exp.print(output);
  9359. // If the final element is a hole, we need to make sure it
  9360. // doesn't look like a trailing comma, by inserting an actual
  9361. // trailing comma.
  9362. if (i === len - 1 && exp instanceof AST_Hole)
  9363. output.comma();
  9364. });
  9365. if (len > 0) output.space();
  9366. });
  9367. });
  9368. DEFPRINT(AST_Object, function(self, output) {
  9369. if (self.properties.length > 0) output.with_block(function() {
  9370. self.properties.forEach(function(prop, i) {
  9371. if (i) {
  9372. output.print(",");
  9373. output.newline();
  9374. }
  9375. output.indent();
  9376. prop.print(output);
  9377. });
  9378. output.newline();
  9379. });
  9380. else print_braced_empty(self, output);
  9381. });
  9382. DEFPRINT(AST_Class, function(self, output) {
  9383. output.print("class");
  9384. output.space();
  9385. if (self.name) {
  9386. self.name.print(output);
  9387. output.space();
  9388. }
  9389. if (self.extends) {
  9390. var parens = (
  9391. !(self.extends instanceof AST_SymbolRef)
  9392. && !(self.extends instanceof AST_PropAccess)
  9393. && !(self.extends instanceof AST_ClassExpression)
  9394. && !(self.extends instanceof AST_Function)
  9395. );
  9396. output.print("extends");
  9397. if (parens) {
  9398. output.print("(");
  9399. } else {
  9400. output.space();
  9401. }
  9402. self.extends.print(output);
  9403. if (parens) {
  9404. output.print(")");
  9405. } else {
  9406. output.space();
  9407. }
  9408. }
  9409. if (self.properties.length > 0) output.with_block(function() {
  9410. self.properties.forEach(function(prop, i) {
  9411. if (i) {
  9412. output.newline();
  9413. }
  9414. output.indent();
  9415. prop.print(output);
  9416. });
  9417. output.newline();
  9418. });
  9419. else output.print("{}");
  9420. });
  9421. DEFPRINT(AST_NewTarget, function(self, output) {
  9422. output.print("new.target");
  9423. });
  9424. function print_property_name(key, quote, output) {
  9425. if (output.option("quote_keys")) {
  9426. return output.print_string(key);
  9427. }
  9428. if ("" + +key == key && key >= 0) {
  9429. if (output.option("keep_numbers")) {
  9430. return output.print(key);
  9431. }
  9432. return output.print(make_num(key));
  9433. }
  9434. var print_string = ALL_RESERVED_WORDS.has(key)
  9435. ? output.option("ie8")
  9436. : (
  9437. output.option("ecma") < 2015 || output.option("safari10")
  9438. ? !is_basic_identifier_string(key)
  9439. : !is_identifier_string(key, true)
  9440. );
  9441. if (print_string || (quote && output.option("keep_quoted_props"))) {
  9442. return output.print_string(key, quote);
  9443. }
  9444. return output.print_name(key);
  9445. }
  9446. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  9447. function get_name(self) {
  9448. var def = self.definition();
  9449. return def ? def.mangled_name || def.name : self.name;
  9450. }
  9451. var allowShortHand = output.option("shorthand");
  9452. if (allowShortHand &&
  9453. self.value instanceof AST_Symbol &&
  9454. is_identifier_string(
  9455. self.key,
  9456. output.option("ecma") >= 2015 || output.option("safari10")
  9457. ) &&
  9458. get_name(self.value) === self.key &&
  9459. !ALL_RESERVED_WORDS.has(self.key)
  9460. ) {
  9461. print_property_name(self.key, self.quote, output);
  9462. } else if (allowShortHand &&
  9463. self.value instanceof AST_DefaultAssign &&
  9464. self.value.left instanceof AST_Symbol &&
  9465. is_identifier_string(
  9466. self.key,
  9467. output.option("ecma") >= 2015 || output.option("safari10")
  9468. ) &&
  9469. get_name(self.value.left) === self.key
  9470. ) {
  9471. print_property_name(self.key, self.quote, output);
  9472. output.space();
  9473. output.print("=");
  9474. output.space();
  9475. self.value.right.print(output);
  9476. } else {
  9477. if (!(self.key instanceof AST_Node)) {
  9478. print_property_name(self.key, self.quote, output);
  9479. } else {
  9480. output.with_square(function() {
  9481. self.key.print(output);
  9482. });
  9483. }
  9484. output.colon();
  9485. self.value.print(output);
  9486. }
  9487. });
  9488. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  9489. if (self.static) {
  9490. output.print("static");
  9491. output.space();
  9492. }
  9493. output.print("#");
  9494. print_property_name(self.key.name, self.quote, output);
  9495. if (self.value) {
  9496. output.print("=");
  9497. self.value.print(output);
  9498. }
  9499. output.semicolon();
  9500. });
  9501. DEFPRINT(AST_ClassProperty, (self, output) => {
  9502. if (self.static) {
  9503. output.print("static");
  9504. output.space();
  9505. }
  9506. if (self.key instanceof AST_SymbolClassProperty) {
  9507. print_property_name(self.key.name, self.quote, output);
  9508. } else {
  9509. output.print("[");
  9510. self.key.print(output);
  9511. output.print("]");
  9512. }
  9513. if (self.value) {
  9514. output.print("=");
  9515. self.value.print(output);
  9516. }
  9517. output.semicolon();
  9518. });
  9519. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  9520. var self = this;
  9521. if (self.static) {
  9522. output.print("static");
  9523. output.space();
  9524. }
  9525. if (type) {
  9526. output.print(type);
  9527. output.space();
  9528. }
  9529. if (self.key instanceof AST_SymbolMethod) {
  9530. if (is_private) output.print("#");
  9531. print_property_name(self.key.name, self.quote, output);
  9532. } else {
  9533. output.with_square(function() {
  9534. self.key.print(output);
  9535. });
  9536. }
  9537. self.value._do_print(output, true);
  9538. });
  9539. DEFPRINT(AST_ObjectSetter, function(self, output) {
  9540. self._print_getter_setter("set", false, output);
  9541. });
  9542. DEFPRINT(AST_ObjectGetter, function(self, output) {
  9543. self._print_getter_setter("get", false, output);
  9544. });
  9545. DEFPRINT(AST_PrivateSetter, function(self, output) {
  9546. self._print_getter_setter("set", true, output);
  9547. });
  9548. DEFPRINT(AST_PrivateGetter, function(self, output) {
  9549. self._print_getter_setter("get", true, output);
  9550. });
  9551. DEFPRINT(AST_PrivateMethod, function(self, output) {
  9552. var type;
  9553. if (self.is_generator && self.async) {
  9554. type = "async*";
  9555. } else if (self.is_generator) {
  9556. type = "*";
  9557. } else if (self.async) {
  9558. type = "async";
  9559. }
  9560. self._print_getter_setter(type, true, output);
  9561. });
  9562. DEFPRINT(AST_ConciseMethod, function(self, output) {
  9563. var type;
  9564. if (self.is_generator && self.async) {
  9565. type = "async*";
  9566. } else if (self.is_generator) {
  9567. type = "*";
  9568. } else if (self.async) {
  9569. type = "async";
  9570. }
  9571. self._print_getter_setter(type, false, output);
  9572. });
  9573. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  9574. var def = this.definition();
  9575. output.print_name(def ? def.mangled_name || def.name : this.name);
  9576. });
  9577. DEFPRINT(AST_Symbol, function (self, output) {
  9578. self._do_print(output);
  9579. });
  9580. DEFPRINT(AST_Hole, noop);
  9581. DEFPRINT(AST_This, function(self, output) {
  9582. output.print("this");
  9583. });
  9584. DEFPRINT(AST_Super, function(self, output) {
  9585. output.print("super");
  9586. });
  9587. DEFPRINT(AST_Constant, function(self, output) {
  9588. output.print(self.getValue());
  9589. });
  9590. DEFPRINT(AST_String, function(self, output) {
  9591. output.print_string(self.getValue(), self.quote, output.in_directive);
  9592. });
  9593. DEFPRINT(AST_Number, function(self, output) {
  9594. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  9595. output.print(self.raw);
  9596. } else {
  9597. output.print(make_num(self.getValue()));
  9598. }
  9599. });
  9600. DEFPRINT(AST_BigInt, function(self, output) {
  9601. output.print(self.getValue() + "n");
  9602. });
  9603. const r_slash_script = /(<\s*\/\s*script)/i;
  9604. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  9605. DEFPRINT(AST_RegExp, function(self, output) {
  9606. let { source, flags } = self.getValue();
  9607. source = regexp_source_fix(source);
  9608. flags = flags ? sort_regexp_flags(flags) : "";
  9609. source = source.replace(r_slash_script, slash_script_replace);
  9610. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  9611. const parent = output.parent();
  9612. if (
  9613. parent instanceof AST_Binary
  9614. && /^\w/.test(parent.operator)
  9615. && parent.left === self
  9616. ) {
  9617. output.print(" ");
  9618. }
  9619. });
  9620. function force_statement(stat, output) {
  9621. if (output.option("braces")) {
  9622. make_block(stat, output);
  9623. } else {
  9624. if (!stat || stat instanceof AST_EmptyStatement)
  9625. output.force_semicolon();
  9626. else
  9627. stat.print(output);
  9628. }
  9629. }
  9630. function best_of(a) {
  9631. var best = a[0], len = best.length;
  9632. for (var i = 1; i < a.length; ++i) {
  9633. if (a[i].length < len) {
  9634. best = a[i];
  9635. len = best.length;
  9636. }
  9637. }
  9638. return best;
  9639. }
  9640. function make_num(num) {
  9641. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  9642. var candidates = [ str ];
  9643. if (Math.floor(num) === num) {
  9644. if (num < 0) {
  9645. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  9646. } else {
  9647. candidates.push("0x" + num.toString(16).toLowerCase());
  9648. }
  9649. }
  9650. var match, len, digits;
  9651. if (match = /^\.0+/.exec(str)) {
  9652. len = match[0].length;
  9653. digits = str.slice(len);
  9654. candidates.push(digits + "e-" + (digits.length + len - 1));
  9655. } else if (match = /0+$/.exec(str)) {
  9656. len = match[0].length;
  9657. candidates.push(str.slice(0, -len) + "e" + len);
  9658. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  9659. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  9660. }
  9661. return best_of(candidates);
  9662. }
  9663. function make_block(stmt, output) {
  9664. if (!stmt || stmt instanceof AST_EmptyStatement)
  9665. output.print("{}");
  9666. else if (stmt instanceof AST_BlockStatement)
  9667. stmt.print(output);
  9668. else output.with_block(function() {
  9669. output.indent();
  9670. stmt.print(output);
  9671. output.newline();
  9672. });
  9673. }
  9674. /* -----[ source map generators ]----- */
  9675. function DEFMAP(nodetype, generator) {
  9676. nodetype.forEach(function(nodetype) {
  9677. nodetype.DEFMETHOD("add_source_map", generator);
  9678. });
  9679. }
  9680. DEFMAP([
  9681. // We could easily add info for ALL nodes, but it seems to me that
  9682. // would be quite wasteful, hence this noop in the base class.
  9683. AST_Node,
  9684. // since the label symbol will mark it
  9685. AST_LabeledStatement,
  9686. AST_Toplevel,
  9687. ], noop);
  9688. // XXX: I'm not exactly sure if we need it for all of these nodes,
  9689. // or if we should add even more.
  9690. DEFMAP([
  9691. AST_Array,
  9692. AST_BlockStatement,
  9693. AST_Catch,
  9694. AST_Class,
  9695. AST_Constant,
  9696. AST_Debugger,
  9697. AST_Definitions,
  9698. AST_Directive,
  9699. AST_Finally,
  9700. AST_Jump,
  9701. AST_Lambda,
  9702. AST_New,
  9703. AST_Object,
  9704. AST_StatementWithBody,
  9705. AST_Symbol,
  9706. AST_Switch,
  9707. AST_SwitchBranch,
  9708. AST_TemplateString,
  9709. AST_TemplateSegment,
  9710. AST_Try,
  9711. ], function(output) {
  9712. output.add_mapping(this.start);
  9713. });
  9714. DEFMAP([
  9715. AST_ObjectGetter,
  9716. AST_ObjectSetter,
  9717. AST_PrivateGetter,
  9718. AST_PrivateSetter,
  9719. ], function(output) {
  9720. output.add_mapping(this.key.end, this.key.name);
  9721. });
  9722. DEFMAP([ AST_ObjectProperty ], function(output) {
  9723. output.add_mapping(this.start, this.key);
  9724. });
  9725. })();
  9726. const shallow_cmp = (node1, node2) => {
  9727. return (
  9728. node1 === null && node2 === null
  9729. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  9730. );
  9731. };
  9732. const equivalent_to = (tree1, tree2) => {
  9733. if (!shallow_cmp(tree1, tree2)) return false;
  9734. const walk_1_state = [tree1];
  9735. const walk_2_state = [tree2];
  9736. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  9737. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  9738. while (walk_1_state.length && walk_2_state.length) {
  9739. const node_1 = walk_1_state.pop();
  9740. const node_2 = walk_2_state.pop();
  9741. if (!shallow_cmp(node_1, node_2)) return false;
  9742. node_1._children_backwards(walk_1_push);
  9743. node_2._children_backwards(walk_2_push);
  9744. if (walk_1_state.length !== walk_2_state.length) {
  9745. // Different number of children
  9746. return false;
  9747. }
  9748. }
  9749. return walk_1_state.length == 0 && walk_2_state.length == 0;
  9750. };
  9751. const pass_through = () => true;
  9752. AST_Node.prototype.shallow_cmp = function () {
  9753. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  9754. };
  9755. AST_Debugger.prototype.shallow_cmp = pass_through;
  9756. AST_Directive.prototype.shallow_cmp = function(other) {
  9757. return this.value === other.value;
  9758. };
  9759. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  9760. AST_Block.prototype.shallow_cmp = pass_through;
  9761. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  9762. AST_LabeledStatement.prototype.shallow_cmp = function(other) {
  9763. return this.label.name === other.label.name;
  9764. };
  9765. AST_Do.prototype.shallow_cmp = pass_through;
  9766. AST_While.prototype.shallow_cmp = pass_through;
  9767. AST_For.prototype.shallow_cmp = function(other) {
  9768. 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);
  9769. };
  9770. AST_ForIn.prototype.shallow_cmp = pass_through;
  9771. AST_ForOf.prototype.shallow_cmp = pass_through;
  9772. AST_With.prototype.shallow_cmp = pass_through;
  9773. AST_Toplevel.prototype.shallow_cmp = pass_through;
  9774. AST_Expansion.prototype.shallow_cmp = pass_through;
  9775. AST_Lambda.prototype.shallow_cmp = function(other) {
  9776. return this.is_generator === other.is_generator && this.async === other.async;
  9777. };
  9778. AST_Destructuring.prototype.shallow_cmp = function(other) {
  9779. return this.is_array === other.is_array;
  9780. };
  9781. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  9782. AST_TemplateString.prototype.shallow_cmp = pass_through;
  9783. AST_TemplateSegment.prototype.shallow_cmp = function(other) {
  9784. return this.value === other.value;
  9785. };
  9786. AST_Jump.prototype.shallow_cmp = pass_through;
  9787. AST_LoopControl.prototype.shallow_cmp = pass_through;
  9788. AST_Await.prototype.shallow_cmp = pass_through;
  9789. AST_Yield.prototype.shallow_cmp = function(other) {
  9790. return this.is_star === other.is_star;
  9791. };
  9792. AST_If.prototype.shallow_cmp = function(other) {
  9793. return this.alternative == null ? other.alternative == null : this.alternative === other.alternative;
  9794. };
  9795. AST_Switch.prototype.shallow_cmp = pass_through;
  9796. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  9797. AST_Try.prototype.shallow_cmp = function(other) {
  9798. return (this.bcatch == null ? other.bcatch == null : this.bcatch === other.bcatch) && (this.bfinally == null ? other.bfinally == null : this.bfinally === other.bfinally);
  9799. };
  9800. AST_Catch.prototype.shallow_cmp = function(other) {
  9801. return this.argname == null ? other.argname == null : this.argname === other.argname;
  9802. };
  9803. AST_Finally.prototype.shallow_cmp = pass_through;
  9804. AST_Definitions.prototype.shallow_cmp = pass_through;
  9805. AST_VarDef.prototype.shallow_cmp = function(other) {
  9806. return this.value == null ? other.value == null : this.value === other.value;
  9807. };
  9808. AST_NameMapping.prototype.shallow_cmp = pass_through;
  9809. AST_Import.prototype.shallow_cmp = function(other) {
  9810. 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);
  9811. };
  9812. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  9813. AST_Export.prototype.shallow_cmp = function(other) {
  9814. 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;
  9815. };
  9816. AST_Call.prototype.shallow_cmp = pass_through;
  9817. AST_Sequence.prototype.shallow_cmp = pass_through;
  9818. AST_PropAccess.prototype.shallow_cmp = pass_through;
  9819. AST_Chain.prototype.shallow_cmp = pass_through;
  9820. AST_Dot.prototype.shallow_cmp = function(other) {
  9821. return this.property === other.property;
  9822. };
  9823. AST_DotHash.prototype.shallow_cmp = function(other) {
  9824. return this.property === other.property;
  9825. };
  9826. AST_Unary.prototype.shallow_cmp = function(other) {
  9827. return this.operator === other.operator;
  9828. };
  9829. AST_Binary.prototype.shallow_cmp = function(other) {
  9830. return this.operator === other.operator;
  9831. };
  9832. AST_Conditional.prototype.shallow_cmp = pass_through;
  9833. AST_Array.prototype.shallow_cmp = pass_through;
  9834. AST_Object.prototype.shallow_cmp = pass_through;
  9835. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  9836. AST_ObjectKeyVal.prototype.shallow_cmp = function(other) {
  9837. return this.key === other.key;
  9838. };
  9839. AST_ObjectSetter.prototype.shallow_cmp = function(other) {
  9840. return this.static === other.static;
  9841. };
  9842. AST_ObjectGetter.prototype.shallow_cmp = function(other) {
  9843. return this.static === other.static;
  9844. };
  9845. AST_ConciseMethod.prototype.shallow_cmp = function(other) {
  9846. return this.static === other.static && this.is_generator === other.is_generator && this.async === other.async;
  9847. };
  9848. AST_Class.prototype.shallow_cmp = function(other) {
  9849. return (this.name == null ? other.name == null : this.name === other.name) && (this.extends == null ? other.extends == null : this.extends === other.extends);
  9850. };
  9851. AST_ClassProperty.prototype.shallow_cmp = function(other) {
  9852. return this.static === other.static;
  9853. };
  9854. AST_Symbol.prototype.shallow_cmp = function(other) {
  9855. return this.name === other.name;
  9856. };
  9857. AST_NewTarget.prototype.shallow_cmp = pass_through;
  9858. AST_This.prototype.shallow_cmp = pass_through;
  9859. AST_Super.prototype.shallow_cmp = pass_through;
  9860. AST_String.prototype.shallow_cmp = function(other) {
  9861. return this.value === other.value;
  9862. };
  9863. AST_Number.prototype.shallow_cmp = function(other) {
  9864. return this.value === other.value;
  9865. };
  9866. AST_BigInt.prototype.shallow_cmp = function(other) {
  9867. return this.value === other.value;
  9868. };
  9869. AST_RegExp.prototype.shallow_cmp = function (other) {
  9870. return (
  9871. this.value.flags === other.value.flags
  9872. && this.value.source === other.value.source
  9873. );
  9874. };
  9875. AST_Atom.prototype.shallow_cmp = pass_through;
  9876. /***********************************************************************
  9877. A JavaScript tokenizer / parser / beautifier / compressor.
  9878. https://github.com/mishoo/UglifyJS2
  9879. -------------------------------- (C) ---------------------------------
  9880. Author: Mihai Bazon
  9881. <mihai.bazon@gmail.com>
  9882. http://mihai.bazon.net/blog
  9883. Distributed under the BSD license:
  9884. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  9885. Redistribution and use in source and binary forms, with or without
  9886. modification, are permitted provided that the following conditions
  9887. are met:
  9888. * Redistributions of source code must retain the above
  9889. copyright notice, this list of conditions and the following
  9890. disclaimer.
  9891. * Redistributions in binary form must reproduce the above
  9892. copyright notice, this list of conditions and the following
  9893. disclaimer in the documentation and/or other materials
  9894. provided with the distribution.
  9895. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  9896. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9897. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9898. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  9899. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  9900. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9901. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9902. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9903. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  9904. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  9905. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9906. SUCH DAMAGE.
  9907. ***********************************************************************/
  9908. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  9909. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  9910. let function_defs = null;
  9911. let unmangleable_names = null;
  9912. /**
  9913. * When defined, there is a function declaration somewhere that's inside of a block.
  9914. * See https://tc39.es/ecma262/multipage/additional-ecmascript-features-for-web-browsers.html#sec-block-level-function-declarations-web-legacy-compatibility-semantics
  9915. */
  9916. let scopes_with_block_defuns = null;
  9917. class SymbolDef {
  9918. constructor(scope, orig, init) {
  9919. this.name = orig.name;
  9920. this.orig = [ orig ];
  9921. this.init = init;
  9922. this.eliminated = 0;
  9923. this.assignments = 0;
  9924. this.scope = scope;
  9925. this.replaced = 0;
  9926. this.global = false;
  9927. this.export = 0;
  9928. this.mangled_name = null;
  9929. this.undeclared = false;
  9930. this.id = SymbolDef.next_id++;
  9931. this.chained = false;
  9932. this.direct_access = false;
  9933. this.escaped = 0;
  9934. this.recursive_refs = 0;
  9935. this.references = [];
  9936. this.should_replace = undefined;
  9937. this.single_use = false;
  9938. this.fixed = false;
  9939. Object.seal(this);
  9940. }
  9941. fixed_value() {
  9942. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  9943. return this.fixed();
  9944. }
  9945. unmangleable(options) {
  9946. if (!options) options = {};
  9947. if (
  9948. function_defs &&
  9949. function_defs.has(this.id) &&
  9950. keep_name(options.keep_fnames, this.orig[0].name)
  9951. ) return true;
  9952. return this.global && !options.toplevel
  9953. || (this.export & MASK_EXPORT_DONT_MANGLE)
  9954. || this.undeclared
  9955. || !options.eval && this.scope.pinned()
  9956. || (this.orig[0] instanceof AST_SymbolLambda
  9957. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  9958. || this.orig[0] instanceof AST_SymbolMethod
  9959. || (this.orig[0] instanceof AST_SymbolClass
  9960. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  9961. }
  9962. mangle(options) {
  9963. const cache = options.cache && options.cache.props;
  9964. if (this.global && cache && cache.has(this.name)) {
  9965. this.mangled_name = cache.get(this.name);
  9966. } else if (!this.mangled_name && !this.unmangleable(options)) {
  9967. var s = this.scope;
  9968. var sym = this.orig[0];
  9969. if (options.ie8 && sym instanceof AST_SymbolLambda)
  9970. s = s.parent_scope;
  9971. const redefinition = redefined_catch_def(this);
  9972. this.mangled_name = redefinition
  9973. ? redefinition.mangled_name || redefinition.name
  9974. : s.next_mangled(options, this);
  9975. if (this.global && cache) {
  9976. cache.set(this.name, this.mangled_name);
  9977. }
  9978. }
  9979. }
  9980. }
  9981. SymbolDef.next_id = 1;
  9982. function redefined_catch_def(def) {
  9983. if (def.orig[0] instanceof AST_SymbolCatch
  9984. && def.scope.is_block_scope()
  9985. ) {
  9986. return def.scope.get_defun_scope().variables.get(def.name);
  9987. }
  9988. }
  9989. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  9990. options = defaults(options, {
  9991. cache: null,
  9992. ie8: false,
  9993. safari10: false,
  9994. });
  9995. if (!(toplevel instanceof AST_Toplevel)) {
  9996. throw new Error("Invalid toplevel scope");
  9997. }
  9998. // pass 1: setup scope chaining and handle definitions
  9999. var scope = this.parent_scope = parent_scope;
  10000. var labels = new Map();
  10001. var defun = null;
  10002. var in_destructuring = null;
  10003. var for_scopes = [];
  10004. var tw = new TreeWalker((node, descend) => {
  10005. if (node.is_block_scope()) {
  10006. const save_scope = scope;
  10007. node.block_scope = scope = new AST_Scope(node);
  10008. scope._block_scope = true;
  10009. // AST_Try in the AST sadly *is* (not has) a body itself,
  10010. // and its catch and finally branches are children of the AST_Try itself
  10011. const parent_scope = node instanceof AST_Catch
  10012. ? save_scope.parent_scope
  10013. : save_scope;
  10014. scope.init_scope_vars(parent_scope);
  10015. scope.uses_with = save_scope.uses_with;
  10016. scope.uses_eval = save_scope.uses_eval;
  10017. if (options.safari10) {
  10018. if (node instanceof AST_For || node instanceof AST_ForIn) {
  10019. for_scopes.push(scope);
  10020. }
  10021. }
  10022. if (node instanceof AST_Switch) {
  10023. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  10024. // AST_Switch has a scope within the body, but it itself "is a block scope"
  10025. // This means the switched expression has to belong to the outer scope
  10026. // while the body inside belongs to the switch itself.
  10027. // This is pretty nasty and warrants an AST change similar to AST_Try (read above)
  10028. const the_block_scope = scope;
  10029. scope = save_scope;
  10030. node.expression.walk(tw);
  10031. scope = the_block_scope;
  10032. for (let i = 0; i < node.body.length; i++) {
  10033. node.body[i].walk(tw);
  10034. }
  10035. } else {
  10036. descend();
  10037. }
  10038. scope = save_scope;
  10039. return true;
  10040. }
  10041. if (node instanceof AST_Destructuring) {
  10042. const save_destructuring = in_destructuring;
  10043. in_destructuring = node;
  10044. descend();
  10045. in_destructuring = save_destructuring;
  10046. return true;
  10047. }
  10048. if (node instanceof AST_Scope) {
  10049. node.init_scope_vars(scope);
  10050. var save_scope = scope;
  10051. var save_defun = defun;
  10052. var save_labels = labels;
  10053. defun = scope = node;
  10054. labels = new Map();
  10055. descend();
  10056. scope = save_scope;
  10057. defun = save_defun;
  10058. labels = save_labels;
  10059. return true; // don't descend again in TreeWalker
  10060. }
  10061. if (node instanceof AST_LabeledStatement) {
  10062. var l = node.label;
  10063. if (labels.has(l.name)) {
  10064. throw new Error(string_template("Label {name} defined twice", l));
  10065. }
  10066. labels.set(l.name, l);
  10067. descend();
  10068. labels.delete(l.name);
  10069. return true; // no descend again
  10070. }
  10071. if (node instanceof AST_With) {
  10072. for (var s = scope; s; s = s.parent_scope)
  10073. s.uses_with = true;
  10074. return;
  10075. }
  10076. if (node instanceof AST_Symbol) {
  10077. node.scope = scope;
  10078. }
  10079. if (node instanceof AST_Label) {
  10080. node.thedef = node;
  10081. node.references = [];
  10082. }
  10083. if (node instanceof AST_SymbolLambda) {
  10084. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  10085. } else if (node instanceof AST_SymbolDefun) {
  10086. // Careful here, the scope where this should be defined is
  10087. // the parent scope. The reason is that we enter a new
  10088. // scope when we encounter the AST_Defun node (which is
  10089. // instanceof AST_Scope) but we get to the symbol a bit
  10090. // later.
  10091. const closest_scope = defun.parent_scope;
  10092. // In strict mode, function definitions are block-scoped
  10093. node.scope = tw.directives["use strict"]
  10094. ? closest_scope
  10095. : closest_scope.get_defun_scope();
  10096. mark_export(node.scope.def_function(node, defun), 1);
  10097. } else if (node instanceof AST_SymbolClass) {
  10098. mark_export(defun.def_variable(node, defun), 1);
  10099. } else if (node instanceof AST_SymbolImport) {
  10100. scope.def_variable(node);
  10101. } else if (node instanceof AST_SymbolDefClass) {
  10102. // This deals with the name of the class being available
  10103. // inside the class.
  10104. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  10105. } else if (
  10106. node instanceof AST_SymbolVar
  10107. || node instanceof AST_SymbolLet
  10108. || node instanceof AST_SymbolConst
  10109. || node instanceof AST_SymbolCatch
  10110. ) {
  10111. var def;
  10112. if (node instanceof AST_SymbolBlockDeclaration) {
  10113. def = scope.def_variable(node, null);
  10114. } else {
  10115. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  10116. }
  10117. if (!def.orig.every((sym) => {
  10118. if (sym === node) return true;
  10119. if (node instanceof AST_SymbolBlockDeclaration) {
  10120. return sym instanceof AST_SymbolLambda;
  10121. }
  10122. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  10123. })) {
  10124. js_error(
  10125. `"${node.name}" is redeclared`,
  10126. node.start.file,
  10127. node.start.line,
  10128. node.start.col,
  10129. node.start.pos
  10130. );
  10131. }
  10132. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  10133. if (defun !== scope) {
  10134. node.mark_enclosed();
  10135. var def = scope.find_variable(node);
  10136. if (node.thedef !== def) {
  10137. node.thedef = def;
  10138. node.reference();
  10139. }
  10140. }
  10141. } else if (node instanceof AST_LabelRef) {
  10142. var sym = labels.get(node.name);
  10143. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  10144. name: node.name,
  10145. line: node.start.line,
  10146. col: node.start.col
  10147. }));
  10148. node.thedef = sym;
  10149. }
  10150. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  10151. js_error(
  10152. `"${node.TYPE}" statement may only appear at the top level`,
  10153. node.start.file,
  10154. node.start.line,
  10155. node.start.col,
  10156. node.start.pos
  10157. );
  10158. }
  10159. });
  10160. this.walk(tw);
  10161. function mark_export(def, level) {
  10162. if (in_destructuring) {
  10163. var i = 0;
  10164. do {
  10165. level++;
  10166. } while (tw.parent(i++) !== in_destructuring);
  10167. }
  10168. var node = tw.parent(level);
  10169. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  10170. var exported = node.exported_definition;
  10171. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  10172. def.export = MASK_EXPORT_WANT_MANGLE;
  10173. }
  10174. }
  10175. }
  10176. // pass 2: find back references and eval
  10177. const is_toplevel = this instanceof AST_Toplevel;
  10178. if (is_toplevel) {
  10179. this.globals = new Map();
  10180. }
  10181. var tw = new TreeWalker(node => {
  10182. if (node instanceof AST_LoopControl && node.label) {
  10183. node.label.thedef.references.push(node);
  10184. return true;
  10185. }
  10186. if (node instanceof AST_SymbolRef) {
  10187. var name = node.name;
  10188. if (name == "eval" && tw.parent() instanceof AST_Call) {
  10189. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  10190. s.uses_eval = true;
  10191. }
  10192. }
  10193. var sym;
  10194. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  10195. || !(sym = node.scope.find_variable(name))) {
  10196. sym = toplevel.def_global(node);
  10197. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  10198. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  10199. sym.scope.uses_arguments = true;
  10200. }
  10201. node.thedef = sym;
  10202. node.reference();
  10203. if (node.scope.is_block_scope()
  10204. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  10205. node.scope = node.scope.get_defun_scope();
  10206. }
  10207. return true;
  10208. }
  10209. // ensure mangling works if catch reuses a scope variable
  10210. var def;
  10211. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  10212. var s = node.scope;
  10213. while (s) {
  10214. push_uniq(s.enclosed, def);
  10215. if (s === def.scope) break;
  10216. s = s.parent_scope;
  10217. }
  10218. }
  10219. });
  10220. this.walk(tw);
  10221. // pass 3: work around IE8 and Safari catch scope bugs
  10222. if (options.ie8 || options.safari10) {
  10223. walk(this, node => {
  10224. if (node instanceof AST_SymbolCatch) {
  10225. var name = node.name;
  10226. var refs = node.thedef.references;
  10227. var scope = node.scope.get_defun_scope();
  10228. var def = scope.find_variable(name)
  10229. || toplevel.globals.get(name)
  10230. || scope.def_variable(node);
  10231. refs.forEach(function(ref) {
  10232. ref.thedef = def;
  10233. ref.reference();
  10234. });
  10235. node.thedef = def;
  10236. node.reference();
  10237. return true;
  10238. }
  10239. });
  10240. }
  10241. // pass 4: add symbol definitions to loop scopes
  10242. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  10243. // https://github.com/mishoo/UglifyJS2/issues/1753
  10244. // https://bugs.webkit.org/show_bug.cgi?id=171041
  10245. if (options.safari10) {
  10246. for (const scope of for_scopes) {
  10247. scope.parent_scope.variables.forEach(function(def) {
  10248. push_uniq(scope.enclosed, def);
  10249. });
  10250. }
  10251. }
  10252. });
  10253. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  10254. var globals = this.globals, name = node.name;
  10255. if (globals.has(name)) {
  10256. return globals.get(name);
  10257. } else {
  10258. var g = new SymbolDef(this, node);
  10259. g.undeclared = true;
  10260. g.global = true;
  10261. globals.set(name, g);
  10262. return g;
  10263. }
  10264. });
  10265. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  10266. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  10267. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  10268. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  10269. this.parent_scope = parent_scope; // the parent scope
  10270. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  10271. this.cname = -1; // the current index for mangling functions/variables
  10272. });
  10273. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  10274. return (
  10275. this.enclosed.find(def => def.name === name)
  10276. || this.variables.has(name)
  10277. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  10278. );
  10279. });
  10280. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  10281. return (
  10282. this.enclosed.find(def => def.name === name)
  10283. || this.variables.has(name)
  10284. );
  10285. });
  10286. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  10287. // `scope` is going to be moved into `this` right now.
  10288. // Update the required scopes' information
  10289. if (scope.parent_scope === this) return;
  10290. scope.parent_scope = this;
  10291. // TODO uses_with, uses_eval, etc
  10292. const scope_ancestry = (() => {
  10293. const ancestry = [];
  10294. let cur = this;
  10295. do {
  10296. ancestry.push(cur);
  10297. } while ((cur = cur.parent_scope));
  10298. ancestry.reverse();
  10299. return ancestry;
  10300. })();
  10301. const new_scope_enclosed_set = new Set(scope.enclosed);
  10302. const to_enclose = [];
  10303. for (const scope_topdown of scope_ancestry) {
  10304. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  10305. for (const def of scope_topdown.variables.values()) {
  10306. if (new_scope_enclosed_set.has(def)) {
  10307. push_uniq(to_enclose, def);
  10308. push_uniq(scope_topdown.enclosed, def);
  10309. }
  10310. }
  10311. }
  10312. });
  10313. function find_scopes_visible_from(scopes) {
  10314. const found_scopes = new Set();
  10315. for (const scope of new Set(scopes)) {
  10316. (function bubble_up(scope) {
  10317. if (scope == null || found_scopes.has(scope)) return;
  10318. found_scopes.add(scope);
  10319. bubble_up(scope.parent_scope);
  10320. })(scope);
  10321. }
  10322. return [...found_scopes];
  10323. }
  10324. // Creates a symbol during compression
  10325. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  10326. source,
  10327. tentative_name,
  10328. scope,
  10329. conflict_scopes = [scope],
  10330. init = null
  10331. } = {}) {
  10332. let symbol_name;
  10333. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  10334. if (tentative_name) {
  10335. // Implement hygiene (no new names are conflicting with existing names)
  10336. tentative_name =
  10337. symbol_name =
  10338. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  10339. let i = 0;
  10340. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  10341. symbol_name = tentative_name + "$" + i++;
  10342. }
  10343. }
  10344. if (!symbol_name) {
  10345. throw new Error("No symbol name could be generated in create_symbol()");
  10346. }
  10347. const symbol = make_node(SymClass, source, {
  10348. name: symbol_name,
  10349. scope
  10350. });
  10351. this.def_variable(symbol, init || null);
  10352. symbol.mark_enclosed();
  10353. return symbol;
  10354. });
  10355. AST_Node.DEFMETHOD("is_block_scope", return_false);
  10356. AST_Class.DEFMETHOD("is_block_scope", return_false);
  10357. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  10358. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  10359. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  10360. AST_Block.DEFMETHOD("is_block_scope", return_true);
  10361. AST_Scope.DEFMETHOD("is_block_scope", function () {
  10362. return this._block_scope || false;
  10363. });
  10364. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  10365. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  10366. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10367. this.uses_arguments = false;
  10368. this.def_variable(new AST_SymbolFunarg({
  10369. name: "arguments",
  10370. start: this.start,
  10371. end: this.end
  10372. }));
  10373. });
  10374. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  10375. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  10376. this.uses_arguments = false;
  10377. });
  10378. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  10379. var def = this.definition();
  10380. var s = this.scope;
  10381. while (s) {
  10382. push_uniq(s.enclosed, def);
  10383. if (s === def.scope) break;
  10384. s = s.parent_scope;
  10385. }
  10386. });
  10387. AST_Symbol.DEFMETHOD("reference", function() {
  10388. this.definition().references.push(this);
  10389. this.mark_enclosed();
  10390. });
  10391. AST_Scope.DEFMETHOD("find_variable", function(name) {
  10392. if (name instanceof AST_Symbol) name = name.name;
  10393. return this.variables.get(name)
  10394. || (this.parent_scope && this.parent_scope.find_variable(name));
  10395. });
  10396. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  10397. var def = this.def_variable(symbol, init);
  10398. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  10399. return def;
  10400. });
  10401. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  10402. var def = this.variables.get(symbol.name);
  10403. if (def) {
  10404. def.orig.push(symbol);
  10405. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  10406. def.init = init;
  10407. }
  10408. } else {
  10409. def = new SymbolDef(this, symbol, init);
  10410. this.variables.set(symbol.name, def);
  10411. def.global = !this.parent_scope;
  10412. }
  10413. return symbol.thedef = def;
  10414. });
  10415. function next_mangled(scope, options) {
  10416. let defun_scope;
  10417. if (
  10418. scopes_with_block_defuns
  10419. && (defun_scope = scope.get_defun_scope())
  10420. && scopes_with_block_defuns.has(defun_scope)
  10421. ) {
  10422. scope = defun_scope;
  10423. }
  10424. var ext = scope.enclosed;
  10425. var nth_identifier = options.nth_identifier;
  10426. out: while (true) {
  10427. var m = nth_identifier.get(++scope.cname);
  10428. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  10429. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  10430. // shadow a name reserved from mangling.
  10431. if (options.reserved.has(m)) continue;
  10432. // Functions with short names might collide with base54 output
  10433. // and therefore cause collisions when keep_fnames is true.
  10434. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  10435. // we must ensure that the mangled name does not shadow a name
  10436. // from some parent scope that is referenced in this or in
  10437. // inner scopes.
  10438. for (let i = ext.length; --i >= 0;) {
  10439. const def = ext[i];
  10440. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  10441. if (m == name) continue out;
  10442. }
  10443. return m;
  10444. }
  10445. }
  10446. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  10447. return next_mangled(this, options);
  10448. });
  10449. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  10450. let name;
  10451. const mangled_names = this.mangled_names;
  10452. do {
  10453. name = next_mangled(this, options);
  10454. } while (mangled_names.has(name));
  10455. return name;
  10456. });
  10457. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  10458. // #179, #326
  10459. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  10460. // a function expression's argument cannot shadow the function expression's name
  10461. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  10462. // the function's mangled_name is null when keep_fnames is true
  10463. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  10464. while (true) {
  10465. var name = next_mangled(this, options);
  10466. if (!tricky_name || tricky_name != name)
  10467. return name;
  10468. }
  10469. });
  10470. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  10471. var def = this.definition();
  10472. return !def || def.unmangleable(options);
  10473. });
  10474. // labels are always mangleable
  10475. AST_Label.DEFMETHOD("unmangleable", return_false);
  10476. AST_Symbol.DEFMETHOD("unreferenced", function() {
  10477. return !this.definition().references.length && !this.scope.pinned();
  10478. });
  10479. AST_Symbol.DEFMETHOD("definition", function() {
  10480. return this.thedef;
  10481. });
  10482. AST_Symbol.DEFMETHOD("global", function() {
  10483. return this.thedef.global;
  10484. });
  10485. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  10486. options = defaults(options, {
  10487. eval : false,
  10488. nth_identifier : base54,
  10489. ie8 : false,
  10490. keep_classnames: false,
  10491. keep_fnames : false,
  10492. module : false,
  10493. reserved : [],
  10494. toplevel : false,
  10495. });
  10496. if (options.module) options.toplevel = true;
  10497. if (!Array.isArray(options.reserved)
  10498. && !(options.reserved instanceof Set)
  10499. ) {
  10500. options.reserved = [];
  10501. }
  10502. options.reserved = new Set(options.reserved);
  10503. // Never mangle arguments
  10504. options.reserved.add("arguments");
  10505. return options;
  10506. });
  10507. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  10508. options = this._default_mangler_options(options);
  10509. var nth_identifier = options.nth_identifier;
  10510. // We only need to mangle declaration nodes. Special logic wired
  10511. // into the code generator will display the mangled name if it's
  10512. // present (and for AST_SymbolRef-s it'll use the mangled name of
  10513. // the AST_SymbolDeclaration that it points to).
  10514. var lname = -1;
  10515. var to_mangle = [];
  10516. if (options.keep_fnames) {
  10517. function_defs = new Set();
  10518. }
  10519. const mangled_names = this.mangled_names = new Set();
  10520. unmangleable_names = new Set();
  10521. if (options.cache) {
  10522. this.globals.forEach(collect);
  10523. if (options.cache.props) {
  10524. options.cache.props.forEach(function(mangled_name) {
  10525. mangled_names.add(mangled_name);
  10526. });
  10527. }
  10528. }
  10529. var tw = new TreeWalker(function(node, descend) {
  10530. if (node instanceof AST_LabeledStatement) {
  10531. // lname is incremented when we get to the AST_Label
  10532. var save_nesting = lname;
  10533. descend();
  10534. lname = save_nesting;
  10535. return true; // don't descend again in TreeWalker
  10536. }
  10537. if (
  10538. node instanceof AST_Defun
  10539. && !(tw.parent() instanceof AST_Scope)
  10540. ) {
  10541. scopes_with_block_defuns = scopes_with_block_defuns || new Set();
  10542. scopes_with_block_defuns.add(node.parent_scope.get_defun_scope());
  10543. }
  10544. if (node instanceof AST_Scope) {
  10545. node.variables.forEach(collect);
  10546. return;
  10547. }
  10548. if (node.is_block_scope()) {
  10549. node.block_scope.variables.forEach(collect);
  10550. return;
  10551. }
  10552. if (
  10553. function_defs
  10554. && node instanceof AST_VarDef
  10555. && node.value instanceof AST_Lambda
  10556. && !node.value.name
  10557. && keep_name(options.keep_fnames, node.name.name)
  10558. ) {
  10559. function_defs.add(node.name.definition().id);
  10560. return;
  10561. }
  10562. if (node instanceof AST_Label) {
  10563. let name;
  10564. do {
  10565. name = nth_identifier.get(++lname);
  10566. } while (ALL_RESERVED_WORDS.has(name));
  10567. node.mangled_name = name;
  10568. return true;
  10569. }
  10570. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  10571. to_mangle.push(node.definition());
  10572. return;
  10573. }
  10574. });
  10575. this.walk(tw);
  10576. if (options.keep_fnames || options.keep_classnames) {
  10577. // Collect a set of short names which are unmangleable,
  10578. // for use in avoiding collisions in next_mangled.
  10579. to_mangle.forEach(def => {
  10580. if (def.name.length < 6 && def.unmangleable(options)) {
  10581. unmangleable_names.add(def.name);
  10582. }
  10583. });
  10584. }
  10585. to_mangle.forEach(def => { def.mangle(options); });
  10586. function_defs = null;
  10587. unmangleable_names = null;
  10588. scopes_with_block_defuns = null;
  10589. function collect(symbol) {
  10590. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  10591. unmangleable_names.add(symbol.name);
  10592. } else if (!options.reserved.has(symbol.name)) {
  10593. to_mangle.push(symbol);
  10594. }
  10595. }
  10596. });
  10597. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  10598. const cache = options.cache && options.cache.props;
  10599. const avoid = new Set();
  10600. options.reserved.forEach(to_avoid);
  10601. this.globals.forEach(add_def);
  10602. this.walk(new TreeWalker(function(node) {
  10603. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  10604. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  10605. }));
  10606. return avoid;
  10607. function to_avoid(name) {
  10608. avoid.add(name);
  10609. }
  10610. function add_def(def) {
  10611. var name = def.name;
  10612. if (def.global && cache && cache.has(name)) name = cache.get(name);
  10613. else if (!def.unmangleable(options)) return;
  10614. to_avoid(name);
  10615. }
  10616. });
  10617. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  10618. options = this._default_mangler_options(options);
  10619. var nth_identifier = options.nth_identifier;
  10620. if (nth_identifier.reset && nth_identifier.sort) {
  10621. nth_identifier.reset();
  10622. nth_identifier.sort();
  10623. }
  10624. var avoid = this.find_colliding_names(options);
  10625. var cname = 0;
  10626. this.globals.forEach(rename);
  10627. this.walk(new TreeWalker(function(node) {
  10628. if (node instanceof AST_Scope) node.variables.forEach(rename);
  10629. if (node instanceof AST_SymbolCatch) rename(node.definition());
  10630. }));
  10631. function next_name() {
  10632. var name;
  10633. do {
  10634. name = nth_identifier.get(cname++);
  10635. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  10636. return name;
  10637. }
  10638. function rename(def) {
  10639. if (def.global && options.cache) return;
  10640. if (def.unmangleable(options)) return;
  10641. if (options.reserved.has(def.name)) return;
  10642. const redefinition = redefined_catch_def(def);
  10643. const name = def.name = redefinition ? redefinition.name : next_name();
  10644. def.orig.forEach(function(sym) {
  10645. sym.name = name;
  10646. });
  10647. def.references.forEach(function(sym) {
  10648. sym.name = name;
  10649. });
  10650. }
  10651. });
  10652. AST_Node.DEFMETHOD("tail_node", return_this);
  10653. AST_Sequence.DEFMETHOD("tail_node", function() {
  10654. return this.expressions[this.expressions.length - 1];
  10655. });
  10656. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  10657. options = this._default_mangler_options(options);
  10658. var nth_identifier = options.nth_identifier;
  10659. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  10660. // If the identifier mangler is invariant, skip computing character frequency.
  10661. return;
  10662. }
  10663. nth_identifier.reset();
  10664. try {
  10665. AST_Node.prototype.print = function(stream, force_parens) {
  10666. this._print(stream, force_parens);
  10667. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  10668. nth_identifier.consider(this.name, -1);
  10669. } else if (options.properties) {
  10670. if (this instanceof AST_DotHash) {
  10671. nth_identifier.consider("#" + this.property, -1);
  10672. } else if (this instanceof AST_Dot) {
  10673. nth_identifier.consider(this.property, -1);
  10674. } else if (this instanceof AST_Sub) {
  10675. skip_string(this.property);
  10676. }
  10677. }
  10678. };
  10679. nth_identifier.consider(this.print_to_string(), 1);
  10680. } finally {
  10681. AST_Node.prototype.print = AST_Node.prototype._print;
  10682. }
  10683. nth_identifier.sort();
  10684. function skip_string(node) {
  10685. if (node instanceof AST_String) {
  10686. nth_identifier.consider(node.value, -1);
  10687. } else if (node instanceof AST_Conditional) {
  10688. skip_string(node.consequent);
  10689. skip_string(node.alternative);
  10690. } else if (node instanceof AST_Sequence) {
  10691. skip_string(node.tail_node());
  10692. }
  10693. }
  10694. });
  10695. const base54 = (() => {
  10696. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  10697. const digits = "0123456789".split("");
  10698. let chars;
  10699. let frequency;
  10700. function reset() {
  10701. frequency = new Map();
  10702. leading.forEach(function(ch) {
  10703. frequency.set(ch, 0);
  10704. });
  10705. digits.forEach(function(ch) {
  10706. frequency.set(ch, 0);
  10707. });
  10708. }
  10709. function consider(str, delta) {
  10710. for (var i = str.length; --i >= 0;) {
  10711. frequency.set(str[i], frequency.get(str[i]) + delta);
  10712. }
  10713. }
  10714. function compare(a, b) {
  10715. return frequency.get(b) - frequency.get(a);
  10716. }
  10717. function sort() {
  10718. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  10719. }
  10720. // Ensure this is in a usable initial state.
  10721. reset();
  10722. sort();
  10723. function base54(num) {
  10724. var ret = "", base = 54;
  10725. num++;
  10726. do {
  10727. num--;
  10728. ret += chars[num % base];
  10729. num = Math.floor(num / base);
  10730. base = 64;
  10731. } while (num > 0);
  10732. return ret;
  10733. }
  10734. return {
  10735. get: base54,
  10736. consider,
  10737. reset,
  10738. sort
  10739. };
  10740. })();
  10741. let mangle_options = undefined;
  10742. AST_Node.prototype.size = function (compressor, stack) {
  10743. mangle_options = compressor && compressor.mangle_options;
  10744. let size = 0;
  10745. walk_parent(this, (node, info) => {
  10746. size += node._size(info);
  10747. // Braceless arrow functions have fake "return" statements
  10748. if (node instanceof AST_Arrow && node.is_braceless()) {
  10749. size += node.body[0].value._size(info);
  10750. return true;
  10751. }
  10752. }, stack || (compressor && compressor.stack));
  10753. // just to save a bit of memory
  10754. mangle_options = undefined;
  10755. return size;
  10756. };
  10757. AST_Node.prototype._size = () => 0;
  10758. AST_Debugger.prototype._size = () => 8;
  10759. AST_Directive.prototype._size = function () {
  10760. // TODO string encoding stuff
  10761. return 2 + this.value.length;
  10762. };
  10763. /** Count commas/semicolons necessary to show a list of expressions/statements */
  10764. const list_overhead = (array) => array.length && array.length - 1;
  10765. AST_Block.prototype._size = function () {
  10766. return 2 + list_overhead(this.body);
  10767. };
  10768. AST_Toplevel.prototype._size = function() {
  10769. return list_overhead(this.body);
  10770. };
  10771. AST_EmptyStatement.prototype._size = () => 1;
  10772. AST_LabeledStatement.prototype._size = () => 2; // x:
  10773. AST_Do.prototype._size = () => 9;
  10774. AST_While.prototype._size = () => 7;
  10775. AST_For.prototype._size = () => 8;
  10776. AST_ForIn.prototype._size = () => 8;
  10777. // AST_ForOf inherits ^
  10778. AST_With.prototype._size = () => 6;
  10779. AST_Expansion.prototype._size = () => 3;
  10780. const lambda_modifiers = func =>
  10781. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  10782. AST_Accessor.prototype._size = function () {
  10783. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  10784. };
  10785. AST_Function.prototype._size = function (info) {
  10786. const first = !!first_in_statement(info);
  10787. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  10788. };
  10789. AST_Defun.prototype._size = function () {
  10790. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  10791. };
  10792. AST_Arrow.prototype._size = function () {
  10793. let args_and_arrow = 2 + list_overhead(this.argnames);
  10794. if (
  10795. !(
  10796. this.argnames.length === 1
  10797. && this.argnames[0] instanceof AST_Symbol
  10798. )
  10799. ) {
  10800. args_and_arrow += 2; // parens around the args
  10801. }
  10802. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  10803. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  10804. };
  10805. AST_Destructuring.prototype._size = () => 2;
  10806. AST_TemplateString.prototype._size = function () {
  10807. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  10808. };
  10809. AST_TemplateSegment.prototype._size = function () {
  10810. return this.value.length;
  10811. };
  10812. AST_Return.prototype._size = function () {
  10813. return this.value ? 7 : 6;
  10814. };
  10815. AST_Throw.prototype._size = () => 6;
  10816. AST_Break.prototype._size = function () {
  10817. return this.label ? 6 : 5;
  10818. };
  10819. AST_Continue.prototype._size = function () {
  10820. return this.label ? 9 : 8;
  10821. };
  10822. AST_If.prototype._size = () => 4;
  10823. AST_Switch.prototype._size = function () {
  10824. return 8 + list_overhead(this.body);
  10825. };
  10826. AST_Case.prototype._size = function () {
  10827. return 5 + list_overhead(this.body);
  10828. };
  10829. AST_Default.prototype._size = function () {
  10830. return 8 + list_overhead(this.body);
  10831. };
  10832. AST_Try.prototype._size = function () {
  10833. return 3 + list_overhead(this.body);
  10834. };
  10835. AST_Catch.prototype._size = function () {
  10836. let size = 7 + list_overhead(this.body);
  10837. if (this.argname) {
  10838. size += 2;
  10839. }
  10840. return size;
  10841. };
  10842. AST_Finally.prototype._size = function () {
  10843. return 7 + list_overhead(this.body);
  10844. };
  10845. AST_Var.prototype._size = function () {
  10846. return 4 + list_overhead(this.definitions);
  10847. };
  10848. AST_Let.prototype._size = function () {
  10849. return 4 + list_overhead(this.definitions);
  10850. };
  10851. AST_Const.prototype._size = function () {
  10852. return 6 + list_overhead(this.definitions);
  10853. };
  10854. AST_VarDef.prototype._size = function () {
  10855. return this.value ? 1 : 0;
  10856. };
  10857. AST_NameMapping.prototype._size = function () {
  10858. // foreign name isn't mangled
  10859. return this.name ? 4 : 0;
  10860. };
  10861. AST_Import.prototype._size = function () {
  10862. // import
  10863. let size = 6;
  10864. if (this.imported_name) size += 1;
  10865. // from
  10866. if (this.imported_name || this.imported_names) size += 5;
  10867. // braces, and the commas
  10868. if (this.imported_names) {
  10869. size += 2 + list_overhead(this.imported_names);
  10870. }
  10871. return size;
  10872. };
  10873. AST_ImportMeta.prototype._size = () => 11;
  10874. AST_Export.prototype._size = function () {
  10875. let size = 7 + (this.is_default ? 8 : 0);
  10876. if (this.exported_value) {
  10877. size += this.exported_value._size();
  10878. }
  10879. if (this.exported_names) {
  10880. // Braces and commas
  10881. size += 2 + list_overhead(this.exported_names);
  10882. }
  10883. if (this.module_name) {
  10884. // "from "
  10885. size += 5;
  10886. }
  10887. return size;
  10888. };
  10889. AST_Call.prototype._size = function () {
  10890. if (this.optional) {
  10891. return 4 + list_overhead(this.args);
  10892. }
  10893. return 2 + list_overhead(this.args);
  10894. };
  10895. AST_New.prototype._size = function () {
  10896. return 6 + list_overhead(this.args);
  10897. };
  10898. AST_Sequence.prototype._size = function () {
  10899. return list_overhead(this.expressions);
  10900. };
  10901. AST_Dot.prototype._size = function () {
  10902. if (this.optional) {
  10903. return this.property.length + 2;
  10904. }
  10905. return this.property.length + 1;
  10906. };
  10907. AST_DotHash.prototype._size = function () {
  10908. if (this.optional) {
  10909. return this.property.length + 3;
  10910. }
  10911. return this.property.length + 2;
  10912. };
  10913. AST_Sub.prototype._size = function () {
  10914. return this.optional ? 4 : 2;
  10915. };
  10916. AST_Unary.prototype._size = function () {
  10917. if (this.operator === "typeof") return 7;
  10918. if (this.operator === "void") return 5;
  10919. return this.operator.length;
  10920. };
  10921. AST_Binary.prototype._size = function (info) {
  10922. if (this.operator === "in") return 4;
  10923. let size = this.operator.length;
  10924. if (
  10925. (this.operator === "+" || this.operator === "-")
  10926. && this.right instanceof AST_Unary && this.right.operator === this.operator
  10927. ) {
  10928. // 1+ +a > needs space between the +
  10929. size += 1;
  10930. }
  10931. if (this.needs_parens(info)) {
  10932. size += 2;
  10933. }
  10934. return size;
  10935. };
  10936. AST_Conditional.prototype._size = () => 3;
  10937. AST_Array.prototype._size = function () {
  10938. return 2 + list_overhead(this.elements);
  10939. };
  10940. AST_Object.prototype._size = function (info) {
  10941. let base = 2;
  10942. if (first_in_statement(info)) {
  10943. base += 2; // parens
  10944. }
  10945. return base + list_overhead(this.properties);
  10946. };
  10947. /*#__INLINE__*/
  10948. const key_size = key =>
  10949. typeof key === "string" ? key.length : 0;
  10950. AST_ObjectKeyVal.prototype._size = function () {
  10951. return key_size(this.key) + 1;
  10952. };
  10953. /*#__INLINE__*/
  10954. const static_size = is_static => is_static ? 7 : 0;
  10955. AST_ObjectGetter.prototype._size = function () {
  10956. return 5 + static_size(this.static) + key_size(this.key);
  10957. };
  10958. AST_ObjectSetter.prototype._size = function () {
  10959. return 5 + static_size(this.static) + key_size(this.key);
  10960. };
  10961. AST_ConciseMethod.prototype._size = function () {
  10962. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  10963. };
  10964. AST_PrivateMethod.prototype._size = function () {
  10965. return AST_ConciseMethod.prototype._size.call(this) + 1;
  10966. };
  10967. AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
  10968. return AST_ConciseMethod.prototype._size.call(this) + 4;
  10969. };
  10970. AST_Class.prototype._size = function () {
  10971. return (
  10972. (this.name ? 8 : 7)
  10973. + (this.extends ? 8 : 0)
  10974. );
  10975. };
  10976. AST_ClassProperty.prototype._size = function () {
  10977. return (
  10978. static_size(this.static)
  10979. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  10980. + (this.value ? 1 : 0)
  10981. );
  10982. };
  10983. AST_ClassPrivateProperty.prototype._size = function () {
  10984. return AST_ClassProperty.prototype._size.call(this) + 1;
  10985. };
  10986. AST_Symbol.prototype._size = function () {
  10987. return !mangle_options || this.definition().unmangleable(mangle_options)
  10988. ? this.name.length
  10989. : 1;
  10990. };
  10991. // TODO take propmangle into account
  10992. AST_SymbolClassProperty.prototype._size = function () {
  10993. return this.name.length;
  10994. };
  10995. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  10996. const { name, thedef } = this;
  10997. if (thedef && thedef.global) return name.length;
  10998. if (name === "arguments") return 9;
  10999. return AST_Symbol.prototype._size.call(this);
  11000. };
  11001. AST_NewTarget.prototype._size = () => 10;
  11002. AST_SymbolImportForeign.prototype._size = function () {
  11003. return this.name.length;
  11004. };
  11005. AST_SymbolExportForeign.prototype._size = function () {
  11006. return this.name.length;
  11007. };
  11008. AST_This.prototype._size = () => 4;
  11009. AST_Super.prototype._size = () => 5;
  11010. AST_String.prototype._size = function () {
  11011. return this.value.length + 2;
  11012. };
  11013. AST_Number.prototype._size = function () {
  11014. const { value } = this;
  11015. if (value === 0) return 1;
  11016. if (value > 0 && Math.floor(value) === value) {
  11017. return Math.floor(Math.log10(value) + 1);
  11018. }
  11019. return value.toString().length;
  11020. };
  11021. AST_BigInt.prototype._size = function () {
  11022. return this.value.length;
  11023. };
  11024. AST_RegExp.prototype._size = function () {
  11025. return this.value.toString().length;
  11026. };
  11027. AST_Null.prototype._size = () => 4;
  11028. AST_NaN.prototype._size = () => 3;
  11029. AST_Undefined.prototype._size = () => 6; // "void 0"
  11030. AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()
  11031. AST_Infinity.prototype._size = () => 8;
  11032. AST_True.prototype._size = () => 4;
  11033. AST_False.prototype._size = () => 5;
  11034. AST_Await.prototype._size = () => 6;
  11035. AST_Yield.prototype._size = () => 6;
  11036. /***********************************************************************
  11037. A JavaScript tokenizer / parser / beautifier / compressor.
  11038. https://github.com/mishoo/UglifyJS2
  11039. -------------------------------- (C) ---------------------------------
  11040. Author: Mihai Bazon
  11041. <mihai.bazon@gmail.com>
  11042. http://mihai.bazon.net/blog
  11043. Distributed under the BSD license:
  11044. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11045. Redistribution and use in source and binary forms, with or without
  11046. modification, are permitted provided that the following conditions
  11047. are met:
  11048. * Redistributions of source code must retain the above
  11049. copyright notice, this list of conditions and the following
  11050. disclaimer.
  11051. * Redistributions in binary form must reproduce the above
  11052. copyright notice, this list of conditions and the following
  11053. disclaimer in the documentation and/or other materials
  11054. provided with the distribution.
  11055. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11056. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11057. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11058. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11059. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11060. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11061. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11062. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11063. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11064. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11065. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11066. SUCH DAMAGE.
  11067. ***********************************************************************/
  11068. // bitfield flags to be stored in node.flags.
  11069. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  11070. const UNUSED = 0b00000001;
  11071. const TRUTHY = 0b00000010;
  11072. const FALSY = 0b00000100;
  11073. const UNDEFINED = 0b00001000;
  11074. const INLINED = 0b00010000;
  11075. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  11076. const WRITE_ONLY = 0b00100000;
  11077. // information specific to a single compression pass
  11078. const SQUEEZED = 0b0000000100000000;
  11079. const OPTIMIZED = 0b0000001000000000;
  11080. const TOP = 0b0000010000000000;
  11081. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  11082. const has_flag = (node, flag) => node.flags & flag;
  11083. const set_flag = (node, flag) => { node.flags |= flag; };
  11084. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  11085. /***********************************************************************
  11086. A JavaScript tokenizer / parser / beautifier / compressor.
  11087. https://github.com/mishoo/UglifyJS2
  11088. -------------------------------- (C) ---------------------------------
  11089. Author: Mihai Bazon
  11090. <mihai.bazon@gmail.com>
  11091. http://mihai.bazon.net/blog
  11092. Distributed under the BSD license:
  11093. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11094. Redistribution and use in source and binary forms, with or without
  11095. modification, are permitted provided that the following conditions
  11096. are met:
  11097. * Redistributions of source code must retain the above
  11098. copyright notice, this list of conditions and the following
  11099. disclaimer.
  11100. * Redistributions in binary form must reproduce the above
  11101. copyright notice, this list of conditions and the following
  11102. disclaimer in the documentation and/or other materials
  11103. provided with the distribution.
  11104. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11105. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11106. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11107. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11108. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11109. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11110. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11111. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11112. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11113. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11114. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11115. SUCH DAMAGE.
  11116. ***********************************************************************/
  11117. function merge_sequence(array, node) {
  11118. if (node instanceof AST_Sequence) {
  11119. array.push(...node.expressions);
  11120. } else {
  11121. array.push(node);
  11122. }
  11123. return array;
  11124. }
  11125. function make_sequence(orig, expressions) {
  11126. if (expressions.length == 1) return expressions[0];
  11127. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  11128. return make_node(AST_Sequence, orig, {
  11129. expressions: expressions.reduce(merge_sequence, [])
  11130. });
  11131. }
  11132. function make_node_from_constant(val, orig) {
  11133. switch (typeof val) {
  11134. case "string":
  11135. return make_node(AST_String, orig, {
  11136. value: val
  11137. });
  11138. case "number":
  11139. if (isNaN(val)) return make_node(AST_NaN, orig);
  11140. if (isFinite(val)) {
  11141. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11142. operator: "-",
  11143. expression: make_node(AST_Number, orig, { value: -val })
  11144. }) : make_node(AST_Number, orig, { value: val });
  11145. }
  11146. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  11147. operator: "-",
  11148. expression: make_node(AST_Infinity, orig)
  11149. }) : make_node(AST_Infinity, orig);
  11150. case "boolean":
  11151. return make_node(val ? AST_True : AST_False, orig);
  11152. case "undefined":
  11153. return make_node(AST_Undefined, orig);
  11154. default:
  11155. if (val === null) {
  11156. return make_node(AST_Null, orig, { value: null });
  11157. }
  11158. if (val instanceof RegExp) {
  11159. return make_node(AST_RegExp, orig, {
  11160. value: {
  11161. source: regexp_source_fix(val.source),
  11162. flags: val.flags
  11163. }
  11164. });
  11165. }
  11166. throw new Error(string_template("Can't handle constant of type: {type}", {
  11167. type: typeof val
  11168. }));
  11169. }
  11170. }
  11171. function best_of_expression(ast1, ast2) {
  11172. return ast1.size() > ast2.size() ? ast2 : ast1;
  11173. }
  11174. function best_of_statement(ast1, ast2) {
  11175. return best_of_expression(
  11176. make_node(AST_SimpleStatement, ast1, {
  11177. body: ast1
  11178. }),
  11179. make_node(AST_SimpleStatement, ast2, {
  11180. body: ast2
  11181. })
  11182. ).body;
  11183. }
  11184. /** Find which node is smaller, and return that */
  11185. function best_of(compressor, ast1, ast2) {
  11186. if (first_in_statement(compressor)) {
  11187. return best_of_statement(ast1, ast2);
  11188. } else {
  11189. return best_of_expression(ast1, ast2);
  11190. }
  11191. }
  11192. /** Simplify an object property's key, if possible */
  11193. function get_simple_key(key) {
  11194. if (key instanceof AST_Constant) {
  11195. return key.getValue();
  11196. }
  11197. if (key instanceof AST_UnaryPrefix
  11198. && key.operator == "void"
  11199. && key.expression instanceof AST_Constant) {
  11200. return;
  11201. }
  11202. return key;
  11203. }
  11204. function read_property(obj, key) {
  11205. key = get_simple_key(key);
  11206. if (key instanceof AST_Node) return;
  11207. var value;
  11208. if (obj instanceof AST_Array) {
  11209. var elements = obj.elements;
  11210. if (key == "length") return make_node_from_constant(elements.length, obj);
  11211. if (typeof key == "number" && key in elements) value = elements[key];
  11212. } else if (obj instanceof AST_Object) {
  11213. key = "" + key;
  11214. var props = obj.properties;
  11215. for (var i = props.length; --i >= 0;) {
  11216. var prop = props[i];
  11217. if (!(prop instanceof AST_ObjectKeyVal)) return;
  11218. if (!value && props[i].key === key) value = props[i].value;
  11219. }
  11220. }
  11221. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  11222. }
  11223. function has_break_or_continue(loop, parent) {
  11224. var found = false;
  11225. var tw = new TreeWalker(function(node) {
  11226. if (found || node instanceof AST_Scope) return true;
  11227. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  11228. return found = true;
  11229. }
  11230. });
  11231. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  11232. tw.push(loop);
  11233. loop.body.walk(tw);
  11234. return found;
  11235. }
  11236. // we shouldn't compress (1,func)(something) to
  11237. // func(something) because that changes the meaning of
  11238. // the func (becomes lexical instead of global).
  11239. function maintain_this_binding(parent, orig, val) {
  11240. if (
  11241. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  11242. || parent instanceof AST_Call && parent.expression === orig
  11243. && (
  11244. val instanceof AST_PropAccess
  11245. || val instanceof AST_SymbolRef && val.name == "eval"
  11246. )
  11247. ) {
  11248. const zero = make_node(AST_Number, orig, { value: 0 });
  11249. return make_sequence(orig, [ zero, val ]);
  11250. } else {
  11251. return val;
  11252. }
  11253. }
  11254. function is_func_expr(node) {
  11255. return node instanceof AST_Arrow || node instanceof AST_Function;
  11256. }
  11257. function is_iife_call(node) {
  11258. // Used to determine whether the node can benefit from negation.
  11259. // Not the case with arrow functions (you need an extra set of parens).
  11260. if (node.TYPE != "Call") return false;
  11261. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  11262. }
  11263. function is_empty(thing) {
  11264. if (thing === null) return true;
  11265. if (thing instanceof AST_EmptyStatement) return true;
  11266. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  11267. return false;
  11268. }
  11269. const identifier_atom = makePredicate("Infinity NaN undefined");
  11270. function is_identifier_atom(node) {
  11271. return node instanceof AST_Infinity
  11272. || node instanceof AST_NaN
  11273. || node instanceof AST_Undefined;
  11274. }
  11275. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  11276. function is_ref_of(ref, type) {
  11277. if (!(ref instanceof AST_SymbolRef)) return false;
  11278. var orig = ref.definition().orig;
  11279. for (var i = orig.length; --i >= 0;) {
  11280. if (orig[i] instanceof type) return true;
  11281. }
  11282. }
  11283. // Can we turn { block contents... } into just the block contents ?
  11284. // Not if one of these is inside.
  11285. function can_be_evicted_from_block(node) {
  11286. return !(
  11287. node instanceof AST_DefClass ||
  11288. node instanceof AST_Defun ||
  11289. node instanceof AST_Let ||
  11290. node instanceof AST_Const ||
  11291. node instanceof AST_Export ||
  11292. node instanceof AST_Import
  11293. );
  11294. }
  11295. function as_statement_array(thing) {
  11296. if (thing === null) return [];
  11297. if (thing instanceof AST_BlockStatement) return thing.body;
  11298. if (thing instanceof AST_EmptyStatement) return [];
  11299. if (thing instanceof AST_Statement) return [ thing ];
  11300. throw new Error("Can't convert thing to statement array");
  11301. }
  11302. function is_reachable(scope_node, defs) {
  11303. const find_ref = node => {
  11304. if (node instanceof AST_SymbolRef && defs.includes(node.definition())) {
  11305. return walk_abort;
  11306. }
  11307. };
  11308. return walk_parent(scope_node, (node, info) => {
  11309. if (node instanceof AST_Scope && node !== scope_node) {
  11310. var parent = info.parent();
  11311. if (
  11312. parent instanceof AST_Call
  11313. && parent.expression === node
  11314. // Async/Generators aren't guaranteed to sync evaluate all of
  11315. // their body steps, so it's possible they close over the variable.
  11316. && !(node.async || node.is_generator)
  11317. ) {
  11318. return;
  11319. }
  11320. if (walk(node, find_ref)) return walk_abort;
  11321. return true;
  11322. }
  11323. });
  11324. }
  11325. /** Check if a ref refers to the name of a function/class it's defined within */
  11326. function is_recursive_ref(compressor, def) {
  11327. var node;
  11328. for (var i = 0; node = compressor.parent(i); i++) {
  11329. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  11330. var name = node.name;
  11331. if (name && name.definition() === def) {
  11332. return true;
  11333. }
  11334. }
  11335. }
  11336. return false;
  11337. }
  11338. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  11339. function retain_top_func(fn, compressor) {
  11340. return compressor.top_retain
  11341. && fn instanceof AST_Defun
  11342. && has_flag(fn, TOP)
  11343. && fn.name
  11344. && compressor.top_retain(fn.name);
  11345. }
  11346. /***********************************************************************
  11347. A JavaScript tokenizer / parser / beautifier / compressor.
  11348. https://github.com/mishoo/UglifyJS2
  11349. -------------------------------- (C) ---------------------------------
  11350. Author: Mihai Bazon
  11351. <mihai.bazon@gmail.com>
  11352. http://mihai.bazon.net/blog
  11353. Distributed under the BSD license:
  11354. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11355. Redistribution and use in source and binary forms, with or without
  11356. modification, are permitted provided that the following conditions
  11357. are met:
  11358. * Redistributions of source code must retain the above
  11359. copyright notice, this list of conditions and the following
  11360. disclaimer.
  11361. * Redistributions in binary form must reproduce the above
  11362. copyright notice, this list of conditions and the following
  11363. disclaimer in the documentation and/or other materials
  11364. provided with the distribution.
  11365. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11366. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11367. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11368. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11369. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11370. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11371. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11372. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11373. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11374. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11375. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11376. SUCH DAMAGE.
  11377. ***********************************************************************/
  11378. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  11379. // Note: Lots of methods and functions are missing here, in case they aren't pure
  11380. // or not available in all JS environments.
  11381. function make_nested_lookup(obj) {
  11382. const out = new Map();
  11383. for (var key of Object.keys(obj)) {
  11384. out.set(key, makePredicate(obj[key]));
  11385. }
  11386. const does_have = (global_name, fname) => {
  11387. const inner_map = out.get(global_name);
  11388. return inner_map != null && inner_map.has(fname);
  11389. };
  11390. return does_have;
  11391. }
  11392. // Objects which are safe to access without throwing or causing a side effect.
  11393. // Usually we'd check the `unsafe` option first but these are way too common for that
  11394. const pure_prop_access_globals = new Set([
  11395. "Number",
  11396. "String",
  11397. "Array",
  11398. "Object",
  11399. "Function",
  11400. "Promise",
  11401. ]);
  11402. const object_methods = [
  11403. "constructor",
  11404. "toString",
  11405. "valueOf",
  11406. ];
  11407. const is_pure_native_method = make_nested_lookup({
  11408. Array: [
  11409. "indexOf",
  11410. "join",
  11411. "lastIndexOf",
  11412. "slice",
  11413. ...object_methods,
  11414. ],
  11415. Boolean: object_methods,
  11416. Function: object_methods,
  11417. Number: [
  11418. "toExponential",
  11419. "toFixed",
  11420. "toPrecision",
  11421. ...object_methods,
  11422. ],
  11423. Object: object_methods,
  11424. RegExp: [
  11425. "test",
  11426. ...object_methods,
  11427. ],
  11428. String: [
  11429. "charAt",
  11430. "charCodeAt",
  11431. "concat",
  11432. "indexOf",
  11433. "italics",
  11434. "lastIndexOf",
  11435. "match",
  11436. "replace",
  11437. "search",
  11438. "slice",
  11439. "split",
  11440. "substr",
  11441. "substring",
  11442. "toLowerCase",
  11443. "toUpperCase",
  11444. "trim",
  11445. ...object_methods,
  11446. ],
  11447. });
  11448. const is_pure_native_fn = make_nested_lookup({
  11449. Array: [
  11450. "isArray",
  11451. ],
  11452. Math: [
  11453. "abs",
  11454. "acos",
  11455. "asin",
  11456. "atan",
  11457. "ceil",
  11458. "cos",
  11459. "exp",
  11460. "floor",
  11461. "log",
  11462. "round",
  11463. "sin",
  11464. "sqrt",
  11465. "tan",
  11466. "atan2",
  11467. "pow",
  11468. "max",
  11469. "min",
  11470. ],
  11471. Number: [
  11472. "isFinite",
  11473. "isNaN",
  11474. ],
  11475. Object: [
  11476. "create",
  11477. "getOwnPropertyDescriptor",
  11478. "getOwnPropertyNames",
  11479. "getPrototypeOf",
  11480. "isExtensible",
  11481. "isFrozen",
  11482. "isSealed",
  11483. "hasOwn",
  11484. "keys",
  11485. ],
  11486. String: [
  11487. "fromCharCode",
  11488. ],
  11489. });
  11490. // Known numeric values which come with JS environments
  11491. const is_pure_native_value = make_nested_lookup({
  11492. Math: [
  11493. "E",
  11494. "LN10",
  11495. "LN2",
  11496. "LOG2E",
  11497. "LOG10E",
  11498. "PI",
  11499. "SQRT1_2",
  11500. "SQRT2",
  11501. ],
  11502. Number: [
  11503. "MAX_VALUE",
  11504. "MIN_VALUE",
  11505. "NaN",
  11506. "NEGATIVE_INFINITY",
  11507. "POSITIVE_INFINITY",
  11508. ],
  11509. });
  11510. /***********************************************************************
  11511. A JavaScript tokenizer / parser / beautifier / compressor.
  11512. https://github.com/mishoo/UglifyJS2
  11513. -------------------------------- (C) ---------------------------------
  11514. Author: Mihai Bazon
  11515. <mihai.bazon@gmail.com>
  11516. http://mihai.bazon.net/blog
  11517. Distributed under the BSD license:
  11518. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11519. Redistribution and use in source and binary forms, with or without
  11520. modification, are permitted provided that the following conditions
  11521. are met:
  11522. * Redistributions of source code must retain the above
  11523. copyright notice, this list of conditions and the following
  11524. disclaimer.
  11525. * Redistributions in binary form must reproduce the above
  11526. copyright notice, this list of conditions and the following
  11527. disclaimer in the documentation and/or other materials
  11528. provided with the distribution.
  11529. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11530. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11531. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11532. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11533. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11534. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11535. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11536. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11537. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11538. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11539. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11540. SUCH DAMAGE.
  11541. ***********************************************************************/
  11542. // Functions and methods to infer certain facts about expressions
  11543. // It's not always possible to be 100% sure about something just by static analysis,
  11544. // so `true` means yes, and `false` means maybe
  11545. const is_undeclared_ref = (node) =>
  11546. node instanceof AST_SymbolRef && node.definition().undeclared;
  11547. const lazy_op = makePredicate("&& || ??");
  11548. const unary_side_effects = makePredicate("delete ++ --");
  11549. // methods to determine whether an expression has a boolean result type
  11550. (function(def_is_boolean) {
  11551. const unary_bool = makePredicate("! delete");
  11552. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  11553. def_is_boolean(AST_Node, return_false);
  11554. def_is_boolean(AST_UnaryPrefix, function() {
  11555. return unary_bool.has(this.operator);
  11556. });
  11557. def_is_boolean(AST_Binary, function() {
  11558. return binary_bool.has(this.operator)
  11559. || lazy_op.has(this.operator)
  11560. && this.left.is_boolean()
  11561. && this.right.is_boolean();
  11562. });
  11563. def_is_boolean(AST_Conditional, function() {
  11564. return this.consequent.is_boolean() && this.alternative.is_boolean();
  11565. });
  11566. def_is_boolean(AST_Assign, function() {
  11567. return this.operator == "=" && this.right.is_boolean();
  11568. });
  11569. def_is_boolean(AST_Sequence, function() {
  11570. return this.tail_node().is_boolean();
  11571. });
  11572. def_is_boolean(AST_True, return_true);
  11573. def_is_boolean(AST_False, return_true);
  11574. })(function(node, func) {
  11575. node.DEFMETHOD("is_boolean", func);
  11576. });
  11577. // methods to determine if an expression has a numeric result type
  11578. (function(def_is_number) {
  11579. def_is_number(AST_Node, return_false);
  11580. def_is_number(AST_Number, return_true);
  11581. const unary = makePredicate("+ - ~ ++ --");
  11582. def_is_number(AST_Unary, function() {
  11583. return unary.has(this.operator);
  11584. });
  11585. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  11586. def_is_number(AST_Binary, function(compressor) {
  11587. return numeric_ops.has(this.operator) || this.operator == "+"
  11588. && this.left.is_number(compressor)
  11589. && this.right.is_number(compressor);
  11590. });
  11591. def_is_number(AST_Assign, function(compressor) {
  11592. return numeric_ops.has(this.operator.slice(0, -1))
  11593. || this.operator == "=" && this.right.is_number(compressor);
  11594. });
  11595. def_is_number(AST_Sequence, function(compressor) {
  11596. return this.tail_node().is_number(compressor);
  11597. });
  11598. def_is_number(AST_Conditional, function(compressor) {
  11599. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  11600. });
  11601. })(function(node, func) {
  11602. node.DEFMETHOD("is_number", func);
  11603. });
  11604. // methods to determine if an expression has a string result type
  11605. (function(def_is_string) {
  11606. def_is_string(AST_Node, return_false);
  11607. def_is_string(AST_String, return_true);
  11608. def_is_string(AST_TemplateString, return_true);
  11609. def_is_string(AST_UnaryPrefix, function() {
  11610. return this.operator == "typeof";
  11611. });
  11612. def_is_string(AST_Binary, function(compressor) {
  11613. return this.operator == "+" &&
  11614. (this.left.is_string(compressor) || this.right.is_string(compressor));
  11615. });
  11616. def_is_string(AST_Assign, function(compressor) {
  11617. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  11618. });
  11619. def_is_string(AST_Sequence, function(compressor) {
  11620. return this.tail_node().is_string(compressor);
  11621. });
  11622. def_is_string(AST_Conditional, function(compressor) {
  11623. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  11624. });
  11625. })(function(node, func) {
  11626. node.DEFMETHOD("is_string", func);
  11627. });
  11628. function is_undefined(node, compressor) {
  11629. return (
  11630. has_flag(node, UNDEFINED)
  11631. || node instanceof AST_Undefined
  11632. || node instanceof AST_UnaryPrefix
  11633. && node.operator == "void"
  11634. && !node.expression.has_side_effects(compressor)
  11635. );
  11636. }
  11637. // Is the node explicitly null or undefined.
  11638. function is_null_or_undefined(node, compressor) {
  11639. let fixed;
  11640. return (
  11641. node instanceof AST_Null
  11642. || is_undefined(node, compressor)
  11643. || (
  11644. node instanceof AST_SymbolRef
  11645. && (fixed = node.definition().fixed) instanceof AST_Node
  11646. && is_nullish(fixed, compressor)
  11647. )
  11648. );
  11649. }
  11650. // Find out if this expression is optionally chained from a base-point that we
  11651. // can statically analyze as null or undefined.
  11652. function is_nullish_shortcircuited(node, compressor) {
  11653. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  11654. return (
  11655. (node.optional && is_null_or_undefined(node.expression, compressor))
  11656. || is_nullish_shortcircuited(node.expression, compressor)
  11657. );
  11658. }
  11659. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  11660. return false;
  11661. }
  11662. // Find out if something is == null, or can short circuit into nullish.
  11663. // Used to optimize ?. and ??
  11664. function is_nullish(node, compressor) {
  11665. if (is_null_or_undefined(node, compressor)) return true;
  11666. return is_nullish_shortcircuited(node, compressor);
  11667. }
  11668. // Determine if expression might cause side effects
  11669. // If there's a possibility that a node may change something when it's executed, this returns true
  11670. (function(def_has_side_effects) {
  11671. def_has_side_effects(AST_Node, return_true);
  11672. def_has_side_effects(AST_EmptyStatement, return_false);
  11673. def_has_side_effects(AST_Constant, return_false);
  11674. def_has_side_effects(AST_This, return_false);
  11675. function any(list, compressor) {
  11676. for (var i = list.length; --i >= 0;)
  11677. if (list[i].has_side_effects(compressor))
  11678. return true;
  11679. return false;
  11680. }
  11681. def_has_side_effects(AST_Block, function(compressor) {
  11682. return any(this.body, compressor);
  11683. });
  11684. def_has_side_effects(AST_Call, function(compressor) {
  11685. if (
  11686. !this.is_callee_pure(compressor)
  11687. && (!this.expression.is_call_pure(compressor)
  11688. || this.expression.has_side_effects(compressor))
  11689. ) {
  11690. return true;
  11691. }
  11692. return any(this.args, compressor);
  11693. });
  11694. def_has_side_effects(AST_Switch, function(compressor) {
  11695. return this.expression.has_side_effects(compressor)
  11696. || any(this.body, compressor);
  11697. });
  11698. def_has_side_effects(AST_Case, function(compressor) {
  11699. return this.expression.has_side_effects(compressor)
  11700. || any(this.body, compressor);
  11701. });
  11702. def_has_side_effects(AST_Try, function(compressor) {
  11703. return any(this.body, compressor)
  11704. || this.bcatch && this.bcatch.has_side_effects(compressor)
  11705. || this.bfinally && this.bfinally.has_side_effects(compressor);
  11706. });
  11707. def_has_side_effects(AST_If, function(compressor) {
  11708. return this.condition.has_side_effects(compressor)
  11709. || this.body && this.body.has_side_effects(compressor)
  11710. || this.alternative && this.alternative.has_side_effects(compressor);
  11711. });
  11712. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  11713. return this.body.has_side_effects(compressor);
  11714. });
  11715. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  11716. return this.body.has_side_effects(compressor);
  11717. });
  11718. def_has_side_effects(AST_Lambda, return_false);
  11719. def_has_side_effects(AST_Class, function (compressor) {
  11720. if (this.extends && this.extends.has_side_effects(compressor)) {
  11721. return true;
  11722. }
  11723. return any(this.properties, compressor);
  11724. });
  11725. def_has_side_effects(AST_Binary, function(compressor) {
  11726. return this.left.has_side_effects(compressor)
  11727. || this.right.has_side_effects(compressor);
  11728. });
  11729. def_has_side_effects(AST_Assign, return_true);
  11730. def_has_side_effects(AST_Conditional, function(compressor) {
  11731. return this.condition.has_side_effects(compressor)
  11732. || this.consequent.has_side_effects(compressor)
  11733. || this.alternative.has_side_effects(compressor);
  11734. });
  11735. def_has_side_effects(AST_Unary, function(compressor) {
  11736. return unary_side_effects.has(this.operator)
  11737. || this.expression.has_side_effects(compressor);
  11738. });
  11739. def_has_side_effects(AST_SymbolRef, function(compressor) {
  11740. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  11741. });
  11742. def_has_side_effects(AST_SymbolClassProperty, return_false);
  11743. def_has_side_effects(AST_SymbolDeclaration, return_false);
  11744. def_has_side_effects(AST_Object, function(compressor) {
  11745. return any(this.properties, compressor);
  11746. });
  11747. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  11748. return (
  11749. this.computed_key() && this.key.has_side_effects(compressor)
  11750. || this.value && this.value.has_side_effects(compressor)
  11751. );
  11752. });
  11753. def_has_side_effects(AST_ClassProperty, function(compressor) {
  11754. return (
  11755. this.computed_key() && this.key.has_side_effects(compressor)
  11756. || this.static && this.value && this.value.has_side_effects(compressor)
  11757. );
  11758. });
  11759. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  11760. return this.computed_key() && this.key.has_side_effects(compressor);
  11761. });
  11762. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  11763. return this.computed_key() && this.key.has_side_effects(compressor);
  11764. });
  11765. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  11766. return this.computed_key() && this.key.has_side_effects(compressor);
  11767. });
  11768. def_has_side_effects(AST_Array, function(compressor) {
  11769. return any(this.elements, compressor);
  11770. });
  11771. def_has_side_effects(AST_Dot, function(compressor) {
  11772. if (is_nullish(this, compressor)) return false;
  11773. return !this.optional && this.expression.may_throw_on_access(compressor)
  11774. || this.expression.has_side_effects(compressor);
  11775. });
  11776. def_has_side_effects(AST_Sub, function(compressor) {
  11777. if (is_nullish(this, compressor)) return false;
  11778. return !this.optional && this.expression.may_throw_on_access(compressor)
  11779. || this.expression.has_side_effects(compressor)
  11780. || this.property.has_side_effects(compressor);
  11781. });
  11782. def_has_side_effects(AST_Chain, function (compressor) {
  11783. return this.expression.has_side_effects(compressor);
  11784. });
  11785. def_has_side_effects(AST_Sequence, function(compressor) {
  11786. return any(this.expressions, compressor);
  11787. });
  11788. def_has_side_effects(AST_Definitions, function(compressor) {
  11789. return any(this.definitions, compressor);
  11790. });
  11791. def_has_side_effects(AST_VarDef, function() {
  11792. return this.value;
  11793. });
  11794. def_has_side_effects(AST_TemplateSegment, return_false);
  11795. def_has_side_effects(AST_TemplateString, function(compressor) {
  11796. return any(this.segments, compressor);
  11797. });
  11798. })(function(node, func) {
  11799. node.DEFMETHOD("has_side_effects", func);
  11800. });
  11801. // determine if expression may throw
  11802. (function(def_may_throw) {
  11803. def_may_throw(AST_Node, return_true);
  11804. def_may_throw(AST_Constant, return_false);
  11805. def_may_throw(AST_EmptyStatement, return_false);
  11806. def_may_throw(AST_Lambda, return_false);
  11807. def_may_throw(AST_SymbolDeclaration, return_false);
  11808. def_may_throw(AST_This, return_false);
  11809. function any(list, compressor) {
  11810. for (var i = list.length; --i >= 0;)
  11811. if (list[i].may_throw(compressor))
  11812. return true;
  11813. return false;
  11814. }
  11815. def_may_throw(AST_Class, function(compressor) {
  11816. if (this.extends && this.extends.may_throw(compressor)) return true;
  11817. return any(this.properties, compressor);
  11818. });
  11819. def_may_throw(AST_Array, function(compressor) {
  11820. return any(this.elements, compressor);
  11821. });
  11822. def_may_throw(AST_Assign, function(compressor) {
  11823. if (this.right.may_throw(compressor)) return true;
  11824. if (!compressor.has_directive("use strict")
  11825. && this.operator == "="
  11826. && this.left instanceof AST_SymbolRef) {
  11827. return false;
  11828. }
  11829. return this.left.may_throw(compressor);
  11830. });
  11831. def_may_throw(AST_Binary, function(compressor) {
  11832. return this.left.may_throw(compressor)
  11833. || this.right.may_throw(compressor);
  11834. });
  11835. def_may_throw(AST_Block, function(compressor) {
  11836. return any(this.body, compressor);
  11837. });
  11838. def_may_throw(AST_Call, function(compressor) {
  11839. if (is_nullish(this, compressor)) return false;
  11840. if (any(this.args, compressor)) return true;
  11841. if (this.is_callee_pure(compressor)) return false;
  11842. if (this.expression.may_throw(compressor)) return true;
  11843. return !(this.expression instanceof AST_Lambda)
  11844. || any(this.expression.body, compressor);
  11845. });
  11846. def_may_throw(AST_Case, function(compressor) {
  11847. return this.expression.may_throw(compressor)
  11848. || any(this.body, compressor);
  11849. });
  11850. def_may_throw(AST_Conditional, function(compressor) {
  11851. return this.condition.may_throw(compressor)
  11852. || this.consequent.may_throw(compressor)
  11853. || this.alternative.may_throw(compressor);
  11854. });
  11855. def_may_throw(AST_Definitions, function(compressor) {
  11856. return any(this.definitions, compressor);
  11857. });
  11858. def_may_throw(AST_If, function(compressor) {
  11859. return this.condition.may_throw(compressor)
  11860. || this.body && this.body.may_throw(compressor)
  11861. || this.alternative && this.alternative.may_throw(compressor);
  11862. });
  11863. def_may_throw(AST_LabeledStatement, function(compressor) {
  11864. return this.body.may_throw(compressor);
  11865. });
  11866. def_may_throw(AST_Object, function(compressor) {
  11867. return any(this.properties, compressor);
  11868. });
  11869. def_may_throw(AST_ObjectProperty, function(compressor) {
  11870. // TODO key may throw too
  11871. return this.value ? this.value.may_throw(compressor) : false;
  11872. });
  11873. def_may_throw(AST_ClassProperty, function(compressor) {
  11874. return (
  11875. this.computed_key() && this.key.may_throw(compressor)
  11876. || this.static && this.value && this.value.may_throw(compressor)
  11877. );
  11878. });
  11879. def_may_throw(AST_ConciseMethod, function(compressor) {
  11880. return this.computed_key() && this.key.may_throw(compressor);
  11881. });
  11882. def_may_throw(AST_ObjectGetter, function(compressor) {
  11883. return this.computed_key() && this.key.may_throw(compressor);
  11884. });
  11885. def_may_throw(AST_ObjectSetter, function(compressor) {
  11886. return this.computed_key() && this.key.may_throw(compressor);
  11887. });
  11888. def_may_throw(AST_Return, function(compressor) {
  11889. return this.value && this.value.may_throw(compressor);
  11890. });
  11891. def_may_throw(AST_Sequence, function(compressor) {
  11892. return any(this.expressions, compressor);
  11893. });
  11894. def_may_throw(AST_SimpleStatement, function(compressor) {
  11895. return this.body.may_throw(compressor);
  11896. });
  11897. def_may_throw(AST_Dot, function(compressor) {
  11898. if (is_nullish(this, compressor)) return false;
  11899. return !this.optional && this.expression.may_throw_on_access(compressor)
  11900. || this.expression.may_throw(compressor);
  11901. });
  11902. def_may_throw(AST_Sub, function(compressor) {
  11903. if (is_nullish(this, compressor)) return false;
  11904. return !this.optional && this.expression.may_throw_on_access(compressor)
  11905. || this.expression.may_throw(compressor)
  11906. || this.property.may_throw(compressor);
  11907. });
  11908. def_may_throw(AST_Chain, function(compressor) {
  11909. return this.expression.may_throw(compressor);
  11910. });
  11911. def_may_throw(AST_Switch, function(compressor) {
  11912. return this.expression.may_throw(compressor)
  11913. || any(this.body, compressor);
  11914. });
  11915. def_may_throw(AST_SymbolRef, function(compressor) {
  11916. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  11917. });
  11918. def_may_throw(AST_SymbolClassProperty, return_false);
  11919. def_may_throw(AST_Try, function(compressor) {
  11920. return this.bcatch ? this.bcatch.may_throw(compressor) : any(this.body, compressor)
  11921. || this.bfinally && this.bfinally.may_throw(compressor);
  11922. });
  11923. def_may_throw(AST_Unary, function(compressor) {
  11924. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  11925. return false;
  11926. return this.expression.may_throw(compressor);
  11927. });
  11928. def_may_throw(AST_VarDef, function(compressor) {
  11929. if (!this.value) return false;
  11930. return this.value.may_throw(compressor);
  11931. });
  11932. })(function(node, func) {
  11933. node.DEFMETHOD("may_throw", func);
  11934. });
  11935. // determine if expression is constant
  11936. (function(def_is_constant_expression) {
  11937. function all_refs_local(scope) {
  11938. let result = true;
  11939. walk(this, node => {
  11940. if (node instanceof AST_SymbolRef) {
  11941. if (has_flag(this, INLINED)) {
  11942. result = false;
  11943. return walk_abort;
  11944. }
  11945. var def = node.definition();
  11946. if (
  11947. member(def, this.enclosed)
  11948. && !this.variables.has(def.name)
  11949. ) {
  11950. if (scope) {
  11951. var scope_def = scope.find_variable(node);
  11952. if (def.undeclared ? !scope_def : scope_def === def) {
  11953. result = "f";
  11954. return true;
  11955. }
  11956. }
  11957. result = false;
  11958. return walk_abort;
  11959. }
  11960. return true;
  11961. }
  11962. if (node instanceof AST_This && this instanceof AST_Arrow) {
  11963. // TODO check arguments too!
  11964. result = false;
  11965. return walk_abort;
  11966. }
  11967. });
  11968. return result;
  11969. }
  11970. def_is_constant_expression(AST_Node, return_false);
  11971. def_is_constant_expression(AST_Constant, return_true);
  11972. def_is_constant_expression(AST_Class, function(scope) {
  11973. if (this.extends && !this.extends.is_constant_expression(scope)) {
  11974. return false;
  11975. }
  11976. for (const prop of this.properties) {
  11977. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  11978. return false;
  11979. }
  11980. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  11981. return false;
  11982. }
  11983. }
  11984. return all_refs_local.call(this, scope);
  11985. });
  11986. def_is_constant_expression(AST_Lambda, all_refs_local);
  11987. def_is_constant_expression(AST_Unary, function() {
  11988. return this.expression.is_constant_expression();
  11989. });
  11990. def_is_constant_expression(AST_Binary, function() {
  11991. return this.left.is_constant_expression()
  11992. && this.right.is_constant_expression();
  11993. });
  11994. def_is_constant_expression(AST_Array, function() {
  11995. return this.elements.every((l) => l.is_constant_expression());
  11996. });
  11997. def_is_constant_expression(AST_Object, function() {
  11998. return this.properties.every((l) => l.is_constant_expression());
  11999. });
  12000. def_is_constant_expression(AST_ObjectProperty, function() {
  12001. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  12002. });
  12003. })(function(node, func) {
  12004. node.DEFMETHOD("is_constant_expression", func);
  12005. });
  12006. // may_throw_on_access()
  12007. // returns true if this node may be null, undefined or contain `AST_Accessor`
  12008. (function(def_may_throw_on_access) {
  12009. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  12010. return !compressor.option("pure_getters")
  12011. || this._dot_throw(compressor);
  12012. });
  12013. function is_strict(compressor) {
  12014. return /strict/.test(compressor.option("pure_getters"));
  12015. }
  12016. def_may_throw_on_access(AST_Node, is_strict);
  12017. def_may_throw_on_access(AST_Null, return_true);
  12018. def_may_throw_on_access(AST_Undefined, return_true);
  12019. def_may_throw_on_access(AST_Constant, return_false);
  12020. def_may_throw_on_access(AST_Array, return_false);
  12021. def_may_throw_on_access(AST_Object, function(compressor) {
  12022. if (!is_strict(compressor)) return false;
  12023. for (var i = this.properties.length; --i >=0;)
  12024. if (this.properties[i]._dot_throw(compressor)) return true;
  12025. return false;
  12026. });
  12027. // Do not be as strict with classes as we are with objects.
  12028. // Hopefully the community is not going to abuse static getters and setters.
  12029. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  12030. def_may_throw_on_access(AST_Class, return_false);
  12031. def_may_throw_on_access(AST_ObjectProperty, return_false);
  12032. def_may_throw_on_access(AST_ObjectGetter, return_true);
  12033. def_may_throw_on_access(AST_Expansion, function(compressor) {
  12034. return this.expression._dot_throw(compressor);
  12035. });
  12036. def_may_throw_on_access(AST_Function, return_false);
  12037. def_may_throw_on_access(AST_Arrow, return_false);
  12038. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  12039. def_may_throw_on_access(AST_UnaryPrefix, function() {
  12040. return this.operator == "void";
  12041. });
  12042. def_may_throw_on_access(AST_Binary, function(compressor) {
  12043. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  12044. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  12045. });
  12046. def_may_throw_on_access(AST_Assign, function(compressor) {
  12047. if (this.logical) return true;
  12048. return this.operator == "="
  12049. && this.right._dot_throw(compressor);
  12050. });
  12051. def_may_throw_on_access(AST_Conditional, function(compressor) {
  12052. return this.consequent._dot_throw(compressor)
  12053. || this.alternative._dot_throw(compressor);
  12054. });
  12055. def_may_throw_on_access(AST_Dot, function(compressor) {
  12056. if (!is_strict(compressor)) return false;
  12057. if (this.property == "prototype") {
  12058. return !(
  12059. this.expression instanceof AST_Function
  12060. || this.expression instanceof AST_Class
  12061. );
  12062. }
  12063. return true;
  12064. });
  12065. def_may_throw_on_access(AST_Chain, function(compressor) {
  12066. return this.expression._dot_throw(compressor);
  12067. });
  12068. def_may_throw_on_access(AST_Sequence, function(compressor) {
  12069. return this.tail_node()._dot_throw(compressor);
  12070. });
  12071. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  12072. if (this.name === "arguments") return false;
  12073. if (has_flag(this, UNDEFINED)) return true;
  12074. if (!is_strict(compressor)) return false;
  12075. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  12076. if (this.is_immutable()) return false;
  12077. var fixed = this.fixed_value();
  12078. return !fixed || fixed._dot_throw(compressor);
  12079. });
  12080. })(function(node, func) {
  12081. node.DEFMETHOD("_dot_throw", func);
  12082. });
  12083. function is_lhs(node, parent) {
  12084. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  12085. if (parent instanceof AST_Assign && parent.left === node) return node;
  12086. }
  12087. (function(def_find_defs) {
  12088. function to_node(value, orig) {
  12089. if (value instanceof AST_Node) {
  12090. if (!(value instanceof AST_Constant)) {
  12091. // Value may be a function, an array including functions and even a complex assign / block expression,
  12092. // so it should never be shared in different places.
  12093. // Otherwise wrong information may be used in the compression phase
  12094. value = value.clone(true);
  12095. }
  12096. return make_node(value.CTOR, orig, value);
  12097. }
  12098. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  12099. elements: value.map(function(value) {
  12100. return to_node(value, orig);
  12101. })
  12102. });
  12103. if (value && typeof value == "object") {
  12104. var props = [];
  12105. for (var key in value) if (HOP(value, key)) {
  12106. props.push(make_node(AST_ObjectKeyVal, orig, {
  12107. key: key,
  12108. value: to_node(value[key], orig)
  12109. }));
  12110. }
  12111. return make_node(AST_Object, orig, {
  12112. properties: props
  12113. });
  12114. }
  12115. return make_node_from_constant(value, orig);
  12116. }
  12117. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  12118. if (!compressor.option("global_defs")) return this;
  12119. this.figure_out_scope({ ie8: compressor.option("ie8") });
  12120. return this.transform(new TreeTransformer(function(node) {
  12121. var def = node._find_defs(compressor, "");
  12122. if (!def) return;
  12123. var level = 0, child = node, parent;
  12124. while (parent = this.parent(level++)) {
  12125. if (!(parent instanceof AST_PropAccess)) break;
  12126. if (parent.expression !== child) break;
  12127. child = parent;
  12128. }
  12129. if (is_lhs(child, parent)) {
  12130. return;
  12131. }
  12132. return def;
  12133. }));
  12134. });
  12135. def_find_defs(AST_Node, noop);
  12136. def_find_defs(AST_Chain, function(compressor, suffix) {
  12137. return this.expression._find_defs(compressor, suffix);
  12138. });
  12139. def_find_defs(AST_Dot, function(compressor, suffix) {
  12140. return this.expression._find_defs(compressor, "." + this.property + suffix);
  12141. });
  12142. def_find_defs(AST_SymbolDeclaration, function() {
  12143. if (!this.global()) return;
  12144. });
  12145. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  12146. if (!this.global()) return;
  12147. var defines = compressor.option("global_defs");
  12148. var name = this.name + suffix;
  12149. if (HOP(defines, name)) return to_node(defines[name], this);
  12150. });
  12151. })(function(node, func) {
  12152. node.DEFMETHOD("_find_defs", func);
  12153. });
  12154. // method to negate an expression
  12155. (function(def_negate) {
  12156. function basic_negation(exp) {
  12157. return make_node(AST_UnaryPrefix, exp, {
  12158. operator: "!",
  12159. expression: exp
  12160. });
  12161. }
  12162. function best(orig, alt, first_in_statement) {
  12163. var negated = basic_negation(orig);
  12164. if (first_in_statement) {
  12165. var stat = make_node(AST_SimpleStatement, alt, {
  12166. body: alt
  12167. });
  12168. return best_of_expression(negated, stat) === stat ? alt : negated;
  12169. }
  12170. return best_of_expression(negated, alt);
  12171. }
  12172. def_negate(AST_Node, function() {
  12173. return basic_negation(this);
  12174. });
  12175. def_negate(AST_Statement, function() {
  12176. throw new Error("Cannot negate a statement");
  12177. });
  12178. def_negate(AST_Function, function() {
  12179. return basic_negation(this);
  12180. });
  12181. def_negate(AST_Arrow, function() {
  12182. return basic_negation(this);
  12183. });
  12184. def_negate(AST_UnaryPrefix, function() {
  12185. if (this.operator == "!")
  12186. return this.expression;
  12187. return basic_negation(this);
  12188. });
  12189. def_negate(AST_Sequence, function(compressor) {
  12190. var expressions = this.expressions.slice();
  12191. expressions.push(expressions.pop().negate(compressor));
  12192. return make_sequence(this, expressions);
  12193. });
  12194. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  12195. var self = this.clone();
  12196. self.consequent = self.consequent.negate(compressor);
  12197. self.alternative = self.alternative.negate(compressor);
  12198. return best(this, self, first_in_statement);
  12199. });
  12200. def_negate(AST_Binary, function(compressor, first_in_statement) {
  12201. var self = this.clone(), op = this.operator;
  12202. if (compressor.option("unsafe_comps")) {
  12203. switch (op) {
  12204. case "<=" : self.operator = ">" ; return self;
  12205. case "<" : self.operator = ">=" ; return self;
  12206. case ">=" : self.operator = "<" ; return self;
  12207. case ">" : self.operator = "<=" ; return self;
  12208. }
  12209. }
  12210. switch (op) {
  12211. case "==" : self.operator = "!="; return self;
  12212. case "!=" : self.operator = "=="; return self;
  12213. case "===": self.operator = "!=="; return self;
  12214. case "!==": self.operator = "==="; return self;
  12215. case "&&":
  12216. self.operator = "||";
  12217. self.left = self.left.negate(compressor, first_in_statement);
  12218. self.right = self.right.negate(compressor);
  12219. return best(this, self, first_in_statement);
  12220. case "||":
  12221. self.operator = "&&";
  12222. self.left = self.left.negate(compressor, first_in_statement);
  12223. self.right = self.right.negate(compressor);
  12224. return best(this, self, first_in_statement);
  12225. }
  12226. return basic_negation(this);
  12227. });
  12228. })(function(node, func) {
  12229. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  12230. return func.call(this, compressor, first_in_statement);
  12231. });
  12232. });
  12233. // Is the callee of this function pure?
  12234. 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");
  12235. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  12236. if (compressor.option("unsafe")) {
  12237. var expr = this.expression;
  12238. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  12239. if (
  12240. expr.expression && expr.expression.name === "hasOwnProperty" &&
  12241. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  12242. ) {
  12243. return false;
  12244. }
  12245. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  12246. if (
  12247. expr instanceof AST_Dot
  12248. && is_undeclared_ref(expr.expression)
  12249. && is_pure_native_fn(expr.expression.name, expr.property)
  12250. ) {
  12251. return true;
  12252. }
  12253. }
  12254. return !!has_annotation(this, _PURE) || !compressor.pure_funcs(this);
  12255. });
  12256. // If I call this, is it a pure function?
  12257. AST_Node.DEFMETHOD("is_call_pure", return_false);
  12258. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  12259. if (!compressor.option("unsafe")) return;
  12260. const expr = this.expression;
  12261. let native_obj;
  12262. if (expr instanceof AST_Array) {
  12263. native_obj = "Array";
  12264. } else if (expr.is_boolean()) {
  12265. native_obj = "Boolean";
  12266. } else if (expr.is_number(compressor)) {
  12267. native_obj = "Number";
  12268. } else if (expr instanceof AST_RegExp) {
  12269. native_obj = "RegExp";
  12270. } else if (expr.is_string(compressor)) {
  12271. native_obj = "String";
  12272. } else if (!this.may_throw_on_access(compressor)) {
  12273. native_obj = "Object";
  12274. }
  12275. return native_obj != null && is_pure_native_method(native_obj, this.property);
  12276. });
  12277. // tell me if a statement aborts
  12278. const aborts = (thing) => thing && thing.aborts();
  12279. (function(def_aborts) {
  12280. def_aborts(AST_Statement, return_null);
  12281. def_aborts(AST_Jump, return_this);
  12282. function block_aborts() {
  12283. for (var i = 0; i < this.body.length; i++) {
  12284. if (aborts(this.body[i])) {
  12285. return this.body[i];
  12286. }
  12287. }
  12288. return null;
  12289. }
  12290. def_aborts(AST_Import, function() { return null; });
  12291. def_aborts(AST_BlockStatement, block_aborts);
  12292. def_aborts(AST_SwitchBranch, block_aborts);
  12293. def_aborts(AST_If, function() {
  12294. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  12295. });
  12296. })(function(node, func) {
  12297. node.DEFMETHOD("aborts", func);
  12298. });
  12299. function is_modified(compressor, tw, node, value, level, immutable) {
  12300. var parent = tw.parent(level);
  12301. var lhs = is_lhs(node, parent);
  12302. if (lhs) return lhs;
  12303. if (!immutable
  12304. && parent instanceof AST_Call
  12305. && parent.expression === node
  12306. && !(value instanceof AST_Arrow)
  12307. && !(value instanceof AST_Class)
  12308. && !parent.is_callee_pure(compressor)
  12309. && (!(value instanceof AST_Function)
  12310. || !(parent instanceof AST_New) && value.contains_this())) {
  12311. return true;
  12312. }
  12313. if (parent instanceof AST_Array) {
  12314. return is_modified(compressor, tw, parent, parent, level + 1);
  12315. }
  12316. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  12317. var obj = tw.parent(level + 1);
  12318. return is_modified(compressor, tw, obj, obj, level + 2);
  12319. }
  12320. if (parent instanceof AST_PropAccess && parent.expression === node) {
  12321. var prop = read_property(value, parent.property);
  12322. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  12323. }
  12324. }
  12325. /***********************************************************************
  12326. A JavaScript tokenizer / parser / beautifier / compressor.
  12327. https://github.com/mishoo/UglifyJS2
  12328. -------------------------------- (C) ---------------------------------
  12329. Author: Mihai Bazon
  12330. <mihai.bazon@gmail.com>
  12331. http://mihai.bazon.net/blog
  12332. Distributed under the BSD license:
  12333. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12334. Redistribution and use in source and binary forms, with or without
  12335. modification, are permitted provided that the following conditions
  12336. are met:
  12337. * Redistributions of source code must retain the above
  12338. copyright notice, this list of conditions and the following
  12339. disclaimer.
  12340. * Redistributions in binary form must reproduce the above
  12341. copyright notice, this list of conditions and the following
  12342. disclaimer in the documentation and/or other materials
  12343. provided with the distribution.
  12344. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12345. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12346. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12347. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12348. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12349. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12350. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12351. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12352. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12353. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12354. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12355. SUCH DAMAGE.
  12356. ***********************************************************************/
  12357. // methods to evaluate a constant expression
  12358. function def_eval(node, func) {
  12359. node.DEFMETHOD("_eval", func);
  12360. }
  12361. // Used to propagate a nullish short-circuit signal upwards through the chain.
  12362. const nullish = Symbol("This AST_Chain is nullish");
  12363. // If the node has been successfully reduced to a constant,
  12364. // then its value is returned; otherwise the element itself
  12365. // is returned.
  12366. // They can be distinguished as constant value is never a
  12367. // descendant of AST_Node.
  12368. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  12369. if (!compressor.option("evaluate"))
  12370. return this;
  12371. var val = this._eval(compressor, 1);
  12372. if (!val || val instanceof RegExp)
  12373. return val;
  12374. if (typeof val == "function" || typeof val == "object" || val == nullish)
  12375. return this;
  12376. return val;
  12377. });
  12378. var unaryPrefix = makePredicate("! ~ - + void");
  12379. AST_Node.DEFMETHOD("is_constant", function () {
  12380. // Accomodate when compress option evaluate=false
  12381. // as well as the common constant expressions !0 and -1
  12382. if (this instanceof AST_Constant) {
  12383. return !(this instanceof AST_RegExp);
  12384. } else {
  12385. return this instanceof AST_UnaryPrefix
  12386. && this.expression instanceof AST_Constant
  12387. && unaryPrefix.has(this.operator);
  12388. }
  12389. });
  12390. def_eval(AST_Statement, function () {
  12391. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  12392. });
  12393. def_eval(AST_Lambda, return_this);
  12394. def_eval(AST_Class, return_this);
  12395. def_eval(AST_Node, return_this);
  12396. def_eval(AST_Constant, function () {
  12397. return this.getValue();
  12398. });
  12399. def_eval(AST_BigInt, return_this);
  12400. def_eval(AST_RegExp, function (compressor) {
  12401. let evaluated = compressor.evaluated_regexps.get(this.value);
  12402. if (evaluated === undefined) {
  12403. try {
  12404. const { source, flags } = this.value;
  12405. evaluated = new RegExp(source, flags);
  12406. } catch (e) {
  12407. evaluated = null;
  12408. }
  12409. compressor.evaluated_regexps.set(this.value, evaluated);
  12410. }
  12411. return evaluated || this;
  12412. });
  12413. def_eval(AST_TemplateString, function () {
  12414. if (this.segments.length !== 1) return this;
  12415. return this.segments[0].value;
  12416. });
  12417. def_eval(AST_Function, function (compressor) {
  12418. if (compressor.option("unsafe")) {
  12419. var fn = function () { };
  12420. fn.node = this;
  12421. fn.toString = () => this.print_to_string();
  12422. return fn;
  12423. }
  12424. return this;
  12425. });
  12426. def_eval(AST_Array, function (compressor, depth) {
  12427. if (compressor.option("unsafe")) {
  12428. var elements = [];
  12429. for (var i = 0, len = this.elements.length; i < len; i++) {
  12430. var element = this.elements[i];
  12431. var value = element._eval(compressor, depth);
  12432. if (element === value)
  12433. return this;
  12434. elements.push(value);
  12435. }
  12436. return elements;
  12437. }
  12438. return this;
  12439. });
  12440. def_eval(AST_Object, function (compressor, depth) {
  12441. if (compressor.option("unsafe")) {
  12442. var val = {};
  12443. for (var i = 0, len = this.properties.length; i < len; i++) {
  12444. var prop = this.properties[i];
  12445. if (prop instanceof AST_Expansion)
  12446. return this;
  12447. var key = prop.key;
  12448. if (key instanceof AST_Symbol) {
  12449. key = key.name;
  12450. } else if (key instanceof AST_Node) {
  12451. key = key._eval(compressor, depth);
  12452. if (key === prop.key)
  12453. return this;
  12454. }
  12455. if (typeof Object.prototype[key] === "function") {
  12456. return this;
  12457. }
  12458. if (prop.value instanceof AST_Function)
  12459. continue;
  12460. val[key] = prop.value._eval(compressor, depth);
  12461. if (val[key] === prop.value)
  12462. return this;
  12463. }
  12464. return val;
  12465. }
  12466. return this;
  12467. });
  12468. var non_converting_unary = makePredicate("! typeof void");
  12469. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  12470. var e = this.expression;
  12471. // Function would be evaluated to an array and so typeof would
  12472. // incorrectly return 'object'. Hence making is a special case.
  12473. if (compressor.option("typeofs")
  12474. && this.operator == "typeof"
  12475. && (e instanceof AST_Lambda
  12476. || e instanceof AST_SymbolRef
  12477. && e.fixed_value() instanceof AST_Lambda)) {
  12478. return typeof function () { };
  12479. }
  12480. if (!non_converting_unary.has(this.operator))
  12481. depth++;
  12482. e = e._eval(compressor, depth);
  12483. if (e === this.expression)
  12484. return this;
  12485. switch (this.operator) {
  12486. case "!": return !e;
  12487. case "typeof":
  12488. // typeof <RegExp> returns "object" or "function" on different platforms
  12489. // so cannot evaluate reliably
  12490. if (e instanceof RegExp)
  12491. return this;
  12492. return typeof e;
  12493. case "void": return void e;
  12494. case "~": return ~e;
  12495. case "-": return -e;
  12496. case "+": return +e;
  12497. }
  12498. return this;
  12499. });
  12500. var non_converting_binary = makePredicate("&& || ?? === !==");
  12501. const identity_comparison = makePredicate("== != === !==");
  12502. const has_identity = value => typeof value === "object"
  12503. || typeof value === "function"
  12504. || typeof value === "symbol";
  12505. def_eval(AST_Binary, function (compressor, depth) {
  12506. if (!non_converting_binary.has(this.operator))
  12507. depth++;
  12508. var left = this.left._eval(compressor, depth);
  12509. if (left === this.left)
  12510. return this;
  12511. var right = this.right._eval(compressor, depth);
  12512. if (right === this.right)
  12513. return this;
  12514. var result;
  12515. if (left != null
  12516. && right != null
  12517. && identity_comparison.has(this.operator)
  12518. && has_identity(left)
  12519. && has_identity(right)
  12520. && typeof left === typeof right) {
  12521. // Do not compare by reference
  12522. return this;
  12523. }
  12524. switch (this.operator) {
  12525. case "&&": result = left && right; break;
  12526. case "||": result = left || right; break;
  12527. case "??": result = left != null ? left : right; break;
  12528. case "|": result = left | right; break;
  12529. case "&": result = left & right; break;
  12530. case "^": result = left ^ right; break;
  12531. case "+": result = left + right; break;
  12532. case "*": result = left * right; break;
  12533. case "**": result = Math.pow(left, right); break;
  12534. case "/": result = left / right; break;
  12535. case "%": result = left % right; break;
  12536. case "-": result = left - right; break;
  12537. case "<<": result = left << right; break;
  12538. case ">>": result = left >> right; break;
  12539. case ">>>": result = left >>> right; break;
  12540. case "==": result = left == right; break;
  12541. case "===": result = left === right; break;
  12542. case "!=": result = left != right; break;
  12543. case "!==": result = left !== right; break;
  12544. case "<": result = left < right; break;
  12545. case "<=": result = left <= right; break;
  12546. case ">": result = left > right; break;
  12547. case ">=": result = left >= right; break;
  12548. default:
  12549. return this;
  12550. }
  12551. if (isNaN(result) && compressor.find_parent(AST_With)) {
  12552. // leave original expression as is
  12553. return this;
  12554. }
  12555. return result;
  12556. });
  12557. def_eval(AST_Conditional, function (compressor, depth) {
  12558. var condition = this.condition._eval(compressor, depth);
  12559. if (condition === this.condition)
  12560. return this;
  12561. var node = condition ? this.consequent : this.alternative;
  12562. var value = node._eval(compressor, depth);
  12563. return value === node ? this : value;
  12564. });
  12565. // Set of AST_SymbolRef which are currently being evaluated.
  12566. // Avoids infinite recursion of ._eval()
  12567. const reentrant_ref_eval = new Set();
  12568. def_eval(AST_SymbolRef, function (compressor, depth) {
  12569. if (reentrant_ref_eval.has(this))
  12570. return this;
  12571. var fixed = this.fixed_value();
  12572. if (!fixed)
  12573. return this;
  12574. reentrant_ref_eval.add(this);
  12575. const value = fixed._eval(compressor, depth);
  12576. reentrant_ref_eval.delete(this);
  12577. if (value === fixed)
  12578. return this;
  12579. if (value && typeof value == "object") {
  12580. var escaped = this.definition().escaped;
  12581. if (escaped && depth > escaped)
  12582. return this;
  12583. }
  12584. return value;
  12585. });
  12586. const global_objs = { Array, Math, Number, Object, String };
  12587. const regexp_flags = new Set([
  12588. "dotAll",
  12589. "global",
  12590. "ignoreCase",
  12591. "multiline",
  12592. "sticky",
  12593. "unicode",
  12594. ]);
  12595. def_eval(AST_PropAccess, function (compressor, depth) {
  12596. const obj = this.expression._eval(compressor, depth);
  12597. if (obj === nullish || (this.optional && obj == null)) return nullish;
  12598. if (compressor.option("unsafe")) {
  12599. var key = this.property;
  12600. if (key instanceof AST_Node) {
  12601. key = key._eval(compressor, depth);
  12602. if (key === this.property)
  12603. return this;
  12604. }
  12605. var exp = this.expression;
  12606. var val;
  12607. if (is_undeclared_ref(exp)) {
  12608. var aa;
  12609. var first_arg = exp.name === "hasOwnProperty"
  12610. && key === "call"
  12611. && (aa = compressor.parent() && compressor.parent().args)
  12612. && (aa && aa[0]
  12613. && aa[0].evaluate(compressor));
  12614. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  12615. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  12616. return this.clone();
  12617. }
  12618. if (!is_pure_native_value(exp.name, key))
  12619. return this;
  12620. val = global_objs[exp.name];
  12621. } else {
  12622. val = exp._eval(compressor, depth + 1);
  12623. if (val instanceof RegExp) {
  12624. if (key == "source") {
  12625. return regexp_source_fix(val.source);
  12626. } else if (key == "flags" || regexp_flags.has(key)) {
  12627. return val[key];
  12628. }
  12629. }
  12630. if (!val || val === exp || !HOP(val, key))
  12631. return this;
  12632. if (typeof val == "function")
  12633. switch (key) {
  12634. case "name":
  12635. return val.node.name ? val.node.name.name : "";
  12636. case "length":
  12637. return val.node.length_property();
  12638. default:
  12639. return this;
  12640. }
  12641. }
  12642. return val[key];
  12643. }
  12644. return this;
  12645. });
  12646. def_eval(AST_Chain, function (compressor, depth) {
  12647. const evaluated = this.expression._eval(compressor, depth);
  12648. return evaluated === nullish
  12649. ? undefined
  12650. : evaluated === this.expression
  12651. ? this
  12652. : evaluated;
  12653. });
  12654. def_eval(AST_Call, function (compressor, depth) {
  12655. var exp = this.expression;
  12656. const callee = exp._eval(compressor, depth);
  12657. if (callee === nullish || (this.optional && callee == null)) return nullish;
  12658. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  12659. var key = exp.property;
  12660. if (key instanceof AST_Node) {
  12661. key = key._eval(compressor, depth);
  12662. if (key === exp.property)
  12663. return this;
  12664. }
  12665. var val;
  12666. var e = exp.expression;
  12667. if (is_undeclared_ref(e)) {
  12668. var first_arg = e.name === "hasOwnProperty" &&
  12669. key === "call" &&
  12670. (this.args[0] && this.args[0].evaluate(compressor));
  12671. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  12672. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  12673. return this.clone();
  12674. }
  12675. if (!is_pure_native_fn(e.name, key)) return this;
  12676. val = global_objs[e.name];
  12677. } else {
  12678. val = e._eval(compressor, depth + 1);
  12679. if (val === e || !val)
  12680. return this;
  12681. if (!is_pure_native_method(val.constructor.name, key))
  12682. return this;
  12683. }
  12684. var args = [];
  12685. for (var i = 0, len = this.args.length; i < len; i++) {
  12686. var arg = this.args[i];
  12687. var value = arg._eval(compressor, depth);
  12688. if (arg === value)
  12689. return this;
  12690. if (arg instanceof AST_Lambda)
  12691. return this;
  12692. args.push(value);
  12693. }
  12694. try {
  12695. return val[key].apply(val, args);
  12696. } catch (ex) {
  12697. // We don't really care
  12698. }
  12699. }
  12700. return this;
  12701. });
  12702. // Also a subclass of AST_Call
  12703. def_eval(AST_New, return_this);
  12704. /***********************************************************************
  12705. A JavaScript tokenizer / parser / beautifier / compressor.
  12706. https://github.com/mishoo/UglifyJS2
  12707. -------------------------------- (C) ---------------------------------
  12708. Author: Mihai Bazon
  12709. <mihai.bazon@gmail.com>
  12710. http://mihai.bazon.net/blog
  12711. Distributed under the BSD license:
  12712. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12713. Redistribution and use in source and binary forms, with or without
  12714. modification, are permitted provided that the following conditions
  12715. are met:
  12716. * Redistributions of source code must retain the above
  12717. copyright notice, this list of conditions and the following
  12718. disclaimer.
  12719. * Redistributions in binary form must reproduce the above
  12720. copyright notice, this list of conditions and the following
  12721. disclaimer in the documentation and/or other materials
  12722. provided with the distribution.
  12723. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12724. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12725. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12726. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12727. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12728. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12729. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12730. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12731. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12732. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12733. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12734. SUCH DAMAGE.
  12735. ***********************************************************************/
  12736. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  12737. // only about side effects. We'll be defining this method for each node type in this module
  12738. //
  12739. // Examples:
  12740. // foo++ -> foo++
  12741. // 1 + func() -> func()
  12742. // 10 -> (nothing)
  12743. // knownPureFunc(foo++) -> foo++
  12744. function def_drop_side_effect_free(node, func) {
  12745. node.DEFMETHOD("drop_side_effect_free", func);
  12746. }
  12747. // Drop side-effect-free elements from an array of expressions.
  12748. // Returns an array of expressions with side-effects or null
  12749. // if all elements were dropped. Note: original array may be
  12750. // returned if nothing changed.
  12751. function trim(nodes, compressor, first_in_statement) {
  12752. var len = nodes.length;
  12753. if (!len) return null;
  12754. var ret = [], changed = false;
  12755. for (var i = 0; i < len; i++) {
  12756. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  12757. changed |= node !== nodes[i];
  12758. if (node) {
  12759. ret.push(node);
  12760. first_in_statement = false;
  12761. }
  12762. }
  12763. return changed ? ret.length ? ret : null : nodes;
  12764. }
  12765. def_drop_side_effect_free(AST_Node, return_this);
  12766. def_drop_side_effect_free(AST_Constant, return_null);
  12767. def_drop_side_effect_free(AST_This, return_null);
  12768. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  12769. if (is_nullish_shortcircuited(this, compressor)) {
  12770. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  12771. }
  12772. if (!this.is_callee_pure(compressor)) {
  12773. if (this.expression.is_call_pure(compressor)) {
  12774. var exprs = this.args.slice();
  12775. exprs.unshift(this.expression.expression);
  12776. exprs = trim(exprs, compressor, first_in_statement);
  12777. return exprs && make_sequence(this, exprs);
  12778. }
  12779. if (is_func_expr(this.expression)
  12780. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  12781. var node = this.clone();
  12782. node.expression.process_expression(false, compressor);
  12783. return node;
  12784. }
  12785. return this;
  12786. }
  12787. var args = trim(this.args, compressor, first_in_statement);
  12788. return args && make_sequence(this, args);
  12789. });
  12790. def_drop_side_effect_free(AST_Accessor, return_null);
  12791. def_drop_side_effect_free(AST_Function, return_null);
  12792. def_drop_side_effect_free(AST_Arrow, return_null);
  12793. def_drop_side_effect_free(AST_Class, function (compressor) {
  12794. const with_effects = [];
  12795. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  12796. if (trimmed_extends)
  12797. with_effects.push(trimmed_extends);
  12798. for (const prop of this.properties) {
  12799. const trimmed_prop = prop.drop_side_effect_free(compressor);
  12800. if (trimmed_prop)
  12801. with_effects.push(trimmed_prop);
  12802. }
  12803. if (!with_effects.length)
  12804. return null;
  12805. return make_sequence(this, with_effects);
  12806. });
  12807. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  12808. var right = this.right.drop_side_effect_free(compressor);
  12809. if (!right)
  12810. return this.left.drop_side_effect_free(compressor, first_in_statement);
  12811. if (lazy_op.has(this.operator)) {
  12812. if (right === this.right)
  12813. return this;
  12814. var node = this.clone();
  12815. node.right = right;
  12816. return node;
  12817. } else {
  12818. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  12819. if (!left)
  12820. return this.right.drop_side_effect_free(compressor, first_in_statement);
  12821. return make_sequence(this, [left, right]);
  12822. }
  12823. });
  12824. def_drop_side_effect_free(AST_Assign, function (compressor) {
  12825. if (this.logical)
  12826. return this;
  12827. var left = this.left;
  12828. if (left.has_side_effects(compressor)
  12829. || compressor.has_directive("use strict")
  12830. && left instanceof AST_PropAccess
  12831. && left.expression.is_constant()) {
  12832. return this;
  12833. }
  12834. set_flag(this, WRITE_ONLY);
  12835. while (left instanceof AST_PropAccess) {
  12836. left = left.expression;
  12837. }
  12838. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  12839. return this.right.drop_side_effect_free(compressor);
  12840. }
  12841. return this;
  12842. });
  12843. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  12844. var consequent = this.consequent.drop_side_effect_free(compressor);
  12845. var alternative = this.alternative.drop_side_effect_free(compressor);
  12846. if (consequent === this.consequent && alternative === this.alternative)
  12847. return this;
  12848. if (!consequent)
  12849. return alternative ? make_node(AST_Binary, this, {
  12850. operator: "||",
  12851. left: this.condition,
  12852. right: alternative
  12853. }) : this.condition.drop_side_effect_free(compressor);
  12854. if (!alternative)
  12855. return make_node(AST_Binary, this, {
  12856. operator: "&&",
  12857. left: this.condition,
  12858. right: consequent
  12859. });
  12860. var node = this.clone();
  12861. node.consequent = consequent;
  12862. node.alternative = alternative;
  12863. return node;
  12864. });
  12865. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  12866. if (unary_side_effects.has(this.operator)) {
  12867. if (!this.expression.has_side_effects(compressor)) {
  12868. set_flag(this, WRITE_ONLY);
  12869. } else {
  12870. clear_flag(this, WRITE_ONLY);
  12871. }
  12872. return this;
  12873. }
  12874. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  12875. return null;
  12876. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  12877. if (first_in_statement && expression && is_iife_call(expression)) {
  12878. if (expression === this.expression && this.operator == "!")
  12879. return this;
  12880. return expression.negate(compressor, first_in_statement);
  12881. }
  12882. return expression;
  12883. });
  12884. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  12885. const safe_access = this.is_declared(compressor)
  12886. || pure_prop_access_globals.has(this.name);
  12887. return safe_access ? null : this;
  12888. });
  12889. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  12890. var values = trim(this.properties, compressor, first_in_statement);
  12891. return values && make_sequence(this, values);
  12892. });
  12893. def_drop_side_effect_free(AST_ObjectProperty, function (compressor, first_in_statement) {
  12894. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  12895. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  12896. const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
  12897. if (key && value) {
  12898. return make_sequence(this, [key, value]);
  12899. }
  12900. return key || value;
  12901. });
  12902. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  12903. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  12904. const value = this.static && this.value
  12905. && this.value.drop_side_effect_free(compressor);
  12906. if (key && value)
  12907. return make_sequence(this, [key, value]);
  12908. return key || value || null;
  12909. });
  12910. def_drop_side_effect_free(AST_ConciseMethod, function () {
  12911. return this.computed_key() ? this.key : null;
  12912. });
  12913. def_drop_side_effect_free(AST_ObjectGetter, function () {
  12914. return this.computed_key() ? this.key : null;
  12915. });
  12916. def_drop_side_effect_free(AST_ObjectSetter, function () {
  12917. return this.computed_key() ? this.key : null;
  12918. });
  12919. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  12920. var values = trim(this.elements, compressor, first_in_statement);
  12921. return values && make_sequence(this, values);
  12922. });
  12923. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  12924. if (is_nullish_shortcircuited(this, compressor)) {
  12925. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  12926. }
  12927. if (this.expression.may_throw_on_access(compressor)) return this;
  12928. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  12929. });
  12930. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  12931. if (is_nullish_shortcircuited(this, compressor)) {
  12932. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  12933. }
  12934. if (this.expression.may_throw_on_access(compressor)) return this;
  12935. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  12936. if (!expression)
  12937. return this.property.drop_side_effect_free(compressor, first_in_statement);
  12938. var property = this.property.drop_side_effect_free(compressor);
  12939. if (!property)
  12940. return expression;
  12941. return make_sequence(this, [expression, property]);
  12942. });
  12943. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  12944. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  12945. });
  12946. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  12947. var last = this.tail_node();
  12948. var expr = last.drop_side_effect_free(compressor);
  12949. if (expr === last)
  12950. return this;
  12951. var expressions = this.expressions.slice(0, -1);
  12952. if (expr)
  12953. expressions.push(expr);
  12954. if (!expressions.length) {
  12955. return make_node(AST_Number, this, { value: 0 });
  12956. }
  12957. return make_sequence(this, expressions);
  12958. });
  12959. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  12960. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  12961. });
  12962. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  12963. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  12964. var values = trim(this.segments, compressor, first_in_statement);
  12965. return values && make_sequence(this, values);
  12966. });
  12967. /***********************************************************************
  12968. A JavaScript tokenizer / parser / beautifier / compressor.
  12969. https://github.com/mishoo/UglifyJS2
  12970. -------------------------------- (C) ---------------------------------
  12971. Author: Mihai Bazon
  12972. <mihai.bazon@gmail.com>
  12973. http://mihai.bazon.net/blog
  12974. Distributed under the BSD license:
  12975. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12976. Redistribution and use in source and binary forms, with or without
  12977. modification, are permitted provided that the following conditions
  12978. are met:
  12979. * Redistributions of source code must retain the above
  12980. copyright notice, this list of conditions and the following
  12981. disclaimer.
  12982. * Redistributions in binary form must reproduce the above
  12983. copyright notice, this list of conditions and the following
  12984. disclaimer in the documentation and/or other materials
  12985. provided with the distribution.
  12986. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12987. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12988. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12989. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12990. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12991. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12992. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12993. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12994. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12995. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12996. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12997. SUCH DAMAGE.
  12998. ***********************************************************************/
  12999. // Define the method AST_Node#reduce_vars, which goes through the AST in
  13000. // execution order to perform basic flow analysis
  13001. function def_reduce_vars(node, func) {
  13002. node.DEFMETHOD("reduce_vars", func);
  13003. }
  13004. def_reduce_vars(AST_Node, noop);
  13005. function reset_def(compressor, def) {
  13006. def.assignments = 0;
  13007. def.chained = false;
  13008. def.direct_access = false;
  13009. def.escaped = 0;
  13010. def.recursive_refs = 0;
  13011. def.references = [];
  13012. def.single_use = undefined;
  13013. if (def.scope.pinned()) {
  13014. def.fixed = false;
  13015. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  13016. def.fixed = def.init;
  13017. } else {
  13018. def.fixed = false;
  13019. }
  13020. }
  13021. function reset_variables(tw, compressor, node) {
  13022. node.variables.forEach(function(def) {
  13023. reset_def(compressor, def);
  13024. if (def.fixed === null) {
  13025. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  13026. mark(tw, def, true);
  13027. } else if (def.fixed) {
  13028. tw.loop_ids.set(def.id, tw.in_loop);
  13029. mark(tw, def, true);
  13030. }
  13031. });
  13032. }
  13033. function reset_block_variables(compressor, node) {
  13034. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  13035. reset_def(compressor, def);
  13036. });
  13037. }
  13038. function push(tw) {
  13039. tw.safe_ids = Object.create(tw.safe_ids);
  13040. }
  13041. function pop(tw) {
  13042. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  13043. }
  13044. function mark(tw, def, safe) {
  13045. tw.safe_ids[def.id] = safe;
  13046. }
  13047. function safe_to_read(tw, def) {
  13048. if (def.single_use == "m") return false;
  13049. if (tw.safe_ids[def.id]) {
  13050. if (def.fixed == null) {
  13051. var orig = def.orig[0];
  13052. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  13053. def.fixed = make_node(AST_Undefined, orig);
  13054. }
  13055. return true;
  13056. }
  13057. return def.fixed instanceof AST_Defun;
  13058. }
  13059. function safe_to_assign(tw, def, scope, value) {
  13060. if (def.fixed === undefined) return true;
  13061. let def_safe_ids;
  13062. if (def.fixed === null
  13063. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  13064. ) {
  13065. def_safe_ids[def.id] = false;
  13066. tw.defs_to_safe_ids.delete(def.id);
  13067. return true;
  13068. }
  13069. if (!HOP(tw.safe_ids, def.id)) return false;
  13070. if (!safe_to_read(tw, def)) return false;
  13071. if (def.fixed === false) return false;
  13072. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  13073. if (def.fixed instanceof AST_Defun) {
  13074. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  13075. }
  13076. return def.orig.every((sym) => {
  13077. return !(sym instanceof AST_SymbolConst
  13078. || sym instanceof AST_SymbolDefun
  13079. || sym instanceof AST_SymbolLambda);
  13080. });
  13081. }
  13082. function ref_once(tw, compressor, def) {
  13083. return compressor.option("unused")
  13084. && !def.scope.pinned()
  13085. && def.references.length - def.recursive_refs == 1
  13086. && tw.loop_ids.get(def.id) === tw.in_loop;
  13087. }
  13088. function is_immutable(value) {
  13089. if (!value) return false;
  13090. return value.is_constant()
  13091. || value instanceof AST_Lambda
  13092. || value instanceof AST_This;
  13093. }
  13094. // A definition "escapes" when its value can leave the point of use.
  13095. // Example: `a = b || c`
  13096. // In this example, "b" and "c" are escaping, because they're going into "a"
  13097. //
  13098. // def.escaped is != 0 when it escapes.
  13099. //
  13100. // When greater than 1, it means that N chained properties will be read off
  13101. // of that def before an escape occurs. This is useful for evaluating
  13102. // property accesses, where you need to know when to stop.
  13103. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  13104. var parent = tw.parent(level);
  13105. if (value) {
  13106. if (value.is_constant()) return;
  13107. if (value instanceof AST_ClassExpression) return;
  13108. }
  13109. if (
  13110. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  13111. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  13112. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  13113. || parent instanceof AST_VarDef && node === parent.value
  13114. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  13115. ) {
  13116. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  13117. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  13118. return;
  13119. } else if (
  13120. parent instanceof AST_Array
  13121. || parent instanceof AST_Await
  13122. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  13123. || parent instanceof AST_Conditional && node !== parent.condition
  13124. || parent instanceof AST_Expansion
  13125. || parent instanceof AST_Sequence && node === parent.tail_node()
  13126. ) {
  13127. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  13128. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  13129. var obj = tw.parent(level + 1);
  13130. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  13131. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  13132. value = read_property(value, parent.property);
  13133. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  13134. if (value) return;
  13135. }
  13136. if (level > 0) return;
  13137. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  13138. if (parent instanceof AST_SimpleStatement) return;
  13139. d.direct_access = true;
  13140. }
  13141. const suppress = node => walk(node, node => {
  13142. if (!(node instanceof AST_Symbol)) return;
  13143. var d = node.definition();
  13144. if (!d) return;
  13145. if (node instanceof AST_SymbolRef) d.references.push(node);
  13146. d.fixed = false;
  13147. });
  13148. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  13149. push(tw);
  13150. reset_variables(tw, compressor, this);
  13151. descend();
  13152. pop(tw);
  13153. return true;
  13154. });
  13155. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  13156. var node = this;
  13157. if (node.left instanceof AST_Destructuring) {
  13158. suppress(node.left);
  13159. return;
  13160. }
  13161. const finish_walk = () => {
  13162. if (node.logical) {
  13163. node.left.walk(tw);
  13164. push(tw);
  13165. node.right.walk(tw);
  13166. pop(tw);
  13167. return true;
  13168. }
  13169. };
  13170. var sym = node.left;
  13171. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  13172. var def = sym.definition();
  13173. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  13174. def.assignments++;
  13175. if (!safe) return finish_walk();
  13176. var fixed = def.fixed;
  13177. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  13178. var eq = node.operator == "=";
  13179. var value = eq ? node.right : node;
  13180. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  13181. def.references.push(sym);
  13182. if (!node.logical) {
  13183. if (!eq) def.chained = true;
  13184. def.fixed = eq ? function() {
  13185. return node.right;
  13186. } : function() {
  13187. return make_node(AST_Binary, node, {
  13188. operator: node.operator.slice(0, -1),
  13189. left: fixed instanceof AST_Node ? fixed : fixed(),
  13190. right: node.right
  13191. });
  13192. };
  13193. }
  13194. if (node.logical) {
  13195. mark(tw, def, false);
  13196. push(tw);
  13197. node.right.walk(tw);
  13198. pop(tw);
  13199. return true;
  13200. }
  13201. mark(tw, def, false);
  13202. node.right.walk(tw);
  13203. mark(tw, def, true);
  13204. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  13205. return true;
  13206. });
  13207. def_reduce_vars(AST_Binary, function(tw) {
  13208. if (!lazy_op.has(this.operator)) return;
  13209. this.left.walk(tw);
  13210. push(tw);
  13211. this.right.walk(tw);
  13212. pop(tw);
  13213. return true;
  13214. });
  13215. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  13216. reset_block_variables(compressor, this);
  13217. });
  13218. def_reduce_vars(AST_Case, function(tw) {
  13219. push(tw);
  13220. this.expression.walk(tw);
  13221. pop(tw);
  13222. push(tw);
  13223. walk_body(this, tw);
  13224. pop(tw);
  13225. return true;
  13226. });
  13227. def_reduce_vars(AST_Class, function(tw, descend) {
  13228. clear_flag(this, INLINED);
  13229. push(tw);
  13230. descend();
  13231. pop(tw);
  13232. return true;
  13233. });
  13234. def_reduce_vars(AST_Conditional, function(tw) {
  13235. this.condition.walk(tw);
  13236. push(tw);
  13237. this.consequent.walk(tw);
  13238. pop(tw);
  13239. push(tw);
  13240. this.alternative.walk(tw);
  13241. pop(tw);
  13242. return true;
  13243. });
  13244. def_reduce_vars(AST_Chain, function(tw, descend) {
  13245. // Chains' conditions apply left-to-right, cumulatively.
  13246. // If we walk normally we don't go in that order because we would pop before pushing again
  13247. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  13248. // Then we pop everything when they are done being walked.
  13249. const safe_ids = tw.safe_ids;
  13250. descend();
  13251. // Unroll back to start
  13252. tw.safe_ids = safe_ids;
  13253. return true;
  13254. });
  13255. def_reduce_vars(AST_Call, function (tw) {
  13256. this.expression.walk(tw);
  13257. if (this.optional) {
  13258. // Never pop -- it's popped at AST_Chain above
  13259. push(tw);
  13260. }
  13261. for (const arg of this.args) arg.walk(tw);
  13262. return true;
  13263. });
  13264. def_reduce_vars(AST_PropAccess, function (tw) {
  13265. if (!this.optional) return;
  13266. this.expression.walk(tw);
  13267. // Never pop -- it's popped at AST_Chain above
  13268. push(tw);
  13269. if (this.property instanceof AST_Node) this.property.walk(tw);
  13270. return true;
  13271. });
  13272. def_reduce_vars(AST_Default, function(tw, descend) {
  13273. push(tw);
  13274. descend();
  13275. pop(tw);
  13276. return true;
  13277. });
  13278. function mark_lambda(tw, descend, compressor) {
  13279. clear_flag(this, INLINED);
  13280. push(tw);
  13281. reset_variables(tw, compressor, this);
  13282. if (this.uses_arguments) {
  13283. descend();
  13284. pop(tw);
  13285. return;
  13286. }
  13287. var iife;
  13288. if (!this.name
  13289. && (iife = tw.parent()) instanceof AST_Call
  13290. && iife.expression === this
  13291. && !iife.args.some(arg => arg instanceof AST_Expansion)
  13292. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  13293. ) {
  13294. // Virtually turn IIFE parameters into variable definitions:
  13295. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  13296. // So existing transformation rules can work on them.
  13297. this.argnames.forEach((arg, i) => {
  13298. if (!arg.definition) return;
  13299. var d = arg.definition();
  13300. // Avoid setting fixed when there's more than one origin for a variable value
  13301. if (d.orig.length > 1) return;
  13302. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  13303. d.fixed = function() {
  13304. return iife.args[i] || make_node(AST_Undefined, iife);
  13305. };
  13306. tw.loop_ids.set(d.id, tw.in_loop);
  13307. mark(tw, d, true);
  13308. } else {
  13309. d.fixed = false;
  13310. }
  13311. });
  13312. }
  13313. descend();
  13314. pop(tw);
  13315. return true;
  13316. }
  13317. def_reduce_vars(AST_Lambda, mark_lambda);
  13318. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  13319. reset_block_variables(compressor, this);
  13320. const saved_loop = tw.in_loop;
  13321. tw.in_loop = this;
  13322. push(tw);
  13323. this.body.walk(tw);
  13324. if (has_break_or_continue(this)) {
  13325. pop(tw);
  13326. push(tw);
  13327. }
  13328. this.condition.walk(tw);
  13329. pop(tw);
  13330. tw.in_loop = saved_loop;
  13331. return true;
  13332. });
  13333. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  13334. reset_block_variables(compressor, this);
  13335. if (this.init) this.init.walk(tw);
  13336. const saved_loop = tw.in_loop;
  13337. tw.in_loop = this;
  13338. push(tw);
  13339. if (this.condition) this.condition.walk(tw);
  13340. this.body.walk(tw);
  13341. if (this.step) {
  13342. if (has_break_or_continue(this)) {
  13343. pop(tw);
  13344. push(tw);
  13345. }
  13346. this.step.walk(tw);
  13347. }
  13348. pop(tw);
  13349. tw.in_loop = saved_loop;
  13350. return true;
  13351. });
  13352. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  13353. reset_block_variables(compressor, this);
  13354. suppress(this.init);
  13355. this.object.walk(tw);
  13356. const saved_loop = tw.in_loop;
  13357. tw.in_loop = this;
  13358. push(tw);
  13359. this.body.walk(tw);
  13360. pop(tw);
  13361. tw.in_loop = saved_loop;
  13362. return true;
  13363. });
  13364. def_reduce_vars(AST_If, function(tw) {
  13365. this.condition.walk(tw);
  13366. push(tw);
  13367. this.body.walk(tw);
  13368. pop(tw);
  13369. if (this.alternative) {
  13370. push(tw);
  13371. this.alternative.walk(tw);
  13372. pop(tw);
  13373. }
  13374. return true;
  13375. });
  13376. def_reduce_vars(AST_LabeledStatement, function(tw) {
  13377. push(tw);
  13378. this.body.walk(tw);
  13379. pop(tw);
  13380. return true;
  13381. });
  13382. def_reduce_vars(AST_SymbolCatch, function() {
  13383. this.definition().fixed = false;
  13384. });
  13385. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  13386. var d = this.definition();
  13387. d.references.push(this);
  13388. if (d.references.length == 1
  13389. && !d.fixed
  13390. && d.orig[0] instanceof AST_SymbolDefun) {
  13391. tw.loop_ids.set(d.id, tw.in_loop);
  13392. }
  13393. var fixed_value;
  13394. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  13395. d.fixed = false;
  13396. } else if (d.fixed) {
  13397. fixed_value = this.fixed_value();
  13398. if (
  13399. fixed_value instanceof AST_Lambda
  13400. && is_recursive_ref(tw, d)
  13401. ) {
  13402. d.recursive_refs++;
  13403. } else if (fixed_value
  13404. && !compressor.exposed(d)
  13405. && ref_once(tw, compressor, d)
  13406. ) {
  13407. d.single_use =
  13408. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  13409. || fixed_value instanceof AST_Class
  13410. || d.scope === this.scope && fixed_value.is_constant_expression();
  13411. } else {
  13412. d.single_use = false;
  13413. }
  13414. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  13415. if (d.single_use) {
  13416. d.single_use = "m";
  13417. } else {
  13418. d.fixed = false;
  13419. }
  13420. }
  13421. }
  13422. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  13423. });
  13424. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  13425. this.globals.forEach(function(def) {
  13426. reset_def(compressor, def);
  13427. });
  13428. reset_variables(tw, compressor, this);
  13429. });
  13430. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  13431. reset_block_variables(compressor, this);
  13432. push(tw);
  13433. walk_body(this, tw);
  13434. pop(tw);
  13435. if (this.bcatch) {
  13436. push(tw);
  13437. this.bcatch.walk(tw);
  13438. pop(tw);
  13439. }
  13440. if (this.bfinally) this.bfinally.walk(tw);
  13441. return true;
  13442. });
  13443. def_reduce_vars(AST_Unary, function(tw) {
  13444. var node = this;
  13445. if (node.operator !== "++" && node.operator !== "--") return;
  13446. var exp = node.expression;
  13447. if (!(exp instanceof AST_SymbolRef)) return;
  13448. var def = exp.definition();
  13449. var safe = safe_to_assign(tw, def, exp.scope, true);
  13450. def.assignments++;
  13451. if (!safe) return;
  13452. var fixed = def.fixed;
  13453. if (!fixed) return;
  13454. def.references.push(exp);
  13455. def.chained = true;
  13456. def.fixed = function() {
  13457. return make_node(AST_Binary, node, {
  13458. operator: node.operator.slice(0, -1),
  13459. left: make_node(AST_UnaryPrefix, node, {
  13460. operator: "+",
  13461. expression: fixed instanceof AST_Node ? fixed : fixed()
  13462. }),
  13463. right: make_node(AST_Number, node, {
  13464. value: 1
  13465. })
  13466. });
  13467. };
  13468. mark(tw, def, true);
  13469. return true;
  13470. });
  13471. def_reduce_vars(AST_VarDef, function(tw, descend) {
  13472. var node = this;
  13473. if (node.name instanceof AST_Destructuring) {
  13474. suppress(node.name);
  13475. return;
  13476. }
  13477. var d = node.name.definition();
  13478. if (node.value) {
  13479. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  13480. d.fixed = function() {
  13481. return node.value;
  13482. };
  13483. tw.loop_ids.set(d.id, tw.in_loop);
  13484. mark(tw, d, false);
  13485. descend();
  13486. mark(tw, d, true);
  13487. return true;
  13488. } else {
  13489. d.fixed = false;
  13490. }
  13491. }
  13492. });
  13493. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  13494. reset_block_variables(compressor, this);
  13495. const saved_loop = tw.in_loop;
  13496. tw.in_loop = this;
  13497. push(tw);
  13498. descend();
  13499. pop(tw);
  13500. tw.in_loop = saved_loop;
  13501. return true;
  13502. });
  13503. /***********************************************************************
  13504. A JavaScript tokenizer / parser / beautifier / compressor.
  13505. https://github.com/mishoo/UglifyJS2
  13506. -------------------------------- (C) ---------------------------------
  13507. Author: Mihai Bazon
  13508. <mihai.bazon@gmail.com>
  13509. http://mihai.bazon.net/blog
  13510. Distributed under the BSD license:
  13511. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13512. Redistribution and use in source and binary forms, with or without
  13513. modification, are permitted provided that the following conditions
  13514. are met:
  13515. * Redistributions of source code must retain the above
  13516. copyright notice, this list of conditions and the following
  13517. disclaimer.
  13518. * Redistributions in binary form must reproduce the above
  13519. copyright notice, this list of conditions and the following
  13520. disclaimer in the documentation and/or other materials
  13521. provided with the distribution.
  13522. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13523. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13524. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13525. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13526. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13527. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13528. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13529. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13530. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13531. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13532. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13533. SUCH DAMAGE.
  13534. ***********************************************************************/
  13535. function loop_body(x) {
  13536. if (x instanceof AST_IterationStatement) {
  13537. return x.body instanceof AST_BlockStatement ? x.body : x;
  13538. }
  13539. return x;
  13540. }
  13541. function is_lhs_read_only(lhs) {
  13542. if (lhs instanceof AST_This) return true;
  13543. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  13544. if (lhs instanceof AST_PropAccess) {
  13545. lhs = lhs.expression;
  13546. if (lhs instanceof AST_SymbolRef) {
  13547. if (lhs.is_immutable()) return false;
  13548. lhs = lhs.fixed_value();
  13549. }
  13550. if (!lhs) return true;
  13551. if (lhs instanceof AST_RegExp) return false;
  13552. if (lhs instanceof AST_Constant) return true;
  13553. return is_lhs_read_only(lhs);
  13554. }
  13555. return false;
  13556. }
  13557. // Remove code which we know is unreachable.
  13558. function trim_unreachable_code(compressor, stat, target) {
  13559. walk(stat, node => {
  13560. if (node instanceof AST_Var) {
  13561. node.remove_initializers();
  13562. target.push(node);
  13563. return true;
  13564. }
  13565. if (
  13566. node instanceof AST_Defun
  13567. && (node === stat || !compressor.has_directive("use strict"))
  13568. ) {
  13569. target.push(node === stat ? node : make_node(AST_Var, node, {
  13570. definitions: [
  13571. make_node(AST_VarDef, node, {
  13572. name: make_node(AST_SymbolVar, node.name, node.name),
  13573. value: null
  13574. })
  13575. ]
  13576. }));
  13577. return true;
  13578. }
  13579. if (node instanceof AST_Export || node instanceof AST_Import) {
  13580. target.push(node);
  13581. return true;
  13582. }
  13583. if (node instanceof AST_Scope) {
  13584. return true;
  13585. }
  13586. });
  13587. }
  13588. /** Tighten a bunch of statements together, and perform statement-level optimization. */
  13589. function tighten_body(statements, compressor) {
  13590. var in_loop, in_try;
  13591. var scope = compressor.find_parent(AST_Scope).get_defun_scope();
  13592. find_loop_scope_try();
  13593. var CHANGED, max_iter = 10;
  13594. do {
  13595. CHANGED = false;
  13596. eliminate_spurious_blocks(statements);
  13597. if (compressor.option("dead_code")) {
  13598. eliminate_dead_code(statements, compressor);
  13599. }
  13600. if (compressor.option("if_return")) {
  13601. handle_if_return(statements, compressor);
  13602. }
  13603. if (compressor.sequences_limit > 0) {
  13604. sequencesize(statements, compressor);
  13605. sequencesize_2(statements, compressor);
  13606. }
  13607. if (compressor.option("join_vars")) {
  13608. join_consecutive_vars(statements);
  13609. }
  13610. if (compressor.option("collapse_vars")) {
  13611. collapse(statements, compressor);
  13612. }
  13613. } while (CHANGED && max_iter-- > 0);
  13614. function find_loop_scope_try() {
  13615. var node = compressor.self(), level = 0;
  13616. do {
  13617. if (node instanceof AST_Catch || node instanceof AST_Finally) {
  13618. level++;
  13619. } else if (node instanceof AST_IterationStatement) {
  13620. in_loop = true;
  13621. } else if (node instanceof AST_Scope) {
  13622. scope = node;
  13623. break;
  13624. } else if (node instanceof AST_Try) {
  13625. in_try = true;
  13626. }
  13627. } while (node = compressor.parent(level++));
  13628. }
  13629. // Search from right to left for assignment-like expressions:
  13630. // - `var a = x;`
  13631. // - `a = x;`
  13632. // - `++a`
  13633. // For each candidate, scan from left to right for first usage, then try
  13634. // to fold assignment into the site for compression.
  13635. // Will not attempt to collapse assignments into or past code blocks
  13636. // which are not sequentially executed, e.g. loops and conditionals.
  13637. function collapse(statements, compressor) {
  13638. if (scope.pinned())
  13639. return statements;
  13640. var args;
  13641. var candidates = [];
  13642. var stat_index = statements.length;
  13643. var scanner = new TreeTransformer(function (node) {
  13644. if (abort)
  13645. return node;
  13646. // Skip nodes before `candidate` as quickly as possible
  13647. if (!hit) {
  13648. if (node !== hit_stack[hit_index])
  13649. return node;
  13650. hit_index++;
  13651. if (hit_index < hit_stack.length)
  13652. return handle_custom_scan_order(node);
  13653. hit = true;
  13654. stop_after = find_stop(node, 0);
  13655. if (stop_after === node)
  13656. abort = true;
  13657. return node;
  13658. }
  13659. // Stop immediately if these node types are encountered
  13660. var parent = scanner.parent();
  13661. if (node instanceof AST_Assign
  13662. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  13663. || node instanceof AST_Await
  13664. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  13665. || node instanceof AST_Debugger
  13666. || node instanceof AST_Destructuring
  13667. || node instanceof AST_Expansion
  13668. && node.expression instanceof AST_Symbol
  13669. && (
  13670. node.expression instanceof AST_This
  13671. || node.expression.definition().references.length > 1
  13672. )
  13673. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  13674. || node instanceof AST_LoopControl
  13675. || node instanceof AST_Try
  13676. || node instanceof AST_With
  13677. || node instanceof AST_Yield
  13678. || node instanceof AST_Export
  13679. || node instanceof AST_Class
  13680. || parent instanceof AST_For && node !== parent.init
  13681. || !replace_all
  13682. && (
  13683. node instanceof AST_SymbolRef
  13684. && !node.is_declared(compressor)
  13685. && !pure_prop_access_globals.has(node)
  13686. )
  13687. || node instanceof AST_SymbolRef
  13688. && parent instanceof AST_Call
  13689. && has_annotation(parent, _NOINLINE)
  13690. ) {
  13691. abort = true;
  13692. return node;
  13693. }
  13694. // Stop only if candidate is found within conditional branches
  13695. if (!stop_if_hit && (!lhs_local || !replace_all)
  13696. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  13697. || parent instanceof AST_Conditional && parent.condition !== node
  13698. || parent instanceof AST_If && parent.condition !== node)) {
  13699. stop_if_hit = parent;
  13700. }
  13701. // Replace variable with assignment when found
  13702. if (can_replace
  13703. && !(node instanceof AST_SymbolDeclaration)
  13704. && lhs.equivalent_to(node)
  13705. && !shadows(node.scope, lvalues)
  13706. ) {
  13707. if (stop_if_hit) {
  13708. abort = true;
  13709. return node;
  13710. }
  13711. if (is_lhs(node, parent)) {
  13712. if (value_def)
  13713. replaced++;
  13714. return node;
  13715. } else {
  13716. replaced++;
  13717. if (value_def && candidate instanceof AST_VarDef)
  13718. return node;
  13719. }
  13720. CHANGED = abort = true;
  13721. if (candidate instanceof AST_UnaryPostfix) {
  13722. return make_node(AST_UnaryPrefix, candidate, candidate);
  13723. }
  13724. if (candidate instanceof AST_VarDef) {
  13725. var def = candidate.name.definition();
  13726. var value = candidate.value;
  13727. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  13728. def.replaced++;
  13729. if (funarg && is_identifier_atom(value)) {
  13730. return value.transform(compressor);
  13731. } else {
  13732. return maintain_this_binding(parent, node, value);
  13733. }
  13734. }
  13735. return make_node(AST_Assign, candidate, {
  13736. operator: "=",
  13737. logical: false,
  13738. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  13739. right: value
  13740. });
  13741. }
  13742. clear_flag(candidate, WRITE_ONLY);
  13743. return candidate;
  13744. }
  13745. // These node types have child nodes that execute sequentially,
  13746. // but are otherwise not safe to scan into or beyond them.
  13747. var sym;
  13748. if (node instanceof AST_Call
  13749. || node instanceof AST_Exit
  13750. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  13751. || node instanceof AST_PropAccess
  13752. && (side_effects || node.expression.may_throw_on_access(compressor))
  13753. || node instanceof AST_SymbolRef
  13754. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  13755. || node instanceof AST_VarDef && node.value
  13756. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  13757. || (sym = is_lhs(node.left, node))
  13758. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  13759. || may_throw
  13760. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  13761. stop_after = node;
  13762. if (node instanceof AST_Scope)
  13763. abort = true;
  13764. }
  13765. return handle_custom_scan_order(node);
  13766. }, function (node) {
  13767. if (abort)
  13768. return;
  13769. if (stop_after === node)
  13770. abort = true;
  13771. if (stop_if_hit === node)
  13772. stop_if_hit = null;
  13773. });
  13774. var multi_replacer = new TreeTransformer(function (node) {
  13775. if (abort)
  13776. return node;
  13777. // Skip nodes before `candidate` as quickly as possible
  13778. if (!hit) {
  13779. if (node !== hit_stack[hit_index])
  13780. return node;
  13781. hit_index++;
  13782. if (hit_index < hit_stack.length)
  13783. return;
  13784. hit = true;
  13785. return node;
  13786. }
  13787. // Replace variable when found
  13788. if (node instanceof AST_SymbolRef
  13789. && node.name == def.name) {
  13790. if (!--replaced)
  13791. abort = true;
  13792. if (is_lhs(node, multi_replacer.parent()))
  13793. return node;
  13794. def.replaced++;
  13795. value_def.replaced--;
  13796. return candidate.value;
  13797. }
  13798. // Skip (non-executed) functions and (leading) default case in switch statements
  13799. if (node instanceof AST_Default || node instanceof AST_Scope)
  13800. return node;
  13801. });
  13802. while (--stat_index >= 0) {
  13803. // Treat parameters as collapsible in IIFE, i.e.
  13804. // function(a, b){ ... }(x());
  13805. // would be translated into equivalent assignments:
  13806. // var a = x(), b = undefined;
  13807. if (stat_index == 0 && compressor.option("unused"))
  13808. extract_args();
  13809. // Find collapsible assignments
  13810. var hit_stack = [];
  13811. extract_candidates(statements[stat_index]);
  13812. while (candidates.length > 0) {
  13813. hit_stack = candidates.pop();
  13814. var hit_index = 0;
  13815. var candidate = hit_stack[hit_stack.length - 1];
  13816. var value_def = null;
  13817. var stop_after = null;
  13818. var stop_if_hit = null;
  13819. var lhs = get_lhs(candidate);
  13820. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  13821. continue;
  13822. // Locate symbols which may execute code outside of scanning range
  13823. var lvalues = get_lvalues(candidate);
  13824. var lhs_local = is_lhs_local(lhs);
  13825. if (lhs instanceof AST_SymbolRef) {
  13826. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  13827. }
  13828. var side_effects = value_has_side_effects(candidate);
  13829. var replace_all = replace_all_symbols();
  13830. var may_throw = candidate.may_throw(compressor);
  13831. var funarg = candidate.name instanceof AST_SymbolFunarg;
  13832. var hit = funarg;
  13833. var abort = false, replaced = 0, can_replace = !args || !hit;
  13834. if (!can_replace) {
  13835. for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
  13836. args[j].transform(scanner);
  13837. }
  13838. can_replace = true;
  13839. }
  13840. for (var i = stat_index; !abort && i < statements.length; i++) {
  13841. statements[i].transform(scanner);
  13842. }
  13843. if (value_def) {
  13844. var def = candidate.name.definition();
  13845. if (abort && def.references.length - def.replaced > replaced)
  13846. replaced = false;
  13847. else {
  13848. abort = false;
  13849. hit_index = 0;
  13850. hit = funarg;
  13851. for (var i = stat_index; !abort && i < statements.length; i++) {
  13852. statements[i].transform(multi_replacer);
  13853. }
  13854. value_def.single_use = false;
  13855. }
  13856. }
  13857. if (replaced && !remove_candidate(candidate))
  13858. statements.splice(stat_index, 1);
  13859. }
  13860. }
  13861. function handle_custom_scan_order(node) {
  13862. // Skip (non-executed) functions
  13863. if (node instanceof AST_Scope)
  13864. return node;
  13865. // Scan case expressions first in a switch statement
  13866. if (node instanceof AST_Switch) {
  13867. node.expression = node.expression.transform(scanner);
  13868. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  13869. var branch = node.body[i];
  13870. if (branch instanceof AST_Case) {
  13871. if (!hit) {
  13872. if (branch !== hit_stack[hit_index])
  13873. continue;
  13874. hit_index++;
  13875. }
  13876. branch.expression = branch.expression.transform(scanner);
  13877. if (!replace_all)
  13878. break;
  13879. }
  13880. }
  13881. abort = true;
  13882. return node;
  13883. }
  13884. }
  13885. function redefined_within_scope(def, scope) {
  13886. if (def.global)
  13887. return false;
  13888. let cur_scope = def.scope;
  13889. while (cur_scope && cur_scope !== scope) {
  13890. if (cur_scope.variables.has(def.name)) {
  13891. return true;
  13892. }
  13893. cur_scope = cur_scope.parent_scope;
  13894. }
  13895. return false;
  13896. }
  13897. function has_overlapping_symbol(fn, arg, fn_strict) {
  13898. var found = false, scan_this = !(fn instanceof AST_Arrow);
  13899. arg.walk(new TreeWalker(function (node, descend) {
  13900. if (found)
  13901. return true;
  13902. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  13903. var s = node.definition().scope;
  13904. if (s !== scope)
  13905. while (s = s.parent_scope) {
  13906. if (s === scope)
  13907. return true;
  13908. }
  13909. return found = true;
  13910. }
  13911. if ((fn_strict || scan_this) && node instanceof AST_This) {
  13912. return found = true;
  13913. }
  13914. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  13915. var prev = scan_this;
  13916. scan_this = false;
  13917. descend();
  13918. scan_this = prev;
  13919. return true;
  13920. }
  13921. }));
  13922. return found;
  13923. }
  13924. function extract_args() {
  13925. var iife, fn = compressor.self();
  13926. if (is_func_expr(fn)
  13927. && !fn.name
  13928. && !fn.uses_arguments
  13929. && !fn.pinned()
  13930. && (iife = compressor.parent()) instanceof AST_Call
  13931. && iife.expression === fn
  13932. && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
  13933. var fn_strict = compressor.has_directive("use strict");
  13934. if (fn_strict && !member(fn_strict, fn.body))
  13935. fn_strict = false;
  13936. var len = fn.argnames.length;
  13937. args = iife.args.slice(len);
  13938. var names = new Set();
  13939. for (var i = len; --i >= 0;) {
  13940. var sym = fn.argnames[i];
  13941. var arg = iife.args[i];
  13942. // The following two line fix is a duplicate of the fix at
  13943. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  13944. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  13945. // Might be doing the exact same thing.
  13946. const def = sym.definition && sym.definition();
  13947. const is_reassigned = def && def.orig.length > 1;
  13948. if (is_reassigned)
  13949. continue;
  13950. args.unshift(make_node(AST_VarDef, sym, {
  13951. name: sym,
  13952. value: arg
  13953. }));
  13954. if (names.has(sym.name))
  13955. continue;
  13956. names.add(sym.name);
  13957. if (sym instanceof AST_Expansion) {
  13958. var elements = iife.args.slice(i);
  13959. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  13960. )) {
  13961. candidates.unshift([make_node(AST_VarDef, sym, {
  13962. name: sym.expression,
  13963. value: make_node(AST_Array, iife, {
  13964. elements: elements
  13965. })
  13966. })]);
  13967. }
  13968. } else {
  13969. if (!arg) {
  13970. arg = make_node(AST_Undefined, sym).transform(compressor);
  13971. } else if (arg instanceof AST_Lambda && arg.pinned()
  13972. || has_overlapping_symbol(fn, arg, fn_strict)) {
  13973. arg = null;
  13974. }
  13975. if (arg)
  13976. candidates.unshift([make_node(AST_VarDef, sym, {
  13977. name: sym,
  13978. value: arg
  13979. })]);
  13980. }
  13981. }
  13982. }
  13983. }
  13984. function extract_candidates(expr) {
  13985. hit_stack.push(expr);
  13986. if (expr instanceof AST_Assign) {
  13987. if (!expr.left.has_side_effects(compressor)
  13988. && !(expr.right instanceof AST_Chain)) {
  13989. candidates.push(hit_stack.slice());
  13990. }
  13991. extract_candidates(expr.right);
  13992. } else if (expr instanceof AST_Binary) {
  13993. extract_candidates(expr.left);
  13994. extract_candidates(expr.right);
  13995. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  13996. extract_candidates(expr.expression);
  13997. expr.args.forEach(extract_candidates);
  13998. } else if (expr instanceof AST_Case) {
  13999. extract_candidates(expr.expression);
  14000. } else if (expr instanceof AST_Conditional) {
  14001. extract_candidates(expr.condition);
  14002. extract_candidates(expr.consequent);
  14003. extract_candidates(expr.alternative);
  14004. } else if (expr instanceof AST_Definitions) {
  14005. var len = expr.definitions.length;
  14006. // limit number of trailing variable definitions for consideration
  14007. var i = len - 200;
  14008. if (i < 0)
  14009. i = 0;
  14010. for (; i < len; i++) {
  14011. extract_candidates(expr.definitions[i]);
  14012. }
  14013. } else if (expr instanceof AST_DWLoop) {
  14014. extract_candidates(expr.condition);
  14015. if (!(expr.body instanceof AST_Block)) {
  14016. extract_candidates(expr.body);
  14017. }
  14018. } else if (expr instanceof AST_Exit) {
  14019. if (expr.value)
  14020. extract_candidates(expr.value);
  14021. } else if (expr instanceof AST_For) {
  14022. if (expr.init)
  14023. extract_candidates(expr.init);
  14024. if (expr.condition)
  14025. extract_candidates(expr.condition);
  14026. if (expr.step)
  14027. extract_candidates(expr.step);
  14028. if (!(expr.body instanceof AST_Block)) {
  14029. extract_candidates(expr.body);
  14030. }
  14031. } else if (expr instanceof AST_ForIn) {
  14032. extract_candidates(expr.object);
  14033. if (!(expr.body instanceof AST_Block)) {
  14034. extract_candidates(expr.body);
  14035. }
  14036. } else if (expr instanceof AST_If) {
  14037. extract_candidates(expr.condition);
  14038. if (!(expr.body instanceof AST_Block)) {
  14039. extract_candidates(expr.body);
  14040. }
  14041. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  14042. extract_candidates(expr.alternative);
  14043. }
  14044. } else if (expr instanceof AST_Sequence) {
  14045. expr.expressions.forEach(extract_candidates);
  14046. } else if (expr instanceof AST_SimpleStatement) {
  14047. extract_candidates(expr.body);
  14048. } else if (expr instanceof AST_Switch) {
  14049. extract_candidates(expr.expression);
  14050. expr.body.forEach(extract_candidates);
  14051. } else if (expr instanceof AST_Unary) {
  14052. if (expr.operator == "++" || expr.operator == "--") {
  14053. candidates.push(hit_stack.slice());
  14054. }
  14055. } else if (expr instanceof AST_VarDef) {
  14056. if (expr.value && !(expr.value instanceof AST_Chain)) {
  14057. candidates.push(hit_stack.slice());
  14058. extract_candidates(expr.value);
  14059. }
  14060. }
  14061. hit_stack.pop();
  14062. }
  14063. function find_stop(node, level, write_only) {
  14064. var parent = scanner.parent(level);
  14065. if (parent instanceof AST_Assign) {
  14066. if (write_only
  14067. && !parent.logical
  14068. && !(parent.left instanceof AST_PropAccess
  14069. || lvalues.has(parent.left.name))) {
  14070. return find_stop(parent, level + 1, write_only);
  14071. }
  14072. return node;
  14073. }
  14074. if (parent instanceof AST_Binary) {
  14075. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  14076. return find_stop(parent, level + 1, write_only);
  14077. }
  14078. return node;
  14079. }
  14080. if (parent instanceof AST_Call)
  14081. return node;
  14082. if (parent instanceof AST_Case)
  14083. return node;
  14084. if (parent instanceof AST_Conditional) {
  14085. if (write_only && parent.condition === node) {
  14086. return find_stop(parent, level + 1, write_only);
  14087. }
  14088. return node;
  14089. }
  14090. if (parent instanceof AST_Definitions) {
  14091. return find_stop(parent, level + 1, true);
  14092. }
  14093. if (parent instanceof AST_Exit) {
  14094. return write_only ? find_stop(parent, level + 1, write_only) : node;
  14095. }
  14096. if (parent instanceof AST_If) {
  14097. if (write_only && parent.condition === node) {
  14098. return find_stop(parent, level + 1, write_only);
  14099. }
  14100. return node;
  14101. }
  14102. if (parent instanceof AST_IterationStatement)
  14103. return node;
  14104. if (parent instanceof AST_Sequence) {
  14105. return find_stop(parent, level + 1, parent.tail_node() !== node);
  14106. }
  14107. if (parent instanceof AST_SimpleStatement) {
  14108. return find_stop(parent, level + 1, true);
  14109. }
  14110. if (parent instanceof AST_Switch)
  14111. return node;
  14112. if (parent instanceof AST_VarDef)
  14113. return node;
  14114. return null;
  14115. }
  14116. function mangleable_var(var_def) {
  14117. var value = var_def.value;
  14118. if (!(value instanceof AST_SymbolRef))
  14119. return;
  14120. if (value.name == "arguments")
  14121. return;
  14122. var def = value.definition();
  14123. if (def.undeclared)
  14124. return;
  14125. return value_def = def;
  14126. }
  14127. function get_lhs(expr) {
  14128. if (expr instanceof AST_Assign && expr.logical) {
  14129. return false;
  14130. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  14131. var def = expr.name.definition();
  14132. if (!member(expr.name, def.orig))
  14133. return;
  14134. var referenced = def.references.length - def.replaced;
  14135. if (!referenced)
  14136. return;
  14137. var declared = def.orig.length - def.eliminated;
  14138. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  14139. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  14140. return make_node(AST_SymbolRef, expr.name, expr.name);
  14141. }
  14142. } else {
  14143. const lhs = expr instanceof AST_Assign
  14144. ? expr.left
  14145. : expr.expression;
  14146. return !is_ref_of(lhs, AST_SymbolConst)
  14147. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  14148. }
  14149. }
  14150. function get_rvalue(expr) {
  14151. if (expr instanceof AST_Assign) {
  14152. return expr.right;
  14153. } else {
  14154. return expr.value;
  14155. }
  14156. }
  14157. function get_lvalues(expr) {
  14158. var lvalues = new Map();
  14159. if (expr instanceof AST_Unary)
  14160. return lvalues;
  14161. var tw = new TreeWalker(function (node) {
  14162. var sym = node;
  14163. while (sym instanceof AST_PropAccess)
  14164. sym = sym.expression;
  14165. if (sym instanceof AST_SymbolRef) {
  14166. const prev = lvalues.get(sym.name);
  14167. if (!prev || !prev.modified) {
  14168. lvalues.set(sym.name, {
  14169. def: sym.definition(),
  14170. modified: is_modified(compressor, tw, node, node, 0)
  14171. });
  14172. }
  14173. }
  14174. });
  14175. get_rvalue(expr).walk(tw);
  14176. return lvalues;
  14177. }
  14178. function remove_candidate(expr) {
  14179. if (expr.name instanceof AST_SymbolFunarg) {
  14180. var iife = compressor.parent(), argnames = compressor.self().argnames;
  14181. var index = argnames.indexOf(expr.name);
  14182. if (index < 0) {
  14183. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  14184. } else {
  14185. var args = iife.args;
  14186. if (args[index])
  14187. args[index] = make_node(AST_Number, args[index], {
  14188. value: 0
  14189. });
  14190. }
  14191. return true;
  14192. }
  14193. var found = false;
  14194. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  14195. if (found)
  14196. return node;
  14197. if (node === expr || node.body === expr) {
  14198. found = true;
  14199. if (node instanceof AST_VarDef) {
  14200. node.value = node.name instanceof AST_SymbolConst
  14201. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  14202. : null;
  14203. return node;
  14204. }
  14205. return in_list ? MAP.skip : null;
  14206. }
  14207. }, function (node) {
  14208. if (node instanceof AST_Sequence)
  14209. switch (node.expressions.length) {
  14210. case 0: return null;
  14211. case 1: return node.expressions[0];
  14212. }
  14213. }));
  14214. }
  14215. function is_lhs_local(lhs) {
  14216. while (lhs instanceof AST_PropAccess)
  14217. lhs = lhs.expression;
  14218. return lhs instanceof AST_SymbolRef
  14219. && lhs.definition().scope === scope
  14220. && !(in_loop
  14221. && (lvalues.has(lhs.name)
  14222. || candidate instanceof AST_Unary
  14223. || (candidate instanceof AST_Assign
  14224. && !candidate.logical
  14225. && candidate.operator != "=")));
  14226. }
  14227. function value_has_side_effects(expr) {
  14228. if (expr instanceof AST_Unary)
  14229. return unary_side_effects.has(expr.operator);
  14230. return get_rvalue(expr).has_side_effects(compressor);
  14231. }
  14232. function replace_all_symbols() {
  14233. if (side_effects)
  14234. return false;
  14235. if (value_def)
  14236. return true;
  14237. if (lhs instanceof AST_SymbolRef) {
  14238. var def = lhs.definition();
  14239. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  14240. return true;
  14241. }
  14242. }
  14243. return false;
  14244. }
  14245. function may_modify(sym) {
  14246. if (!sym.definition)
  14247. return true; // AST_Destructuring
  14248. var def = sym.definition();
  14249. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  14250. return false;
  14251. if (def.scope.get_defun_scope() !== scope)
  14252. return true;
  14253. return !def.references.every((ref) => {
  14254. var s = ref.scope.get_defun_scope();
  14255. // "block" scope within AST_Catch
  14256. if (s.TYPE == "Scope")
  14257. s = s.parent_scope;
  14258. return s === scope;
  14259. });
  14260. }
  14261. function side_effects_external(node, lhs) {
  14262. if (node instanceof AST_Assign)
  14263. return side_effects_external(node.left, true);
  14264. if (node instanceof AST_Unary)
  14265. return side_effects_external(node.expression, true);
  14266. if (node instanceof AST_VarDef)
  14267. return node.value && side_effects_external(node.value);
  14268. if (lhs) {
  14269. if (node instanceof AST_Dot)
  14270. return side_effects_external(node.expression, true);
  14271. if (node instanceof AST_Sub)
  14272. return side_effects_external(node.expression, true);
  14273. if (node instanceof AST_SymbolRef)
  14274. return node.definition().scope !== scope;
  14275. }
  14276. return false;
  14277. }
  14278. function shadows(newScope, lvalues) {
  14279. for (const {def} of lvalues.values()) {
  14280. let current = newScope;
  14281. while (current && current !== def.scope) {
  14282. let nested_def = current.variables.get(def.name);
  14283. if (nested_def && nested_def !== def) return true;
  14284. current = current.parent_scope;
  14285. }
  14286. }
  14287. return false;
  14288. }
  14289. }
  14290. function eliminate_spurious_blocks(statements) {
  14291. var seen_dirs = [];
  14292. for (var i = 0; i < statements.length;) {
  14293. var stat = statements[i];
  14294. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  14295. CHANGED = true;
  14296. eliminate_spurious_blocks(stat.body);
  14297. statements.splice(i, 1, ...stat.body);
  14298. i += stat.body.length;
  14299. } else if (stat instanceof AST_EmptyStatement) {
  14300. CHANGED = true;
  14301. statements.splice(i, 1);
  14302. } else if (stat instanceof AST_Directive) {
  14303. if (seen_dirs.indexOf(stat.value) < 0) {
  14304. i++;
  14305. seen_dirs.push(stat.value);
  14306. } else {
  14307. CHANGED = true;
  14308. statements.splice(i, 1);
  14309. }
  14310. } else
  14311. i++;
  14312. }
  14313. }
  14314. function handle_if_return(statements, compressor) {
  14315. var self = compressor.self();
  14316. var multiple_if_returns = has_multiple_if_returns(statements);
  14317. var in_lambda = self instanceof AST_Lambda;
  14318. for (var i = statements.length; --i >= 0;) {
  14319. var stat = statements[i];
  14320. var j = next_index(i);
  14321. var next = statements[j];
  14322. if (in_lambda && !next && stat instanceof AST_Return) {
  14323. if (!stat.value) {
  14324. CHANGED = true;
  14325. statements.splice(i, 1);
  14326. continue;
  14327. }
  14328. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  14329. CHANGED = true;
  14330. statements[i] = make_node(AST_SimpleStatement, stat, {
  14331. body: stat.value.expression
  14332. });
  14333. continue;
  14334. }
  14335. }
  14336. if (stat instanceof AST_If) {
  14337. var ab = aborts(stat.body);
  14338. if (can_merge_flow(ab)) {
  14339. if (ab.label) {
  14340. remove(ab.label.thedef.references, ab);
  14341. }
  14342. CHANGED = true;
  14343. stat = stat.clone();
  14344. stat.condition = stat.condition.negate(compressor);
  14345. var body = as_statement_array_with_return(stat.body, ab);
  14346. stat.body = make_node(AST_BlockStatement, stat, {
  14347. body: as_statement_array(stat.alternative).concat(extract_functions())
  14348. });
  14349. stat.alternative = make_node(AST_BlockStatement, stat, {
  14350. body: body
  14351. });
  14352. statements[i] = stat.transform(compressor);
  14353. continue;
  14354. }
  14355. var ab = aborts(stat.alternative);
  14356. if (can_merge_flow(ab)) {
  14357. if (ab.label) {
  14358. remove(ab.label.thedef.references, ab);
  14359. }
  14360. CHANGED = true;
  14361. stat = stat.clone();
  14362. stat.body = make_node(AST_BlockStatement, stat.body, {
  14363. body: as_statement_array(stat.body).concat(extract_functions())
  14364. });
  14365. var body = as_statement_array_with_return(stat.alternative, ab);
  14366. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  14367. body: body
  14368. });
  14369. statements[i] = stat.transform(compressor);
  14370. continue;
  14371. }
  14372. }
  14373. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  14374. var value = stat.body.value;
  14375. //---
  14376. // pretty silly case, but:
  14377. // if (foo()) return; return; ==> foo(); return;
  14378. if (!value && !stat.alternative
  14379. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  14380. CHANGED = true;
  14381. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  14382. body: stat.condition
  14383. });
  14384. continue;
  14385. }
  14386. //---
  14387. // if (foo()) return x; return y; ==> return foo() ? x : y;
  14388. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  14389. CHANGED = true;
  14390. stat = stat.clone();
  14391. stat.alternative = next;
  14392. statements[i] = stat.transform(compressor);
  14393. statements.splice(j, 1);
  14394. continue;
  14395. }
  14396. //---
  14397. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  14398. if (value && !stat.alternative
  14399. && (!next && in_lambda && multiple_if_returns
  14400. || next instanceof AST_Return)) {
  14401. CHANGED = true;
  14402. stat = stat.clone();
  14403. stat.alternative = next || make_node(AST_Return, stat, {
  14404. value: null
  14405. });
  14406. statements[i] = stat.transform(compressor);
  14407. if (next)
  14408. statements.splice(j, 1);
  14409. continue;
  14410. }
  14411. //---
  14412. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  14413. //
  14414. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  14415. // however, with sequences on this helps producing slightly better output for
  14416. // the example code.
  14417. var prev = statements[prev_index(i)];
  14418. if (compressor.option("sequences") && in_lambda && !stat.alternative
  14419. && prev instanceof AST_If && prev.body instanceof AST_Return
  14420. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  14421. CHANGED = true;
  14422. stat = stat.clone();
  14423. stat.alternative = make_node(AST_BlockStatement, next, {
  14424. body: [
  14425. next,
  14426. make_node(AST_Return, next, {
  14427. value: null
  14428. })
  14429. ]
  14430. });
  14431. statements[i] = stat.transform(compressor);
  14432. statements.splice(j, 1);
  14433. continue;
  14434. }
  14435. }
  14436. }
  14437. function has_multiple_if_returns(statements) {
  14438. var n = 0;
  14439. for (var i = statements.length; --i >= 0;) {
  14440. var stat = statements[i];
  14441. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  14442. if (++n > 1)
  14443. return true;
  14444. }
  14445. }
  14446. return false;
  14447. }
  14448. function is_return_void(value) {
  14449. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  14450. }
  14451. function can_merge_flow(ab) {
  14452. if (!ab)
  14453. return false;
  14454. for (var j = i + 1, len = statements.length; j < len; j++) {
  14455. var stat = statements[j];
  14456. if (stat instanceof AST_Const || stat instanceof AST_Let)
  14457. return false;
  14458. }
  14459. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  14460. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  14461. || ab instanceof AST_Continue && self === loop_body(lct)
  14462. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  14463. }
  14464. function extract_functions() {
  14465. var tail = statements.slice(i + 1);
  14466. statements.length = i + 1;
  14467. return tail.filter(function (stat) {
  14468. if (stat instanceof AST_Defun) {
  14469. statements.push(stat);
  14470. return false;
  14471. }
  14472. return true;
  14473. });
  14474. }
  14475. function as_statement_array_with_return(node, ab) {
  14476. var body = as_statement_array(node).slice(0, -1);
  14477. if (ab.value) {
  14478. body.push(make_node(AST_SimpleStatement, ab.value, {
  14479. body: ab.value.expression
  14480. }));
  14481. }
  14482. return body;
  14483. }
  14484. function next_index(i) {
  14485. for (var j = i + 1, len = statements.length; j < len; j++) {
  14486. var stat = statements[j];
  14487. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  14488. break;
  14489. }
  14490. }
  14491. return j;
  14492. }
  14493. function prev_index(i) {
  14494. for (var j = i; --j >= 0;) {
  14495. var stat = statements[j];
  14496. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  14497. break;
  14498. }
  14499. }
  14500. return j;
  14501. }
  14502. }
  14503. function eliminate_dead_code(statements, compressor) {
  14504. var has_quit;
  14505. var self = compressor.self();
  14506. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  14507. var stat = statements[i];
  14508. if (stat instanceof AST_LoopControl) {
  14509. var lct = compressor.loopcontrol_target(stat);
  14510. if (stat instanceof AST_Break
  14511. && !(lct instanceof AST_IterationStatement)
  14512. && loop_body(lct) === self
  14513. || stat instanceof AST_Continue
  14514. && loop_body(lct) === self) {
  14515. if (stat.label) {
  14516. remove(stat.label.thedef.references, stat);
  14517. }
  14518. } else {
  14519. statements[n++] = stat;
  14520. }
  14521. } else {
  14522. statements[n++] = stat;
  14523. }
  14524. if (aborts(stat)) {
  14525. has_quit = statements.slice(i + 1);
  14526. break;
  14527. }
  14528. }
  14529. statements.length = n;
  14530. CHANGED = n != len;
  14531. if (has_quit)
  14532. has_quit.forEach(function (stat) {
  14533. trim_unreachable_code(compressor, stat, statements);
  14534. });
  14535. }
  14536. function declarations_only(node) {
  14537. return node.definitions.every((var_def) => !var_def.value
  14538. );
  14539. }
  14540. function sequencesize(statements, compressor) {
  14541. if (statements.length < 2)
  14542. return;
  14543. var seq = [], n = 0;
  14544. function push_seq() {
  14545. if (!seq.length)
  14546. return;
  14547. var body = make_sequence(seq[0], seq);
  14548. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  14549. seq = [];
  14550. }
  14551. for (var i = 0, len = statements.length; i < len; i++) {
  14552. var stat = statements[i];
  14553. if (stat instanceof AST_SimpleStatement) {
  14554. if (seq.length >= compressor.sequences_limit)
  14555. push_seq();
  14556. var body = stat.body;
  14557. if (seq.length > 0)
  14558. body = body.drop_side_effect_free(compressor);
  14559. if (body)
  14560. merge_sequence(seq, body);
  14561. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  14562. || stat instanceof AST_Defun) {
  14563. statements[n++] = stat;
  14564. } else {
  14565. push_seq();
  14566. statements[n++] = stat;
  14567. }
  14568. }
  14569. push_seq();
  14570. statements.length = n;
  14571. if (n != len)
  14572. CHANGED = true;
  14573. }
  14574. function to_simple_statement(block, decls) {
  14575. if (!(block instanceof AST_BlockStatement))
  14576. return block;
  14577. var stat = null;
  14578. for (var i = 0, len = block.body.length; i < len; i++) {
  14579. var line = block.body[i];
  14580. if (line instanceof AST_Var && declarations_only(line)) {
  14581. decls.push(line);
  14582. } else if (stat) {
  14583. return false;
  14584. } else {
  14585. stat = line;
  14586. }
  14587. }
  14588. return stat;
  14589. }
  14590. function sequencesize_2(statements, compressor) {
  14591. function cons_seq(right) {
  14592. n--;
  14593. CHANGED = true;
  14594. var left = prev.body;
  14595. return make_sequence(left, [left, right]).transform(compressor);
  14596. }
  14597. var n = 0, prev;
  14598. for (var i = 0; i < statements.length; i++) {
  14599. var stat = statements[i];
  14600. if (prev) {
  14601. if (stat instanceof AST_Exit) {
  14602. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  14603. } else if (stat instanceof AST_For) {
  14604. if (!(stat.init instanceof AST_Definitions)) {
  14605. const abort = walk(prev.body, node => {
  14606. if (node instanceof AST_Scope)
  14607. return true;
  14608. if (node instanceof AST_Binary
  14609. && node.operator === "in") {
  14610. return walk_abort;
  14611. }
  14612. });
  14613. if (!abort) {
  14614. if (stat.init)
  14615. stat.init = cons_seq(stat.init);
  14616. else {
  14617. stat.init = prev.body;
  14618. n--;
  14619. CHANGED = true;
  14620. }
  14621. }
  14622. }
  14623. } else if (stat instanceof AST_ForIn) {
  14624. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  14625. stat.object = cons_seq(stat.object);
  14626. }
  14627. } else if (stat instanceof AST_If) {
  14628. stat.condition = cons_seq(stat.condition);
  14629. } else if (stat instanceof AST_Switch) {
  14630. stat.expression = cons_seq(stat.expression);
  14631. } else if (stat instanceof AST_With) {
  14632. stat.expression = cons_seq(stat.expression);
  14633. }
  14634. }
  14635. if (compressor.option("conditionals") && stat instanceof AST_If) {
  14636. var decls = [];
  14637. var body = to_simple_statement(stat.body, decls);
  14638. var alt = to_simple_statement(stat.alternative, decls);
  14639. if (body !== false && alt !== false && decls.length > 0) {
  14640. var len = decls.length;
  14641. decls.push(make_node(AST_If, stat, {
  14642. condition: stat.condition,
  14643. body: body || make_node(AST_EmptyStatement, stat.body),
  14644. alternative: alt
  14645. }));
  14646. decls.unshift(n, 1);
  14647. [].splice.apply(statements, decls);
  14648. i += len;
  14649. n += len + 1;
  14650. prev = null;
  14651. CHANGED = true;
  14652. continue;
  14653. }
  14654. }
  14655. statements[n++] = stat;
  14656. prev = stat instanceof AST_SimpleStatement ? stat : null;
  14657. }
  14658. statements.length = n;
  14659. }
  14660. function join_object_assignments(defn, body) {
  14661. if (!(defn instanceof AST_Definitions))
  14662. return;
  14663. var def = defn.definitions[defn.definitions.length - 1];
  14664. if (!(def.value instanceof AST_Object))
  14665. return;
  14666. var exprs;
  14667. if (body instanceof AST_Assign && !body.logical) {
  14668. exprs = [body];
  14669. } else if (body instanceof AST_Sequence) {
  14670. exprs = body.expressions.slice();
  14671. }
  14672. if (!exprs)
  14673. return;
  14674. var trimmed = false;
  14675. do {
  14676. var node = exprs[0];
  14677. if (!(node instanceof AST_Assign))
  14678. break;
  14679. if (node.operator != "=")
  14680. break;
  14681. if (!(node.left instanceof AST_PropAccess))
  14682. break;
  14683. var sym = node.left.expression;
  14684. if (!(sym instanceof AST_SymbolRef))
  14685. break;
  14686. if (def.name.name != sym.name)
  14687. break;
  14688. if (!node.right.is_constant_expression(scope))
  14689. break;
  14690. var prop = node.left.property;
  14691. if (prop instanceof AST_Node) {
  14692. prop = prop.evaluate(compressor);
  14693. }
  14694. if (prop instanceof AST_Node)
  14695. break;
  14696. prop = "" + prop;
  14697. var diff = compressor.option("ecma") < 2015
  14698. && compressor.has_directive("use strict") ? function (node) {
  14699. return node.key != prop && (node.key && node.key.name != prop);
  14700. } : function (node) {
  14701. return node.key && node.key.name != prop;
  14702. };
  14703. if (!def.value.properties.every(diff))
  14704. break;
  14705. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  14706. if (!p) {
  14707. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  14708. key: prop,
  14709. value: node.right
  14710. }));
  14711. } else {
  14712. p.value = new AST_Sequence({
  14713. start: p.start,
  14714. expressions: [p.value.clone(), node.right.clone()],
  14715. end: p.end
  14716. });
  14717. }
  14718. exprs.shift();
  14719. trimmed = true;
  14720. } while (exprs.length);
  14721. return trimmed && exprs;
  14722. }
  14723. function join_consecutive_vars(statements) {
  14724. var defs;
  14725. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  14726. var stat = statements[i];
  14727. var prev = statements[j];
  14728. if (stat instanceof AST_Definitions) {
  14729. if (prev && prev.TYPE == stat.TYPE) {
  14730. prev.definitions = prev.definitions.concat(stat.definitions);
  14731. CHANGED = true;
  14732. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  14733. defs.definitions = defs.definitions.concat(stat.definitions);
  14734. CHANGED = true;
  14735. } else {
  14736. statements[++j] = stat;
  14737. defs = stat;
  14738. }
  14739. } else if (stat instanceof AST_Exit) {
  14740. stat.value = extract_object_assignments(stat.value);
  14741. } else if (stat instanceof AST_For) {
  14742. var exprs = join_object_assignments(prev, stat.init);
  14743. if (exprs) {
  14744. CHANGED = true;
  14745. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  14746. statements[++j] = stat;
  14747. } else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  14748. if (stat.init) {
  14749. prev.definitions = prev.definitions.concat(stat.init.definitions);
  14750. }
  14751. stat.init = prev;
  14752. statements[j] = stat;
  14753. CHANGED = true;
  14754. } else if (defs && stat.init && defs.TYPE == stat.init.TYPE && declarations_only(stat.init)) {
  14755. defs.definitions = defs.definitions.concat(stat.init.definitions);
  14756. stat.init = null;
  14757. statements[++j] = stat;
  14758. CHANGED = true;
  14759. } else {
  14760. statements[++j] = stat;
  14761. }
  14762. } else if (stat instanceof AST_ForIn) {
  14763. stat.object = extract_object_assignments(stat.object);
  14764. } else if (stat instanceof AST_If) {
  14765. stat.condition = extract_object_assignments(stat.condition);
  14766. } else if (stat instanceof AST_SimpleStatement) {
  14767. var exprs = join_object_assignments(prev, stat.body);
  14768. if (exprs) {
  14769. CHANGED = true;
  14770. if (!exprs.length)
  14771. continue;
  14772. stat.body = make_sequence(stat.body, exprs);
  14773. }
  14774. statements[++j] = stat;
  14775. } else if (stat instanceof AST_Switch) {
  14776. stat.expression = extract_object_assignments(stat.expression);
  14777. } else if (stat instanceof AST_With) {
  14778. stat.expression = extract_object_assignments(stat.expression);
  14779. } else {
  14780. statements[++j] = stat;
  14781. }
  14782. }
  14783. statements.length = j + 1;
  14784. function extract_object_assignments(value) {
  14785. statements[++j] = stat;
  14786. var exprs = join_object_assignments(prev, value);
  14787. if (exprs) {
  14788. CHANGED = true;
  14789. if (exprs.length) {
  14790. return make_sequence(value, exprs);
  14791. } else if (value instanceof AST_Sequence) {
  14792. return value.tail_node().left;
  14793. } else {
  14794. return value.left;
  14795. }
  14796. }
  14797. return value;
  14798. }
  14799. }
  14800. }
  14801. /***********************************************************************
  14802. A JavaScript tokenizer / parser / beautifier / compressor.
  14803. https://github.com/mishoo/UglifyJS2
  14804. -------------------------------- (C) ---------------------------------
  14805. Author: Mihai Bazon
  14806. <mihai.bazon@gmail.com>
  14807. http://mihai.bazon.net/blog
  14808. Distributed under the BSD license:
  14809. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  14810. Redistribution and use in source and binary forms, with or without
  14811. modification, are permitted provided that the following conditions
  14812. are met:
  14813. * Redistributions of source code must retain the above
  14814. copyright notice, this list of conditions and the following
  14815. disclaimer.
  14816. * Redistributions in binary form must reproduce the above
  14817. copyright notice, this list of conditions and the following
  14818. disclaimer in the documentation and/or other materials
  14819. provided with the distribution.
  14820. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  14821. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14822. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  14823. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  14824. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  14825. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  14826. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14827. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14828. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  14829. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  14830. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14831. SUCH DAMAGE.
  14832. ***********************************************************************/
  14833. function within_array_or_object_literal(compressor) {
  14834. var node, level = 0;
  14835. while (node = compressor.parent(level++)) {
  14836. if (node instanceof AST_Statement) return false;
  14837. if (node instanceof AST_Array
  14838. || node instanceof AST_ObjectKeyVal
  14839. || node instanceof AST_Object) {
  14840. return true;
  14841. }
  14842. }
  14843. return false;
  14844. }
  14845. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  14846. for (const enclosed of pulled_scope.enclosed) {
  14847. if (pulled_scope.variables.has(enclosed.name)) {
  14848. continue;
  14849. }
  14850. const looked_up = scope.find_variable(enclosed.name);
  14851. if (looked_up) {
  14852. if (looked_up === enclosed) continue;
  14853. return true;
  14854. }
  14855. }
  14856. return false;
  14857. }
  14858. function inline_into_symbolref(self, compressor) {
  14859. if (
  14860. !compressor.option("ie8")
  14861. && is_undeclared_ref(self)
  14862. && !compressor.find_parent(AST_With)
  14863. ) {
  14864. switch (self.name) {
  14865. case "undefined":
  14866. return make_node(AST_Undefined, self).optimize(compressor);
  14867. case "NaN":
  14868. return make_node(AST_NaN, self).optimize(compressor);
  14869. case "Infinity":
  14870. return make_node(AST_Infinity, self).optimize(compressor);
  14871. }
  14872. }
  14873. const parent = compressor.parent();
  14874. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  14875. const def = self.definition();
  14876. const nearest_scope = compressor.find_scope();
  14877. if (compressor.top_retain && def.global && compressor.top_retain(def)) {
  14878. def.fixed = false;
  14879. def.single_use = false;
  14880. return self;
  14881. }
  14882. let fixed = self.fixed_value();
  14883. let single_use = def.single_use
  14884. && !(parent instanceof AST_Call
  14885. && (parent.is_callee_pure(compressor))
  14886. || has_annotation(parent, _NOINLINE))
  14887. && !(parent instanceof AST_Export
  14888. && fixed instanceof AST_Lambda
  14889. && fixed.name);
  14890. if (single_use && fixed instanceof AST_Node) {
  14891. single_use =
  14892. !fixed.has_side_effects(compressor)
  14893. && !fixed.may_throw(compressor);
  14894. }
  14895. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  14896. if (retain_top_func(fixed, compressor)) {
  14897. single_use = false;
  14898. } else if (def.scope !== self.scope
  14899. && (def.escaped == 1
  14900. || has_flag(fixed, INLINED)
  14901. || within_array_or_object_literal(compressor)
  14902. || !compressor.option("reduce_funcs"))) {
  14903. single_use = false;
  14904. } else if (is_recursive_ref(compressor, def)) {
  14905. single_use = false;
  14906. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  14907. single_use = fixed.is_constant_expression(self.scope);
  14908. if (single_use == "f") {
  14909. var scope = self.scope;
  14910. do {
  14911. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  14912. set_flag(scope, INLINED);
  14913. }
  14914. } while (scope = scope.parent_scope);
  14915. }
  14916. }
  14917. }
  14918. if (single_use && fixed instanceof AST_Lambda) {
  14919. single_use =
  14920. def.scope === self.scope
  14921. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  14922. || parent instanceof AST_Call
  14923. && parent.expression === self
  14924. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  14925. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  14926. }
  14927. if (single_use && fixed) {
  14928. if (fixed instanceof AST_DefClass) {
  14929. set_flag(fixed, SQUEEZED);
  14930. fixed = make_node(AST_ClassExpression, fixed, fixed);
  14931. }
  14932. if (fixed instanceof AST_Defun) {
  14933. set_flag(fixed, SQUEEZED);
  14934. fixed = make_node(AST_Function, fixed, fixed);
  14935. }
  14936. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  14937. const defun_def = fixed.name.definition();
  14938. let lambda_def = fixed.variables.get(fixed.name.name);
  14939. let name = lambda_def && lambda_def.orig[0];
  14940. if (!(name instanceof AST_SymbolLambda)) {
  14941. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  14942. name.scope = fixed;
  14943. fixed.name = name;
  14944. lambda_def = fixed.def_function(name);
  14945. }
  14946. walk(fixed, node => {
  14947. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  14948. node.thedef = lambda_def;
  14949. lambda_def.references.push(node);
  14950. }
  14951. });
  14952. }
  14953. if (
  14954. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  14955. && fixed.parent_scope !== nearest_scope
  14956. ) {
  14957. fixed = fixed.clone(true, compressor.get_toplevel());
  14958. nearest_scope.add_child_scope(fixed);
  14959. }
  14960. return fixed.optimize(compressor);
  14961. }
  14962. // multiple uses
  14963. if (fixed) {
  14964. let replace;
  14965. if (fixed instanceof AST_This) {
  14966. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  14967. && def.references.every((ref) =>
  14968. def.scope === ref.scope
  14969. )) {
  14970. replace = fixed;
  14971. }
  14972. } else {
  14973. var ev = fixed.evaluate(compressor);
  14974. if (
  14975. ev !== fixed
  14976. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  14977. ) {
  14978. replace = make_node_from_constant(ev, fixed);
  14979. }
  14980. }
  14981. if (replace) {
  14982. const name_length = self.size(compressor);
  14983. const replace_size = replace.size(compressor);
  14984. let overhead = 0;
  14985. if (compressor.option("unused") && !compressor.exposed(def)) {
  14986. overhead =
  14987. (name_length + 2 + replace_size) /
  14988. (def.references.length - def.assignments);
  14989. }
  14990. if (replace_size <= name_length + overhead) {
  14991. return replace;
  14992. }
  14993. }
  14994. }
  14995. }
  14996. return self;
  14997. }
  14998. function inline_into_call(self, fn, compressor) {
  14999. var exp = self.expression;
  15000. var simple_args = self.args.every((arg) => !(arg instanceof AST_Expansion));
  15001. if (compressor.option("reduce_vars")
  15002. && fn instanceof AST_SymbolRef
  15003. && !has_annotation(self, _NOINLINE)
  15004. ) {
  15005. const fixed = fn.fixed_value();
  15006. if (!retain_top_func(fixed, compressor)) {
  15007. fn = fixed;
  15008. }
  15009. }
  15010. var is_func = fn instanceof AST_Lambda;
  15011. var stat = is_func && fn.body[0];
  15012. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  15013. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  15014. if (can_inline && stat instanceof AST_Return) {
  15015. let returned = stat.value;
  15016. if (!returned || returned.is_constant_expression()) {
  15017. if (returned) {
  15018. returned = returned.clone(true);
  15019. } else {
  15020. returned = make_node(AST_Undefined, self);
  15021. }
  15022. const args = self.args.concat(returned);
  15023. return make_sequence(self, args).optimize(compressor);
  15024. }
  15025. // optimize identity function
  15026. if (
  15027. fn.argnames.length === 1
  15028. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  15029. && self.args.length < 2
  15030. && returned instanceof AST_SymbolRef
  15031. && returned.name === fn.argnames[0].name
  15032. ) {
  15033. const replacement =
  15034. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  15035. let parent;
  15036. if (
  15037. replacement instanceof AST_PropAccess
  15038. && (parent = compressor.parent()) instanceof AST_Call
  15039. && parent.expression === self
  15040. ) {
  15041. // identity function was being used to remove `this`, like in
  15042. //
  15043. // id(bag.no_this)(...)
  15044. //
  15045. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  15046. return make_sequence(self, [
  15047. make_node(AST_Number, self, { value: 0 }),
  15048. replacement
  15049. ]);
  15050. }
  15051. // replace call with first argument or undefined if none passed
  15052. return replacement;
  15053. }
  15054. }
  15055. if (can_inline) {
  15056. var scope, in_loop, level = -1;
  15057. let def;
  15058. let returned_value;
  15059. let nearest_scope;
  15060. if (simple_args
  15061. && !fn.uses_arguments
  15062. && !(compressor.parent() instanceof AST_Class)
  15063. && !(fn.name && fn instanceof AST_Function)
  15064. && (returned_value = can_flatten_body(stat))
  15065. && (exp === fn
  15066. || has_annotation(self, _INLINE)
  15067. || compressor.option("unused")
  15068. && (def = exp.definition()).references.length == 1
  15069. && !is_recursive_ref(compressor, def)
  15070. && fn.is_constant_expression(exp.scope))
  15071. && !has_annotation(self, _PURE | _NOINLINE)
  15072. && !fn.contains_this()
  15073. && can_inject_symbols()
  15074. && (nearest_scope = compressor.find_scope())
  15075. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  15076. && !(function in_default_assign() {
  15077. // Due to the fact function parameters have their own scope
  15078. // which can't use `var something` in the function body within,
  15079. // we simply don't inline into DefaultAssign.
  15080. let i = 0;
  15081. let p;
  15082. while ((p = compressor.parent(i++))) {
  15083. if (p instanceof AST_DefaultAssign) return true;
  15084. if (p instanceof AST_Block) break;
  15085. }
  15086. return false;
  15087. })()
  15088. && !(scope instanceof AST_Class)
  15089. ) {
  15090. set_flag(fn, SQUEEZED);
  15091. nearest_scope.add_child_scope(fn);
  15092. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  15093. }
  15094. }
  15095. if (can_inline && has_annotation(self, _INLINE)) {
  15096. set_flag(fn, SQUEEZED);
  15097. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  15098. fn = fn.clone(true);
  15099. fn.figure_out_scope({}, {
  15100. parent_scope: compressor.find_scope(),
  15101. toplevel: compressor.get_toplevel()
  15102. });
  15103. return make_node(AST_Call, self, {
  15104. expression: fn,
  15105. args: self.args,
  15106. }).optimize(compressor);
  15107. }
  15108. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  15109. if (can_drop_this_call) {
  15110. var args = self.args.concat(make_node(AST_Undefined, self));
  15111. return make_sequence(self, args).optimize(compressor);
  15112. }
  15113. if (compressor.option("negate_iife")
  15114. && compressor.parent() instanceof AST_SimpleStatement
  15115. && is_iife_call(self)) {
  15116. return self.negate(compressor, true);
  15117. }
  15118. var ev = self.evaluate(compressor);
  15119. if (ev !== self) {
  15120. ev = make_node_from_constant(ev, self).optimize(compressor);
  15121. return best_of(compressor, ev, self);
  15122. }
  15123. return self;
  15124. function return_value(stat) {
  15125. if (!stat) return make_node(AST_Undefined, self);
  15126. if (stat instanceof AST_Return) {
  15127. if (!stat.value) return make_node(AST_Undefined, self);
  15128. return stat.value.clone(true);
  15129. }
  15130. if (stat instanceof AST_SimpleStatement) {
  15131. return make_node(AST_UnaryPrefix, stat, {
  15132. operator: "void",
  15133. expression: stat.body.clone(true)
  15134. });
  15135. }
  15136. }
  15137. function can_flatten_body(stat) {
  15138. var body = fn.body;
  15139. var len = body.length;
  15140. if (compressor.option("inline") < 3) {
  15141. return len == 1 && return_value(stat);
  15142. }
  15143. stat = null;
  15144. for (var i = 0; i < len; i++) {
  15145. var line = body[i];
  15146. if (line instanceof AST_Var) {
  15147. if (stat && !line.definitions.every((var_def) =>
  15148. !var_def.value
  15149. )) {
  15150. return false;
  15151. }
  15152. } else if (stat) {
  15153. return false;
  15154. } else if (!(line instanceof AST_EmptyStatement)) {
  15155. stat = line;
  15156. }
  15157. }
  15158. return return_value(stat);
  15159. }
  15160. function can_inject_args(block_scoped, safe_to_inject) {
  15161. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  15162. var arg = fn.argnames[i];
  15163. if (arg instanceof AST_DefaultAssign) {
  15164. if (has_flag(arg.left, UNUSED)) continue;
  15165. return false;
  15166. }
  15167. if (arg instanceof AST_Destructuring) return false;
  15168. if (arg instanceof AST_Expansion) {
  15169. if (has_flag(arg.expression, UNUSED)) continue;
  15170. return false;
  15171. }
  15172. if (has_flag(arg, UNUSED)) continue;
  15173. if (!safe_to_inject
  15174. || block_scoped.has(arg.name)
  15175. || identifier_atom.has(arg.name)
  15176. || scope.conflicting_def(arg.name)) {
  15177. return false;
  15178. }
  15179. if (in_loop) in_loop.push(arg.definition());
  15180. }
  15181. return true;
  15182. }
  15183. function can_inject_vars(block_scoped, safe_to_inject) {
  15184. var len = fn.body.length;
  15185. for (var i = 0; i < len; i++) {
  15186. var stat = fn.body[i];
  15187. if (!(stat instanceof AST_Var)) continue;
  15188. if (!safe_to_inject) return false;
  15189. for (var j = stat.definitions.length; --j >= 0;) {
  15190. var name = stat.definitions[j].name;
  15191. if (name instanceof AST_Destructuring
  15192. || block_scoped.has(name.name)
  15193. || identifier_atom.has(name.name)
  15194. || scope.conflicting_def(name.name)) {
  15195. return false;
  15196. }
  15197. if (in_loop) in_loop.push(name.definition());
  15198. }
  15199. }
  15200. return true;
  15201. }
  15202. function can_inject_symbols() {
  15203. var block_scoped = new Set();
  15204. do {
  15205. scope = compressor.parent(++level);
  15206. if (scope.is_block_scope() && scope.block_scope) {
  15207. // TODO this is sometimes undefined during compression.
  15208. // But it should always have a value!
  15209. scope.block_scope.variables.forEach(function (variable) {
  15210. block_scoped.add(variable.name);
  15211. });
  15212. }
  15213. if (scope instanceof AST_Catch) {
  15214. // TODO can we delete? AST_Catch is a block scope.
  15215. if (scope.argname) {
  15216. block_scoped.add(scope.argname.name);
  15217. }
  15218. } else if (scope instanceof AST_IterationStatement) {
  15219. in_loop = [];
  15220. } else if (scope instanceof AST_SymbolRef) {
  15221. if (scope.fixed_value() instanceof AST_Scope) return false;
  15222. }
  15223. } while (!(scope instanceof AST_Scope));
  15224. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  15225. var inline = compressor.option("inline");
  15226. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  15227. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  15228. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  15229. }
  15230. function append_var(decls, expressions, name, value) {
  15231. var def = name.definition();
  15232. // Name already exists, only when a function argument had the same name
  15233. const already_appended = scope.variables.has(name.name);
  15234. if (!already_appended) {
  15235. scope.variables.set(name.name, def);
  15236. scope.enclosed.push(def);
  15237. decls.push(make_node(AST_VarDef, name, {
  15238. name: name,
  15239. value: null
  15240. }));
  15241. }
  15242. var sym = make_node(AST_SymbolRef, name, name);
  15243. def.references.push(sym);
  15244. if (value) expressions.push(make_node(AST_Assign, self, {
  15245. operator: "=",
  15246. logical: false,
  15247. left: sym,
  15248. right: value.clone()
  15249. }));
  15250. }
  15251. function flatten_args(decls, expressions) {
  15252. var len = fn.argnames.length;
  15253. for (var i = self.args.length; --i >= len;) {
  15254. expressions.push(self.args[i]);
  15255. }
  15256. for (i = len; --i >= 0;) {
  15257. var name = fn.argnames[i];
  15258. var value = self.args[i];
  15259. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  15260. if (value) expressions.push(value);
  15261. } else {
  15262. var symbol = make_node(AST_SymbolVar, name, name);
  15263. name.definition().orig.push(symbol);
  15264. if (!value && in_loop) value = make_node(AST_Undefined, self);
  15265. append_var(decls, expressions, symbol, value);
  15266. }
  15267. }
  15268. decls.reverse();
  15269. expressions.reverse();
  15270. }
  15271. function flatten_vars(decls, expressions) {
  15272. var pos = expressions.length;
  15273. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  15274. var stat = fn.body[i];
  15275. if (!(stat instanceof AST_Var)) continue;
  15276. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  15277. var var_def = stat.definitions[j];
  15278. var name = var_def.name;
  15279. append_var(decls, expressions, name, var_def.value);
  15280. if (in_loop && fn.argnames.every((argname) =>
  15281. argname.name != name.name
  15282. )) {
  15283. var def = fn.variables.get(name.name);
  15284. var sym = make_node(AST_SymbolRef, name, name);
  15285. def.references.push(sym);
  15286. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  15287. operator: "=",
  15288. logical: false,
  15289. left: sym,
  15290. right: make_node(AST_Undefined, name)
  15291. }));
  15292. }
  15293. }
  15294. }
  15295. }
  15296. function flatten_fn(returned_value) {
  15297. var decls = [];
  15298. var expressions = [];
  15299. flatten_args(decls, expressions);
  15300. flatten_vars(decls, expressions);
  15301. expressions.push(returned_value);
  15302. if (decls.length) {
  15303. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  15304. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  15305. definitions: decls
  15306. }));
  15307. }
  15308. return expressions.map(exp => exp.clone(true));
  15309. }
  15310. }
  15311. /***********************************************************************
  15312. A JavaScript tokenizer / parser / beautifier / compressor.
  15313. https://github.com/mishoo/UglifyJS2
  15314. -------------------------------- (C) ---------------------------------
  15315. Author: Mihai Bazon
  15316. <mihai.bazon@gmail.com>
  15317. http://mihai.bazon.net/blog
  15318. Distributed under the BSD license:
  15319. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  15320. Redistribution and use in source and binary forms, with or without
  15321. modification, are permitted provided that the following conditions
  15322. are met:
  15323. * Redistributions of source code must retain the above
  15324. copyright notice, this list of conditions and the following
  15325. disclaimer.
  15326. * Redistributions in binary form must reproduce the above
  15327. copyright notice, this list of conditions and the following
  15328. disclaimer in the documentation and/or other materials
  15329. provided with the distribution.
  15330. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  15331. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15332. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  15333. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  15334. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  15335. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15336. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  15337. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  15338. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  15339. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15340. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15341. SUCH DAMAGE.
  15342. ***********************************************************************/
  15343. class Compressor extends TreeWalker {
  15344. constructor(options, { false_by_default = false, mangle_options = false }) {
  15345. super();
  15346. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  15347. this.options = defaults(options, {
  15348. arguments : false,
  15349. arrows : !false_by_default,
  15350. booleans : !false_by_default,
  15351. booleans_as_integers : false,
  15352. collapse_vars : !false_by_default,
  15353. comparisons : !false_by_default,
  15354. computed_props: !false_by_default,
  15355. conditionals : !false_by_default,
  15356. dead_code : !false_by_default,
  15357. defaults : true,
  15358. directives : !false_by_default,
  15359. drop_console : false,
  15360. drop_debugger : !false_by_default,
  15361. ecma : 5,
  15362. evaluate : !false_by_default,
  15363. expression : false,
  15364. global_defs : false,
  15365. hoist_funs : false,
  15366. hoist_props : !false_by_default,
  15367. hoist_vars : false,
  15368. ie8 : false,
  15369. if_return : !false_by_default,
  15370. inline : !false_by_default,
  15371. join_vars : !false_by_default,
  15372. keep_classnames: false,
  15373. keep_fargs : true,
  15374. keep_fnames : false,
  15375. keep_infinity : false,
  15376. loops : !false_by_default,
  15377. module : false,
  15378. negate_iife : !false_by_default,
  15379. passes : 1,
  15380. properties : !false_by_default,
  15381. pure_getters : !false_by_default && "strict",
  15382. pure_funcs : null,
  15383. reduce_funcs : !false_by_default,
  15384. reduce_vars : !false_by_default,
  15385. sequences : !false_by_default,
  15386. side_effects : !false_by_default,
  15387. switches : !false_by_default,
  15388. top_retain : null,
  15389. toplevel : !!(options && options["top_retain"]),
  15390. typeofs : !false_by_default,
  15391. unsafe : false,
  15392. unsafe_arrows : false,
  15393. unsafe_comps : false,
  15394. unsafe_Function: false,
  15395. unsafe_math : false,
  15396. unsafe_symbols: false,
  15397. unsafe_methods: false,
  15398. unsafe_proto : false,
  15399. unsafe_regexp : false,
  15400. unsafe_undefined: false,
  15401. unused : !false_by_default,
  15402. warnings : false // legacy
  15403. }, true);
  15404. var global_defs = this.options["global_defs"];
  15405. if (typeof global_defs == "object") for (var key in global_defs) {
  15406. if (key[0] === "@" && HOP(global_defs, key)) {
  15407. global_defs[key.slice(1)] = parse(global_defs[key], {
  15408. expression: true
  15409. });
  15410. }
  15411. }
  15412. if (this.options["inline"] === true) this.options["inline"] = 3;
  15413. var pure_funcs = this.options["pure_funcs"];
  15414. if (typeof pure_funcs == "function") {
  15415. this.pure_funcs = pure_funcs;
  15416. } else {
  15417. this.pure_funcs = pure_funcs ? function(node) {
  15418. return !pure_funcs.includes(node.expression.print_to_string());
  15419. } : return_true;
  15420. }
  15421. var top_retain = this.options["top_retain"];
  15422. if (top_retain instanceof RegExp) {
  15423. this.top_retain = function(def) {
  15424. return top_retain.test(def.name);
  15425. };
  15426. } else if (typeof top_retain == "function") {
  15427. this.top_retain = top_retain;
  15428. } else if (top_retain) {
  15429. if (typeof top_retain == "string") {
  15430. top_retain = top_retain.split(/,/);
  15431. }
  15432. this.top_retain = function(def) {
  15433. return top_retain.includes(def.name);
  15434. };
  15435. }
  15436. if (this.options["module"]) {
  15437. this.directives["use strict"] = true;
  15438. this.options["toplevel"] = true;
  15439. }
  15440. var toplevel = this.options["toplevel"];
  15441. this.toplevel = typeof toplevel == "string" ? {
  15442. funcs: /funcs/.test(toplevel),
  15443. vars: /vars/.test(toplevel)
  15444. } : {
  15445. funcs: toplevel,
  15446. vars: toplevel
  15447. };
  15448. var sequences = this.options["sequences"];
  15449. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  15450. this.evaluated_regexps = new Map();
  15451. this._toplevel = undefined;
  15452. this.mangle_options = mangle_options;
  15453. }
  15454. option(key) {
  15455. return this.options[key];
  15456. }
  15457. exposed(def) {
  15458. if (def.export) return true;
  15459. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  15460. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  15461. return true;
  15462. return false;
  15463. }
  15464. in_boolean_context() {
  15465. if (!this.option("booleans")) return false;
  15466. var self = this.self();
  15467. for (var i = 0, p; p = this.parent(i); i++) {
  15468. if (p instanceof AST_SimpleStatement
  15469. || p instanceof AST_Conditional && p.condition === self
  15470. || p instanceof AST_DWLoop && p.condition === self
  15471. || p instanceof AST_For && p.condition === self
  15472. || p instanceof AST_If && p.condition === self
  15473. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  15474. return true;
  15475. }
  15476. if (
  15477. p instanceof AST_Binary
  15478. && (
  15479. p.operator == "&&"
  15480. || p.operator == "||"
  15481. || p.operator == "??"
  15482. )
  15483. || p instanceof AST_Conditional
  15484. || p.tail_node() === self
  15485. ) {
  15486. self = p;
  15487. } else {
  15488. return false;
  15489. }
  15490. }
  15491. }
  15492. get_toplevel() {
  15493. return this._toplevel;
  15494. }
  15495. compress(toplevel) {
  15496. toplevel = toplevel.resolve_defines(this);
  15497. this._toplevel = toplevel;
  15498. if (this.option("expression")) {
  15499. this._toplevel.process_expression(true);
  15500. }
  15501. var passes = +this.options.passes || 1;
  15502. var min_count = 1 / 0;
  15503. var stopping = false;
  15504. var nth_identifier = this.mangle_options && this.mangle_options.nth_identifier || base54;
  15505. var mangle = { ie8: this.option("ie8"), nth_identifier: nth_identifier };
  15506. for (var pass = 0; pass < passes; pass++) {
  15507. this._toplevel.figure_out_scope(mangle);
  15508. if (pass === 0 && this.option("drop_console")) {
  15509. // must be run before reduce_vars and compress pass
  15510. this._toplevel = this._toplevel.drop_console();
  15511. }
  15512. if (pass > 0 || this.option("reduce_vars")) {
  15513. this._toplevel.reset_opt_flags(this);
  15514. }
  15515. this._toplevel = this._toplevel.transform(this);
  15516. if (passes > 1) {
  15517. let count = 0;
  15518. walk(this._toplevel, () => { count++; });
  15519. if (count < min_count) {
  15520. min_count = count;
  15521. stopping = false;
  15522. } else if (stopping) {
  15523. break;
  15524. } else {
  15525. stopping = true;
  15526. }
  15527. }
  15528. }
  15529. if (this.option("expression")) {
  15530. this._toplevel.process_expression(false);
  15531. }
  15532. toplevel = this._toplevel;
  15533. this._toplevel = undefined;
  15534. return toplevel;
  15535. }
  15536. before(node, descend) {
  15537. if (has_flag(node, SQUEEZED)) return node;
  15538. var was_scope = false;
  15539. if (node instanceof AST_Scope) {
  15540. node = node.hoist_properties(this);
  15541. node = node.hoist_declarations(this);
  15542. was_scope = true;
  15543. }
  15544. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  15545. // would call AST_Node.transform() if a different instance of AST_Node is
  15546. // produced after def_optimize().
  15547. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  15548. // Migrate and defer all children's AST_Node.transform() to below, which
  15549. // will now happen after this parent AST_Node has been properly substituted
  15550. // thus gives a consistent AST snapshot.
  15551. descend(node, this);
  15552. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  15553. // following replacement call would result in degraded efficiency of both
  15554. // output and performance.
  15555. descend(node, this);
  15556. var opt = node.optimize(this);
  15557. if (was_scope && opt instanceof AST_Scope) {
  15558. opt.drop_unused(this);
  15559. descend(opt, this);
  15560. }
  15561. if (opt === node) set_flag(opt, SQUEEZED);
  15562. return opt;
  15563. }
  15564. }
  15565. function def_optimize(node, optimizer) {
  15566. node.DEFMETHOD("optimize", function(compressor) {
  15567. var self = this;
  15568. if (has_flag(self, OPTIMIZED)) return self;
  15569. if (compressor.has_directive("use asm")) return self;
  15570. var opt = optimizer(self, compressor);
  15571. set_flag(opt, OPTIMIZED);
  15572. return opt;
  15573. });
  15574. }
  15575. def_optimize(AST_Node, function(self) {
  15576. return self;
  15577. });
  15578. AST_Toplevel.DEFMETHOD("drop_console", function() {
  15579. return this.transform(new TreeTransformer(function(self) {
  15580. if (self.TYPE == "Call") {
  15581. var exp = self.expression;
  15582. if (exp instanceof AST_PropAccess) {
  15583. var name = exp.expression;
  15584. while (name.expression) {
  15585. name = name.expression;
  15586. }
  15587. if (is_undeclared_ref(name) && name.name == "console") {
  15588. return make_node(AST_Undefined, self);
  15589. }
  15590. }
  15591. }
  15592. }));
  15593. });
  15594. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  15595. return equivalent_to(this, node);
  15596. });
  15597. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  15598. var self = this;
  15599. var tt = new TreeTransformer(function(node) {
  15600. if (insert && node instanceof AST_SimpleStatement) {
  15601. return make_node(AST_Return, node, {
  15602. value: node.body
  15603. });
  15604. }
  15605. if (!insert && node instanceof AST_Return) {
  15606. if (compressor) {
  15607. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  15608. return value
  15609. ? make_node(AST_SimpleStatement, node, { body: value })
  15610. : make_node(AST_EmptyStatement, node);
  15611. }
  15612. return make_node(AST_SimpleStatement, node, {
  15613. body: node.value || make_node(AST_UnaryPrefix, node, {
  15614. operator: "void",
  15615. expression: make_node(AST_Number, node, {
  15616. value: 0
  15617. })
  15618. })
  15619. });
  15620. }
  15621. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  15622. return node;
  15623. }
  15624. if (node instanceof AST_Block) {
  15625. var index = node.body.length - 1;
  15626. if (index >= 0) {
  15627. node.body[index] = node.body[index].transform(tt);
  15628. }
  15629. } else if (node instanceof AST_If) {
  15630. node.body = node.body.transform(tt);
  15631. if (node.alternative) {
  15632. node.alternative = node.alternative.transform(tt);
  15633. }
  15634. } else if (node instanceof AST_With) {
  15635. node.body = node.body.transform(tt);
  15636. }
  15637. return node;
  15638. });
  15639. self.transform(tt);
  15640. });
  15641. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  15642. const self = this;
  15643. const reduce_vars = compressor.option("reduce_vars");
  15644. const preparation = new TreeWalker(function(node, descend) {
  15645. clear_flag(node, CLEAR_BETWEEN_PASSES);
  15646. if (reduce_vars) {
  15647. if (compressor.top_retain
  15648. && node instanceof AST_Defun // Only functions are retained
  15649. && preparation.parent() === self
  15650. ) {
  15651. set_flag(node, TOP);
  15652. }
  15653. return node.reduce_vars(preparation, descend, compressor);
  15654. }
  15655. });
  15656. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  15657. // properly assigned before use:
  15658. // - `push()` & `pop()` when visiting conditional branches
  15659. preparation.safe_ids = Object.create(null);
  15660. preparation.in_loop = null;
  15661. preparation.loop_ids = new Map();
  15662. preparation.defs_to_safe_ids = new Map();
  15663. self.walk(preparation);
  15664. });
  15665. AST_Symbol.DEFMETHOD("fixed_value", function() {
  15666. var fixed = this.thedef.fixed;
  15667. if (!fixed || fixed instanceof AST_Node) return fixed;
  15668. return fixed();
  15669. });
  15670. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  15671. var orig = this.definition().orig;
  15672. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  15673. });
  15674. function find_variable(compressor, name) {
  15675. var scope, i = 0;
  15676. while (scope = compressor.parent(i++)) {
  15677. if (scope instanceof AST_Scope) break;
  15678. if (scope instanceof AST_Catch && scope.argname) {
  15679. scope = scope.argname.definition().scope;
  15680. break;
  15681. }
  15682. }
  15683. return scope.find_variable(name);
  15684. }
  15685. 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");
  15686. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  15687. return !this.definition().undeclared
  15688. || compressor.option("unsafe") && global_names.has(this.name);
  15689. });
  15690. /* -----[ optimizers ]----- */
  15691. var directives = new Set(["use asm", "use strict"]);
  15692. def_optimize(AST_Directive, function(self, compressor) {
  15693. if (compressor.option("directives")
  15694. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  15695. return make_node(AST_EmptyStatement, self);
  15696. }
  15697. return self;
  15698. });
  15699. def_optimize(AST_Debugger, function(self, compressor) {
  15700. if (compressor.option("drop_debugger"))
  15701. return make_node(AST_EmptyStatement, self);
  15702. return self;
  15703. });
  15704. def_optimize(AST_LabeledStatement, function(self, compressor) {
  15705. if (self.body instanceof AST_Break
  15706. && compressor.loopcontrol_target(self.body) === self.body) {
  15707. return make_node(AST_EmptyStatement, self);
  15708. }
  15709. return self.label.references.length == 0 ? self.body : self;
  15710. });
  15711. def_optimize(AST_Block, function(self, compressor) {
  15712. tighten_body(self.body, compressor);
  15713. return self;
  15714. });
  15715. function can_be_extracted_from_if_block(node) {
  15716. return !(
  15717. node instanceof AST_Const
  15718. || node instanceof AST_Let
  15719. || node instanceof AST_Class
  15720. );
  15721. }
  15722. def_optimize(AST_BlockStatement, function(self, compressor) {
  15723. tighten_body(self.body, compressor);
  15724. switch (self.body.length) {
  15725. case 1:
  15726. if (!compressor.has_directive("use strict")
  15727. && compressor.parent() instanceof AST_If
  15728. && can_be_extracted_from_if_block(self.body[0])
  15729. || can_be_evicted_from_block(self.body[0])) {
  15730. return self.body[0];
  15731. }
  15732. break;
  15733. case 0: return make_node(AST_EmptyStatement, self);
  15734. }
  15735. return self;
  15736. });
  15737. function opt_AST_Lambda(self, compressor) {
  15738. tighten_body(self.body, compressor);
  15739. if (compressor.option("side_effects")
  15740. && self.body.length == 1
  15741. && self.body[0] === compressor.has_directive("use strict")) {
  15742. self.body.length = 0;
  15743. }
  15744. return self;
  15745. }
  15746. def_optimize(AST_Lambda, opt_AST_Lambda);
  15747. const r_keep_assign = /keep_assign/;
  15748. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  15749. if (!compressor.option("unused")) return;
  15750. if (compressor.has_directive("use asm")) return;
  15751. var self = this;
  15752. if (self.pinned()) return;
  15753. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  15754. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  15755. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  15756. if (node instanceof AST_Assign
  15757. && !node.logical
  15758. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  15759. ) {
  15760. return node.left;
  15761. }
  15762. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  15763. return node.expression;
  15764. }
  15765. };
  15766. var in_use_ids = new Map();
  15767. var fixed_ids = new Map();
  15768. if (self instanceof AST_Toplevel && compressor.top_retain) {
  15769. self.variables.forEach(function(def) {
  15770. if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
  15771. in_use_ids.set(def.id, def);
  15772. }
  15773. });
  15774. }
  15775. var var_defs_by_id = new Map();
  15776. var initializations = new Map();
  15777. // pass 1: find out which symbols are directly used in
  15778. // this scope (not in nested scopes).
  15779. var scope = this;
  15780. var tw = new TreeWalker(function(node, descend) {
  15781. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  15782. node.argnames.forEach(function(argname) {
  15783. if (!(argname instanceof AST_SymbolDeclaration)) return;
  15784. var def = argname.definition();
  15785. if (!in_use_ids.has(def.id)) {
  15786. in_use_ids.set(def.id, def);
  15787. }
  15788. });
  15789. }
  15790. if (node === self) return;
  15791. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  15792. var node_def = node.name.definition();
  15793. const in_export = tw.parent() instanceof AST_Export;
  15794. if (in_export || !drop_funcs && scope === self) {
  15795. if (node_def.global && !in_use_ids.has(node_def.id)) {
  15796. in_use_ids.set(node_def.id, node_def);
  15797. }
  15798. }
  15799. if (node instanceof AST_DefClass) {
  15800. if (
  15801. node.extends
  15802. && (node.extends.has_side_effects(compressor)
  15803. || node.extends.may_throw(compressor))
  15804. ) {
  15805. node.extends.walk(tw);
  15806. }
  15807. for (const prop of node.properties) {
  15808. if (
  15809. prop.has_side_effects(compressor) ||
  15810. prop.may_throw(compressor)
  15811. ) {
  15812. prop.walk(tw);
  15813. }
  15814. }
  15815. }
  15816. map_add(initializations, node_def.id, node);
  15817. return true; // don't go in nested scopes
  15818. }
  15819. if (node instanceof AST_SymbolFunarg && scope === self) {
  15820. map_add(var_defs_by_id, node.definition().id, node);
  15821. }
  15822. if (node instanceof AST_Definitions && scope === self) {
  15823. const in_export = tw.parent() instanceof AST_Export;
  15824. node.definitions.forEach(function(def) {
  15825. if (def.name instanceof AST_SymbolVar) {
  15826. map_add(var_defs_by_id, def.name.definition().id, def);
  15827. }
  15828. if (in_export || !drop_vars) {
  15829. walk(def.name, node => {
  15830. if (node instanceof AST_SymbolDeclaration) {
  15831. const def = node.definition();
  15832. if (
  15833. (in_export || def.global)
  15834. && !in_use_ids.has(def.id)
  15835. ) {
  15836. in_use_ids.set(def.id, def);
  15837. }
  15838. }
  15839. });
  15840. }
  15841. if (def.value) {
  15842. if (def.name instanceof AST_Destructuring) {
  15843. def.walk(tw);
  15844. } else {
  15845. var node_def = def.name.definition();
  15846. map_add(initializations, node_def.id, def.value);
  15847. if (!node_def.chained && def.name.fixed_value() === def.value) {
  15848. fixed_ids.set(node_def.id, def);
  15849. }
  15850. }
  15851. if (def.value.has_side_effects(compressor)) {
  15852. def.value.walk(tw);
  15853. }
  15854. }
  15855. });
  15856. return true;
  15857. }
  15858. return scan_ref_scoped(node, descend);
  15859. });
  15860. self.walk(tw);
  15861. // pass 2: for every used symbol we need to walk its
  15862. // initialization code to figure out if it uses other
  15863. // symbols (that may not be in_use).
  15864. tw = new TreeWalker(scan_ref_scoped);
  15865. in_use_ids.forEach(function (def) {
  15866. var init = initializations.get(def.id);
  15867. if (init) init.forEach(function(init) {
  15868. init.walk(tw);
  15869. });
  15870. });
  15871. // pass 3: we should drop declarations not in_use
  15872. var tt = new TreeTransformer(
  15873. function before(node, descend, in_list) {
  15874. var parent = tt.parent();
  15875. if (drop_vars) {
  15876. const sym = assign_as_unused(node);
  15877. if (sym instanceof AST_SymbolRef) {
  15878. var def = sym.definition();
  15879. var in_use = in_use_ids.has(def.id);
  15880. if (node instanceof AST_Assign) {
  15881. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  15882. return maintain_this_binding(parent, node, node.right.transform(tt));
  15883. }
  15884. } else if (!in_use) return in_list ? MAP.skip : make_node(AST_Number, node, {
  15885. value: 0
  15886. });
  15887. }
  15888. }
  15889. if (scope !== self) return;
  15890. var def;
  15891. if (node.name
  15892. && (node instanceof AST_ClassExpression
  15893. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  15894. || node instanceof AST_Function
  15895. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  15896. // any declarations with same name will overshadow
  15897. // name of this anonymous function and can therefore
  15898. // never be used anywhere
  15899. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  15900. }
  15901. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  15902. var trim = !compressor.option("keep_fargs");
  15903. for (var a = node.argnames, i = a.length; --i >= 0;) {
  15904. var sym = a[i];
  15905. if (sym instanceof AST_Expansion) {
  15906. sym = sym.expression;
  15907. }
  15908. if (sym instanceof AST_DefaultAssign) {
  15909. sym = sym.left;
  15910. }
  15911. // Do not drop destructuring arguments.
  15912. // They constitute a type assertion, so dropping
  15913. // them would stop that TypeError which would happen
  15914. // if someone called it with an incorrectly formatted
  15915. // parameter.
  15916. if (!(sym instanceof AST_Destructuring) && !in_use_ids.has(sym.definition().id)) {
  15917. set_flag(sym, UNUSED);
  15918. if (trim) {
  15919. a.pop();
  15920. }
  15921. } else {
  15922. trim = false;
  15923. }
  15924. }
  15925. }
  15926. if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
  15927. const def = node.name.definition();
  15928. let keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  15929. if (!keep) {
  15930. def.eliminated++;
  15931. if (node instanceof AST_DefClass) {
  15932. // Classes might have extends with side effects
  15933. const side_effects = node.drop_side_effect_free(compressor);
  15934. if (side_effects) {
  15935. return make_node(AST_SimpleStatement, node, {
  15936. body: side_effects
  15937. });
  15938. }
  15939. }
  15940. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  15941. }
  15942. }
  15943. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  15944. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  15945. // place uninitialized names at the start
  15946. var body = [], head = [], tail = [];
  15947. // for unused names whose initialization has
  15948. // side effects, we can cascade the init. code
  15949. // into the next one, or next statement.
  15950. var side_effects = [];
  15951. node.definitions.forEach(function(def) {
  15952. if (def.value) def.value = def.value.transform(tt);
  15953. var is_destructure = def.name instanceof AST_Destructuring;
  15954. var sym = is_destructure
  15955. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  15956. : def.name.definition();
  15957. if (drop_block && sym.global) return tail.push(def);
  15958. if (!(drop_vars || drop_block)
  15959. || is_destructure
  15960. && (def.name.names.length
  15961. || def.name.is_array
  15962. || compressor.option("pure_getters") != true)
  15963. || in_use_ids.has(sym.id)
  15964. ) {
  15965. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  15966. def.value = def.value.drop_side_effect_free(compressor);
  15967. }
  15968. if (def.name instanceof AST_SymbolVar) {
  15969. var var_defs = var_defs_by_id.get(sym.id);
  15970. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  15971. if (def.value) {
  15972. var ref = make_node(AST_SymbolRef, def.name, def.name);
  15973. sym.references.push(ref);
  15974. var assign = make_node(AST_Assign, def, {
  15975. operator: "=",
  15976. logical: false,
  15977. left: ref,
  15978. right: def.value
  15979. });
  15980. if (fixed_ids.get(sym.id) === def) {
  15981. fixed_ids.set(sym.id, assign);
  15982. }
  15983. side_effects.push(assign.transform(tt));
  15984. }
  15985. remove(var_defs, def);
  15986. sym.eliminated++;
  15987. return;
  15988. }
  15989. }
  15990. if (def.value) {
  15991. if (side_effects.length > 0) {
  15992. if (tail.length > 0) {
  15993. side_effects.push(def.value);
  15994. def.value = make_sequence(def.value, side_effects);
  15995. } else {
  15996. body.push(make_node(AST_SimpleStatement, node, {
  15997. body: make_sequence(node, side_effects)
  15998. }));
  15999. }
  16000. side_effects = [];
  16001. }
  16002. tail.push(def);
  16003. } else {
  16004. head.push(def);
  16005. }
  16006. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  16007. var value = def.value && def.value.drop_side_effect_free(compressor);
  16008. if (value) side_effects.push(value);
  16009. def.value = null;
  16010. head.push(def);
  16011. } else {
  16012. var value = def.value && def.value.drop_side_effect_free(compressor);
  16013. if (value) {
  16014. side_effects.push(value);
  16015. }
  16016. sym.eliminated++;
  16017. }
  16018. });
  16019. if (head.length > 0 || tail.length > 0) {
  16020. node.definitions = head.concat(tail);
  16021. body.push(node);
  16022. }
  16023. if (side_effects.length > 0) {
  16024. body.push(make_node(AST_SimpleStatement, node, {
  16025. body: make_sequence(node, side_effects)
  16026. }));
  16027. }
  16028. switch (body.length) {
  16029. case 0:
  16030. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  16031. case 1:
  16032. return body[0];
  16033. default:
  16034. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  16035. body: body
  16036. });
  16037. }
  16038. }
  16039. // certain combination of unused name + side effect leads to:
  16040. // https://github.com/mishoo/UglifyJS2/issues/44
  16041. // https://github.com/mishoo/UglifyJS2/issues/1830
  16042. // https://github.com/mishoo/UglifyJS2/issues/1838
  16043. // that's an invalid AST.
  16044. // We fix it at this stage by moving the `var` outside the `for`.
  16045. if (node instanceof AST_For) {
  16046. descend(node, this);
  16047. var block;
  16048. if (node.init instanceof AST_BlockStatement) {
  16049. block = node.init;
  16050. node.init = block.body.pop();
  16051. block.body.push(node);
  16052. }
  16053. if (node.init instanceof AST_SimpleStatement) {
  16054. node.init = node.init.body;
  16055. } else if (is_empty(node.init)) {
  16056. node.init = null;
  16057. }
  16058. return !block ? node : in_list ? MAP.splice(block.body) : block;
  16059. }
  16060. if (node instanceof AST_LabeledStatement
  16061. && node.body instanceof AST_For
  16062. ) {
  16063. descend(node, this);
  16064. if (node.body instanceof AST_BlockStatement) {
  16065. var block = node.body;
  16066. node.body = block.body.pop();
  16067. block.body.push(node);
  16068. return in_list ? MAP.splice(block.body) : block;
  16069. }
  16070. return node;
  16071. }
  16072. if (node instanceof AST_BlockStatement) {
  16073. descend(node, this);
  16074. if (in_list && node.body.every(can_be_evicted_from_block)) {
  16075. return MAP.splice(node.body);
  16076. }
  16077. return node;
  16078. }
  16079. if (node instanceof AST_Scope) {
  16080. const save_scope = scope;
  16081. scope = node;
  16082. descend(node, this);
  16083. scope = save_scope;
  16084. return node;
  16085. }
  16086. }
  16087. );
  16088. self.transform(tt);
  16089. function scan_ref_scoped(node, descend) {
  16090. var node_def;
  16091. const sym = assign_as_unused(node);
  16092. if (sym instanceof AST_SymbolRef
  16093. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  16094. && self.variables.get(sym.name) === (node_def = sym.definition())
  16095. ) {
  16096. if (node instanceof AST_Assign) {
  16097. node.right.walk(tw);
  16098. if (!node_def.chained && node.left.fixed_value() === node.right) {
  16099. fixed_ids.set(node_def.id, node);
  16100. }
  16101. }
  16102. return true;
  16103. }
  16104. if (node instanceof AST_SymbolRef) {
  16105. node_def = node.definition();
  16106. if (!in_use_ids.has(node_def.id)) {
  16107. in_use_ids.set(node_def.id, node_def);
  16108. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  16109. const redef = node_def.scope.is_block_scope()
  16110. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  16111. if (redef) in_use_ids.set(redef.id, redef);
  16112. }
  16113. }
  16114. return true;
  16115. }
  16116. if (node instanceof AST_Scope) {
  16117. var save_scope = scope;
  16118. scope = node;
  16119. descend();
  16120. scope = save_scope;
  16121. return true;
  16122. }
  16123. }
  16124. });
  16125. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  16126. var self = this;
  16127. if (compressor.has_directive("use asm")) return self;
  16128. // Hoisting makes no sense in an arrow func
  16129. if (!Array.isArray(self.body)) return self;
  16130. var hoist_funs = compressor.option("hoist_funs");
  16131. var hoist_vars = compressor.option("hoist_vars");
  16132. if (hoist_funs || hoist_vars) {
  16133. var dirs = [];
  16134. var hoisted = [];
  16135. var vars = new Map(), vars_found = 0, var_decl = 0;
  16136. // let's count var_decl first, we seem to waste a lot of
  16137. // space if we hoist `var` when there's only one.
  16138. walk(self, node => {
  16139. if (node instanceof AST_Scope && node !== self)
  16140. return true;
  16141. if (node instanceof AST_Var) {
  16142. ++var_decl;
  16143. return true;
  16144. }
  16145. });
  16146. hoist_vars = hoist_vars && var_decl > 1;
  16147. var tt = new TreeTransformer(
  16148. function before(node) {
  16149. if (node !== self) {
  16150. if (node instanceof AST_Directive) {
  16151. dirs.push(node);
  16152. return make_node(AST_EmptyStatement, node);
  16153. }
  16154. if (hoist_funs && node instanceof AST_Defun
  16155. && !(tt.parent() instanceof AST_Export)
  16156. && tt.parent() === self) {
  16157. hoisted.push(node);
  16158. return make_node(AST_EmptyStatement, node);
  16159. }
  16160. if (
  16161. hoist_vars
  16162. && node instanceof AST_Var
  16163. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  16164. ) {
  16165. node.definitions.forEach(function(def) {
  16166. vars.set(def.name.name, def);
  16167. ++vars_found;
  16168. });
  16169. var seq = node.to_assignments(compressor);
  16170. var p = tt.parent();
  16171. if (p instanceof AST_ForIn && p.init === node) {
  16172. if (seq == null) {
  16173. var def = node.definitions[0].name;
  16174. return make_node(AST_SymbolRef, def, def);
  16175. }
  16176. return seq;
  16177. }
  16178. if (p instanceof AST_For && p.init === node) {
  16179. return seq;
  16180. }
  16181. if (!seq) return make_node(AST_EmptyStatement, node);
  16182. return make_node(AST_SimpleStatement, node, {
  16183. body: seq
  16184. });
  16185. }
  16186. if (node instanceof AST_Scope)
  16187. return node; // to avoid descending in nested scopes
  16188. }
  16189. }
  16190. );
  16191. self = self.transform(tt);
  16192. if (vars_found > 0) {
  16193. // collect only vars which don't show up in self's arguments list
  16194. var defs = [];
  16195. const is_lambda = self instanceof AST_Lambda;
  16196. const args_as_names = is_lambda ? self.args_as_names() : null;
  16197. vars.forEach((def, name) => {
  16198. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  16199. vars.delete(name);
  16200. } else {
  16201. def = def.clone();
  16202. def.value = null;
  16203. defs.push(def);
  16204. vars.set(name, def);
  16205. }
  16206. });
  16207. if (defs.length > 0) {
  16208. // try to merge in assignments
  16209. for (var i = 0; i < self.body.length;) {
  16210. if (self.body[i] instanceof AST_SimpleStatement) {
  16211. var expr = self.body[i].body, sym, assign;
  16212. if (expr instanceof AST_Assign
  16213. && expr.operator == "="
  16214. && (sym = expr.left) instanceof AST_Symbol
  16215. && vars.has(sym.name)
  16216. ) {
  16217. var def = vars.get(sym.name);
  16218. if (def.value) break;
  16219. def.value = expr.right;
  16220. remove(defs, def);
  16221. defs.push(def);
  16222. self.body.splice(i, 1);
  16223. continue;
  16224. }
  16225. if (expr instanceof AST_Sequence
  16226. && (assign = expr.expressions[0]) instanceof AST_Assign
  16227. && assign.operator == "="
  16228. && (sym = assign.left) instanceof AST_Symbol
  16229. && vars.has(sym.name)
  16230. ) {
  16231. var def = vars.get(sym.name);
  16232. if (def.value) break;
  16233. def.value = assign.right;
  16234. remove(defs, def);
  16235. defs.push(def);
  16236. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  16237. continue;
  16238. }
  16239. }
  16240. if (self.body[i] instanceof AST_EmptyStatement) {
  16241. self.body.splice(i, 1);
  16242. continue;
  16243. }
  16244. if (self.body[i] instanceof AST_BlockStatement) {
  16245. self.body.splice(i, 1, ...self.body[i].body);
  16246. continue;
  16247. }
  16248. break;
  16249. }
  16250. defs = make_node(AST_Var, self, {
  16251. definitions: defs
  16252. });
  16253. hoisted.push(defs);
  16254. }
  16255. }
  16256. self.body = dirs.concat(hoisted, self.body);
  16257. }
  16258. return self;
  16259. });
  16260. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  16261. var self = this;
  16262. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  16263. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  16264. var defs_by_id = new Map();
  16265. var hoister = new TreeTransformer(function(node, descend) {
  16266. if (node instanceof AST_Definitions
  16267. && hoister.parent() instanceof AST_Export) return node;
  16268. if (node instanceof AST_VarDef) {
  16269. const sym = node.name;
  16270. let def;
  16271. let value;
  16272. if (sym.scope === self
  16273. && (def = sym.definition()).escaped != 1
  16274. && !def.assignments
  16275. && !def.direct_access
  16276. && !def.single_use
  16277. && !compressor.exposed(def)
  16278. && !top_retain(def)
  16279. && (value = sym.fixed_value()) === node.value
  16280. && value instanceof AST_Object
  16281. && !value.properties.some(prop =>
  16282. prop instanceof AST_Expansion || prop.computed_key()
  16283. )
  16284. ) {
  16285. descend(node, this);
  16286. const defs = new Map();
  16287. const assignments = [];
  16288. value.properties.forEach(({ key, value }) => {
  16289. const scope = hoister.find_scope();
  16290. const symbol = self.create_symbol(sym.CTOR, {
  16291. source: sym,
  16292. scope,
  16293. conflict_scopes: new Set([
  16294. scope,
  16295. ...sym.definition().references.map(ref => ref.scope)
  16296. ]),
  16297. tentative_name: sym.name + "_" + key
  16298. });
  16299. defs.set(String(key), symbol.definition());
  16300. assignments.push(make_node(AST_VarDef, node, {
  16301. name: symbol,
  16302. value
  16303. }));
  16304. });
  16305. defs_by_id.set(def.id, defs);
  16306. return MAP.splice(assignments);
  16307. }
  16308. } else if (node instanceof AST_PropAccess
  16309. && node.expression instanceof AST_SymbolRef
  16310. ) {
  16311. const defs = defs_by_id.get(node.expression.definition().id);
  16312. if (defs) {
  16313. const def = defs.get(String(get_simple_key(node.property)));
  16314. const sym = make_node(AST_SymbolRef, node, {
  16315. name: def.name,
  16316. scope: node.expression.scope,
  16317. thedef: def
  16318. });
  16319. sym.reference({});
  16320. return sym;
  16321. }
  16322. }
  16323. });
  16324. return self.transform(hoister);
  16325. });
  16326. def_optimize(AST_SimpleStatement, function(self, compressor) {
  16327. if (compressor.option("side_effects")) {
  16328. var body = self.body;
  16329. var node = body.drop_side_effect_free(compressor, true);
  16330. if (!node) {
  16331. return make_node(AST_EmptyStatement, self);
  16332. }
  16333. if (node !== body) {
  16334. return make_node(AST_SimpleStatement, self, { body: node });
  16335. }
  16336. }
  16337. return self;
  16338. });
  16339. def_optimize(AST_While, function(self, compressor) {
  16340. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  16341. });
  16342. def_optimize(AST_Do, function(self, compressor) {
  16343. if (!compressor.option("loops")) return self;
  16344. var cond = self.condition.tail_node().evaluate(compressor);
  16345. if (!(cond instanceof AST_Node)) {
  16346. if (cond) return make_node(AST_For, self, {
  16347. body: make_node(AST_BlockStatement, self.body, {
  16348. body: [
  16349. self.body,
  16350. make_node(AST_SimpleStatement, self.condition, {
  16351. body: self.condition
  16352. })
  16353. ]
  16354. })
  16355. }).optimize(compressor);
  16356. if (!has_break_or_continue(self, compressor.parent())) {
  16357. return make_node(AST_BlockStatement, self.body, {
  16358. body: [
  16359. self.body,
  16360. make_node(AST_SimpleStatement, self.condition, {
  16361. body: self.condition
  16362. })
  16363. ]
  16364. }).optimize(compressor);
  16365. }
  16366. }
  16367. return self;
  16368. });
  16369. function if_break_in_loop(self, compressor) {
  16370. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  16371. if (compressor.option("dead_code") && is_break(first)) {
  16372. var body = [];
  16373. if (self.init instanceof AST_Statement) {
  16374. body.push(self.init);
  16375. } else if (self.init) {
  16376. body.push(make_node(AST_SimpleStatement, self.init, {
  16377. body: self.init
  16378. }));
  16379. }
  16380. if (self.condition) {
  16381. body.push(make_node(AST_SimpleStatement, self.condition, {
  16382. body: self.condition
  16383. }));
  16384. }
  16385. trim_unreachable_code(compressor, self.body, body);
  16386. return make_node(AST_BlockStatement, self, {
  16387. body: body
  16388. });
  16389. }
  16390. if (first instanceof AST_If) {
  16391. if (is_break(first.body)) {
  16392. if (self.condition) {
  16393. self.condition = make_node(AST_Binary, self.condition, {
  16394. left: self.condition,
  16395. operator: "&&",
  16396. right: first.condition.negate(compressor),
  16397. });
  16398. } else {
  16399. self.condition = first.condition.negate(compressor);
  16400. }
  16401. drop_it(first.alternative);
  16402. } else if (is_break(first.alternative)) {
  16403. if (self.condition) {
  16404. self.condition = make_node(AST_Binary, self.condition, {
  16405. left: self.condition,
  16406. operator: "&&",
  16407. right: first.condition,
  16408. });
  16409. } else {
  16410. self.condition = first.condition;
  16411. }
  16412. drop_it(first.body);
  16413. }
  16414. }
  16415. return self;
  16416. function is_break(node) {
  16417. return node instanceof AST_Break
  16418. && compressor.loopcontrol_target(node) === compressor.self();
  16419. }
  16420. function drop_it(rest) {
  16421. rest = as_statement_array(rest);
  16422. if (self.body instanceof AST_BlockStatement) {
  16423. self.body = self.body.clone();
  16424. self.body.body = rest.concat(self.body.body.slice(1));
  16425. self.body = self.body.transform(compressor);
  16426. } else {
  16427. self.body = make_node(AST_BlockStatement, self.body, {
  16428. body: rest
  16429. }).transform(compressor);
  16430. }
  16431. self = if_break_in_loop(self, compressor);
  16432. }
  16433. }
  16434. def_optimize(AST_For, function(self, compressor) {
  16435. if (!compressor.option("loops")) return self;
  16436. if (compressor.option("side_effects") && self.init) {
  16437. self.init = self.init.drop_side_effect_free(compressor);
  16438. }
  16439. if (self.condition) {
  16440. var cond = self.condition.evaluate(compressor);
  16441. if (!(cond instanceof AST_Node)) {
  16442. if (cond) self.condition = null;
  16443. else if (!compressor.option("dead_code")) {
  16444. var orig = self.condition;
  16445. self.condition = make_node_from_constant(cond, self.condition);
  16446. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  16447. }
  16448. }
  16449. if (compressor.option("dead_code")) {
  16450. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  16451. if (!cond) {
  16452. var body = [];
  16453. trim_unreachable_code(compressor, self.body, body);
  16454. if (self.init instanceof AST_Statement) {
  16455. body.push(self.init);
  16456. } else if (self.init) {
  16457. body.push(make_node(AST_SimpleStatement, self.init, {
  16458. body: self.init
  16459. }));
  16460. }
  16461. body.push(make_node(AST_SimpleStatement, self.condition, {
  16462. body: self.condition
  16463. }));
  16464. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  16465. }
  16466. }
  16467. }
  16468. return if_break_in_loop(self, compressor);
  16469. });
  16470. def_optimize(AST_If, function(self, compressor) {
  16471. if (is_empty(self.alternative)) self.alternative = null;
  16472. if (!compressor.option("conditionals")) return self;
  16473. // if condition can be statically determined, drop
  16474. // one of the blocks. note, statically determined implies
  16475. // “has no side effects”; also it doesn't work for cases like
  16476. // `x && true`, though it probably should.
  16477. var cond = self.condition.evaluate(compressor);
  16478. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  16479. var orig = self.condition;
  16480. self.condition = make_node_from_constant(cond, orig);
  16481. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  16482. }
  16483. if (compressor.option("dead_code")) {
  16484. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  16485. if (!cond) {
  16486. var body = [];
  16487. trim_unreachable_code(compressor, self.body, body);
  16488. body.push(make_node(AST_SimpleStatement, self.condition, {
  16489. body: self.condition
  16490. }));
  16491. if (self.alternative) body.push(self.alternative);
  16492. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  16493. } else if (!(cond instanceof AST_Node)) {
  16494. var body = [];
  16495. body.push(make_node(AST_SimpleStatement, self.condition, {
  16496. body: self.condition
  16497. }));
  16498. body.push(self.body);
  16499. if (self.alternative) {
  16500. trim_unreachable_code(compressor, self.alternative, body);
  16501. }
  16502. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  16503. }
  16504. }
  16505. var negated = self.condition.negate(compressor);
  16506. var self_condition_length = self.condition.size();
  16507. var negated_length = negated.size();
  16508. var negated_is_best = negated_length < self_condition_length;
  16509. if (self.alternative && negated_is_best) {
  16510. negated_is_best = false; // because we already do the switch here.
  16511. // no need to swap values of self_condition_length and negated_length
  16512. // here because they are only used in an equality comparison later on.
  16513. self.condition = negated;
  16514. var tmp = self.body;
  16515. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  16516. self.alternative = tmp;
  16517. }
  16518. if (is_empty(self.body) && is_empty(self.alternative)) {
  16519. return make_node(AST_SimpleStatement, self.condition, {
  16520. body: self.condition.clone()
  16521. }).optimize(compressor);
  16522. }
  16523. if (self.body instanceof AST_SimpleStatement
  16524. && self.alternative instanceof AST_SimpleStatement) {
  16525. return make_node(AST_SimpleStatement, self, {
  16526. body: make_node(AST_Conditional, self, {
  16527. condition : self.condition,
  16528. consequent : self.body.body,
  16529. alternative : self.alternative.body
  16530. })
  16531. }).optimize(compressor);
  16532. }
  16533. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  16534. if (self_condition_length === negated_length && !negated_is_best
  16535. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  16536. // although the code length of self.condition and negated are the same,
  16537. // negated does not require additional surrounding parentheses.
  16538. // see https://github.com/mishoo/UglifyJS2/issues/979
  16539. negated_is_best = true;
  16540. }
  16541. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  16542. body: make_node(AST_Binary, self, {
  16543. operator : "||",
  16544. left : negated,
  16545. right : self.body.body
  16546. })
  16547. }).optimize(compressor);
  16548. return make_node(AST_SimpleStatement, self, {
  16549. body: make_node(AST_Binary, self, {
  16550. operator : "&&",
  16551. left : self.condition,
  16552. right : self.body.body
  16553. })
  16554. }).optimize(compressor);
  16555. }
  16556. if (self.body instanceof AST_EmptyStatement
  16557. && self.alternative instanceof AST_SimpleStatement) {
  16558. return make_node(AST_SimpleStatement, self, {
  16559. body: make_node(AST_Binary, self, {
  16560. operator : "||",
  16561. left : self.condition,
  16562. right : self.alternative.body
  16563. })
  16564. }).optimize(compressor);
  16565. }
  16566. if (self.body instanceof AST_Exit
  16567. && self.alternative instanceof AST_Exit
  16568. && self.body.TYPE == self.alternative.TYPE) {
  16569. return make_node(self.body.CTOR, self, {
  16570. value: make_node(AST_Conditional, self, {
  16571. condition : self.condition,
  16572. consequent : self.body.value || make_node(AST_Undefined, self.body),
  16573. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  16574. }).transform(compressor)
  16575. }).optimize(compressor);
  16576. }
  16577. if (self.body instanceof AST_If
  16578. && !self.body.alternative
  16579. && !self.alternative) {
  16580. self = make_node(AST_If, self, {
  16581. condition: make_node(AST_Binary, self.condition, {
  16582. operator: "&&",
  16583. left: self.condition,
  16584. right: self.body.condition
  16585. }),
  16586. body: self.body.body,
  16587. alternative: null
  16588. });
  16589. }
  16590. if (aborts(self.body)) {
  16591. if (self.alternative) {
  16592. var alt = self.alternative;
  16593. self.alternative = null;
  16594. return make_node(AST_BlockStatement, self, {
  16595. body: [ self, alt ]
  16596. }).optimize(compressor);
  16597. }
  16598. }
  16599. if (aborts(self.alternative)) {
  16600. var body = self.body;
  16601. self.body = self.alternative;
  16602. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  16603. self.alternative = null;
  16604. return make_node(AST_BlockStatement, self, {
  16605. body: [ self, body ]
  16606. }).optimize(compressor);
  16607. }
  16608. return self;
  16609. });
  16610. def_optimize(AST_Switch, function(self, compressor) {
  16611. if (!compressor.option("switches")) return self;
  16612. var branch;
  16613. var value = self.expression.evaluate(compressor);
  16614. if (!(value instanceof AST_Node)) {
  16615. var orig = self.expression;
  16616. self.expression = make_node_from_constant(value, orig);
  16617. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  16618. }
  16619. if (!compressor.option("dead_code")) return self;
  16620. if (value instanceof AST_Node) {
  16621. value = self.expression.tail_node().evaluate(compressor);
  16622. }
  16623. var decl = [];
  16624. var body = [];
  16625. var default_branch;
  16626. var exact_match;
  16627. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  16628. branch = self.body[i];
  16629. if (branch instanceof AST_Default) {
  16630. if (!default_branch) {
  16631. default_branch = branch;
  16632. } else {
  16633. eliminate_branch(branch, body[body.length - 1]);
  16634. }
  16635. } else if (!(value instanceof AST_Node)) {
  16636. var exp = branch.expression.evaluate(compressor);
  16637. if (!(exp instanceof AST_Node) && exp !== value) {
  16638. eliminate_branch(branch, body[body.length - 1]);
  16639. continue;
  16640. }
  16641. if (exp instanceof AST_Node) exp = branch.expression.tail_node().evaluate(compressor);
  16642. if (exp === value) {
  16643. exact_match = branch;
  16644. if (default_branch) {
  16645. var default_index = body.indexOf(default_branch);
  16646. body.splice(default_index, 1);
  16647. eliminate_branch(default_branch, body[default_index - 1]);
  16648. default_branch = null;
  16649. }
  16650. }
  16651. }
  16652. body.push(branch);
  16653. }
  16654. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  16655. self.body = body;
  16656. let default_or_exact = default_branch || exact_match;
  16657. default_branch = null;
  16658. exact_match = null;
  16659. // group equivalent branches so they will be located next to each other,
  16660. // that way the next micro-optimization will merge them.
  16661. // ** bail micro-optimization if not a simple switch case with breaks
  16662. if (body.every((branch, i) =>
  16663. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  16664. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  16665. ) {
  16666. for (let i = 0; i < body.length; i++) {
  16667. const branch = body[i];
  16668. for (let j = i + 1; j < body.length; j++) {
  16669. const next = body[j];
  16670. if (next.body.length === 0) continue;
  16671. const last_branch = j === (body.length - 1);
  16672. const equivalentBranch = branches_equivalent(next, branch, false);
  16673. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  16674. if (!equivalentBranch && last_branch) {
  16675. next.body.push(make_node(AST_Break));
  16676. }
  16677. // let's find previous siblings with inert fallthrough...
  16678. let x = j - 1;
  16679. let fallthroughDepth = 0;
  16680. while (x > i) {
  16681. if (is_inert_body(body[x--])) {
  16682. fallthroughDepth++;
  16683. } else {
  16684. break;
  16685. }
  16686. }
  16687. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  16688. body.splice(i + 1, 0, ...plucked);
  16689. i += plucked.length;
  16690. }
  16691. }
  16692. }
  16693. }
  16694. // merge equivalent branches in a row
  16695. for (let i = 0; i < body.length; i++) {
  16696. let branch = body[i];
  16697. if (branch.body.length === 0) continue;
  16698. if (!aborts(branch)) continue;
  16699. for (let j = i + 1; j < body.length; i++, j++) {
  16700. let next = body[j];
  16701. if (next.body.length === 0) continue;
  16702. if (
  16703. branches_equivalent(next, branch, false)
  16704. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  16705. ) {
  16706. branch.body = [];
  16707. branch = next;
  16708. continue;
  16709. }
  16710. break;
  16711. }
  16712. }
  16713. // Prune any empty branches at the end of the switch statement.
  16714. {
  16715. let i = body.length - 1;
  16716. for (; i >= 0; i--) {
  16717. let bbody = body[i].body;
  16718. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  16719. if (!is_inert_body(body[i])) break;
  16720. }
  16721. // i now points to the index of a branch that contains a body. By incrementing, it's
  16722. // pointing to the first branch that's empty.
  16723. i++;
  16724. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  16725. // The default behavior is to do nothing. We can take advantage of that to
  16726. // remove all case expressions that are side-effect free that also do
  16727. // nothing, since they'll default to doing nothing. But we can't remove any
  16728. // case expressions before one that would side-effect, since they may cause
  16729. // the side-effect to be skipped.
  16730. for (let j = body.length - 1; j >= i; j--) {
  16731. let branch = body[j];
  16732. if (branch === default_or_exact) {
  16733. default_or_exact = null;
  16734. body.pop();
  16735. } else if (!branch.expression.has_side_effects(compressor)) {
  16736. body.pop();
  16737. } else {
  16738. break;
  16739. }
  16740. }
  16741. }
  16742. }
  16743. // Prune side-effect free branches that fall into default.
  16744. DEFAULT: if (default_or_exact) {
  16745. let default_index = body.indexOf(default_or_exact);
  16746. let default_body_index = default_index;
  16747. for (; default_body_index < body.length - 1; default_body_index++) {
  16748. if (!is_inert_body(body[default_body_index])) break;
  16749. }
  16750. if (default_body_index < body.length - 1) {
  16751. break DEFAULT;
  16752. }
  16753. let side_effect_index = body.length - 1;
  16754. for (; side_effect_index >= 0; side_effect_index--) {
  16755. let branch = body[side_effect_index];
  16756. if (branch === default_or_exact) continue;
  16757. if (branch.expression.has_side_effects(compressor)) break;
  16758. }
  16759. // If the default behavior comes after any side-effect case expressions,
  16760. // then we can fold all side-effect free cases into the default branch.
  16761. // If the side-effect case is after the default, then any side-effect
  16762. // free cases could prevent the side-effect from occurring.
  16763. if (default_body_index > side_effect_index) {
  16764. let prev_body_index = default_index - 1;
  16765. for (; prev_body_index >= 0; prev_body_index--) {
  16766. if (!is_inert_body(body[prev_body_index])) break;
  16767. }
  16768. let before = Math.max(side_effect_index, prev_body_index) + 1;
  16769. let after = default_index;
  16770. if (side_effect_index > default_index) {
  16771. // If the default falls into the same body as a side-effect
  16772. // case, then we need preserve that case and only prune the
  16773. // cases after it.
  16774. after = side_effect_index;
  16775. body[side_effect_index].body = body[default_body_index].body;
  16776. } else {
  16777. // The default will be the last branch.
  16778. default_or_exact.body = body[default_body_index].body;
  16779. }
  16780. // Prune everything after the default (or last side-effect case)
  16781. // until the next case with a body.
  16782. body.splice(after + 1, default_body_index - after);
  16783. // Prune everything before the default that falls into it.
  16784. body.splice(before, default_index - before);
  16785. }
  16786. }
  16787. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  16788. DEFAULT: if (default_or_exact) {
  16789. let i = body.findIndex(branch => !is_inert_body(branch));
  16790. let caseBody;
  16791. // `i` is equal to one of the following:
  16792. // - `-1`, there is no body in the switch statement.
  16793. // - `body.length - 1`, all cases fall into the same body.
  16794. // - anything else, there are multiple bodies in the switch.
  16795. if (i === body.length - 1) {
  16796. // All cases fall into the case body.
  16797. let branch = body[i];
  16798. if (has_nested_break(self)) break DEFAULT;
  16799. // This is the last case body, and we've already pruned any breaks, so it's
  16800. // safe to hoist.
  16801. caseBody = make_node(AST_BlockStatement, branch, {
  16802. body: branch.body
  16803. });
  16804. branch.body = [];
  16805. } else if (i !== -1) {
  16806. // If there are multiple bodies, then we cannot optimize anything.
  16807. break DEFAULT;
  16808. }
  16809. let sideEffect = body.find(branch => {
  16810. return (
  16811. branch !== default_or_exact
  16812. && branch.expression.has_side_effects(compressor)
  16813. );
  16814. });
  16815. // If no cases cause a side-effect, we can eliminate the switch entirely.
  16816. if (!sideEffect) {
  16817. return make_node(AST_BlockStatement, self, {
  16818. body: decl.concat(
  16819. statement(self.expression),
  16820. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  16821. caseBody || []
  16822. )
  16823. }).optimize(compressor);
  16824. }
  16825. // If we're this far, either there was no body or all cases fell into the same body.
  16826. // If there was no body, then we don't need a default branch (because the default is
  16827. // do nothing). If there was a body, we'll extract it to after the switch, so the
  16828. // switch's new default is to do nothing and we can still prune it.
  16829. const default_index = body.indexOf(default_or_exact);
  16830. body.splice(default_index, 1);
  16831. default_or_exact = null;
  16832. if (caseBody) {
  16833. // Recurse into switch statement one more time so that we can append the case body
  16834. // outside of the switch. This recursion will only happen once since we've pruned
  16835. // the default case.
  16836. return make_node(AST_BlockStatement, self, {
  16837. body: decl.concat(self, caseBody)
  16838. }).optimize(compressor);
  16839. }
  16840. // If we fall here, there is a default branch somewhere, there are no case bodies,
  16841. // and there's a side-effect somewhere. Just let the below paths take care of it.
  16842. }
  16843. if (body.length > 0) {
  16844. body[0].body = decl.concat(body[0].body);
  16845. }
  16846. if (body.length == 0) {
  16847. return make_node(AST_BlockStatement, self, {
  16848. body: decl.concat(statement(self.expression))
  16849. }).optimize(compressor);
  16850. }
  16851. if (body.length == 1 && !has_nested_break(self)) {
  16852. // This is the last case body, and we've already pruned any breaks, so it's
  16853. // safe to hoist.
  16854. let branch = body[0];
  16855. return make_node(AST_If, self, {
  16856. condition: make_node(AST_Binary, self, {
  16857. operator: "===",
  16858. left: self.expression,
  16859. right: branch.expression,
  16860. }),
  16861. body: make_node(AST_BlockStatement, branch, {
  16862. body: branch.body
  16863. }),
  16864. alternative: null
  16865. }).optimize(compressor);
  16866. }
  16867. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  16868. let branch = body[0] === default_or_exact ? body[1] : body[0];
  16869. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  16870. if (aborts(body[0])) {
  16871. // Only the first branch body could have a break (at the last statement)
  16872. let first = body[0];
  16873. if (is_break(first.body[first.body.length - 1], compressor)) {
  16874. first.body.pop();
  16875. }
  16876. return make_node(AST_If, self, {
  16877. condition: make_node(AST_Binary, self, {
  16878. operator: "===",
  16879. left: self.expression,
  16880. right: branch.expression,
  16881. }),
  16882. body: make_node(AST_BlockStatement, branch, {
  16883. body: branch.body
  16884. }),
  16885. alternative: make_node(AST_BlockStatement, default_or_exact, {
  16886. body: [].concat(
  16887. exact_exp || [],
  16888. default_or_exact.body
  16889. )
  16890. })
  16891. }).optimize(compressor);
  16892. }
  16893. let operator = "===";
  16894. let consequent = make_node(AST_BlockStatement, branch, {
  16895. body: branch.body,
  16896. });
  16897. let always = make_node(AST_BlockStatement, default_or_exact, {
  16898. body: [].concat(
  16899. exact_exp || [],
  16900. default_or_exact.body
  16901. )
  16902. });
  16903. if (body[0] === default_or_exact) {
  16904. operator = "!==";
  16905. let tmp = always;
  16906. always = consequent;
  16907. consequent = tmp;
  16908. }
  16909. return make_node(AST_BlockStatement, self, {
  16910. body: [
  16911. make_node(AST_If, self, {
  16912. condition: make_node(AST_Binary, self, {
  16913. operator: operator,
  16914. left: self.expression,
  16915. right: branch.expression,
  16916. }),
  16917. body: consequent,
  16918. alternative: null
  16919. })
  16920. ].concat(always)
  16921. }).optimize(compressor);
  16922. }
  16923. return self;
  16924. function eliminate_branch(branch, prev) {
  16925. if (prev && !aborts(prev)) {
  16926. prev.body = prev.body.concat(branch.body);
  16927. } else {
  16928. trim_unreachable_code(compressor, branch, decl);
  16929. }
  16930. }
  16931. function branches_equivalent(branch, prev, insertBreak) {
  16932. let bbody = branch.body;
  16933. let pbody = prev.body;
  16934. if (insertBreak) {
  16935. bbody = bbody.concat(make_node(AST_Break));
  16936. }
  16937. if (bbody.length !== pbody.length) return false;
  16938. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  16939. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  16940. return bblock.equivalent_to(pblock);
  16941. }
  16942. function statement(expression) {
  16943. return make_node(AST_SimpleStatement, expression, {
  16944. body: expression
  16945. });
  16946. }
  16947. function has_nested_break(root) {
  16948. let has_break = false;
  16949. let tw = new TreeWalker(node => {
  16950. if (has_break) return true;
  16951. if (node instanceof AST_Lambda) return true;
  16952. if (node instanceof AST_SimpleStatement) return true;
  16953. if (!is_break(node, tw)) return;
  16954. let parent = tw.parent();
  16955. if (
  16956. parent instanceof AST_SwitchBranch
  16957. && parent.body[parent.body.length - 1] === node
  16958. ) {
  16959. return;
  16960. }
  16961. has_break = true;
  16962. });
  16963. root.walk(tw);
  16964. return has_break;
  16965. }
  16966. function is_break(node, stack) {
  16967. return node instanceof AST_Break
  16968. && stack.loopcontrol_target(node) === self;
  16969. }
  16970. function is_inert_body(branch) {
  16971. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  16972. body: branch.body
  16973. }).has_side_effects(compressor);
  16974. }
  16975. });
  16976. def_optimize(AST_Try, function(self, compressor) {
  16977. tighten_body(self.body, compressor);
  16978. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  16979. if (compressor.option("dead_code") && self.body.every(is_empty)) {
  16980. var body = [];
  16981. if (self.bcatch) {
  16982. trim_unreachable_code(compressor, self.bcatch, body);
  16983. }
  16984. if (self.bfinally) body.push(...self.bfinally.body);
  16985. return make_node(AST_BlockStatement, self, {
  16986. body: body
  16987. }).optimize(compressor);
  16988. }
  16989. return self;
  16990. });
  16991. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  16992. var decls = [];
  16993. this.definitions.forEach(function(def) {
  16994. if (def.name instanceof AST_SymbolDeclaration) {
  16995. def.value = null;
  16996. decls.push(def);
  16997. } else {
  16998. walk(def.name, node => {
  16999. if (node instanceof AST_SymbolDeclaration) {
  17000. decls.push(make_node(AST_VarDef, def, {
  17001. name: node,
  17002. value: null
  17003. }));
  17004. }
  17005. });
  17006. }
  17007. });
  17008. this.definitions = decls;
  17009. });
  17010. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  17011. var reduce_vars = compressor.option("reduce_vars");
  17012. var assignments = [];
  17013. for (const def of this.definitions) {
  17014. if (def.value) {
  17015. var name = make_node(AST_SymbolRef, def.name, def.name);
  17016. assignments.push(make_node(AST_Assign, def, {
  17017. operator : "=",
  17018. logical: false,
  17019. left : name,
  17020. right : def.value
  17021. }));
  17022. if (reduce_vars) name.definition().fixed = false;
  17023. } else if (def.value) {
  17024. // Because it's a destructuring, do not turn into an assignment.
  17025. var varDef = make_node(AST_VarDef, def, {
  17026. name: def.name,
  17027. value: def.value
  17028. });
  17029. var var_ = make_node(AST_Var, def, {
  17030. definitions: [ varDef ]
  17031. });
  17032. assignments.push(var_);
  17033. }
  17034. const thedef = def.name.definition();
  17035. thedef.eliminated++;
  17036. thedef.replaced--;
  17037. }
  17038. if (assignments.length == 0) return null;
  17039. return make_sequence(this, assignments);
  17040. });
  17041. def_optimize(AST_Definitions, function(self) {
  17042. if (self.definitions.length == 0)
  17043. return make_node(AST_EmptyStatement, self);
  17044. return self;
  17045. });
  17046. def_optimize(AST_VarDef, function(self, compressor) {
  17047. if (
  17048. self.name instanceof AST_SymbolLet
  17049. && self.value != null
  17050. && is_undefined(self.value, compressor)
  17051. ) {
  17052. self.value = null;
  17053. }
  17054. return self;
  17055. });
  17056. def_optimize(AST_Import, function(self) {
  17057. return self;
  17058. });
  17059. def_optimize(AST_Call, function(self, compressor) {
  17060. var exp = self.expression;
  17061. var fn = exp;
  17062. inline_array_like_spread(self.args);
  17063. var simple_args = self.args.every((arg) =>
  17064. !(arg instanceof AST_Expansion)
  17065. );
  17066. if (compressor.option("reduce_vars")
  17067. && fn instanceof AST_SymbolRef
  17068. && !has_annotation(self, _NOINLINE)
  17069. ) {
  17070. const fixed = fn.fixed_value();
  17071. if (!retain_top_func(fixed, compressor)) {
  17072. fn = fixed;
  17073. }
  17074. }
  17075. var is_func = fn instanceof AST_Lambda;
  17076. if (is_func && fn.pinned()) return self;
  17077. if (compressor.option("unused")
  17078. && simple_args
  17079. && is_func
  17080. && !fn.uses_arguments) {
  17081. var pos = 0, last = 0;
  17082. for (var i = 0, len = self.args.length; i < len; i++) {
  17083. if (fn.argnames[i] instanceof AST_Expansion) {
  17084. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  17085. var node = self.args[i++].drop_side_effect_free(compressor);
  17086. if (node) {
  17087. self.args[pos++] = node;
  17088. }
  17089. } else while (i < len) {
  17090. self.args[pos++] = self.args[i++];
  17091. }
  17092. last = pos;
  17093. break;
  17094. }
  17095. var trim = i >= fn.argnames.length;
  17096. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  17097. var node = self.args[i].drop_side_effect_free(compressor);
  17098. if (node) {
  17099. self.args[pos++] = node;
  17100. } else if (!trim) {
  17101. self.args[pos++] = make_node(AST_Number, self.args[i], {
  17102. value: 0
  17103. });
  17104. continue;
  17105. }
  17106. } else {
  17107. self.args[pos++] = self.args[i];
  17108. }
  17109. last = pos;
  17110. }
  17111. self.args.length = last;
  17112. }
  17113. if (compressor.option("unsafe")) {
  17114. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  17115. const [argument] = self.args;
  17116. if (argument instanceof AST_Array) {
  17117. return make_node(AST_Array, argument, {
  17118. elements: argument.elements
  17119. }).optimize(compressor);
  17120. }
  17121. }
  17122. if (is_undeclared_ref(exp)) switch (exp.name) {
  17123. case "Array":
  17124. if (self.args.length != 1) {
  17125. return make_node(AST_Array, self, {
  17126. elements: self.args
  17127. }).optimize(compressor);
  17128. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  17129. const elements = [];
  17130. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  17131. return new AST_Array({ elements });
  17132. }
  17133. break;
  17134. case "Object":
  17135. if (self.args.length == 0) {
  17136. return make_node(AST_Object, self, {
  17137. properties: []
  17138. });
  17139. }
  17140. break;
  17141. case "String":
  17142. if (self.args.length == 0) return make_node(AST_String, self, {
  17143. value: ""
  17144. });
  17145. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  17146. left: self.args[0],
  17147. operator: "+",
  17148. right: make_node(AST_String, self, { value: "" })
  17149. }).optimize(compressor);
  17150. break;
  17151. case "Number":
  17152. if (self.args.length == 0) return make_node(AST_Number, self, {
  17153. value: 0
  17154. });
  17155. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  17156. return make_node(AST_UnaryPrefix, self, {
  17157. expression: self.args[0],
  17158. operator: "+"
  17159. }).optimize(compressor);
  17160. }
  17161. break;
  17162. case "Symbol":
  17163. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  17164. self.args.length = 0;
  17165. break;
  17166. case "Boolean":
  17167. if (self.args.length == 0) return make_node(AST_False, self);
  17168. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  17169. expression: make_node(AST_UnaryPrefix, self, {
  17170. expression: self.args[0],
  17171. operator: "!"
  17172. }),
  17173. operator: "!"
  17174. }).optimize(compressor);
  17175. break;
  17176. case "RegExp":
  17177. var params = [];
  17178. if (self.args.length >= 1
  17179. && self.args.length <= 2
  17180. && self.args.every((arg) => {
  17181. var value = arg.evaluate(compressor);
  17182. params.push(value);
  17183. return arg !== value;
  17184. })
  17185. ) {
  17186. let [ source, flags ] = params;
  17187. source = regexp_source_fix(new RegExp(source).source);
  17188. const rx = make_node(AST_RegExp, self, {
  17189. value: { source, flags }
  17190. });
  17191. if (rx._eval(compressor) !== rx) {
  17192. return rx;
  17193. }
  17194. }
  17195. break;
  17196. } else if (exp instanceof AST_Dot) switch(exp.property) {
  17197. case "toString":
  17198. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  17199. return make_node(AST_Binary, self, {
  17200. left: make_node(AST_String, self, { value: "" }),
  17201. operator: "+",
  17202. right: exp.expression
  17203. }).optimize(compressor);
  17204. }
  17205. break;
  17206. case "join":
  17207. if (exp.expression instanceof AST_Array) EXIT: {
  17208. var separator;
  17209. if (self.args.length > 0) {
  17210. separator = self.args[0].evaluate(compressor);
  17211. if (separator === self.args[0]) break EXIT; // not a constant
  17212. }
  17213. var elements = [];
  17214. var consts = [];
  17215. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  17216. var el = exp.expression.elements[i];
  17217. if (el instanceof AST_Expansion) break EXIT;
  17218. var value = el.evaluate(compressor);
  17219. if (value !== el) {
  17220. consts.push(value);
  17221. } else {
  17222. if (consts.length > 0) {
  17223. elements.push(make_node(AST_String, self, {
  17224. value: consts.join(separator)
  17225. }));
  17226. consts.length = 0;
  17227. }
  17228. elements.push(el);
  17229. }
  17230. }
  17231. if (consts.length > 0) {
  17232. elements.push(make_node(AST_String, self, {
  17233. value: consts.join(separator)
  17234. }));
  17235. }
  17236. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  17237. if (elements.length == 1) {
  17238. if (elements[0].is_string(compressor)) {
  17239. return elements[0];
  17240. }
  17241. return make_node(AST_Binary, elements[0], {
  17242. operator : "+",
  17243. left : make_node(AST_String, self, { value: "" }),
  17244. right : elements[0]
  17245. });
  17246. }
  17247. if (separator == "") {
  17248. var first;
  17249. if (elements[0].is_string(compressor)
  17250. || elements[1].is_string(compressor)) {
  17251. first = elements.shift();
  17252. } else {
  17253. first = make_node(AST_String, self, { value: "" });
  17254. }
  17255. return elements.reduce(function(prev, el) {
  17256. return make_node(AST_Binary, el, {
  17257. operator : "+",
  17258. left : prev,
  17259. right : el
  17260. });
  17261. }, first).optimize(compressor);
  17262. }
  17263. // need this awkward cloning to not affect original element
  17264. // best_of will decide which one to get through.
  17265. var node = self.clone();
  17266. node.expression = node.expression.clone();
  17267. node.expression.expression = node.expression.expression.clone();
  17268. node.expression.expression.elements = elements;
  17269. return best_of(compressor, self, node);
  17270. }
  17271. break;
  17272. case "charAt":
  17273. if (exp.expression.is_string(compressor)) {
  17274. var arg = self.args[0];
  17275. var index = arg ? arg.evaluate(compressor) : 0;
  17276. if (index !== arg) {
  17277. return make_node(AST_Sub, exp, {
  17278. expression: exp.expression,
  17279. property: make_node_from_constant(index | 0, arg || exp)
  17280. }).optimize(compressor);
  17281. }
  17282. }
  17283. break;
  17284. case "apply":
  17285. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  17286. var args = self.args[1].elements.slice();
  17287. args.unshift(self.args[0]);
  17288. return make_node(AST_Call, self, {
  17289. expression: make_node(AST_Dot, exp, {
  17290. expression: exp.expression,
  17291. optional: false,
  17292. property: "call"
  17293. }),
  17294. args: args
  17295. }).optimize(compressor);
  17296. }
  17297. break;
  17298. case "call":
  17299. var func = exp.expression;
  17300. if (func instanceof AST_SymbolRef) {
  17301. func = func.fixed_value();
  17302. }
  17303. if (func instanceof AST_Lambda && !func.contains_this()) {
  17304. return (self.args.length ? make_sequence(this, [
  17305. self.args[0],
  17306. make_node(AST_Call, self, {
  17307. expression: exp.expression,
  17308. args: self.args.slice(1)
  17309. })
  17310. ]) : make_node(AST_Call, self, {
  17311. expression: exp.expression,
  17312. args: []
  17313. })).optimize(compressor);
  17314. }
  17315. break;
  17316. }
  17317. }
  17318. if (compressor.option("unsafe_Function")
  17319. && is_undeclared_ref(exp)
  17320. && exp.name == "Function") {
  17321. // new Function() => function(){}
  17322. if (self.args.length == 0) return make_node(AST_Function, self, {
  17323. argnames: [],
  17324. body: []
  17325. }).optimize(compressor);
  17326. var nth_identifier = compressor.mangle_options && compressor.mangle_options.nth_identifier || base54;
  17327. if (self.args.every((x) => x instanceof AST_String)) {
  17328. // quite a corner-case, but we can handle it:
  17329. // https://github.com/mishoo/UglifyJS2/issues/203
  17330. // if the code argument is a constant, then we can minify it.
  17331. try {
  17332. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  17333. return arg.value;
  17334. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  17335. var ast = parse(code);
  17336. var mangle = { ie8: compressor.option("ie8"), nth_identifier: nth_identifier };
  17337. ast.figure_out_scope(mangle);
  17338. var comp = new Compressor(compressor.options, {
  17339. mangle_options: compressor.mangle_options
  17340. });
  17341. ast = ast.transform(comp);
  17342. ast.figure_out_scope(mangle);
  17343. ast.compute_char_frequency(mangle);
  17344. ast.mangle_names(mangle);
  17345. var fun;
  17346. walk(ast, node => {
  17347. if (is_func_expr(node)) {
  17348. fun = node;
  17349. return walk_abort;
  17350. }
  17351. });
  17352. var code = OutputStream();
  17353. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  17354. self.args = [
  17355. make_node(AST_String, self, {
  17356. value: fun.argnames.map(function(arg) {
  17357. return arg.print_to_string();
  17358. }).join(",")
  17359. }),
  17360. make_node(AST_String, self.args[self.args.length - 1], {
  17361. value: code.get().replace(/^{|}$/g, "")
  17362. })
  17363. ];
  17364. return self;
  17365. } catch (ex) {
  17366. if (!(ex instanceof JS_Parse_Error)) {
  17367. throw ex;
  17368. }
  17369. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  17370. }
  17371. }
  17372. }
  17373. return inline_into_call(self, fn, compressor);
  17374. });
  17375. def_optimize(AST_New, function(self, compressor) {
  17376. if (
  17377. compressor.option("unsafe") &&
  17378. is_undeclared_ref(self.expression) &&
  17379. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  17380. ) return make_node(AST_Call, self, self).transform(compressor);
  17381. return self;
  17382. });
  17383. def_optimize(AST_Sequence, function(self, compressor) {
  17384. if (!compressor.option("side_effects")) return self;
  17385. var expressions = [];
  17386. filter_for_side_effects();
  17387. var end = expressions.length - 1;
  17388. trim_right_for_undefined();
  17389. if (end == 0) {
  17390. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  17391. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  17392. return self;
  17393. }
  17394. self.expressions = expressions;
  17395. return self;
  17396. function filter_for_side_effects() {
  17397. var first = first_in_statement(compressor);
  17398. var last = self.expressions.length - 1;
  17399. self.expressions.forEach(function(expr, index) {
  17400. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  17401. if (expr) {
  17402. merge_sequence(expressions, expr);
  17403. first = false;
  17404. }
  17405. });
  17406. }
  17407. function trim_right_for_undefined() {
  17408. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  17409. if (end < expressions.length - 1) {
  17410. expressions[end] = make_node(AST_UnaryPrefix, self, {
  17411. operator : "void",
  17412. expression : expressions[end]
  17413. });
  17414. expressions.length = end + 1;
  17415. }
  17416. }
  17417. });
  17418. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  17419. if (compressor.option("sequences")) {
  17420. if (this.expression instanceof AST_Sequence) {
  17421. var x = this.expression.expressions.slice();
  17422. var e = this.clone();
  17423. e.expression = x.pop();
  17424. x.push(e);
  17425. return make_sequence(this, x).optimize(compressor);
  17426. }
  17427. }
  17428. return this;
  17429. });
  17430. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  17431. return self.lift_sequences(compressor);
  17432. });
  17433. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  17434. var e = self.expression;
  17435. if (
  17436. self.operator == "delete" &&
  17437. !(
  17438. e instanceof AST_SymbolRef ||
  17439. e instanceof AST_PropAccess ||
  17440. e instanceof AST_Chain ||
  17441. is_identifier_atom(e)
  17442. )
  17443. ) {
  17444. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  17445. }
  17446. var seq = self.lift_sequences(compressor);
  17447. if (seq !== self) {
  17448. return seq;
  17449. }
  17450. if (compressor.option("side_effects") && self.operator == "void") {
  17451. e = e.drop_side_effect_free(compressor);
  17452. if (e) {
  17453. self.expression = e;
  17454. return self;
  17455. } else {
  17456. return make_node(AST_Undefined, self).optimize(compressor);
  17457. }
  17458. }
  17459. if (compressor.in_boolean_context()) {
  17460. switch (self.operator) {
  17461. case "!":
  17462. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  17463. // !!foo ==> foo, if we're in boolean context
  17464. return e.expression;
  17465. }
  17466. if (e instanceof AST_Binary) {
  17467. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  17468. }
  17469. break;
  17470. case "typeof":
  17471. // typeof always returns a non-empty string, thus it's
  17472. // always true in booleans
  17473. // And we don't need to check if it's undeclared, because in typeof, that's OK
  17474. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  17475. e,
  17476. make_node(AST_True, self)
  17477. ])).optimize(compressor);
  17478. }
  17479. }
  17480. if (self.operator == "-" && e instanceof AST_Infinity) {
  17481. e = e.transform(compressor);
  17482. }
  17483. if (e instanceof AST_Binary
  17484. && (self.operator == "+" || self.operator == "-")
  17485. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  17486. return make_node(AST_Binary, self, {
  17487. operator: e.operator,
  17488. left: make_node(AST_UnaryPrefix, e.left, {
  17489. operator: self.operator,
  17490. expression: e.left
  17491. }),
  17492. right: e.right
  17493. });
  17494. }
  17495. // avoids infinite recursion of numerals
  17496. if (self.operator != "-"
  17497. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)) {
  17498. var ev = self.evaluate(compressor);
  17499. if (ev !== self) {
  17500. ev = make_node_from_constant(ev, self).optimize(compressor);
  17501. return best_of(compressor, ev, self);
  17502. }
  17503. }
  17504. return self;
  17505. });
  17506. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  17507. if (compressor.option("sequences")) {
  17508. if (this.left instanceof AST_Sequence) {
  17509. var x = this.left.expressions.slice();
  17510. var e = this.clone();
  17511. e.left = x.pop();
  17512. x.push(e);
  17513. return make_sequence(this, x).optimize(compressor);
  17514. }
  17515. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  17516. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  17517. var x = this.right.expressions;
  17518. var last = x.length - 1;
  17519. for (var i = 0; i < last; i++) {
  17520. if (!assign && x[i].has_side_effects(compressor)) break;
  17521. }
  17522. if (i == last) {
  17523. x = x.slice();
  17524. var e = this.clone();
  17525. e.right = x.pop();
  17526. x.push(e);
  17527. return make_sequence(this, x).optimize(compressor);
  17528. } else if (i > 0) {
  17529. var e = this.clone();
  17530. e.right = make_sequence(this.right, x.slice(i));
  17531. x = x.slice(0, i);
  17532. x.push(e);
  17533. return make_sequence(this, x).optimize(compressor);
  17534. }
  17535. }
  17536. }
  17537. return this;
  17538. });
  17539. var commutativeOperators = makePredicate("== === != !== * & | ^");
  17540. function is_object(node) {
  17541. return node instanceof AST_Array
  17542. || node instanceof AST_Lambda
  17543. || node instanceof AST_Object
  17544. || node instanceof AST_Class;
  17545. }
  17546. def_optimize(AST_Binary, function(self, compressor) {
  17547. function reversible() {
  17548. return self.left.is_constant()
  17549. || self.right.is_constant()
  17550. || !self.left.has_side_effects(compressor)
  17551. && !self.right.has_side_effects(compressor);
  17552. }
  17553. function reverse(op) {
  17554. if (reversible()) {
  17555. if (op) self.operator = op;
  17556. var tmp = self.left;
  17557. self.left = self.right;
  17558. self.right = tmp;
  17559. }
  17560. }
  17561. if (commutativeOperators.has(self.operator)) {
  17562. if (self.right.is_constant()
  17563. && !self.left.is_constant()) {
  17564. // if right is a constant, whatever side effects the
  17565. // left side might have could not influence the
  17566. // result. hence, force switch.
  17567. if (!(self.left instanceof AST_Binary
  17568. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  17569. reverse();
  17570. }
  17571. }
  17572. }
  17573. self = self.lift_sequences(compressor);
  17574. if (compressor.option("comparisons")) switch (self.operator) {
  17575. case "===":
  17576. case "!==":
  17577. var is_strict_comparison = true;
  17578. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  17579. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  17580. (self.left.is_boolean() && self.right.is_boolean()) ||
  17581. self.left.equivalent_to(self.right)) {
  17582. self.operator = self.operator.substr(0, 2);
  17583. }
  17584. // XXX: intentionally falling down to the next case
  17585. case "==":
  17586. case "!=":
  17587. // void 0 == x => null == x
  17588. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  17589. self.left = make_node(AST_Null, self.left);
  17590. } else if (compressor.option("typeofs")
  17591. // "undefined" == typeof x => undefined === x
  17592. && self.left instanceof AST_String
  17593. && self.left.value == "undefined"
  17594. && self.right instanceof AST_UnaryPrefix
  17595. && self.right.operator == "typeof") {
  17596. var expr = self.right.expression;
  17597. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  17598. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  17599. self.right = expr;
  17600. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  17601. if (self.operator.length == 2) self.operator += "=";
  17602. }
  17603. } else if (self.left instanceof AST_SymbolRef
  17604. // obj !== obj => false
  17605. && self.right instanceof AST_SymbolRef
  17606. && self.left.definition() === self.right.definition()
  17607. && is_object(self.left.fixed_value())) {
  17608. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  17609. }
  17610. break;
  17611. case "&&":
  17612. case "||":
  17613. var lhs = self.left;
  17614. if (lhs.operator == self.operator) {
  17615. lhs = lhs.right;
  17616. }
  17617. if (lhs instanceof AST_Binary
  17618. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  17619. && self.right instanceof AST_Binary
  17620. && lhs.operator == self.right.operator
  17621. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  17622. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  17623. && !lhs.right.has_side_effects(compressor)
  17624. && lhs.right.equivalent_to(self.right.right)) {
  17625. var combined = make_node(AST_Binary, self, {
  17626. operator: lhs.operator.slice(0, -1),
  17627. left: make_node(AST_Null, self),
  17628. right: lhs.right
  17629. });
  17630. if (lhs !== self.left) {
  17631. combined = make_node(AST_Binary, self, {
  17632. operator: self.operator,
  17633. left: self.left.left,
  17634. right: combined
  17635. });
  17636. }
  17637. return combined;
  17638. }
  17639. break;
  17640. }
  17641. if (self.operator == "+" && compressor.in_boolean_context()) {
  17642. var ll = self.left.evaluate(compressor);
  17643. var rr = self.right.evaluate(compressor);
  17644. if (ll && typeof ll == "string") {
  17645. return make_sequence(self, [
  17646. self.right,
  17647. make_node(AST_True, self)
  17648. ]).optimize(compressor);
  17649. }
  17650. if (rr && typeof rr == "string") {
  17651. return make_sequence(self, [
  17652. self.left,
  17653. make_node(AST_True, self)
  17654. ]).optimize(compressor);
  17655. }
  17656. }
  17657. if (compressor.option("comparisons") && self.is_boolean()) {
  17658. if (!(compressor.parent() instanceof AST_Binary)
  17659. || compressor.parent() instanceof AST_Assign) {
  17660. var negated = make_node(AST_UnaryPrefix, self, {
  17661. operator: "!",
  17662. expression: self.negate(compressor, first_in_statement(compressor))
  17663. });
  17664. self = best_of(compressor, self, negated);
  17665. }
  17666. if (compressor.option("unsafe_comps")) {
  17667. switch (self.operator) {
  17668. case "<": reverse(">"); break;
  17669. case "<=": reverse(">="); break;
  17670. }
  17671. }
  17672. }
  17673. if (self.operator == "+") {
  17674. if (self.right instanceof AST_String
  17675. && self.right.getValue() == ""
  17676. && self.left.is_string(compressor)) {
  17677. return self.left;
  17678. }
  17679. if (self.left instanceof AST_String
  17680. && self.left.getValue() == ""
  17681. && self.right.is_string(compressor)) {
  17682. return self.right;
  17683. }
  17684. if (self.left instanceof AST_Binary
  17685. && self.left.operator == "+"
  17686. && self.left.left instanceof AST_String
  17687. && self.left.left.getValue() == ""
  17688. && self.right.is_string(compressor)) {
  17689. self.left = self.left.right;
  17690. return self;
  17691. }
  17692. }
  17693. if (compressor.option("evaluate")) {
  17694. switch (self.operator) {
  17695. case "&&":
  17696. var ll = has_flag(self.left, TRUTHY)
  17697. ? true
  17698. : has_flag(self.left, FALSY)
  17699. ? false
  17700. : self.left.evaluate(compressor);
  17701. if (!ll) {
  17702. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  17703. } else if (!(ll instanceof AST_Node)) {
  17704. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  17705. }
  17706. var rr = self.right.evaluate(compressor);
  17707. if (!rr) {
  17708. if (compressor.in_boolean_context()) {
  17709. return make_sequence(self, [
  17710. self.left,
  17711. make_node(AST_False, self)
  17712. ]).optimize(compressor);
  17713. } else {
  17714. set_flag(self, FALSY);
  17715. }
  17716. } else if (!(rr instanceof AST_Node)) {
  17717. var parent = compressor.parent();
  17718. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  17719. return self.left.optimize(compressor);
  17720. }
  17721. }
  17722. // x || false && y ---> x ? y : false
  17723. if (self.left.operator == "||") {
  17724. var lr = self.left.right.evaluate(compressor);
  17725. if (!lr) return make_node(AST_Conditional, self, {
  17726. condition: self.left.left,
  17727. consequent: self.right,
  17728. alternative: self.left.right
  17729. }).optimize(compressor);
  17730. }
  17731. break;
  17732. case "||":
  17733. var ll = has_flag(self.left, TRUTHY)
  17734. ? true
  17735. : has_flag(self.left, FALSY)
  17736. ? false
  17737. : self.left.evaluate(compressor);
  17738. if (!ll) {
  17739. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  17740. } else if (!(ll instanceof AST_Node)) {
  17741. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  17742. }
  17743. var rr = self.right.evaluate(compressor);
  17744. if (!rr) {
  17745. var parent = compressor.parent();
  17746. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  17747. return self.left.optimize(compressor);
  17748. }
  17749. } else if (!(rr instanceof AST_Node)) {
  17750. if (compressor.in_boolean_context()) {
  17751. return make_sequence(self, [
  17752. self.left,
  17753. make_node(AST_True, self)
  17754. ]).optimize(compressor);
  17755. } else {
  17756. set_flag(self, TRUTHY);
  17757. }
  17758. }
  17759. if (self.left.operator == "&&") {
  17760. var lr = self.left.right.evaluate(compressor);
  17761. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  17762. condition: self.left.left,
  17763. consequent: self.left.right,
  17764. alternative: self.right
  17765. }).optimize(compressor);
  17766. }
  17767. break;
  17768. case "??":
  17769. if (is_nullish(self.left, compressor)) {
  17770. return self.right;
  17771. }
  17772. var ll = self.left.evaluate(compressor);
  17773. if (!(ll instanceof AST_Node)) {
  17774. // if we know the value for sure we can simply compute right away.
  17775. return ll == null ? self.right : self.left;
  17776. }
  17777. if (compressor.in_boolean_context()) {
  17778. const rr = self.right.evaluate(compressor);
  17779. if (!(rr instanceof AST_Node) && !rr) {
  17780. return self.left;
  17781. }
  17782. }
  17783. }
  17784. var associative = true;
  17785. switch (self.operator) {
  17786. case "+":
  17787. // (x + "foo") + "bar" => x + "foobar"
  17788. if (self.right instanceof AST_Constant
  17789. && self.left instanceof AST_Binary
  17790. && self.left.operator == "+"
  17791. && self.left.is_string(compressor)) {
  17792. var binary = make_node(AST_Binary, self, {
  17793. operator: "+",
  17794. left: self.left.right,
  17795. right: self.right,
  17796. });
  17797. var r = binary.optimize(compressor);
  17798. if (binary !== r) {
  17799. self = make_node(AST_Binary, self, {
  17800. operator: "+",
  17801. left: self.left.left,
  17802. right: r
  17803. });
  17804. }
  17805. }
  17806. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  17807. if (self.left instanceof AST_Binary
  17808. && self.left.operator == "+"
  17809. && self.left.is_string(compressor)
  17810. && self.right instanceof AST_Binary
  17811. && self.right.operator == "+"
  17812. && self.right.is_string(compressor)) {
  17813. var binary = make_node(AST_Binary, self, {
  17814. operator: "+",
  17815. left: self.left.right,
  17816. right: self.right.left,
  17817. });
  17818. var m = binary.optimize(compressor);
  17819. if (binary !== m) {
  17820. self = make_node(AST_Binary, self, {
  17821. operator: "+",
  17822. left: make_node(AST_Binary, self.left, {
  17823. operator: "+",
  17824. left: self.left.left,
  17825. right: m
  17826. }),
  17827. right: self.right.right
  17828. });
  17829. }
  17830. }
  17831. // a + -b => a - b
  17832. if (self.right instanceof AST_UnaryPrefix
  17833. && self.right.operator == "-"
  17834. && self.left.is_number(compressor)) {
  17835. self = make_node(AST_Binary, self, {
  17836. operator: "-",
  17837. left: self.left,
  17838. right: self.right.expression
  17839. });
  17840. break;
  17841. }
  17842. // -a + b => b - a
  17843. if (self.left instanceof AST_UnaryPrefix
  17844. && self.left.operator == "-"
  17845. && reversible()
  17846. && self.right.is_number(compressor)) {
  17847. self = make_node(AST_Binary, self, {
  17848. operator: "-",
  17849. left: self.right,
  17850. right: self.left.expression
  17851. });
  17852. break;
  17853. }
  17854. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  17855. if (self.left instanceof AST_TemplateString) {
  17856. var l = self.left;
  17857. var r = self.right.evaluate(compressor);
  17858. if (r != self.right) {
  17859. l.segments[l.segments.length - 1].value += String(r);
  17860. return l;
  17861. }
  17862. }
  17863. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  17864. if (self.right instanceof AST_TemplateString) {
  17865. var r = self.right;
  17866. var l = self.left.evaluate(compressor);
  17867. if (l != self.left) {
  17868. r.segments[0].value = String(l) + r.segments[0].value;
  17869. return r;
  17870. }
  17871. }
  17872. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  17873. if (self.left instanceof AST_TemplateString
  17874. && self.right instanceof AST_TemplateString) {
  17875. var l = self.left;
  17876. var segments = l.segments;
  17877. var r = self.right;
  17878. segments[segments.length - 1].value += r.segments[0].value;
  17879. for (var i = 1; i < r.segments.length; i++) {
  17880. segments.push(r.segments[i]);
  17881. }
  17882. return l;
  17883. }
  17884. case "*":
  17885. associative = compressor.option("unsafe_math");
  17886. case "&":
  17887. case "|":
  17888. case "^":
  17889. // a + +b => +b + a
  17890. if (self.left.is_number(compressor)
  17891. && self.right.is_number(compressor)
  17892. && reversible()
  17893. && !(self.left instanceof AST_Binary
  17894. && self.left.operator != self.operator
  17895. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  17896. var reversed = make_node(AST_Binary, self, {
  17897. operator: self.operator,
  17898. left: self.right,
  17899. right: self.left
  17900. });
  17901. if (self.right instanceof AST_Constant
  17902. && !(self.left instanceof AST_Constant)) {
  17903. self = best_of(compressor, reversed, self);
  17904. } else {
  17905. self = best_of(compressor, self, reversed);
  17906. }
  17907. }
  17908. if (associative && self.is_number(compressor)) {
  17909. // a + (b + c) => (a + b) + c
  17910. if (self.right instanceof AST_Binary
  17911. && self.right.operator == self.operator) {
  17912. self = make_node(AST_Binary, self, {
  17913. operator: self.operator,
  17914. left: make_node(AST_Binary, self.left, {
  17915. operator: self.operator,
  17916. left: self.left,
  17917. right: self.right.left,
  17918. start: self.left.start,
  17919. end: self.right.left.end
  17920. }),
  17921. right: self.right.right
  17922. });
  17923. }
  17924. // (n + 2) + 3 => 5 + n
  17925. // (2 * n) * 3 => 6 + n
  17926. if (self.right instanceof AST_Constant
  17927. && self.left instanceof AST_Binary
  17928. && self.left.operator == self.operator) {
  17929. if (self.left.left instanceof AST_Constant) {
  17930. self = make_node(AST_Binary, self, {
  17931. operator: self.operator,
  17932. left: make_node(AST_Binary, self.left, {
  17933. operator: self.operator,
  17934. left: self.left.left,
  17935. right: self.right,
  17936. start: self.left.left.start,
  17937. end: self.right.end
  17938. }),
  17939. right: self.left.right
  17940. });
  17941. } else if (self.left.right instanceof AST_Constant) {
  17942. self = make_node(AST_Binary, self, {
  17943. operator: self.operator,
  17944. left: make_node(AST_Binary, self.left, {
  17945. operator: self.operator,
  17946. left: self.left.right,
  17947. right: self.right,
  17948. start: self.left.right.start,
  17949. end: self.right.end
  17950. }),
  17951. right: self.left.left
  17952. });
  17953. }
  17954. }
  17955. // (a | 1) | (2 | d) => (3 | a) | b
  17956. if (self.left instanceof AST_Binary
  17957. && self.left.operator == self.operator
  17958. && self.left.right instanceof AST_Constant
  17959. && self.right instanceof AST_Binary
  17960. && self.right.operator == self.operator
  17961. && self.right.left instanceof AST_Constant) {
  17962. self = make_node(AST_Binary, self, {
  17963. operator: self.operator,
  17964. left: make_node(AST_Binary, self.left, {
  17965. operator: self.operator,
  17966. left: make_node(AST_Binary, self.left.left, {
  17967. operator: self.operator,
  17968. left: self.left.right,
  17969. right: self.right.left,
  17970. start: self.left.right.start,
  17971. end: self.right.left.end
  17972. }),
  17973. right: self.left.left
  17974. }),
  17975. right: self.right.right
  17976. });
  17977. }
  17978. }
  17979. }
  17980. }
  17981. // x && (y && z) ==> x && y && z
  17982. // x || (y || z) ==> x || y || z
  17983. // x + ("y" + z) ==> x + "y" + z
  17984. // "x" + (y + "z")==> "x" + y + "z"
  17985. if (self.right instanceof AST_Binary
  17986. && self.right.operator == self.operator
  17987. && (lazy_op.has(self.operator)
  17988. || (self.operator == "+"
  17989. && (self.right.left.is_string(compressor)
  17990. || (self.left.is_string(compressor)
  17991. && self.right.right.is_string(compressor)))))
  17992. ) {
  17993. self.left = make_node(AST_Binary, self.left, {
  17994. operator : self.operator,
  17995. left : self.left.transform(compressor),
  17996. right : self.right.left.transform(compressor)
  17997. });
  17998. self.right = self.right.right.transform(compressor);
  17999. return self.transform(compressor);
  18000. }
  18001. var ev = self.evaluate(compressor);
  18002. if (ev !== self) {
  18003. ev = make_node_from_constant(ev, self).optimize(compressor);
  18004. return best_of(compressor, ev, self);
  18005. }
  18006. return self;
  18007. });
  18008. def_optimize(AST_SymbolExport, function(self) {
  18009. return self;
  18010. });
  18011. def_optimize(AST_SymbolRef, function(self, compressor) {
  18012. if (
  18013. !compressor.option("ie8")
  18014. && is_undeclared_ref(self)
  18015. && !compressor.find_parent(AST_With)
  18016. ) {
  18017. switch (self.name) {
  18018. case "undefined":
  18019. return make_node(AST_Undefined, self).optimize(compressor);
  18020. case "NaN":
  18021. return make_node(AST_NaN, self).optimize(compressor);
  18022. case "Infinity":
  18023. return make_node(AST_Infinity, self).optimize(compressor);
  18024. }
  18025. }
  18026. const parent = compressor.parent();
  18027. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  18028. return inline_into_symbolref(self, compressor);
  18029. } else {
  18030. return self;
  18031. }
  18032. });
  18033. function is_atomic(lhs, self) {
  18034. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  18035. }
  18036. def_optimize(AST_Undefined, function(self, compressor) {
  18037. if (compressor.option("unsafe_undefined")) {
  18038. var undef = find_variable(compressor, "undefined");
  18039. if (undef) {
  18040. var ref = make_node(AST_SymbolRef, self, {
  18041. name : "undefined",
  18042. scope : undef.scope,
  18043. thedef : undef
  18044. });
  18045. set_flag(ref, UNDEFINED);
  18046. return ref;
  18047. }
  18048. }
  18049. var lhs = is_lhs(compressor.self(), compressor.parent());
  18050. if (lhs && is_atomic(lhs, self)) return self;
  18051. return make_node(AST_UnaryPrefix, self, {
  18052. operator: "void",
  18053. expression: make_node(AST_Number, self, {
  18054. value: 0
  18055. })
  18056. });
  18057. });
  18058. def_optimize(AST_Infinity, function(self, compressor) {
  18059. var lhs = is_lhs(compressor.self(), compressor.parent());
  18060. if (lhs && is_atomic(lhs, self)) return self;
  18061. if (
  18062. compressor.option("keep_infinity")
  18063. && !(lhs && !is_atomic(lhs, self))
  18064. && !find_variable(compressor, "Infinity")
  18065. ) {
  18066. return self;
  18067. }
  18068. return make_node(AST_Binary, self, {
  18069. operator: "/",
  18070. left: make_node(AST_Number, self, {
  18071. value: 1
  18072. }),
  18073. right: make_node(AST_Number, self, {
  18074. value: 0
  18075. })
  18076. });
  18077. });
  18078. def_optimize(AST_NaN, function(self, compressor) {
  18079. var lhs = is_lhs(compressor.self(), compressor.parent());
  18080. if (lhs && !is_atomic(lhs, self)
  18081. || find_variable(compressor, "NaN")) {
  18082. return make_node(AST_Binary, self, {
  18083. operator: "/",
  18084. left: make_node(AST_Number, self, {
  18085. value: 0
  18086. }),
  18087. right: make_node(AST_Number, self, {
  18088. value: 0
  18089. })
  18090. });
  18091. }
  18092. return self;
  18093. });
  18094. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  18095. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  18096. def_optimize(AST_Assign, function(self, compressor) {
  18097. if (self.logical) {
  18098. return self.lift_sequences(compressor);
  18099. }
  18100. var def;
  18101. // x = x ---> x
  18102. if (
  18103. self.operator === "="
  18104. && self.left instanceof AST_SymbolRef
  18105. && self.left.name !== "arguments"
  18106. && !(def = self.left.definition()).undeclared
  18107. && self.right.equivalent_to(self.left)
  18108. ) {
  18109. return self.right;
  18110. }
  18111. if (compressor.option("dead_code")
  18112. && self.left instanceof AST_SymbolRef
  18113. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  18114. var level = 0, node, parent = self;
  18115. do {
  18116. node = parent;
  18117. parent = compressor.parent(level++);
  18118. if (parent instanceof AST_Exit) {
  18119. if (in_try(level, parent)) break;
  18120. if (is_reachable(def.scope, [ def ])) break;
  18121. if (self.operator == "=") return self.right;
  18122. def.fixed = false;
  18123. return make_node(AST_Binary, self, {
  18124. operator: self.operator.slice(0, -1),
  18125. left: self.left,
  18126. right: self.right
  18127. }).optimize(compressor);
  18128. }
  18129. } while (parent instanceof AST_Binary && parent.right === node
  18130. || parent instanceof AST_Sequence && parent.tail_node() === node);
  18131. }
  18132. self = self.lift_sequences(compressor);
  18133. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  18134. // x = expr1 OP expr2
  18135. if (self.right.left instanceof AST_SymbolRef
  18136. && self.right.left.name == self.left.name
  18137. && ASSIGN_OPS.has(self.right.operator)) {
  18138. // x = x - 2 ---> x -= 2
  18139. self.operator = self.right.operator + "=";
  18140. self.right = self.right.right;
  18141. } else if (self.right.right instanceof AST_SymbolRef
  18142. && self.right.right.name == self.left.name
  18143. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  18144. && !self.right.left.has_side_effects(compressor)) {
  18145. // x = 2 & x ---> x &= 2
  18146. self.operator = self.right.operator + "=";
  18147. self.right = self.right.left;
  18148. }
  18149. }
  18150. return self;
  18151. function in_try(level, node) {
  18152. var right = self.right;
  18153. self.right = make_node(AST_Null, right);
  18154. var may_throw = node.may_throw(compressor);
  18155. self.right = right;
  18156. var scope = self.left.definition().scope;
  18157. var parent;
  18158. while ((parent = compressor.parent(level++)) !== scope) {
  18159. if (parent instanceof AST_Try) {
  18160. if (parent.bfinally) return true;
  18161. if (may_throw && parent.bcatch) return true;
  18162. }
  18163. }
  18164. }
  18165. });
  18166. def_optimize(AST_DefaultAssign, function(self, compressor) {
  18167. if (!compressor.option("evaluate")) {
  18168. return self;
  18169. }
  18170. var evaluateRight = self.right.evaluate(compressor);
  18171. // `[x = undefined] = foo` ---> `[x] = foo`
  18172. if (evaluateRight === undefined) {
  18173. self = self.left;
  18174. } else if (evaluateRight !== self.right) {
  18175. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  18176. self.right = best_of_expression(evaluateRight, self.right);
  18177. }
  18178. return self;
  18179. });
  18180. function is_nullish_check(check, check_subject, compressor) {
  18181. if (check_subject.may_throw(compressor)) return false;
  18182. let nullish_side;
  18183. // foo == null
  18184. if (
  18185. check instanceof AST_Binary
  18186. && check.operator === "=="
  18187. // which side is nullish?
  18188. && (
  18189. (nullish_side = is_nullish(check.left, compressor) && check.left)
  18190. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  18191. )
  18192. // is the other side the same as the check_subject
  18193. && (
  18194. nullish_side === check.left
  18195. ? check.right
  18196. : check.left
  18197. ).equivalent_to(check_subject)
  18198. ) {
  18199. return true;
  18200. }
  18201. // foo === null || foo === undefined
  18202. if (check instanceof AST_Binary && check.operator === "||") {
  18203. let null_cmp;
  18204. let undefined_cmp;
  18205. const find_comparison = cmp => {
  18206. if (!(
  18207. cmp instanceof AST_Binary
  18208. && (cmp.operator === "===" || cmp.operator === "==")
  18209. )) {
  18210. return false;
  18211. }
  18212. let found = 0;
  18213. let defined_side;
  18214. if (cmp.left instanceof AST_Null) {
  18215. found++;
  18216. null_cmp = cmp;
  18217. defined_side = cmp.right;
  18218. }
  18219. if (cmp.right instanceof AST_Null) {
  18220. found++;
  18221. null_cmp = cmp;
  18222. defined_side = cmp.left;
  18223. }
  18224. if (is_undefined(cmp.left, compressor)) {
  18225. found++;
  18226. undefined_cmp = cmp;
  18227. defined_side = cmp.right;
  18228. }
  18229. if (is_undefined(cmp.right, compressor)) {
  18230. found++;
  18231. undefined_cmp = cmp;
  18232. defined_side = cmp.left;
  18233. }
  18234. if (found !== 1) {
  18235. return false;
  18236. }
  18237. if (!defined_side.equivalent_to(check_subject)) {
  18238. return false;
  18239. }
  18240. return true;
  18241. };
  18242. if (!find_comparison(check.left)) return false;
  18243. if (!find_comparison(check.right)) return false;
  18244. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  18245. return true;
  18246. }
  18247. }
  18248. return false;
  18249. }
  18250. def_optimize(AST_Conditional, function(self, compressor) {
  18251. if (!compressor.option("conditionals")) return self;
  18252. // This looks like lift_sequences(), should probably be under "sequences"
  18253. if (self.condition instanceof AST_Sequence) {
  18254. var expressions = self.condition.expressions.slice();
  18255. self.condition = expressions.pop();
  18256. expressions.push(self);
  18257. return make_sequence(self, expressions);
  18258. }
  18259. var cond = self.condition.evaluate(compressor);
  18260. if (cond !== self.condition) {
  18261. if (cond) {
  18262. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  18263. } else {
  18264. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  18265. }
  18266. }
  18267. var negated = cond.negate(compressor, first_in_statement(compressor));
  18268. if (best_of(compressor, cond, negated) === negated) {
  18269. self = make_node(AST_Conditional, self, {
  18270. condition: negated,
  18271. consequent: self.alternative,
  18272. alternative: self.consequent
  18273. });
  18274. }
  18275. var condition = self.condition;
  18276. var consequent = self.consequent;
  18277. var alternative = self.alternative;
  18278. // x?x:y --> x||y
  18279. if (condition instanceof AST_SymbolRef
  18280. && consequent instanceof AST_SymbolRef
  18281. && condition.definition() === consequent.definition()) {
  18282. return make_node(AST_Binary, self, {
  18283. operator: "||",
  18284. left: condition,
  18285. right: alternative
  18286. });
  18287. }
  18288. // if (foo) exp = something; else exp = something_else;
  18289. // |
  18290. // v
  18291. // exp = foo ? something : something_else;
  18292. if (
  18293. consequent instanceof AST_Assign
  18294. && alternative instanceof AST_Assign
  18295. && consequent.operator === alternative.operator
  18296. && consequent.logical === alternative.logical
  18297. && consequent.left.equivalent_to(alternative.left)
  18298. && (!self.condition.has_side_effects(compressor)
  18299. || consequent.operator == "="
  18300. && !consequent.left.has_side_effects(compressor))
  18301. ) {
  18302. return make_node(AST_Assign, self, {
  18303. operator: consequent.operator,
  18304. left: consequent.left,
  18305. logical: consequent.logical,
  18306. right: make_node(AST_Conditional, self, {
  18307. condition: self.condition,
  18308. consequent: consequent.right,
  18309. alternative: alternative.right
  18310. })
  18311. });
  18312. }
  18313. // x ? y(a) : y(b) --> y(x ? a : b)
  18314. var arg_index;
  18315. if (consequent instanceof AST_Call
  18316. && alternative.TYPE === consequent.TYPE
  18317. && consequent.args.length > 0
  18318. && consequent.args.length == alternative.args.length
  18319. && consequent.expression.equivalent_to(alternative.expression)
  18320. && !self.condition.has_side_effects(compressor)
  18321. && !consequent.expression.has_side_effects(compressor)
  18322. && typeof (arg_index = single_arg_diff()) == "number") {
  18323. var node = consequent.clone();
  18324. node.args[arg_index] = make_node(AST_Conditional, self, {
  18325. condition: self.condition,
  18326. consequent: consequent.args[arg_index],
  18327. alternative: alternative.args[arg_index]
  18328. });
  18329. return node;
  18330. }
  18331. // a ? b : c ? b : d --> (a || c) ? b : d
  18332. if (alternative instanceof AST_Conditional
  18333. && consequent.equivalent_to(alternative.consequent)) {
  18334. return make_node(AST_Conditional, self, {
  18335. condition: make_node(AST_Binary, self, {
  18336. operator: "||",
  18337. left: condition,
  18338. right: alternative.condition
  18339. }),
  18340. consequent: consequent,
  18341. alternative: alternative.alternative
  18342. }).optimize(compressor);
  18343. }
  18344. // a == null ? b : a -> a ?? b
  18345. if (
  18346. compressor.option("ecma") >= 2020 &&
  18347. is_nullish_check(condition, alternative, compressor)
  18348. ) {
  18349. return make_node(AST_Binary, self, {
  18350. operator: "??",
  18351. left: alternative,
  18352. right: consequent
  18353. }).optimize(compressor);
  18354. }
  18355. // a ? b : (c, b) --> (a || c), b
  18356. if (alternative instanceof AST_Sequence
  18357. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  18358. return make_sequence(self, [
  18359. make_node(AST_Binary, self, {
  18360. operator: "||",
  18361. left: condition,
  18362. right: make_sequence(self, alternative.expressions.slice(0, -1))
  18363. }),
  18364. consequent
  18365. ]).optimize(compressor);
  18366. }
  18367. // a ? b : (c && b) --> (a || c) && b
  18368. if (alternative instanceof AST_Binary
  18369. && alternative.operator == "&&"
  18370. && consequent.equivalent_to(alternative.right)) {
  18371. return make_node(AST_Binary, self, {
  18372. operator: "&&",
  18373. left: make_node(AST_Binary, self, {
  18374. operator: "||",
  18375. left: condition,
  18376. right: alternative.left
  18377. }),
  18378. right: consequent
  18379. }).optimize(compressor);
  18380. }
  18381. // x?y?z:a:a --> x&&y?z:a
  18382. if (consequent instanceof AST_Conditional
  18383. && consequent.alternative.equivalent_to(alternative)) {
  18384. return make_node(AST_Conditional, self, {
  18385. condition: make_node(AST_Binary, self, {
  18386. left: self.condition,
  18387. operator: "&&",
  18388. right: consequent.condition
  18389. }),
  18390. consequent: consequent.consequent,
  18391. alternative: alternative
  18392. });
  18393. }
  18394. // x ? y : y --> x, y
  18395. if (consequent.equivalent_to(alternative)) {
  18396. return make_sequence(self, [
  18397. self.condition,
  18398. consequent
  18399. ]).optimize(compressor);
  18400. }
  18401. // x ? y || z : z --> x && y || z
  18402. if (consequent instanceof AST_Binary
  18403. && consequent.operator == "||"
  18404. && consequent.right.equivalent_to(alternative)) {
  18405. return make_node(AST_Binary, self, {
  18406. operator: "||",
  18407. left: make_node(AST_Binary, self, {
  18408. operator: "&&",
  18409. left: self.condition,
  18410. right: consequent.left
  18411. }),
  18412. right: alternative
  18413. }).optimize(compressor);
  18414. }
  18415. const in_bool = compressor.in_boolean_context();
  18416. if (is_true(self.consequent)) {
  18417. if (is_false(self.alternative)) {
  18418. // c ? true : false ---> !!c
  18419. return booleanize(self.condition);
  18420. }
  18421. // c ? true : x ---> !!c || x
  18422. return make_node(AST_Binary, self, {
  18423. operator: "||",
  18424. left: booleanize(self.condition),
  18425. right: self.alternative
  18426. });
  18427. }
  18428. if (is_false(self.consequent)) {
  18429. if (is_true(self.alternative)) {
  18430. // c ? false : true ---> !c
  18431. return booleanize(self.condition.negate(compressor));
  18432. }
  18433. // c ? false : x ---> !c && x
  18434. return make_node(AST_Binary, self, {
  18435. operator: "&&",
  18436. left: booleanize(self.condition.negate(compressor)),
  18437. right: self.alternative
  18438. });
  18439. }
  18440. if (is_true(self.alternative)) {
  18441. // c ? x : true ---> !c || x
  18442. return make_node(AST_Binary, self, {
  18443. operator: "||",
  18444. left: booleanize(self.condition.negate(compressor)),
  18445. right: self.consequent
  18446. });
  18447. }
  18448. if (is_false(self.alternative)) {
  18449. // c ? x : false ---> !!c && x
  18450. return make_node(AST_Binary, self, {
  18451. operator: "&&",
  18452. left: booleanize(self.condition),
  18453. right: self.consequent
  18454. });
  18455. }
  18456. return self;
  18457. function booleanize(node) {
  18458. if (node.is_boolean()) return node;
  18459. // !!expression
  18460. return make_node(AST_UnaryPrefix, node, {
  18461. operator: "!",
  18462. expression: node.negate(compressor)
  18463. });
  18464. }
  18465. // AST_True or !0
  18466. function is_true(node) {
  18467. return node instanceof AST_True
  18468. || in_bool
  18469. && node instanceof AST_Constant
  18470. && node.getValue()
  18471. || (node instanceof AST_UnaryPrefix
  18472. && node.operator == "!"
  18473. && node.expression instanceof AST_Constant
  18474. && !node.expression.getValue());
  18475. }
  18476. // AST_False or !1
  18477. function is_false(node) {
  18478. return node instanceof AST_False
  18479. || in_bool
  18480. && node instanceof AST_Constant
  18481. && !node.getValue()
  18482. || (node instanceof AST_UnaryPrefix
  18483. && node.operator == "!"
  18484. && node.expression instanceof AST_Constant
  18485. && node.expression.getValue());
  18486. }
  18487. function single_arg_diff() {
  18488. var a = consequent.args;
  18489. var b = alternative.args;
  18490. for (var i = 0, len = a.length; i < len; i++) {
  18491. if (a[i] instanceof AST_Expansion) return;
  18492. if (!a[i].equivalent_to(b[i])) {
  18493. if (b[i] instanceof AST_Expansion) return;
  18494. for (var j = i + 1; j < len; j++) {
  18495. if (a[j] instanceof AST_Expansion) return;
  18496. if (!a[j].equivalent_to(b[j])) return;
  18497. }
  18498. return i;
  18499. }
  18500. }
  18501. }
  18502. });
  18503. def_optimize(AST_Boolean, function(self, compressor) {
  18504. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  18505. value: +self.value
  18506. });
  18507. var p = compressor.parent();
  18508. if (compressor.option("booleans_as_integers")) {
  18509. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  18510. p.operator = p.operator.replace(/=$/, "");
  18511. }
  18512. return make_node(AST_Number, self, {
  18513. value: +self.value
  18514. });
  18515. }
  18516. if (compressor.option("booleans")) {
  18517. if (p instanceof AST_Binary && (p.operator == "=="
  18518. || p.operator == "!=")) {
  18519. return make_node(AST_Number, self, {
  18520. value: +self.value
  18521. });
  18522. }
  18523. return make_node(AST_UnaryPrefix, self, {
  18524. operator: "!",
  18525. expression: make_node(AST_Number, self, {
  18526. value: 1 - self.value
  18527. })
  18528. });
  18529. }
  18530. return self;
  18531. });
  18532. function safe_to_flatten(value, compressor) {
  18533. if (value instanceof AST_SymbolRef) {
  18534. value = value.fixed_value();
  18535. }
  18536. if (!value) return false;
  18537. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  18538. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  18539. return compressor.parent() instanceof AST_New;
  18540. }
  18541. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  18542. if (!compressor.option("properties")) return;
  18543. if (key === "__proto__") return;
  18544. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  18545. var expr = this.expression;
  18546. if (expr instanceof AST_Object) {
  18547. var props = expr.properties;
  18548. for (var i = props.length; --i >= 0;) {
  18549. var prop = props[i];
  18550. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  18551. const all_props_flattenable = props.every((p) =>
  18552. (p instanceof AST_ObjectKeyVal
  18553. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  18554. )
  18555. && !p.computed_key()
  18556. );
  18557. if (!all_props_flattenable) return;
  18558. if (!safe_to_flatten(prop.value, compressor)) return;
  18559. return make_node(AST_Sub, this, {
  18560. expression: make_node(AST_Array, expr, {
  18561. elements: props.map(function(prop) {
  18562. var v = prop.value;
  18563. if (v instanceof AST_Accessor) {
  18564. v = make_node(AST_Function, v, v);
  18565. }
  18566. var k = prop.key;
  18567. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  18568. return make_sequence(prop, [ k, v ]);
  18569. }
  18570. return v;
  18571. })
  18572. }),
  18573. property: make_node(AST_Number, this, {
  18574. value: i
  18575. })
  18576. });
  18577. }
  18578. }
  18579. }
  18580. });
  18581. def_optimize(AST_Sub, function(self, compressor) {
  18582. var expr = self.expression;
  18583. var prop = self.property;
  18584. if (compressor.option("properties")) {
  18585. var key = prop.evaluate(compressor);
  18586. if (key !== prop) {
  18587. if (typeof key == "string") {
  18588. if (key == "undefined") {
  18589. key = undefined;
  18590. } else {
  18591. var value = parseFloat(key);
  18592. if (value.toString() == key) {
  18593. key = value;
  18594. }
  18595. }
  18596. }
  18597. prop = self.property = best_of_expression(prop, make_node_from_constant(key, prop).transform(compressor));
  18598. var property = "" + key;
  18599. if (is_basic_identifier_string(property)
  18600. && property.length <= prop.size() + 1) {
  18601. return make_node(AST_Dot, self, {
  18602. expression: expr,
  18603. optional: self.optional,
  18604. property: property,
  18605. quote: prop.quote,
  18606. }).optimize(compressor);
  18607. }
  18608. }
  18609. }
  18610. var fn;
  18611. OPT_ARGUMENTS: if (compressor.option("arguments")
  18612. && expr instanceof AST_SymbolRef
  18613. && expr.name == "arguments"
  18614. && expr.definition().orig.length == 1
  18615. && (fn = expr.scope) instanceof AST_Lambda
  18616. && fn.uses_arguments
  18617. && !(fn instanceof AST_Arrow)
  18618. && prop instanceof AST_Number) {
  18619. var index = prop.getValue();
  18620. var params = new Set();
  18621. var argnames = fn.argnames;
  18622. for (var n = 0; n < argnames.length; n++) {
  18623. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  18624. break OPT_ARGUMENTS; // destructuring parameter - bail
  18625. }
  18626. var param = argnames[n].name;
  18627. if (params.has(param)) {
  18628. break OPT_ARGUMENTS; // duplicate parameter - bail
  18629. }
  18630. params.add(param);
  18631. }
  18632. var argname = fn.argnames[index];
  18633. if (argname && compressor.has_directive("use strict")) {
  18634. var def = argname.definition();
  18635. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  18636. argname = null;
  18637. }
  18638. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  18639. while (index >= fn.argnames.length) {
  18640. argname = fn.create_symbol(AST_SymbolFunarg, {
  18641. source: fn,
  18642. scope: fn,
  18643. tentative_name: "argument_" + fn.argnames.length,
  18644. });
  18645. fn.argnames.push(argname);
  18646. }
  18647. }
  18648. if (argname) {
  18649. var sym = make_node(AST_SymbolRef, self, argname);
  18650. sym.reference({});
  18651. clear_flag(argname, UNUSED);
  18652. return sym;
  18653. }
  18654. }
  18655. if (is_lhs(self, compressor.parent())) return self;
  18656. if (key !== prop) {
  18657. var sub = self.flatten_object(property, compressor);
  18658. if (sub) {
  18659. expr = self.expression = sub.expression;
  18660. prop = self.property = sub.property;
  18661. }
  18662. }
  18663. if (compressor.option("properties") && compressor.option("side_effects")
  18664. && prop instanceof AST_Number && expr instanceof AST_Array) {
  18665. var index = prop.getValue();
  18666. var elements = expr.elements;
  18667. var retValue = elements[index];
  18668. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  18669. var flatten = true;
  18670. var values = [];
  18671. for (var i = elements.length; --i > index;) {
  18672. var value = elements[i].drop_side_effect_free(compressor);
  18673. if (value) {
  18674. values.unshift(value);
  18675. if (flatten && value.has_side_effects(compressor)) flatten = false;
  18676. }
  18677. }
  18678. if (retValue instanceof AST_Expansion) break FLATTEN;
  18679. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  18680. if (!flatten) values.unshift(retValue);
  18681. while (--i >= 0) {
  18682. var value = elements[i];
  18683. if (value instanceof AST_Expansion) break FLATTEN;
  18684. value = value.drop_side_effect_free(compressor);
  18685. if (value) values.unshift(value);
  18686. else index--;
  18687. }
  18688. if (flatten) {
  18689. values.push(retValue);
  18690. return make_sequence(self, values).optimize(compressor);
  18691. } else return make_node(AST_Sub, self, {
  18692. expression: make_node(AST_Array, expr, {
  18693. elements: values
  18694. }),
  18695. property: make_node(AST_Number, prop, {
  18696. value: index
  18697. })
  18698. });
  18699. }
  18700. }
  18701. var ev = self.evaluate(compressor);
  18702. if (ev !== self) {
  18703. ev = make_node_from_constant(ev, self).optimize(compressor);
  18704. return best_of(compressor, ev, self);
  18705. }
  18706. return self;
  18707. });
  18708. def_optimize(AST_Chain, function (self, compressor) {
  18709. if (is_nullish(self.expression, compressor)) {
  18710. let parent = compressor.parent();
  18711. // It's valid to delete a nullish optional chain, but if we optimized
  18712. // this to `delete undefined` then it would appear to be a syntax error
  18713. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  18714. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  18715. return make_node_from_constant(0, self);
  18716. }
  18717. return make_node(AST_Undefined, self);
  18718. }
  18719. return self;
  18720. });
  18721. AST_Lambda.DEFMETHOD("contains_this", function() {
  18722. return walk(this, node => {
  18723. if (node instanceof AST_This) return walk_abort;
  18724. if (
  18725. node !== this
  18726. && node instanceof AST_Scope
  18727. && !(node instanceof AST_Arrow)
  18728. ) {
  18729. return true;
  18730. }
  18731. });
  18732. });
  18733. def_optimize(AST_Dot, function(self, compressor) {
  18734. const parent = compressor.parent();
  18735. if (is_lhs(self, parent)) return self;
  18736. if (compressor.option("unsafe_proto")
  18737. && self.expression instanceof AST_Dot
  18738. && self.expression.property == "prototype") {
  18739. var exp = self.expression.expression;
  18740. if (is_undeclared_ref(exp)) switch (exp.name) {
  18741. case "Array":
  18742. self.expression = make_node(AST_Array, self.expression, {
  18743. elements: []
  18744. });
  18745. break;
  18746. case "Function":
  18747. self.expression = make_node(AST_Function, self.expression, {
  18748. argnames: [],
  18749. body: []
  18750. });
  18751. break;
  18752. case "Number":
  18753. self.expression = make_node(AST_Number, self.expression, {
  18754. value: 0
  18755. });
  18756. break;
  18757. case "Object":
  18758. self.expression = make_node(AST_Object, self.expression, {
  18759. properties: []
  18760. });
  18761. break;
  18762. case "RegExp":
  18763. self.expression = make_node(AST_RegExp, self.expression, {
  18764. value: { source: "t", flags: "" }
  18765. });
  18766. break;
  18767. case "String":
  18768. self.expression = make_node(AST_String, self.expression, {
  18769. value: ""
  18770. });
  18771. break;
  18772. }
  18773. }
  18774. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  18775. const sub = self.flatten_object(self.property, compressor);
  18776. if (sub) return sub.optimize(compressor);
  18777. }
  18778. let ev = self.evaluate(compressor);
  18779. if (ev !== self) {
  18780. ev = make_node_from_constant(ev, self).optimize(compressor);
  18781. return best_of(compressor, ev, self);
  18782. }
  18783. return self;
  18784. });
  18785. function literals_in_boolean_context(self, compressor) {
  18786. if (compressor.in_boolean_context()) {
  18787. return best_of(compressor, self, make_sequence(self, [
  18788. self,
  18789. make_node(AST_True, self)
  18790. ]).optimize(compressor));
  18791. }
  18792. return self;
  18793. }
  18794. function inline_array_like_spread(elements) {
  18795. for (var i = 0; i < elements.length; i++) {
  18796. var el = elements[i];
  18797. if (el instanceof AST_Expansion) {
  18798. var expr = el.expression;
  18799. if (
  18800. expr instanceof AST_Array
  18801. && !expr.elements.some(elm => elm instanceof AST_Hole)
  18802. ) {
  18803. elements.splice(i, 1, ...expr.elements);
  18804. // Step back one, as the element at i is now new.
  18805. i--;
  18806. }
  18807. // In array-like spread, spreading a non-iterable value is TypeError.
  18808. // We therefore can’t optimize anything else, unlike with object spread.
  18809. }
  18810. }
  18811. }
  18812. def_optimize(AST_Array, function(self, compressor) {
  18813. var optimized = literals_in_boolean_context(self, compressor);
  18814. if (optimized !== self) {
  18815. return optimized;
  18816. }
  18817. inline_array_like_spread(self.elements);
  18818. return self;
  18819. });
  18820. function inline_object_prop_spread(props, compressor) {
  18821. for (var i = 0; i < props.length; i++) {
  18822. var prop = props[i];
  18823. if (prop instanceof AST_Expansion) {
  18824. const expr = prop.expression;
  18825. if (
  18826. expr instanceof AST_Object
  18827. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  18828. ) {
  18829. props.splice(i, 1, ...expr.properties);
  18830. // Step back one, as the property at i is now new.
  18831. i--;
  18832. } else if (expr instanceof AST_Constant
  18833. && !(expr instanceof AST_String)) {
  18834. // Unlike array-like spread, in object spread, spreading a
  18835. // non-iterable value silently does nothing; it is thus safe
  18836. // to remove. AST_String is the only iterable AST_Constant.
  18837. props.splice(i, 1);
  18838. i--;
  18839. } else if (is_nullish(expr, compressor)) {
  18840. // Likewise, null and undefined can be silently removed.
  18841. props.splice(i, 1);
  18842. i--;
  18843. }
  18844. }
  18845. }
  18846. }
  18847. def_optimize(AST_Object, function(self, compressor) {
  18848. var optimized = literals_in_boolean_context(self, compressor);
  18849. if (optimized !== self) {
  18850. return optimized;
  18851. }
  18852. inline_object_prop_spread(self.properties, compressor);
  18853. return self;
  18854. });
  18855. def_optimize(AST_RegExp, literals_in_boolean_context);
  18856. def_optimize(AST_Return, function(self, compressor) {
  18857. if (self.value && is_undefined(self.value, compressor)) {
  18858. self.value = null;
  18859. }
  18860. return self;
  18861. });
  18862. def_optimize(AST_Arrow, opt_AST_Lambda);
  18863. def_optimize(AST_Function, function(self, compressor) {
  18864. self = opt_AST_Lambda(self, compressor);
  18865. if (compressor.option("unsafe_arrows")
  18866. && compressor.option("ecma") >= 2015
  18867. && !self.name
  18868. && !self.is_generator
  18869. && !self.uses_arguments
  18870. && !self.pinned()) {
  18871. const uses_this = walk(self, node => {
  18872. if (node instanceof AST_This) return walk_abort;
  18873. });
  18874. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  18875. }
  18876. return self;
  18877. });
  18878. def_optimize(AST_Class, function(self) {
  18879. // HACK to avoid compress failure.
  18880. // AST_Class is not really an AST_Scope/AST_Block as it lacks a body.
  18881. return self;
  18882. });
  18883. def_optimize(AST_Yield, function(self, compressor) {
  18884. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  18885. self.expression = null;
  18886. }
  18887. return self;
  18888. });
  18889. def_optimize(AST_TemplateString, function(self, compressor) {
  18890. if (
  18891. !compressor.option("evaluate")
  18892. || compressor.parent() instanceof AST_PrefixedTemplateString
  18893. ) {
  18894. return self;
  18895. }
  18896. var segments = [];
  18897. for (var i = 0; i < self.segments.length; i++) {
  18898. var segment = self.segments[i];
  18899. if (segment instanceof AST_Node) {
  18900. var result = segment.evaluate(compressor);
  18901. // Evaluate to constant value
  18902. // Constant value shorter than ${segment}
  18903. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  18904. // There should always be a previous and next segment if segment is a node
  18905. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  18906. continue;
  18907. }
  18908. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  18909. // TODO:
  18910. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  18911. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  18912. if (segment instanceof AST_TemplateString) {
  18913. var inners = segment.segments;
  18914. segments[segments.length - 1].value += inners[0].value;
  18915. for (var j = 1; j < inners.length; j++) {
  18916. segment = inners[j];
  18917. segments.push(segment);
  18918. }
  18919. continue;
  18920. }
  18921. }
  18922. segments.push(segment);
  18923. }
  18924. self.segments = segments;
  18925. // `foo` => "foo"
  18926. if (segments.length == 1) {
  18927. return make_node(AST_String, self, segments[0]);
  18928. }
  18929. if (
  18930. segments.length === 3
  18931. && segments[1] instanceof AST_Node
  18932. && (
  18933. segments[1].is_string(compressor)
  18934. || segments[1].is_number(compressor)
  18935. || is_nullish(segments[1], compressor)
  18936. || compressor.option("unsafe")
  18937. )
  18938. ) {
  18939. // `foo${bar}` => "foo" + bar
  18940. if (segments[2].value === "") {
  18941. return make_node(AST_Binary, self, {
  18942. operator: "+",
  18943. left: make_node(AST_String, self, {
  18944. value: segments[0].value,
  18945. }),
  18946. right: segments[1],
  18947. });
  18948. }
  18949. // `${bar}baz` => bar + "baz"
  18950. if (segments[0].value === "") {
  18951. return make_node(AST_Binary, self, {
  18952. operator: "+",
  18953. left: segments[1],
  18954. right: make_node(AST_String, self, {
  18955. value: segments[2].value,
  18956. }),
  18957. });
  18958. }
  18959. }
  18960. return self;
  18961. });
  18962. def_optimize(AST_PrefixedTemplateString, function(self) {
  18963. return self;
  18964. });
  18965. // ["p"]:1 ---> p:1
  18966. // [42]:1 ---> 42:1
  18967. function lift_key(self, compressor) {
  18968. if (!compressor.option("computed_props")) return self;
  18969. // save a comparison in the typical case
  18970. if (!(self.key instanceof AST_Constant)) return self;
  18971. // allow certain acceptable props as not all AST_Constants are true constants
  18972. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  18973. if (self.key.value === "__proto__") return self;
  18974. if (self.key.value == "constructor"
  18975. && compressor.parent() instanceof AST_Class) return self;
  18976. if (self instanceof AST_ObjectKeyVal) {
  18977. self.quote = self.key.quote;
  18978. self.key = self.key.value;
  18979. } else if (self instanceof AST_ClassProperty) {
  18980. self.quote = self.key.quote;
  18981. self.key = make_node(AST_SymbolClassProperty, self.key, {
  18982. name: self.key.value
  18983. });
  18984. } else {
  18985. self.quote = self.key.quote;
  18986. self.key = make_node(AST_SymbolMethod, self.key, {
  18987. name: self.key.value
  18988. });
  18989. }
  18990. }
  18991. return self;
  18992. }
  18993. def_optimize(AST_ObjectProperty, lift_key);
  18994. def_optimize(AST_ConciseMethod, function(self, compressor) {
  18995. lift_key(self, compressor);
  18996. // p(){return x;} ---> p:()=>x
  18997. if (compressor.option("arrows")
  18998. && compressor.parent() instanceof AST_Object
  18999. && !self.is_generator
  19000. && !self.value.uses_arguments
  19001. && !self.value.pinned()
  19002. && self.value.body.length == 1
  19003. && self.value.body[0] instanceof AST_Return
  19004. && self.value.body[0].value
  19005. && !self.value.contains_this()) {
  19006. var arrow = make_node(AST_Arrow, self.value, self.value);
  19007. arrow.async = self.async;
  19008. arrow.is_generator = self.is_generator;
  19009. return make_node(AST_ObjectKeyVal, self, {
  19010. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  19011. value: arrow,
  19012. quote: self.quote,
  19013. });
  19014. }
  19015. return self;
  19016. });
  19017. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  19018. lift_key(self, compressor);
  19019. // p:function(){} ---> p(){}
  19020. // p:function*(){} ---> *p(){}
  19021. // p:async function(){} ---> async p(){}
  19022. // p:()=>{} ---> p(){}
  19023. // p:async()=>{} ---> async p(){}
  19024. var unsafe_methods = compressor.option("unsafe_methods");
  19025. if (unsafe_methods
  19026. && compressor.option("ecma") >= 2015
  19027. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  19028. var key = self.key;
  19029. var value = self.value;
  19030. var is_arrow_with_block = value instanceof AST_Arrow
  19031. && Array.isArray(value.body)
  19032. && !value.contains_this();
  19033. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  19034. return make_node(AST_ConciseMethod, self, {
  19035. async: value.async,
  19036. is_generator: value.is_generator,
  19037. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  19038. name: key,
  19039. }),
  19040. value: make_node(AST_Accessor, value, value),
  19041. quote: self.quote,
  19042. });
  19043. }
  19044. }
  19045. return self;
  19046. });
  19047. def_optimize(AST_Destructuring, function(self, compressor) {
  19048. if (compressor.option("pure_getters") == true
  19049. && compressor.option("unused")
  19050. && !self.is_array
  19051. && Array.isArray(self.names)
  19052. && !is_destructuring_export_decl(compressor)
  19053. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  19054. var keep = [];
  19055. for (var i = 0; i < self.names.length; i++) {
  19056. var elem = self.names[i];
  19057. if (!(elem instanceof AST_ObjectKeyVal
  19058. && typeof elem.key == "string"
  19059. && elem.value instanceof AST_SymbolDeclaration
  19060. && !should_retain(compressor, elem.value.definition()))) {
  19061. keep.push(elem);
  19062. }
  19063. }
  19064. if (keep.length != self.names.length) {
  19065. self.names = keep;
  19066. }
  19067. }
  19068. return self;
  19069. function is_destructuring_export_decl(compressor) {
  19070. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  19071. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  19072. var parent = compressor.parent(p);
  19073. if (!parent) return false;
  19074. if (a === 0 && parent.TYPE == "Destructuring") continue;
  19075. if (!ancestors[a].test(parent.TYPE)) {
  19076. return false;
  19077. }
  19078. a++;
  19079. }
  19080. return true;
  19081. }
  19082. function should_retain(compressor, def) {
  19083. if (def.references.length) return true;
  19084. if (!def.global) return false;
  19085. if (compressor.toplevel.vars) {
  19086. if (compressor.top_retain) {
  19087. return compressor.top_retain(def);
  19088. }
  19089. return false;
  19090. }
  19091. return true;
  19092. }
  19093. });
  19094. /***********************************************************************
  19095. A JavaScript tokenizer / parser / beautifier / compressor.
  19096. https://github.com/mishoo/UglifyJS2
  19097. -------------------------------- (C) ---------------------------------
  19098. Author: Mihai Bazon
  19099. <mihai.bazon@gmail.com>
  19100. http://mihai.bazon.net/blog
  19101. Distributed under the BSD license:
  19102. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  19103. Redistribution and use in source and binary forms, with or without
  19104. modification, are permitted provided that the following conditions
  19105. are met:
  19106. * Redistributions of source code must retain the above
  19107. copyright notice, this list of conditions and the following
  19108. disclaimer.
  19109. * Redistributions in binary form must reproduce the above
  19110. copyright notice, this list of conditions and the following
  19111. disclaimer in the documentation and/or other materials
  19112. provided with the distribution.
  19113. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  19114. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19115. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19116. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  19117. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  19118. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19119. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19120. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19121. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  19122. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  19123. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  19124. SUCH DAMAGE.
  19125. ***********************************************************************/
  19126. // a small wrapper around fitzgen's source-map library
  19127. async function SourceMap(options) {
  19128. options = defaults(options, {
  19129. file : null,
  19130. root : null,
  19131. orig : null,
  19132. orig_line_diff : 0,
  19133. dest_line_diff : 0,
  19134. });
  19135. var orig_map;
  19136. var generator = new MOZ_SourceMap__default['default'].SourceMapGenerator({
  19137. file : options.file,
  19138. sourceRoot : options.root
  19139. });
  19140. if (options.orig) {
  19141. orig_map = await new MOZ_SourceMap__default['default'].SourceMapConsumer(options.orig);
  19142. orig_map.sources.forEach(function(source) {
  19143. var sourceContent = orig_map.sourceContentFor(source, true);
  19144. if (sourceContent) {
  19145. generator.setSourceContent(source, sourceContent);
  19146. }
  19147. });
  19148. }
  19149. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  19150. if (orig_map) {
  19151. var info = orig_map.originalPositionFor({
  19152. line: orig_line,
  19153. column: orig_col
  19154. });
  19155. if (info.source === null) {
  19156. return;
  19157. }
  19158. source = info.source;
  19159. orig_line = info.line;
  19160. orig_col = info.column;
  19161. name = info.name || name;
  19162. }
  19163. generator.addMapping({
  19164. generated : { line: gen_line + options.dest_line_diff, column: gen_col },
  19165. original : { line: orig_line + options.orig_line_diff, column: orig_col },
  19166. source : source,
  19167. name : name
  19168. });
  19169. }
  19170. return {
  19171. add : add,
  19172. get : function() { return generator; },
  19173. toString : function() { return generator.toString(); },
  19174. destroy : function () {
  19175. if (orig_map && orig_map.destroy) {
  19176. orig_map.destroy();
  19177. }
  19178. }
  19179. };
  19180. }
  19181. var domprops = [
  19182. "$&",
  19183. "$'",
  19184. "$*",
  19185. "$+",
  19186. "$1",
  19187. "$2",
  19188. "$3",
  19189. "$4",
  19190. "$5",
  19191. "$6",
  19192. "$7",
  19193. "$8",
  19194. "$9",
  19195. "$_",
  19196. "$`",
  19197. "$input",
  19198. "-moz-animation",
  19199. "-moz-animation-delay",
  19200. "-moz-animation-direction",
  19201. "-moz-animation-duration",
  19202. "-moz-animation-fill-mode",
  19203. "-moz-animation-iteration-count",
  19204. "-moz-animation-name",
  19205. "-moz-animation-play-state",
  19206. "-moz-animation-timing-function",
  19207. "-moz-appearance",
  19208. "-moz-backface-visibility",
  19209. "-moz-border-end",
  19210. "-moz-border-end-color",
  19211. "-moz-border-end-style",
  19212. "-moz-border-end-width",
  19213. "-moz-border-image",
  19214. "-moz-border-start",
  19215. "-moz-border-start-color",
  19216. "-moz-border-start-style",
  19217. "-moz-border-start-width",
  19218. "-moz-box-align",
  19219. "-moz-box-direction",
  19220. "-moz-box-flex",
  19221. "-moz-box-ordinal-group",
  19222. "-moz-box-orient",
  19223. "-moz-box-pack",
  19224. "-moz-box-sizing",
  19225. "-moz-float-edge",
  19226. "-moz-font-feature-settings",
  19227. "-moz-font-language-override",
  19228. "-moz-force-broken-image-icon",
  19229. "-moz-hyphens",
  19230. "-moz-image-region",
  19231. "-moz-margin-end",
  19232. "-moz-margin-start",
  19233. "-moz-orient",
  19234. "-moz-osx-font-smoothing",
  19235. "-moz-outline-radius",
  19236. "-moz-outline-radius-bottomleft",
  19237. "-moz-outline-radius-bottomright",
  19238. "-moz-outline-radius-topleft",
  19239. "-moz-outline-radius-topright",
  19240. "-moz-padding-end",
  19241. "-moz-padding-start",
  19242. "-moz-perspective",
  19243. "-moz-perspective-origin",
  19244. "-moz-tab-size",
  19245. "-moz-text-size-adjust",
  19246. "-moz-transform",
  19247. "-moz-transform-origin",
  19248. "-moz-transform-style",
  19249. "-moz-transition",
  19250. "-moz-transition-delay",
  19251. "-moz-transition-duration",
  19252. "-moz-transition-property",
  19253. "-moz-transition-timing-function",
  19254. "-moz-user-focus",
  19255. "-moz-user-input",
  19256. "-moz-user-modify",
  19257. "-moz-user-select",
  19258. "-moz-window-dragging",
  19259. "-webkit-align-content",
  19260. "-webkit-align-items",
  19261. "-webkit-align-self",
  19262. "-webkit-animation",
  19263. "-webkit-animation-delay",
  19264. "-webkit-animation-direction",
  19265. "-webkit-animation-duration",
  19266. "-webkit-animation-fill-mode",
  19267. "-webkit-animation-iteration-count",
  19268. "-webkit-animation-name",
  19269. "-webkit-animation-play-state",
  19270. "-webkit-animation-timing-function",
  19271. "-webkit-appearance",
  19272. "-webkit-backface-visibility",
  19273. "-webkit-background-clip",
  19274. "-webkit-background-origin",
  19275. "-webkit-background-size",
  19276. "-webkit-border-bottom-left-radius",
  19277. "-webkit-border-bottom-right-radius",
  19278. "-webkit-border-image",
  19279. "-webkit-border-radius",
  19280. "-webkit-border-top-left-radius",
  19281. "-webkit-border-top-right-radius",
  19282. "-webkit-box-align",
  19283. "-webkit-box-direction",
  19284. "-webkit-box-flex",
  19285. "-webkit-box-ordinal-group",
  19286. "-webkit-box-orient",
  19287. "-webkit-box-pack",
  19288. "-webkit-box-shadow",
  19289. "-webkit-box-sizing",
  19290. "-webkit-filter",
  19291. "-webkit-flex",
  19292. "-webkit-flex-basis",
  19293. "-webkit-flex-direction",
  19294. "-webkit-flex-flow",
  19295. "-webkit-flex-grow",
  19296. "-webkit-flex-shrink",
  19297. "-webkit-flex-wrap",
  19298. "-webkit-justify-content",
  19299. "-webkit-line-clamp",
  19300. "-webkit-mask",
  19301. "-webkit-mask-clip",
  19302. "-webkit-mask-composite",
  19303. "-webkit-mask-image",
  19304. "-webkit-mask-origin",
  19305. "-webkit-mask-position",
  19306. "-webkit-mask-position-x",
  19307. "-webkit-mask-position-y",
  19308. "-webkit-mask-repeat",
  19309. "-webkit-mask-size",
  19310. "-webkit-order",
  19311. "-webkit-perspective",
  19312. "-webkit-perspective-origin",
  19313. "-webkit-text-fill-color",
  19314. "-webkit-text-size-adjust",
  19315. "-webkit-text-stroke",
  19316. "-webkit-text-stroke-color",
  19317. "-webkit-text-stroke-width",
  19318. "-webkit-transform",
  19319. "-webkit-transform-origin",
  19320. "-webkit-transform-style",
  19321. "-webkit-transition",
  19322. "-webkit-transition-delay",
  19323. "-webkit-transition-duration",
  19324. "-webkit-transition-property",
  19325. "-webkit-transition-timing-function",
  19326. "-webkit-user-select",
  19327. "0",
  19328. "1",
  19329. "10",
  19330. "11",
  19331. "12",
  19332. "13",
  19333. "14",
  19334. "15",
  19335. "16",
  19336. "17",
  19337. "18",
  19338. "19",
  19339. "2",
  19340. "20",
  19341. "3",
  19342. "4",
  19343. "5",
  19344. "6",
  19345. "7",
  19346. "8",
  19347. "9",
  19348. "@@iterator",
  19349. "ABORT_ERR",
  19350. "ACTIVE",
  19351. "ACTIVE_ATTRIBUTES",
  19352. "ACTIVE_TEXTURE",
  19353. "ACTIVE_UNIFORMS",
  19354. "ACTIVE_UNIFORM_BLOCKS",
  19355. "ADDITION",
  19356. "ALIASED_LINE_WIDTH_RANGE",
  19357. "ALIASED_POINT_SIZE_RANGE",
  19358. "ALLOW_KEYBOARD_INPUT",
  19359. "ALLPASS",
  19360. "ALPHA",
  19361. "ALPHA_BITS",
  19362. "ALREADY_SIGNALED",
  19363. "ALT_MASK",
  19364. "ALWAYS",
  19365. "ANY_SAMPLES_PASSED",
  19366. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  19367. "ANY_TYPE",
  19368. "ANY_UNORDERED_NODE_TYPE",
  19369. "ARRAY_BUFFER",
  19370. "ARRAY_BUFFER_BINDING",
  19371. "ATTACHED_SHADERS",
  19372. "ATTRIBUTE_NODE",
  19373. "AT_TARGET",
  19374. "AbortController",
  19375. "AbortSignal",
  19376. "AbsoluteOrientationSensor",
  19377. "AbstractRange",
  19378. "Accelerometer",
  19379. "AddSearchProvider",
  19380. "AggregateError",
  19381. "AnalyserNode",
  19382. "Animation",
  19383. "AnimationEffect",
  19384. "AnimationEvent",
  19385. "AnimationPlaybackEvent",
  19386. "AnimationTimeline",
  19387. "AnonXMLHttpRequest",
  19388. "Any",
  19389. "ApplicationCache",
  19390. "ApplicationCacheErrorEvent",
  19391. "Array",
  19392. "ArrayBuffer",
  19393. "ArrayType",
  19394. "Atomics",
  19395. "Attr",
  19396. "Audio",
  19397. "AudioBuffer",
  19398. "AudioBufferSourceNode",
  19399. "AudioContext",
  19400. "AudioDestinationNode",
  19401. "AudioListener",
  19402. "AudioNode",
  19403. "AudioParam",
  19404. "AudioParamMap",
  19405. "AudioProcessingEvent",
  19406. "AudioScheduledSourceNode",
  19407. "AudioStreamTrack",
  19408. "AudioWorklet",
  19409. "AudioWorkletNode",
  19410. "AuthenticatorAssertionResponse",
  19411. "AuthenticatorAttestationResponse",
  19412. "AuthenticatorResponse",
  19413. "AutocompleteErrorEvent",
  19414. "BACK",
  19415. "BAD_BOUNDARYPOINTS_ERR",
  19416. "BAD_REQUEST",
  19417. "BANDPASS",
  19418. "BLEND",
  19419. "BLEND_COLOR",
  19420. "BLEND_DST_ALPHA",
  19421. "BLEND_DST_RGB",
  19422. "BLEND_EQUATION",
  19423. "BLEND_EQUATION_ALPHA",
  19424. "BLEND_EQUATION_RGB",
  19425. "BLEND_SRC_ALPHA",
  19426. "BLEND_SRC_RGB",
  19427. "BLUE_BITS",
  19428. "BLUR",
  19429. "BOOL",
  19430. "BOOLEAN_TYPE",
  19431. "BOOL_VEC2",
  19432. "BOOL_VEC3",
  19433. "BOOL_VEC4",
  19434. "BOTH",
  19435. "BROWSER_DEFAULT_WEBGL",
  19436. "BUBBLING_PHASE",
  19437. "BUFFER_SIZE",
  19438. "BUFFER_USAGE",
  19439. "BYTE",
  19440. "BYTES_PER_ELEMENT",
  19441. "BackgroundFetchManager",
  19442. "BackgroundFetchRecord",
  19443. "BackgroundFetchRegistration",
  19444. "BarProp",
  19445. "BarcodeDetector",
  19446. "BaseAudioContext",
  19447. "BaseHref",
  19448. "BatteryManager",
  19449. "BeforeInstallPromptEvent",
  19450. "BeforeLoadEvent",
  19451. "BeforeUnloadEvent",
  19452. "BigInt",
  19453. "BigInt64Array",
  19454. "BigUint64Array",
  19455. "BiquadFilterNode",
  19456. "Blob",
  19457. "BlobEvent",
  19458. "Bluetooth",
  19459. "BluetoothCharacteristicProperties",
  19460. "BluetoothDevice",
  19461. "BluetoothRemoteGATTCharacteristic",
  19462. "BluetoothRemoteGATTDescriptor",
  19463. "BluetoothRemoteGATTServer",
  19464. "BluetoothRemoteGATTService",
  19465. "BluetoothUUID",
  19466. "Boolean",
  19467. "BroadcastChannel",
  19468. "ByteLengthQueuingStrategy",
  19469. "CAPTURING_PHASE",
  19470. "CCW",
  19471. "CDATASection",
  19472. "CDATA_SECTION_NODE",
  19473. "CHANGE",
  19474. "CHARSET_RULE",
  19475. "CHECKING",
  19476. "CLAMP_TO_EDGE",
  19477. "CLICK",
  19478. "CLOSED",
  19479. "CLOSING",
  19480. "COLOR",
  19481. "COLOR_ATTACHMENT0",
  19482. "COLOR_ATTACHMENT1",
  19483. "COLOR_ATTACHMENT10",
  19484. "COLOR_ATTACHMENT11",
  19485. "COLOR_ATTACHMENT12",
  19486. "COLOR_ATTACHMENT13",
  19487. "COLOR_ATTACHMENT14",
  19488. "COLOR_ATTACHMENT15",
  19489. "COLOR_ATTACHMENT2",
  19490. "COLOR_ATTACHMENT3",
  19491. "COLOR_ATTACHMENT4",
  19492. "COLOR_ATTACHMENT5",
  19493. "COLOR_ATTACHMENT6",
  19494. "COLOR_ATTACHMENT7",
  19495. "COLOR_ATTACHMENT8",
  19496. "COLOR_ATTACHMENT9",
  19497. "COLOR_BUFFER_BIT",
  19498. "COLOR_CLEAR_VALUE",
  19499. "COLOR_WRITEMASK",
  19500. "COMMENT_NODE",
  19501. "COMPARE_REF_TO_TEXTURE",
  19502. "COMPILE_STATUS",
  19503. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  19504. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  19505. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  19506. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  19507. "COMPRESSED_TEXTURE_FORMATS",
  19508. "CONDITION_SATISFIED",
  19509. "CONFIGURATION_UNSUPPORTED",
  19510. "CONNECTING",
  19511. "CONSTANT_ALPHA",
  19512. "CONSTANT_COLOR",
  19513. "CONSTRAINT_ERR",
  19514. "CONTEXT_LOST_WEBGL",
  19515. "CONTROL_MASK",
  19516. "COPY_READ_BUFFER",
  19517. "COPY_READ_BUFFER_BINDING",
  19518. "COPY_WRITE_BUFFER",
  19519. "COPY_WRITE_BUFFER_BINDING",
  19520. "COUNTER_STYLE_RULE",
  19521. "CSS",
  19522. "CSS2Properties",
  19523. "CSSAnimation",
  19524. "CSSCharsetRule",
  19525. "CSSConditionRule",
  19526. "CSSCounterStyleRule",
  19527. "CSSFontFaceRule",
  19528. "CSSFontFeatureValuesRule",
  19529. "CSSGroupingRule",
  19530. "CSSImageValue",
  19531. "CSSImportRule",
  19532. "CSSKeyframeRule",
  19533. "CSSKeyframesRule",
  19534. "CSSKeywordValue",
  19535. "CSSMathInvert",
  19536. "CSSMathMax",
  19537. "CSSMathMin",
  19538. "CSSMathNegate",
  19539. "CSSMathProduct",
  19540. "CSSMathSum",
  19541. "CSSMathValue",
  19542. "CSSMatrixComponent",
  19543. "CSSMediaRule",
  19544. "CSSMozDocumentRule",
  19545. "CSSNameSpaceRule",
  19546. "CSSNamespaceRule",
  19547. "CSSNumericArray",
  19548. "CSSNumericValue",
  19549. "CSSPageRule",
  19550. "CSSPerspective",
  19551. "CSSPositionValue",
  19552. "CSSPrimitiveValue",
  19553. "CSSRotate",
  19554. "CSSRule",
  19555. "CSSRuleList",
  19556. "CSSScale",
  19557. "CSSSkew",
  19558. "CSSSkewX",
  19559. "CSSSkewY",
  19560. "CSSStyleDeclaration",
  19561. "CSSStyleRule",
  19562. "CSSStyleSheet",
  19563. "CSSStyleValue",
  19564. "CSSSupportsRule",
  19565. "CSSTransformComponent",
  19566. "CSSTransformValue",
  19567. "CSSTransition",
  19568. "CSSTranslate",
  19569. "CSSUnitValue",
  19570. "CSSUnknownRule",
  19571. "CSSUnparsedValue",
  19572. "CSSValue",
  19573. "CSSValueList",
  19574. "CSSVariableReferenceValue",
  19575. "CSSVariablesDeclaration",
  19576. "CSSVariablesRule",
  19577. "CSSViewportRule",
  19578. "CSS_ATTR",
  19579. "CSS_CM",
  19580. "CSS_COUNTER",
  19581. "CSS_CUSTOM",
  19582. "CSS_DEG",
  19583. "CSS_DIMENSION",
  19584. "CSS_EMS",
  19585. "CSS_EXS",
  19586. "CSS_FILTER_BLUR",
  19587. "CSS_FILTER_BRIGHTNESS",
  19588. "CSS_FILTER_CONTRAST",
  19589. "CSS_FILTER_CUSTOM",
  19590. "CSS_FILTER_DROP_SHADOW",
  19591. "CSS_FILTER_GRAYSCALE",
  19592. "CSS_FILTER_HUE_ROTATE",
  19593. "CSS_FILTER_INVERT",
  19594. "CSS_FILTER_OPACITY",
  19595. "CSS_FILTER_REFERENCE",
  19596. "CSS_FILTER_SATURATE",
  19597. "CSS_FILTER_SEPIA",
  19598. "CSS_GRAD",
  19599. "CSS_HZ",
  19600. "CSS_IDENT",
  19601. "CSS_IN",
  19602. "CSS_INHERIT",
  19603. "CSS_KHZ",
  19604. "CSS_MATRIX",
  19605. "CSS_MATRIX3D",
  19606. "CSS_MM",
  19607. "CSS_MS",
  19608. "CSS_NUMBER",
  19609. "CSS_PC",
  19610. "CSS_PERCENTAGE",
  19611. "CSS_PERSPECTIVE",
  19612. "CSS_PRIMITIVE_VALUE",
  19613. "CSS_PT",
  19614. "CSS_PX",
  19615. "CSS_RAD",
  19616. "CSS_RECT",
  19617. "CSS_RGBCOLOR",
  19618. "CSS_ROTATE",
  19619. "CSS_ROTATE3D",
  19620. "CSS_ROTATEX",
  19621. "CSS_ROTATEY",
  19622. "CSS_ROTATEZ",
  19623. "CSS_S",
  19624. "CSS_SCALE",
  19625. "CSS_SCALE3D",
  19626. "CSS_SCALEX",
  19627. "CSS_SCALEY",
  19628. "CSS_SCALEZ",
  19629. "CSS_SKEW",
  19630. "CSS_SKEWX",
  19631. "CSS_SKEWY",
  19632. "CSS_STRING",
  19633. "CSS_TRANSLATE",
  19634. "CSS_TRANSLATE3D",
  19635. "CSS_TRANSLATEX",
  19636. "CSS_TRANSLATEY",
  19637. "CSS_TRANSLATEZ",
  19638. "CSS_UNKNOWN",
  19639. "CSS_URI",
  19640. "CSS_VALUE_LIST",
  19641. "CSS_VH",
  19642. "CSS_VMAX",
  19643. "CSS_VMIN",
  19644. "CSS_VW",
  19645. "CULL_FACE",
  19646. "CULL_FACE_MODE",
  19647. "CURRENT_PROGRAM",
  19648. "CURRENT_QUERY",
  19649. "CURRENT_VERTEX_ATTRIB",
  19650. "CUSTOM",
  19651. "CW",
  19652. "Cache",
  19653. "CacheStorage",
  19654. "CanvasCaptureMediaStream",
  19655. "CanvasCaptureMediaStreamTrack",
  19656. "CanvasGradient",
  19657. "CanvasPattern",
  19658. "CanvasRenderingContext2D",
  19659. "CaretPosition",
  19660. "ChannelMergerNode",
  19661. "ChannelSplitterNode",
  19662. "CharacterData",
  19663. "ClientRect",
  19664. "ClientRectList",
  19665. "Clipboard",
  19666. "ClipboardEvent",
  19667. "ClipboardItem",
  19668. "CloseEvent",
  19669. "Collator",
  19670. "CommandEvent",
  19671. "Comment",
  19672. "CompileError",
  19673. "CompositionEvent",
  19674. "CompressionStream",
  19675. "Console",
  19676. "ConstantSourceNode",
  19677. "Controllers",
  19678. "ConvolverNode",
  19679. "CountQueuingStrategy",
  19680. "Counter",
  19681. "Credential",
  19682. "CredentialsContainer",
  19683. "Crypto",
  19684. "CryptoKey",
  19685. "CustomElementRegistry",
  19686. "CustomEvent",
  19687. "DATABASE_ERR",
  19688. "DATA_CLONE_ERR",
  19689. "DATA_ERR",
  19690. "DBLCLICK",
  19691. "DECR",
  19692. "DECR_WRAP",
  19693. "DELETE_STATUS",
  19694. "DEPTH",
  19695. "DEPTH24_STENCIL8",
  19696. "DEPTH32F_STENCIL8",
  19697. "DEPTH_ATTACHMENT",
  19698. "DEPTH_BITS",
  19699. "DEPTH_BUFFER_BIT",
  19700. "DEPTH_CLEAR_VALUE",
  19701. "DEPTH_COMPONENT",
  19702. "DEPTH_COMPONENT16",
  19703. "DEPTH_COMPONENT24",
  19704. "DEPTH_COMPONENT32F",
  19705. "DEPTH_FUNC",
  19706. "DEPTH_RANGE",
  19707. "DEPTH_STENCIL",
  19708. "DEPTH_STENCIL_ATTACHMENT",
  19709. "DEPTH_TEST",
  19710. "DEPTH_WRITEMASK",
  19711. "DEVICE_INELIGIBLE",
  19712. "DIRECTION_DOWN",
  19713. "DIRECTION_LEFT",
  19714. "DIRECTION_RIGHT",
  19715. "DIRECTION_UP",
  19716. "DISABLED",
  19717. "DISPATCH_REQUEST_ERR",
  19718. "DITHER",
  19719. "DOCUMENT_FRAGMENT_NODE",
  19720. "DOCUMENT_NODE",
  19721. "DOCUMENT_POSITION_CONTAINED_BY",
  19722. "DOCUMENT_POSITION_CONTAINS",
  19723. "DOCUMENT_POSITION_DISCONNECTED",
  19724. "DOCUMENT_POSITION_FOLLOWING",
  19725. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  19726. "DOCUMENT_POSITION_PRECEDING",
  19727. "DOCUMENT_TYPE_NODE",
  19728. "DOMCursor",
  19729. "DOMError",
  19730. "DOMException",
  19731. "DOMImplementation",
  19732. "DOMImplementationLS",
  19733. "DOMMatrix",
  19734. "DOMMatrixReadOnly",
  19735. "DOMParser",
  19736. "DOMPoint",
  19737. "DOMPointReadOnly",
  19738. "DOMQuad",
  19739. "DOMRect",
  19740. "DOMRectList",
  19741. "DOMRectReadOnly",
  19742. "DOMRequest",
  19743. "DOMSTRING_SIZE_ERR",
  19744. "DOMSettableTokenList",
  19745. "DOMStringList",
  19746. "DOMStringMap",
  19747. "DOMTokenList",
  19748. "DOMTransactionEvent",
  19749. "DOM_DELTA_LINE",
  19750. "DOM_DELTA_PAGE",
  19751. "DOM_DELTA_PIXEL",
  19752. "DOM_INPUT_METHOD_DROP",
  19753. "DOM_INPUT_METHOD_HANDWRITING",
  19754. "DOM_INPUT_METHOD_IME",
  19755. "DOM_INPUT_METHOD_KEYBOARD",
  19756. "DOM_INPUT_METHOD_MULTIMODAL",
  19757. "DOM_INPUT_METHOD_OPTION",
  19758. "DOM_INPUT_METHOD_PASTE",
  19759. "DOM_INPUT_METHOD_SCRIPT",
  19760. "DOM_INPUT_METHOD_UNKNOWN",
  19761. "DOM_INPUT_METHOD_VOICE",
  19762. "DOM_KEY_LOCATION_JOYSTICK",
  19763. "DOM_KEY_LOCATION_LEFT",
  19764. "DOM_KEY_LOCATION_MOBILE",
  19765. "DOM_KEY_LOCATION_NUMPAD",
  19766. "DOM_KEY_LOCATION_RIGHT",
  19767. "DOM_KEY_LOCATION_STANDARD",
  19768. "DOM_VK_0",
  19769. "DOM_VK_1",
  19770. "DOM_VK_2",
  19771. "DOM_VK_3",
  19772. "DOM_VK_4",
  19773. "DOM_VK_5",
  19774. "DOM_VK_6",
  19775. "DOM_VK_7",
  19776. "DOM_VK_8",
  19777. "DOM_VK_9",
  19778. "DOM_VK_A",
  19779. "DOM_VK_ACCEPT",
  19780. "DOM_VK_ADD",
  19781. "DOM_VK_ALT",
  19782. "DOM_VK_ALTGR",
  19783. "DOM_VK_AMPERSAND",
  19784. "DOM_VK_ASTERISK",
  19785. "DOM_VK_AT",
  19786. "DOM_VK_ATTN",
  19787. "DOM_VK_B",
  19788. "DOM_VK_BACKSPACE",
  19789. "DOM_VK_BACK_QUOTE",
  19790. "DOM_VK_BACK_SLASH",
  19791. "DOM_VK_BACK_SPACE",
  19792. "DOM_VK_C",
  19793. "DOM_VK_CANCEL",
  19794. "DOM_VK_CAPS_LOCK",
  19795. "DOM_VK_CIRCUMFLEX",
  19796. "DOM_VK_CLEAR",
  19797. "DOM_VK_CLOSE_BRACKET",
  19798. "DOM_VK_CLOSE_CURLY_BRACKET",
  19799. "DOM_VK_CLOSE_PAREN",
  19800. "DOM_VK_COLON",
  19801. "DOM_VK_COMMA",
  19802. "DOM_VK_CONTEXT_MENU",
  19803. "DOM_VK_CONTROL",
  19804. "DOM_VK_CONVERT",
  19805. "DOM_VK_CRSEL",
  19806. "DOM_VK_CTRL",
  19807. "DOM_VK_D",
  19808. "DOM_VK_DECIMAL",
  19809. "DOM_VK_DELETE",
  19810. "DOM_VK_DIVIDE",
  19811. "DOM_VK_DOLLAR",
  19812. "DOM_VK_DOUBLE_QUOTE",
  19813. "DOM_VK_DOWN",
  19814. "DOM_VK_E",
  19815. "DOM_VK_EISU",
  19816. "DOM_VK_END",
  19817. "DOM_VK_ENTER",
  19818. "DOM_VK_EQUALS",
  19819. "DOM_VK_EREOF",
  19820. "DOM_VK_ESCAPE",
  19821. "DOM_VK_EXCLAMATION",
  19822. "DOM_VK_EXECUTE",
  19823. "DOM_VK_EXSEL",
  19824. "DOM_VK_F",
  19825. "DOM_VK_F1",
  19826. "DOM_VK_F10",
  19827. "DOM_VK_F11",
  19828. "DOM_VK_F12",
  19829. "DOM_VK_F13",
  19830. "DOM_VK_F14",
  19831. "DOM_VK_F15",
  19832. "DOM_VK_F16",
  19833. "DOM_VK_F17",
  19834. "DOM_VK_F18",
  19835. "DOM_VK_F19",
  19836. "DOM_VK_F2",
  19837. "DOM_VK_F20",
  19838. "DOM_VK_F21",
  19839. "DOM_VK_F22",
  19840. "DOM_VK_F23",
  19841. "DOM_VK_F24",
  19842. "DOM_VK_F25",
  19843. "DOM_VK_F26",
  19844. "DOM_VK_F27",
  19845. "DOM_VK_F28",
  19846. "DOM_VK_F29",
  19847. "DOM_VK_F3",
  19848. "DOM_VK_F30",
  19849. "DOM_VK_F31",
  19850. "DOM_VK_F32",
  19851. "DOM_VK_F33",
  19852. "DOM_VK_F34",
  19853. "DOM_VK_F35",
  19854. "DOM_VK_F36",
  19855. "DOM_VK_F4",
  19856. "DOM_VK_F5",
  19857. "DOM_VK_F6",
  19858. "DOM_VK_F7",
  19859. "DOM_VK_F8",
  19860. "DOM_VK_F9",
  19861. "DOM_VK_FINAL",
  19862. "DOM_VK_FRONT",
  19863. "DOM_VK_G",
  19864. "DOM_VK_GREATER_THAN",
  19865. "DOM_VK_H",
  19866. "DOM_VK_HANGUL",
  19867. "DOM_VK_HANJA",
  19868. "DOM_VK_HASH",
  19869. "DOM_VK_HELP",
  19870. "DOM_VK_HK_TOGGLE",
  19871. "DOM_VK_HOME",
  19872. "DOM_VK_HYPHEN_MINUS",
  19873. "DOM_VK_I",
  19874. "DOM_VK_INSERT",
  19875. "DOM_VK_J",
  19876. "DOM_VK_JUNJA",
  19877. "DOM_VK_K",
  19878. "DOM_VK_KANA",
  19879. "DOM_VK_KANJI",
  19880. "DOM_VK_L",
  19881. "DOM_VK_LEFT",
  19882. "DOM_VK_LEFT_TAB",
  19883. "DOM_VK_LESS_THAN",
  19884. "DOM_VK_M",
  19885. "DOM_VK_META",
  19886. "DOM_VK_MODECHANGE",
  19887. "DOM_VK_MULTIPLY",
  19888. "DOM_VK_N",
  19889. "DOM_VK_NONCONVERT",
  19890. "DOM_VK_NUMPAD0",
  19891. "DOM_VK_NUMPAD1",
  19892. "DOM_VK_NUMPAD2",
  19893. "DOM_VK_NUMPAD3",
  19894. "DOM_VK_NUMPAD4",
  19895. "DOM_VK_NUMPAD5",
  19896. "DOM_VK_NUMPAD6",
  19897. "DOM_VK_NUMPAD7",
  19898. "DOM_VK_NUMPAD8",
  19899. "DOM_VK_NUMPAD9",
  19900. "DOM_VK_NUM_LOCK",
  19901. "DOM_VK_O",
  19902. "DOM_VK_OEM_1",
  19903. "DOM_VK_OEM_102",
  19904. "DOM_VK_OEM_2",
  19905. "DOM_VK_OEM_3",
  19906. "DOM_VK_OEM_4",
  19907. "DOM_VK_OEM_5",
  19908. "DOM_VK_OEM_6",
  19909. "DOM_VK_OEM_7",
  19910. "DOM_VK_OEM_8",
  19911. "DOM_VK_OEM_COMMA",
  19912. "DOM_VK_OEM_MINUS",
  19913. "DOM_VK_OEM_PERIOD",
  19914. "DOM_VK_OEM_PLUS",
  19915. "DOM_VK_OPEN_BRACKET",
  19916. "DOM_VK_OPEN_CURLY_BRACKET",
  19917. "DOM_VK_OPEN_PAREN",
  19918. "DOM_VK_P",
  19919. "DOM_VK_PA1",
  19920. "DOM_VK_PAGEDOWN",
  19921. "DOM_VK_PAGEUP",
  19922. "DOM_VK_PAGE_DOWN",
  19923. "DOM_VK_PAGE_UP",
  19924. "DOM_VK_PAUSE",
  19925. "DOM_VK_PERCENT",
  19926. "DOM_VK_PERIOD",
  19927. "DOM_VK_PIPE",
  19928. "DOM_VK_PLAY",
  19929. "DOM_VK_PLUS",
  19930. "DOM_VK_PRINT",
  19931. "DOM_VK_PRINTSCREEN",
  19932. "DOM_VK_PROCESSKEY",
  19933. "DOM_VK_PROPERITES",
  19934. "DOM_VK_Q",
  19935. "DOM_VK_QUESTION_MARK",
  19936. "DOM_VK_QUOTE",
  19937. "DOM_VK_R",
  19938. "DOM_VK_REDO",
  19939. "DOM_VK_RETURN",
  19940. "DOM_VK_RIGHT",
  19941. "DOM_VK_S",
  19942. "DOM_VK_SCROLL_LOCK",
  19943. "DOM_VK_SELECT",
  19944. "DOM_VK_SEMICOLON",
  19945. "DOM_VK_SEPARATOR",
  19946. "DOM_VK_SHIFT",
  19947. "DOM_VK_SLASH",
  19948. "DOM_VK_SLEEP",
  19949. "DOM_VK_SPACE",
  19950. "DOM_VK_SUBTRACT",
  19951. "DOM_VK_T",
  19952. "DOM_VK_TAB",
  19953. "DOM_VK_TILDE",
  19954. "DOM_VK_U",
  19955. "DOM_VK_UNDERSCORE",
  19956. "DOM_VK_UNDO",
  19957. "DOM_VK_UNICODE",
  19958. "DOM_VK_UP",
  19959. "DOM_VK_V",
  19960. "DOM_VK_VOLUME_DOWN",
  19961. "DOM_VK_VOLUME_MUTE",
  19962. "DOM_VK_VOLUME_UP",
  19963. "DOM_VK_W",
  19964. "DOM_VK_WIN",
  19965. "DOM_VK_WINDOW",
  19966. "DOM_VK_WIN_ICO_00",
  19967. "DOM_VK_WIN_ICO_CLEAR",
  19968. "DOM_VK_WIN_ICO_HELP",
  19969. "DOM_VK_WIN_OEM_ATTN",
  19970. "DOM_VK_WIN_OEM_AUTO",
  19971. "DOM_VK_WIN_OEM_BACKTAB",
  19972. "DOM_VK_WIN_OEM_CLEAR",
  19973. "DOM_VK_WIN_OEM_COPY",
  19974. "DOM_VK_WIN_OEM_CUSEL",
  19975. "DOM_VK_WIN_OEM_ENLW",
  19976. "DOM_VK_WIN_OEM_FINISH",
  19977. "DOM_VK_WIN_OEM_FJ_JISHO",
  19978. "DOM_VK_WIN_OEM_FJ_LOYA",
  19979. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  19980. "DOM_VK_WIN_OEM_FJ_ROYA",
  19981. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  19982. "DOM_VK_WIN_OEM_JUMP",
  19983. "DOM_VK_WIN_OEM_PA1",
  19984. "DOM_VK_WIN_OEM_PA2",
  19985. "DOM_VK_WIN_OEM_PA3",
  19986. "DOM_VK_WIN_OEM_RESET",
  19987. "DOM_VK_WIN_OEM_WSCTRL",
  19988. "DOM_VK_X",
  19989. "DOM_VK_XF86XK_ADD_FAVORITE",
  19990. "DOM_VK_XF86XK_APPLICATION_LEFT",
  19991. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  19992. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  19993. "DOM_VK_XF86XK_AUDIO_FORWARD",
  19994. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  19995. "DOM_VK_XF86XK_AUDIO_MEDIA",
  19996. "DOM_VK_XF86XK_AUDIO_MUTE",
  19997. "DOM_VK_XF86XK_AUDIO_NEXT",
  19998. "DOM_VK_XF86XK_AUDIO_PAUSE",
  19999. "DOM_VK_XF86XK_AUDIO_PLAY",
  20000. "DOM_VK_XF86XK_AUDIO_PREV",
  20001. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  20002. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  20003. "DOM_VK_XF86XK_AUDIO_RECORD",
  20004. "DOM_VK_XF86XK_AUDIO_REPEAT",
  20005. "DOM_VK_XF86XK_AUDIO_REWIND",
  20006. "DOM_VK_XF86XK_AUDIO_STOP",
  20007. "DOM_VK_XF86XK_AWAY",
  20008. "DOM_VK_XF86XK_BACK",
  20009. "DOM_VK_XF86XK_BACK_FORWARD",
  20010. "DOM_VK_XF86XK_BATTERY",
  20011. "DOM_VK_XF86XK_BLUE",
  20012. "DOM_VK_XF86XK_BLUETOOTH",
  20013. "DOM_VK_XF86XK_BOOK",
  20014. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  20015. "DOM_VK_XF86XK_CALCULATOR",
  20016. "DOM_VK_XF86XK_CALENDAR",
  20017. "DOM_VK_XF86XK_CD",
  20018. "DOM_VK_XF86XK_CLOSE",
  20019. "DOM_VK_XF86XK_COMMUNITY",
  20020. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  20021. "DOM_VK_XF86XK_COPY",
  20022. "DOM_VK_XF86XK_CUT",
  20023. "DOM_VK_XF86XK_CYCLE_ANGLE",
  20024. "DOM_VK_XF86XK_DISPLAY",
  20025. "DOM_VK_XF86XK_DOCUMENTS",
  20026. "DOM_VK_XF86XK_DOS",
  20027. "DOM_VK_XF86XK_EJECT",
  20028. "DOM_VK_XF86XK_EXCEL",
  20029. "DOM_VK_XF86XK_EXPLORER",
  20030. "DOM_VK_XF86XK_FAVORITES",
  20031. "DOM_VK_XF86XK_FINANCE",
  20032. "DOM_VK_XF86XK_FORWARD",
  20033. "DOM_VK_XF86XK_FRAME_BACK",
  20034. "DOM_VK_XF86XK_FRAME_FORWARD",
  20035. "DOM_VK_XF86XK_GAME",
  20036. "DOM_VK_XF86XK_GO",
  20037. "DOM_VK_XF86XK_GREEN",
  20038. "DOM_VK_XF86XK_HIBERNATE",
  20039. "DOM_VK_XF86XK_HISTORY",
  20040. "DOM_VK_XF86XK_HOME_PAGE",
  20041. "DOM_VK_XF86XK_HOT_LINKS",
  20042. "DOM_VK_XF86XK_I_TOUCH",
  20043. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  20044. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  20045. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  20046. "DOM_VK_XF86XK_LAUNCH0",
  20047. "DOM_VK_XF86XK_LAUNCH1",
  20048. "DOM_VK_XF86XK_LAUNCH2",
  20049. "DOM_VK_XF86XK_LAUNCH3",
  20050. "DOM_VK_XF86XK_LAUNCH4",
  20051. "DOM_VK_XF86XK_LAUNCH5",
  20052. "DOM_VK_XF86XK_LAUNCH6",
  20053. "DOM_VK_XF86XK_LAUNCH7",
  20054. "DOM_VK_XF86XK_LAUNCH8",
  20055. "DOM_VK_XF86XK_LAUNCH9",
  20056. "DOM_VK_XF86XK_LAUNCH_A",
  20057. "DOM_VK_XF86XK_LAUNCH_B",
  20058. "DOM_VK_XF86XK_LAUNCH_C",
  20059. "DOM_VK_XF86XK_LAUNCH_D",
  20060. "DOM_VK_XF86XK_LAUNCH_E",
  20061. "DOM_VK_XF86XK_LAUNCH_F",
  20062. "DOM_VK_XF86XK_LIGHT_BULB",
  20063. "DOM_VK_XF86XK_LOG_OFF",
  20064. "DOM_VK_XF86XK_MAIL",
  20065. "DOM_VK_XF86XK_MAIL_FORWARD",
  20066. "DOM_VK_XF86XK_MARKET",
  20067. "DOM_VK_XF86XK_MEETING",
  20068. "DOM_VK_XF86XK_MEMO",
  20069. "DOM_VK_XF86XK_MENU_KB",
  20070. "DOM_VK_XF86XK_MENU_PB",
  20071. "DOM_VK_XF86XK_MESSENGER",
  20072. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  20073. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  20074. "DOM_VK_XF86XK_MUSIC",
  20075. "DOM_VK_XF86XK_MY_COMPUTER",
  20076. "DOM_VK_XF86XK_MY_SITES",
  20077. "DOM_VK_XF86XK_NEW",
  20078. "DOM_VK_XF86XK_NEWS",
  20079. "DOM_VK_XF86XK_OFFICE_HOME",
  20080. "DOM_VK_XF86XK_OPEN",
  20081. "DOM_VK_XF86XK_OPEN_URL",
  20082. "DOM_VK_XF86XK_OPTION",
  20083. "DOM_VK_XF86XK_PASTE",
  20084. "DOM_VK_XF86XK_PHONE",
  20085. "DOM_VK_XF86XK_PICTURES",
  20086. "DOM_VK_XF86XK_POWER_DOWN",
  20087. "DOM_VK_XF86XK_POWER_OFF",
  20088. "DOM_VK_XF86XK_RED",
  20089. "DOM_VK_XF86XK_REFRESH",
  20090. "DOM_VK_XF86XK_RELOAD",
  20091. "DOM_VK_XF86XK_REPLY",
  20092. "DOM_VK_XF86XK_ROCKER_DOWN",
  20093. "DOM_VK_XF86XK_ROCKER_ENTER",
  20094. "DOM_VK_XF86XK_ROCKER_UP",
  20095. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  20096. "DOM_VK_XF86XK_ROTATION_KB",
  20097. "DOM_VK_XF86XK_ROTATION_PB",
  20098. "DOM_VK_XF86XK_SAVE",
  20099. "DOM_VK_XF86XK_SCREEN_SAVER",
  20100. "DOM_VK_XF86XK_SCROLL_CLICK",
  20101. "DOM_VK_XF86XK_SCROLL_DOWN",
  20102. "DOM_VK_XF86XK_SCROLL_UP",
  20103. "DOM_VK_XF86XK_SEARCH",
  20104. "DOM_VK_XF86XK_SEND",
  20105. "DOM_VK_XF86XK_SHOP",
  20106. "DOM_VK_XF86XK_SPELL",
  20107. "DOM_VK_XF86XK_SPLIT_SCREEN",
  20108. "DOM_VK_XF86XK_STANDBY",
  20109. "DOM_VK_XF86XK_START",
  20110. "DOM_VK_XF86XK_STOP",
  20111. "DOM_VK_XF86XK_SUBTITLE",
  20112. "DOM_VK_XF86XK_SUPPORT",
  20113. "DOM_VK_XF86XK_SUSPEND",
  20114. "DOM_VK_XF86XK_TASK_PANE",
  20115. "DOM_VK_XF86XK_TERMINAL",
  20116. "DOM_VK_XF86XK_TIME",
  20117. "DOM_VK_XF86XK_TOOLS",
  20118. "DOM_VK_XF86XK_TOP_MENU",
  20119. "DOM_VK_XF86XK_TO_DO_LIST",
  20120. "DOM_VK_XF86XK_TRAVEL",
  20121. "DOM_VK_XF86XK_USER1KB",
  20122. "DOM_VK_XF86XK_USER2KB",
  20123. "DOM_VK_XF86XK_USER_PB",
  20124. "DOM_VK_XF86XK_UWB",
  20125. "DOM_VK_XF86XK_VENDOR_HOME",
  20126. "DOM_VK_XF86XK_VIDEO",
  20127. "DOM_VK_XF86XK_VIEW",
  20128. "DOM_VK_XF86XK_WAKE_UP",
  20129. "DOM_VK_XF86XK_WEB_CAM",
  20130. "DOM_VK_XF86XK_WHEEL_BUTTON",
  20131. "DOM_VK_XF86XK_WLAN",
  20132. "DOM_VK_XF86XK_WORD",
  20133. "DOM_VK_XF86XK_WWW",
  20134. "DOM_VK_XF86XK_XFER",
  20135. "DOM_VK_XF86XK_YELLOW",
  20136. "DOM_VK_XF86XK_ZOOM_IN",
  20137. "DOM_VK_XF86XK_ZOOM_OUT",
  20138. "DOM_VK_Y",
  20139. "DOM_VK_Z",
  20140. "DOM_VK_ZOOM",
  20141. "DONE",
  20142. "DONT_CARE",
  20143. "DOWNLOADING",
  20144. "DRAGDROP",
  20145. "DRAW_BUFFER0",
  20146. "DRAW_BUFFER1",
  20147. "DRAW_BUFFER10",
  20148. "DRAW_BUFFER11",
  20149. "DRAW_BUFFER12",
  20150. "DRAW_BUFFER13",
  20151. "DRAW_BUFFER14",
  20152. "DRAW_BUFFER15",
  20153. "DRAW_BUFFER2",
  20154. "DRAW_BUFFER3",
  20155. "DRAW_BUFFER4",
  20156. "DRAW_BUFFER5",
  20157. "DRAW_BUFFER6",
  20158. "DRAW_BUFFER7",
  20159. "DRAW_BUFFER8",
  20160. "DRAW_BUFFER9",
  20161. "DRAW_FRAMEBUFFER",
  20162. "DRAW_FRAMEBUFFER_BINDING",
  20163. "DST_ALPHA",
  20164. "DST_COLOR",
  20165. "DYNAMIC_COPY",
  20166. "DYNAMIC_DRAW",
  20167. "DYNAMIC_READ",
  20168. "DataChannel",
  20169. "DataTransfer",
  20170. "DataTransferItem",
  20171. "DataTransferItemList",
  20172. "DataView",
  20173. "Date",
  20174. "DateTimeFormat",
  20175. "DecompressionStream",
  20176. "DelayNode",
  20177. "DeprecationReportBody",
  20178. "DesktopNotification",
  20179. "DesktopNotificationCenter",
  20180. "DeviceLightEvent",
  20181. "DeviceMotionEvent",
  20182. "DeviceMotionEventAcceleration",
  20183. "DeviceMotionEventRotationRate",
  20184. "DeviceOrientationEvent",
  20185. "DeviceProximityEvent",
  20186. "DeviceStorage",
  20187. "DeviceStorageChangeEvent",
  20188. "Directory",
  20189. "DisplayNames",
  20190. "Document",
  20191. "DocumentFragment",
  20192. "DocumentTimeline",
  20193. "DocumentType",
  20194. "DragEvent",
  20195. "DynamicsCompressorNode",
  20196. "E",
  20197. "ELEMENT_ARRAY_BUFFER",
  20198. "ELEMENT_ARRAY_BUFFER_BINDING",
  20199. "ELEMENT_NODE",
  20200. "EMPTY",
  20201. "ENCODING_ERR",
  20202. "ENDED",
  20203. "END_TO_END",
  20204. "END_TO_START",
  20205. "ENTITY_NODE",
  20206. "ENTITY_REFERENCE_NODE",
  20207. "EPSILON",
  20208. "EQUAL",
  20209. "EQUALPOWER",
  20210. "ERROR",
  20211. "EXPONENTIAL_DISTANCE",
  20212. "Element",
  20213. "ElementInternals",
  20214. "ElementQuery",
  20215. "EnterPictureInPictureEvent",
  20216. "Entity",
  20217. "EntityReference",
  20218. "Error",
  20219. "ErrorEvent",
  20220. "EvalError",
  20221. "Event",
  20222. "EventException",
  20223. "EventSource",
  20224. "EventTarget",
  20225. "External",
  20226. "FASTEST",
  20227. "FIDOSDK",
  20228. "FILTER_ACCEPT",
  20229. "FILTER_INTERRUPT",
  20230. "FILTER_REJECT",
  20231. "FILTER_SKIP",
  20232. "FINISHED_STATE",
  20233. "FIRST_ORDERED_NODE_TYPE",
  20234. "FLOAT",
  20235. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  20236. "FLOAT_MAT2",
  20237. "FLOAT_MAT2x3",
  20238. "FLOAT_MAT2x4",
  20239. "FLOAT_MAT3",
  20240. "FLOAT_MAT3x2",
  20241. "FLOAT_MAT3x4",
  20242. "FLOAT_MAT4",
  20243. "FLOAT_MAT4x2",
  20244. "FLOAT_MAT4x3",
  20245. "FLOAT_VEC2",
  20246. "FLOAT_VEC3",
  20247. "FLOAT_VEC4",
  20248. "FOCUS",
  20249. "FONT_FACE_RULE",
  20250. "FONT_FEATURE_VALUES_RULE",
  20251. "FRAGMENT_SHADER",
  20252. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  20253. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  20254. "FRAMEBUFFER",
  20255. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  20256. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  20257. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  20258. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  20259. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  20260. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  20261. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  20262. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  20263. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  20264. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  20265. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  20266. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  20267. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  20268. "FRAMEBUFFER_BINDING",
  20269. "FRAMEBUFFER_COMPLETE",
  20270. "FRAMEBUFFER_DEFAULT",
  20271. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  20272. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  20273. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  20274. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  20275. "FRAMEBUFFER_UNSUPPORTED",
  20276. "FRONT",
  20277. "FRONT_AND_BACK",
  20278. "FRONT_FACE",
  20279. "FUNC_ADD",
  20280. "FUNC_REVERSE_SUBTRACT",
  20281. "FUNC_SUBTRACT",
  20282. "FeaturePolicy",
  20283. "FeaturePolicyViolationReportBody",
  20284. "FederatedCredential",
  20285. "Feed",
  20286. "FeedEntry",
  20287. "File",
  20288. "FileError",
  20289. "FileList",
  20290. "FileReader",
  20291. "FileSystem",
  20292. "FileSystemDirectoryEntry",
  20293. "FileSystemDirectoryReader",
  20294. "FileSystemEntry",
  20295. "FileSystemFileEntry",
  20296. "FinalizationRegistry",
  20297. "FindInPage",
  20298. "Float32Array",
  20299. "Float64Array",
  20300. "FocusEvent",
  20301. "FontFace",
  20302. "FontFaceSet",
  20303. "FontFaceSetLoadEvent",
  20304. "FormData",
  20305. "FormDataEvent",
  20306. "FragmentDirective",
  20307. "Function",
  20308. "GENERATE_MIPMAP_HINT",
  20309. "GEQUAL",
  20310. "GREATER",
  20311. "GREEN_BITS",
  20312. "GainNode",
  20313. "Gamepad",
  20314. "GamepadAxisMoveEvent",
  20315. "GamepadButton",
  20316. "GamepadButtonEvent",
  20317. "GamepadEvent",
  20318. "GamepadHapticActuator",
  20319. "GamepadPose",
  20320. "Geolocation",
  20321. "GeolocationCoordinates",
  20322. "GeolocationPosition",
  20323. "GeolocationPositionError",
  20324. "GestureEvent",
  20325. "Global",
  20326. "Gyroscope",
  20327. "HALF_FLOAT",
  20328. "HAVE_CURRENT_DATA",
  20329. "HAVE_ENOUGH_DATA",
  20330. "HAVE_FUTURE_DATA",
  20331. "HAVE_METADATA",
  20332. "HAVE_NOTHING",
  20333. "HEADERS_RECEIVED",
  20334. "HIDDEN",
  20335. "HIERARCHY_REQUEST_ERR",
  20336. "HIGHPASS",
  20337. "HIGHSHELF",
  20338. "HIGH_FLOAT",
  20339. "HIGH_INT",
  20340. "HORIZONTAL",
  20341. "HORIZONTAL_AXIS",
  20342. "HRTF",
  20343. "HTMLAllCollection",
  20344. "HTMLAnchorElement",
  20345. "HTMLAppletElement",
  20346. "HTMLAreaElement",
  20347. "HTMLAudioElement",
  20348. "HTMLBRElement",
  20349. "HTMLBaseElement",
  20350. "HTMLBaseFontElement",
  20351. "HTMLBlockquoteElement",
  20352. "HTMLBodyElement",
  20353. "HTMLButtonElement",
  20354. "HTMLCanvasElement",
  20355. "HTMLCollection",
  20356. "HTMLCommandElement",
  20357. "HTMLContentElement",
  20358. "HTMLDListElement",
  20359. "HTMLDataElement",
  20360. "HTMLDataListElement",
  20361. "HTMLDetailsElement",
  20362. "HTMLDialogElement",
  20363. "HTMLDirectoryElement",
  20364. "HTMLDivElement",
  20365. "HTMLDocument",
  20366. "HTMLElement",
  20367. "HTMLEmbedElement",
  20368. "HTMLFieldSetElement",
  20369. "HTMLFontElement",
  20370. "HTMLFormControlsCollection",
  20371. "HTMLFormElement",
  20372. "HTMLFrameElement",
  20373. "HTMLFrameSetElement",
  20374. "HTMLHRElement",
  20375. "HTMLHeadElement",
  20376. "HTMLHeadingElement",
  20377. "HTMLHtmlElement",
  20378. "HTMLIFrameElement",
  20379. "HTMLImageElement",
  20380. "HTMLInputElement",
  20381. "HTMLIsIndexElement",
  20382. "HTMLKeygenElement",
  20383. "HTMLLIElement",
  20384. "HTMLLabelElement",
  20385. "HTMLLegendElement",
  20386. "HTMLLinkElement",
  20387. "HTMLMapElement",
  20388. "HTMLMarqueeElement",
  20389. "HTMLMediaElement",
  20390. "HTMLMenuElement",
  20391. "HTMLMenuItemElement",
  20392. "HTMLMetaElement",
  20393. "HTMLMeterElement",
  20394. "HTMLModElement",
  20395. "HTMLOListElement",
  20396. "HTMLObjectElement",
  20397. "HTMLOptGroupElement",
  20398. "HTMLOptionElement",
  20399. "HTMLOptionsCollection",
  20400. "HTMLOutputElement",
  20401. "HTMLParagraphElement",
  20402. "HTMLParamElement",
  20403. "HTMLPictureElement",
  20404. "HTMLPreElement",
  20405. "HTMLProgressElement",
  20406. "HTMLPropertiesCollection",
  20407. "HTMLQuoteElement",
  20408. "HTMLScriptElement",
  20409. "HTMLSelectElement",
  20410. "HTMLShadowElement",
  20411. "HTMLSlotElement",
  20412. "HTMLSourceElement",
  20413. "HTMLSpanElement",
  20414. "HTMLStyleElement",
  20415. "HTMLTableCaptionElement",
  20416. "HTMLTableCellElement",
  20417. "HTMLTableColElement",
  20418. "HTMLTableElement",
  20419. "HTMLTableRowElement",
  20420. "HTMLTableSectionElement",
  20421. "HTMLTemplateElement",
  20422. "HTMLTextAreaElement",
  20423. "HTMLTimeElement",
  20424. "HTMLTitleElement",
  20425. "HTMLTrackElement",
  20426. "HTMLUListElement",
  20427. "HTMLUnknownElement",
  20428. "HTMLVideoElement",
  20429. "HashChangeEvent",
  20430. "Headers",
  20431. "History",
  20432. "Hz",
  20433. "ICE_CHECKING",
  20434. "ICE_CLOSED",
  20435. "ICE_COMPLETED",
  20436. "ICE_CONNECTED",
  20437. "ICE_FAILED",
  20438. "ICE_GATHERING",
  20439. "ICE_WAITING",
  20440. "IDBCursor",
  20441. "IDBCursorWithValue",
  20442. "IDBDatabase",
  20443. "IDBDatabaseException",
  20444. "IDBFactory",
  20445. "IDBFileHandle",
  20446. "IDBFileRequest",
  20447. "IDBIndex",
  20448. "IDBKeyRange",
  20449. "IDBMutableFile",
  20450. "IDBObjectStore",
  20451. "IDBOpenDBRequest",
  20452. "IDBRequest",
  20453. "IDBTransaction",
  20454. "IDBVersionChangeEvent",
  20455. "IDLE",
  20456. "IIRFilterNode",
  20457. "IMPLEMENTATION_COLOR_READ_FORMAT",
  20458. "IMPLEMENTATION_COLOR_READ_TYPE",
  20459. "IMPORT_RULE",
  20460. "INCR",
  20461. "INCR_WRAP",
  20462. "INDEX_SIZE_ERR",
  20463. "INT",
  20464. "INTERLEAVED_ATTRIBS",
  20465. "INT_2_10_10_10_REV",
  20466. "INT_SAMPLER_2D",
  20467. "INT_SAMPLER_2D_ARRAY",
  20468. "INT_SAMPLER_3D",
  20469. "INT_SAMPLER_CUBE",
  20470. "INT_VEC2",
  20471. "INT_VEC3",
  20472. "INT_VEC4",
  20473. "INUSE_ATTRIBUTE_ERR",
  20474. "INVALID_ACCESS_ERR",
  20475. "INVALID_CHARACTER_ERR",
  20476. "INVALID_ENUM",
  20477. "INVALID_EXPRESSION_ERR",
  20478. "INVALID_FRAMEBUFFER_OPERATION",
  20479. "INVALID_INDEX",
  20480. "INVALID_MODIFICATION_ERR",
  20481. "INVALID_NODE_TYPE_ERR",
  20482. "INVALID_OPERATION",
  20483. "INVALID_STATE_ERR",
  20484. "INVALID_VALUE",
  20485. "INVERSE_DISTANCE",
  20486. "INVERT",
  20487. "IceCandidate",
  20488. "IdleDeadline",
  20489. "Image",
  20490. "ImageBitmap",
  20491. "ImageBitmapRenderingContext",
  20492. "ImageCapture",
  20493. "ImageData",
  20494. "Infinity",
  20495. "InputDeviceCapabilities",
  20496. "InputDeviceInfo",
  20497. "InputEvent",
  20498. "InputMethodContext",
  20499. "InstallTrigger",
  20500. "InstallTriggerImpl",
  20501. "Instance",
  20502. "Int16Array",
  20503. "Int32Array",
  20504. "Int8Array",
  20505. "Intent",
  20506. "InternalError",
  20507. "IntersectionObserver",
  20508. "IntersectionObserverEntry",
  20509. "Intl",
  20510. "IsSearchProviderInstalled",
  20511. "Iterator",
  20512. "JSON",
  20513. "KEEP",
  20514. "KEYDOWN",
  20515. "KEYFRAMES_RULE",
  20516. "KEYFRAME_RULE",
  20517. "KEYPRESS",
  20518. "KEYUP",
  20519. "KeyEvent",
  20520. "Keyboard",
  20521. "KeyboardEvent",
  20522. "KeyboardLayoutMap",
  20523. "KeyframeEffect",
  20524. "LENGTHADJUST_SPACING",
  20525. "LENGTHADJUST_SPACINGANDGLYPHS",
  20526. "LENGTHADJUST_UNKNOWN",
  20527. "LEQUAL",
  20528. "LESS",
  20529. "LINEAR",
  20530. "LINEAR_DISTANCE",
  20531. "LINEAR_MIPMAP_LINEAR",
  20532. "LINEAR_MIPMAP_NEAREST",
  20533. "LINES",
  20534. "LINE_LOOP",
  20535. "LINE_STRIP",
  20536. "LINE_WIDTH",
  20537. "LINK_STATUS",
  20538. "LIVE",
  20539. "LN10",
  20540. "LN2",
  20541. "LOADED",
  20542. "LOADING",
  20543. "LOG10E",
  20544. "LOG2E",
  20545. "LOWPASS",
  20546. "LOWSHELF",
  20547. "LOW_FLOAT",
  20548. "LOW_INT",
  20549. "LSException",
  20550. "LSParserFilter",
  20551. "LUMINANCE",
  20552. "LUMINANCE_ALPHA",
  20553. "LargestContentfulPaint",
  20554. "LayoutShift",
  20555. "LayoutShiftAttribution",
  20556. "LinearAccelerationSensor",
  20557. "LinkError",
  20558. "ListFormat",
  20559. "LocalMediaStream",
  20560. "Locale",
  20561. "Location",
  20562. "Lock",
  20563. "LockManager",
  20564. "MAX",
  20565. "MAX_3D_TEXTURE_SIZE",
  20566. "MAX_ARRAY_TEXTURE_LAYERS",
  20567. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  20568. "MAX_COLOR_ATTACHMENTS",
  20569. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  20570. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  20571. "MAX_COMBINED_UNIFORM_BLOCKS",
  20572. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  20573. "MAX_CUBE_MAP_TEXTURE_SIZE",
  20574. "MAX_DRAW_BUFFERS",
  20575. "MAX_ELEMENTS_INDICES",
  20576. "MAX_ELEMENTS_VERTICES",
  20577. "MAX_ELEMENT_INDEX",
  20578. "MAX_FRAGMENT_INPUT_COMPONENTS",
  20579. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  20580. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  20581. "MAX_FRAGMENT_UNIFORM_VECTORS",
  20582. "MAX_PROGRAM_TEXEL_OFFSET",
  20583. "MAX_RENDERBUFFER_SIZE",
  20584. "MAX_SAFE_INTEGER",
  20585. "MAX_SAMPLES",
  20586. "MAX_SERVER_WAIT_TIMEOUT",
  20587. "MAX_TEXTURE_IMAGE_UNITS",
  20588. "MAX_TEXTURE_LOD_BIAS",
  20589. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  20590. "MAX_TEXTURE_SIZE",
  20591. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  20592. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  20593. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  20594. "MAX_UNIFORM_BLOCK_SIZE",
  20595. "MAX_UNIFORM_BUFFER_BINDINGS",
  20596. "MAX_VALUE",
  20597. "MAX_VARYING_COMPONENTS",
  20598. "MAX_VARYING_VECTORS",
  20599. "MAX_VERTEX_ATTRIBS",
  20600. "MAX_VERTEX_OUTPUT_COMPONENTS",
  20601. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  20602. "MAX_VERTEX_UNIFORM_BLOCKS",
  20603. "MAX_VERTEX_UNIFORM_COMPONENTS",
  20604. "MAX_VERTEX_UNIFORM_VECTORS",
  20605. "MAX_VIEWPORT_DIMS",
  20606. "MEDIA_ERR_ABORTED",
  20607. "MEDIA_ERR_DECODE",
  20608. "MEDIA_ERR_ENCRYPTED",
  20609. "MEDIA_ERR_NETWORK",
  20610. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  20611. "MEDIA_KEYERR_CLIENT",
  20612. "MEDIA_KEYERR_DOMAIN",
  20613. "MEDIA_KEYERR_HARDWARECHANGE",
  20614. "MEDIA_KEYERR_OUTPUT",
  20615. "MEDIA_KEYERR_SERVICE",
  20616. "MEDIA_KEYERR_UNKNOWN",
  20617. "MEDIA_RULE",
  20618. "MEDIUM_FLOAT",
  20619. "MEDIUM_INT",
  20620. "META_MASK",
  20621. "MIDIAccess",
  20622. "MIDIConnectionEvent",
  20623. "MIDIInput",
  20624. "MIDIInputMap",
  20625. "MIDIMessageEvent",
  20626. "MIDIOutput",
  20627. "MIDIOutputMap",
  20628. "MIDIPort",
  20629. "MIN",
  20630. "MIN_PROGRAM_TEXEL_OFFSET",
  20631. "MIN_SAFE_INTEGER",
  20632. "MIN_VALUE",
  20633. "MIRRORED_REPEAT",
  20634. "MODE_ASYNCHRONOUS",
  20635. "MODE_SYNCHRONOUS",
  20636. "MODIFICATION",
  20637. "MOUSEDOWN",
  20638. "MOUSEDRAG",
  20639. "MOUSEMOVE",
  20640. "MOUSEOUT",
  20641. "MOUSEOVER",
  20642. "MOUSEUP",
  20643. "MOZ_KEYFRAMES_RULE",
  20644. "MOZ_KEYFRAME_RULE",
  20645. "MOZ_SOURCE_CURSOR",
  20646. "MOZ_SOURCE_ERASER",
  20647. "MOZ_SOURCE_KEYBOARD",
  20648. "MOZ_SOURCE_MOUSE",
  20649. "MOZ_SOURCE_PEN",
  20650. "MOZ_SOURCE_TOUCH",
  20651. "MOZ_SOURCE_UNKNOWN",
  20652. "MSGESTURE_FLAG_BEGIN",
  20653. "MSGESTURE_FLAG_CANCEL",
  20654. "MSGESTURE_FLAG_END",
  20655. "MSGESTURE_FLAG_INERTIA",
  20656. "MSGESTURE_FLAG_NONE",
  20657. "MSPOINTER_TYPE_MOUSE",
  20658. "MSPOINTER_TYPE_PEN",
  20659. "MSPOINTER_TYPE_TOUCH",
  20660. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  20661. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  20662. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  20663. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  20664. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  20665. "MS_ASYNC_OP_STATUS_CANCELED",
  20666. "MS_ASYNC_OP_STATUS_ERROR",
  20667. "MS_ASYNC_OP_STATUS_SUCCESS",
  20668. "MS_MANIPULATION_STATE_ACTIVE",
  20669. "MS_MANIPULATION_STATE_CANCELLED",
  20670. "MS_MANIPULATION_STATE_COMMITTED",
  20671. "MS_MANIPULATION_STATE_DRAGGING",
  20672. "MS_MANIPULATION_STATE_INERTIA",
  20673. "MS_MANIPULATION_STATE_PRESELECT",
  20674. "MS_MANIPULATION_STATE_SELECTING",
  20675. "MS_MANIPULATION_STATE_STOPPED",
  20676. "MS_MEDIA_ERR_ENCRYPTED",
  20677. "MS_MEDIA_KEYERR_CLIENT",
  20678. "MS_MEDIA_KEYERR_DOMAIN",
  20679. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  20680. "MS_MEDIA_KEYERR_OUTPUT",
  20681. "MS_MEDIA_KEYERR_SERVICE",
  20682. "MS_MEDIA_KEYERR_UNKNOWN",
  20683. "Map",
  20684. "Math",
  20685. "MathMLElement",
  20686. "MediaCapabilities",
  20687. "MediaCapabilitiesInfo",
  20688. "MediaController",
  20689. "MediaDeviceInfo",
  20690. "MediaDevices",
  20691. "MediaElementAudioSourceNode",
  20692. "MediaEncryptedEvent",
  20693. "MediaError",
  20694. "MediaKeyError",
  20695. "MediaKeyEvent",
  20696. "MediaKeyMessageEvent",
  20697. "MediaKeyNeededEvent",
  20698. "MediaKeySession",
  20699. "MediaKeyStatusMap",
  20700. "MediaKeySystemAccess",
  20701. "MediaKeys",
  20702. "MediaList",
  20703. "MediaMetadata",
  20704. "MediaQueryList",
  20705. "MediaQueryListEvent",
  20706. "MediaRecorder",
  20707. "MediaRecorderErrorEvent",
  20708. "MediaSession",
  20709. "MediaSettingsRange",
  20710. "MediaSource",
  20711. "MediaStream",
  20712. "MediaStreamAudioDestinationNode",
  20713. "MediaStreamAudioSourceNode",
  20714. "MediaStreamEvent",
  20715. "MediaStreamTrack",
  20716. "MediaStreamTrackAudioSourceNode",
  20717. "MediaStreamTrackEvent",
  20718. "Memory",
  20719. "MessageChannel",
  20720. "MessageEvent",
  20721. "MessagePort",
  20722. "Methods",
  20723. "MimeType",
  20724. "MimeTypeArray",
  20725. "Module",
  20726. "MouseEvent",
  20727. "MouseScrollEvent",
  20728. "MozAnimation",
  20729. "MozAnimationDelay",
  20730. "MozAnimationDirection",
  20731. "MozAnimationDuration",
  20732. "MozAnimationFillMode",
  20733. "MozAnimationIterationCount",
  20734. "MozAnimationName",
  20735. "MozAnimationPlayState",
  20736. "MozAnimationTimingFunction",
  20737. "MozAppearance",
  20738. "MozBackfaceVisibility",
  20739. "MozBinding",
  20740. "MozBorderBottomColors",
  20741. "MozBorderEnd",
  20742. "MozBorderEndColor",
  20743. "MozBorderEndStyle",
  20744. "MozBorderEndWidth",
  20745. "MozBorderImage",
  20746. "MozBorderLeftColors",
  20747. "MozBorderRightColors",
  20748. "MozBorderStart",
  20749. "MozBorderStartColor",
  20750. "MozBorderStartStyle",
  20751. "MozBorderStartWidth",
  20752. "MozBorderTopColors",
  20753. "MozBoxAlign",
  20754. "MozBoxDirection",
  20755. "MozBoxFlex",
  20756. "MozBoxOrdinalGroup",
  20757. "MozBoxOrient",
  20758. "MozBoxPack",
  20759. "MozBoxSizing",
  20760. "MozCSSKeyframeRule",
  20761. "MozCSSKeyframesRule",
  20762. "MozColumnCount",
  20763. "MozColumnFill",
  20764. "MozColumnGap",
  20765. "MozColumnRule",
  20766. "MozColumnRuleColor",
  20767. "MozColumnRuleStyle",
  20768. "MozColumnRuleWidth",
  20769. "MozColumnWidth",
  20770. "MozColumns",
  20771. "MozContactChangeEvent",
  20772. "MozFloatEdge",
  20773. "MozFontFeatureSettings",
  20774. "MozFontLanguageOverride",
  20775. "MozForceBrokenImageIcon",
  20776. "MozHyphens",
  20777. "MozImageRegion",
  20778. "MozMarginEnd",
  20779. "MozMarginStart",
  20780. "MozMmsEvent",
  20781. "MozMmsMessage",
  20782. "MozMobileMessageThread",
  20783. "MozOSXFontSmoothing",
  20784. "MozOrient",
  20785. "MozOsxFontSmoothing",
  20786. "MozOutlineRadius",
  20787. "MozOutlineRadiusBottomleft",
  20788. "MozOutlineRadiusBottomright",
  20789. "MozOutlineRadiusTopleft",
  20790. "MozOutlineRadiusTopright",
  20791. "MozPaddingEnd",
  20792. "MozPaddingStart",
  20793. "MozPerspective",
  20794. "MozPerspectiveOrigin",
  20795. "MozPowerManager",
  20796. "MozSettingsEvent",
  20797. "MozSmsEvent",
  20798. "MozSmsMessage",
  20799. "MozStackSizing",
  20800. "MozTabSize",
  20801. "MozTextAlignLast",
  20802. "MozTextDecorationColor",
  20803. "MozTextDecorationLine",
  20804. "MozTextDecorationStyle",
  20805. "MozTextSizeAdjust",
  20806. "MozTransform",
  20807. "MozTransformOrigin",
  20808. "MozTransformStyle",
  20809. "MozTransition",
  20810. "MozTransitionDelay",
  20811. "MozTransitionDuration",
  20812. "MozTransitionProperty",
  20813. "MozTransitionTimingFunction",
  20814. "MozUserFocus",
  20815. "MozUserInput",
  20816. "MozUserModify",
  20817. "MozUserSelect",
  20818. "MozWindowDragging",
  20819. "MozWindowShadow",
  20820. "MutationEvent",
  20821. "MutationObserver",
  20822. "MutationRecord",
  20823. "NAMESPACE_ERR",
  20824. "NAMESPACE_RULE",
  20825. "NEAREST",
  20826. "NEAREST_MIPMAP_LINEAR",
  20827. "NEAREST_MIPMAP_NEAREST",
  20828. "NEGATIVE_INFINITY",
  20829. "NETWORK_EMPTY",
  20830. "NETWORK_ERR",
  20831. "NETWORK_IDLE",
  20832. "NETWORK_LOADED",
  20833. "NETWORK_LOADING",
  20834. "NETWORK_NO_SOURCE",
  20835. "NEVER",
  20836. "NEW",
  20837. "NEXT",
  20838. "NEXT_NO_DUPLICATE",
  20839. "NICEST",
  20840. "NODE_AFTER",
  20841. "NODE_BEFORE",
  20842. "NODE_BEFORE_AND_AFTER",
  20843. "NODE_INSIDE",
  20844. "NONE",
  20845. "NON_TRANSIENT_ERR",
  20846. "NOTATION_NODE",
  20847. "NOTCH",
  20848. "NOTEQUAL",
  20849. "NOT_ALLOWED_ERR",
  20850. "NOT_FOUND_ERR",
  20851. "NOT_READABLE_ERR",
  20852. "NOT_SUPPORTED_ERR",
  20853. "NO_DATA_ALLOWED_ERR",
  20854. "NO_ERR",
  20855. "NO_ERROR",
  20856. "NO_MODIFICATION_ALLOWED_ERR",
  20857. "NUMBER_TYPE",
  20858. "NUM_COMPRESSED_TEXTURE_FORMATS",
  20859. "NaN",
  20860. "NamedNodeMap",
  20861. "NavigationPreloadManager",
  20862. "Navigator",
  20863. "NearbyLinks",
  20864. "NetworkInformation",
  20865. "Node",
  20866. "NodeFilter",
  20867. "NodeIterator",
  20868. "NodeList",
  20869. "Notation",
  20870. "Notification",
  20871. "NotifyPaintEvent",
  20872. "Number",
  20873. "NumberFormat",
  20874. "OBJECT_TYPE",
  20875. "OBSOLETE",
  20876. "OK",
  20877. "ONE",
  20878. "ONE_MINUS_CONSTANT_ALPHA",
  20879. "ONE_MINUS_CONSTANT_COLOR",
  20880. "ONE_MINUS_DST_ALPHA",
  20881. "ONE_MINUS_DST_COLOR",
  20882. "ONE_MINUS_SRC_ALPHA",
  20883. "ONE_MINUS_SRC_COLOR",
  20884. "OPEN",
  20885. "OPENED",
  20886. "OPENING",
  20887. "ORDERED_NODE_ITERATOR_TYPE",
  20888. "ORDERED_NODE_SNAPSHOT_TYPE",
  20889. "OTHER_ERROR",
  20890. "OUT_OF_MEMORY",
  20891. "Object",
  20892. "OfflineAudioCompletionEvent",
  20893. "OfflineAudioContext",
  20894. "OfflineResourceList",
  20895. "OffscreenCanvas",
  20896. "OffscreenCanvasRenderingContext2D",
  20897. "Option",
  20898. "OrientationSensor",
  20899. "OscillatorNode",
  20900. "OverconstrainedError",
  20901. "OverflowEvent",
  20902. "PACK_ALIGNMENT",
  20903. "PACK_ROW_LENGTH",
  20904. "PACK_SKIP_PIXELS",
  20905. "PACK_SKIP_ROWS",
  20906. "PAGE_RULE",
  20907. "PARSE_ERR",
  20908. "PATHSEG_ARC_ABS",
  20909. "PATHSEG_ARC_REL",
  20910. "PATHSEG_CLOSEPATH",
  20911. "PATHSEG_CURVETO_CUBIC_ABS",
  20912. "PATHSEG_CURVETO_CUBIC_REL",
  20913. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  20914. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  20915. "PATHSEG_CURVETO_QUADRATIC_ABS",
  20916. "PATHSEG_CURVETO_QUADRATIC_REL",
  20917. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  20918. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  20919. "PATHSEG_LINETO_ABS",
  20920. "PATHSEG_LINETO_HORIZONTAL_ABS",
  20921. "PATHSEG_LINETO_HORIZONTAL_REL",
  20922. "PATHSEG_LINETO_REL",
  20923. "PATHSEG_LINETO_VERTICAL_ABS",
  20924. "PATHSEG_LINETO_VERTICAL_REL",
  20925. "PATHSEG_MOVETO_ABS",
  20926. "PATHSEG_MOVETO_REL",
  20927. "PATHSEG_UNKNOWN",
  20928. "PATH_EXISTS_ERR",
  20929. "PEAKING",
  20930. "PERMISSION_DENIED",
  20931. "PERSISTENT",
  20932. "PI",
  20933. "PIXEL_PACK_BUFFER",
  20934. "PIXEL_PACK_BUFFER_BINDING",
  20935. "PIXEL_UNPACK_BUFFER",
  20936. "PIXEL_UNPACK_BUFFER_BINDING",
  20937. "PLAYING_STATE",
  20938. "POINTS",
  20939. "POLYGON_OFFSET_FACTOR",
  20940. "POLYGON_OFFSET_FILL",
  20941. "POLYGON_OFFSET_UNITS",
  20942. "POSITION_UNAVAILABLE",
  20943. "POSITIVE_INFINITY",
  20944. "PREV",
  20945. "PREV_NO_DUPLICATE",
  20946. "PROCESSING_INSTRUCTION_NODE",
  20947. "PageChangeEvent",
  20948. "PageTransitionEvent",
  20949. "PaintRequest",
  20950. "PaintRequestList",
  20951. "PannerNode",
  20952. "PasswordCredential",
  20953. "Path2D",
  20954. "PaymentAddress",
  20955. "PaymentInstruments",
  20956. "PaymentManager",
  20957. "PaymentMethodChangeEvent",
  20958. "PaymentRequest",
  20959. "PaymentRequestUpdateEvent",
  20960. "PaymentResponse",
  20961. "Performance",
  20962. "PerformanceElementTiming",
  20963. "PerformanceEntry",
  20964. "PerformanceEventTiming",
  20965. "PerformanceLongTaskTiming",
  20966. "PerformanceMark",
  20967. "PerformanceMeasure",
  20968. "PerformanceNavigation",
  20969. "PerformanceNavigationTiming",
  20970. "PerformanceObserver",
  20971. "PerformanceObserverEntryList",
  20972. "PerformancePaintTiming",
  20973. "PerformanceResourceTiming",
  20974. "PerformanceServerTiming",
  20975. "PerformanceTiming",
  20976. "PeriodicSyncManager",
  20977. "PeriodicWave",
  20978. "PermissionStatus",
  20979. "Permissions",
  20980. "PhotoCapabilities",
  20981. "PictureInPictureWindow",
  20982. "Plugin",
  20983. "PluginArray",
  20984. "PluralRules",
  20985. "PointerEvent",
  20986. "PopStateEvent",
  20987. "PopupBlockedEvent",
  20988. "Presentation",
  20989. "PresentationAvailability",
  20990. "PresentationConnection",
  20991. "PresentationConnectionAvailableEvent",
  20992. "PresentationConnectionCloseEvent",
  20993. "PresentationConnectionList",
  20994. "PresentationReceiver",
  20995. "PresentationRequest",
  20996. "ProcessingInstruction",
  20997. "ProgressEvent",
  20998. "Promise",
  20999. "PromiseRejectionEvent",
  21000. "PropertyNodeList",
  21001. "Proxy",
  21002. "PublicKeyCredential",
  21003. "PushManager",
  21004. "PushSubscription",
  21005. "PushSubscriptionOptions",
  21006. "Q",
  21007. "QUERY_RESULT",
  21008. "QUERY_RESULT_AVAILABLE",
  21009. "QUOTA_ERR",
  21010. "QUOTA_EXCEEDED_ERR",
  21011. "QueryInterface",
  21012. "R11F_G11F_B10F",
  21013. "R16F",
  21014. "R16I",
  21015. "R16UI",
  21016. "R32F",
  21017. "R32I",
  21018. "R32UI",
  21019. "R8",
  21020. "R8I",
  21021. "R8UI",
  21022. "R8_SNORM",
  21023. "RASTERIZER_DISCARD",
  21024. "READ_BUFFER",
  21025. "READ_FRAMEBUFFER",
  21026. "READ_FRAMEBUFFER_BINDING",
  21027. "READ_ONLY",
  21028. "READ_ONLY_ERR",
  21029. "READ_WRITE",
  21030. "RED",
  21031. "RED_BITS",
  21032. "RED_INTEGER",
  21033. "REMOVAL",
  21034. "RENDERBUFFER",
  21035. "RENDERBUFFER_ALPHA_SIZE",
  21036. "RENDERBUFFER_BINDING",
  21037. "RENDERBUFFER_BLUE_SIZE",
  21038. "RENDERBUFFER_DEPTH_SIZE",
  21039. "RENDERBUFFER_GREEN_SIZE",
  21040. "RENDERBUFFER_HEIGHT",
  21041. "RENDERBUFFER_INTERNAL_FORMAT",
  21042. "RENDERBUFFER_RED_SIZE",
  21043. "RENDERBUFFER_SAMPLES",
  21044. "RENDERBUFFER_STENCIL_SIZE",
  21045. "RENDERBUFFER_WIDTH",
  21046. "RENDERER",
  21047. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  21048. "RENDERING_INTENT_AUTO",
  21049. "RENDERING_INTENT_PERCEPTUAL",
  21050. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  21051. "RENDERING_INTENT_SATURATION",
  21052. "RENDERING_INTENT_UNKNOWN",
  21053. "REPEAT",
  21054. "REPLACE",
  21055. "RG",
  21056. "RG16F",
  21057. "RG16I",
  21058. "RG16UI",
  21059. "RG32F",
  21060. "RG32I",
  21061. "RG32UI",
  21062. "RG8",
  21063. "RG8I",
  21064. "RG8UI",
  21065. "RG8_SNORM",
  21066. "RGB",
  21067. "RGB10_A2",
  21068. "RGB10_A2UI",
  21069. "RGB16F",
  21070. "RGB16I",
  21071. "RGB16UI",
  21072. "RGB32F",
  21073. "RGB32I",
  21074. "RGB32UI",
  21075. "RGB565",
  21076. "RGB5_A1",
  21077. "RGB8",
  21078. "RGB8I",
  21079. "RGB8UI",
  21080. "RGB8_SNORM",
  21081. "RGB9_E5",
  21082. "RGBA",
  21083. "RGBA16F",
  21084. "RGBA16I",
  21085. "RGBA16UI",
  21086. "RGBA32F",
  21087. "RGBA32I",
  21088. "RGBA32UI",
  21089. "RGBA4",
  21090. "RGBA8",
  21091. "RGBA8I",
  21092. "RGBA8UI",
  21093. "RGBA8_SNORM",
  21094. "RGBA_INTEGER",
  21095. "RGBColor",
  21096. "RGB_INTEGER",
  21097. "RG_INTEGER",
  21098. "ROTATION_CLOCKWISE",
  21099. "ROTATION_COUNTERCLOCKWISE",
  21100. "RTCCertificate",
  21101. "RTCDTMFSender",
  21102. "RTCDTMFToneChangeEvent",
  21103. "RTCDataChannel",
  21104. "RTCDataChannelEvent",
  21105. "RTCDtlsTransport",
  21106. "RTCError",
  21107. "RTCErrorEvent",
  21108. "RTCIceCandidate",
  21109. "RTCIceTransport",
  21110. "RTCPeerConnection",
  21111. "RTCPeerConnectionIceErrorEvent",
  21112. "RTCPeerConnectionIceEvent",
  21113. "RTCRtpReceiver",
  21114. "RTCRtpSender",
  21115. "RTCRtpTransceiver",
  21116. "RTCSctpTransport",
  21117. "RTCSessionDescription",
  21118. "RTCStatsReport",
  21119. "RTCTrackEvent",
  21120. "RadioNodeList",
  21121. "Range",
  21122. "RangeError",
  21123. "RangeException",
  21124. "ReadableStream",
  21125. "ReadableStreamDefaultReader",
  21126. "RecordErrorEvent",
  21127. "Rect",
  21128. "ReferenceError",
  21129. "Reflect",
  21130. "RegExp",
  21131. "RelativeOrientationSensor",
  21132. "RelativeTimeFormat",
  21133. "RemotePlayback",
  21134. "Report",
  21135. "ReportBody",
  21136. "ReportingObserver",
  21137. "Request",
  21138. "ResizeObserver",
  21139. "ResizeObserverEntry",
  21140. "ResizeObserverSize",
  21141. "Response",
  21142. "RuntimeError",
  21143. "SAMPLER_2D",
  21144. "SAMPLER_2D_ARRAY",
  21145. "SAMPLER_2D_ARRAY_SHADOW",
  21146. "SAMPLER_2D_SHADOW",
  21147. "SAMPLER_3D",
  21148. "SAMPLER_BINDING",
  21149. "SAMPLER_CUBE",
  21150. "SAMPLER_CUBE_SHADOW",
  21151. "SAMPLES",
  21152. "SAMPLE_ALPHA_TO_COVERAGE",
  21153. "SAMPLE_BUFFERS",
  21154. "SAMPLE_COVERAGE",
  21155. "SAMPLE_COVERAGE_INVERT",
  21156. "SAMPLE_COVERAGE_VALUE",
  21157. "SAWTOOTH",
  21158. "SCHEDULED_STATE",
  21159. "SCISSOR_BOX",
  21160. "SCISSOR_TEST",
  21161. "SCROLL_PAGE_DOWN",
  21162. "SCROLL_PAGE_UP",
  21163. "SDP_ANSWER",
  21164. "SDP_OFFER",
  21165. "SDP_PRANSWER",
  21166. "SECURITY_ERR",
  21167. "SELECT",
  21168. "SEPARATE_ATTRIBS",
  21169. "SERIALIZE_ERR",
  21170. "SEVERITY_ERROR",
  21171. "SEVERITY_FATAL_ERROR",
  21172. "SEVERITY_WARNING",
  21173. "SHADER_COMPILER",
  21174. "SHADER_TYPE",
  21175. "SHADING_LANGUAGE_VERSION",
  21176. "SHIFT_MASK",
  21177. "SHORT",
  21178. "SHOWING",
  21179. "SHOW_ALL",
  21180. "SHOW_ATTRIBUTE",
  21181. "SHOW_CDATA_SECTION",
  21182. "SHOW_COMMENT",
  21183. "SHOW_DOCUMENT",
  21184. "SHOW_DOCUMENT_FRAGMENT",
  21185. "SHOW_DOCUMENT_TYPE",
  21186. "SHOW_ELEMENT",
  21187. "SHOW_ENTITY",
  21188. "SHOW_ENTITY_REFERENCE",
  21189. "SHOW_NOTATION",
  21190. "SHOW_PROCESSING_INSTRUCTION",
  21191. "SHOW_TEXT",
  21192. "SIGNALED",
  21193. "SIGNED_NORMALIZED",
  21194. "SINE",
  21195. "SOUNDFIELD",
  21196. "SQLException",
  21197. "SQRT1_2",
  21198. "SQRT2",
  21199. "SQUARE",
  21200. "SRC_ALPHA",
  21201. "SRC_ALPHA_SATURATE",
  21202. "SRC_COLOR",
  21203. "SRGB",
  21204. "SRGB8",
  21205. "SRGB8_ALPHA8",
  21206. "START_TO_END",
  21207. "START_TO_START",
  21208. "STATIC_COPY",
  21209. "STATIC_DRAW",
  21210. "STATIC_READ",
  21211. "STENCIL",
  21212. "STENCIL_ATTACHMENT",
  21213. "STENCIL_BACK_FAIL",
  21214. "STENCIL_BACK_FUNC",
  21215. "STENCIL_BACK_PASS_DEPTH_FAIL",
  21216. "STENCIL_BACK_PASS_DEPTH_PASS",
  21217. "STENCIL_BACK_REF",
  21218. "STENCIL_BACK_VALUE_MASK",
  21219. "STENCIL_BACK_WRITEMASK",
  21220. "STENCIL_BITS",
  21221. "STENCIL_BUFFER_BIT",
  21222. "STENCIL_CLEAR_VALUE",
  21223. "STENCIL_FAIL",
  21224. "STENCIL_FUNC",
  21225. "STENCIL_INDEX",
  21226. "STENCIL_INDEX8",
  21227. "STENCIL_PASS_DEPTH_FAIL",
  21228. "STENCIL_PASS_DEPTH_PASS",
  21229. "STENCIL_REF",
  21230. "STENCIL_TEST",
  21231. "STENCIL_VALUE_MASK",
  21232. "STENCIL_WRITEMASK",
  21233. "STREAM_COPY",
  21234. "STREAM_DRAW",
  21235. "STREAM_READ",
  21236. "STRING_TYPE",
  21237. "STYLE_RULE",
  21238. "SUBPIXEL_BITS",
  21239. "SUPPORTS_RULE",
  21240. "SVGAElement",
  21241. "SVGAltGlyphDefElement",
  21242. "SVGAltGlyphElement",
  21243. "SVGAltGlyphItemElement",
  21244. "SVGAngle",
  21245. "SVGAnimateColorElement",
  21246. "SVGAnimateElement",
  21247. "SVGAnimateMotionElement",
  21248. "SVGAnimateTransformElement",
  21249. "SVGAnimatedAngle",
  21250. "SVGAnimatedBoolean",
  21251. "SVGAnimatedEnumeration",
  21252. "SVGAnimatedInteger",
  21253. "SVGAnimatedLength",
  21254. "SVGAnimatedLengthList",
  21255. "SVGAnimatedNumber",
  21256. "SVGAnimatedNumberList",
  21257. "SVGAnimatedPreserveAspectRatio",
  21258. "SVGAnimatedRect",
  21259. "SVGAnimatedString",
  21260. "SVGAnimatedTransformList",
  21261. "SVGAnimationElement",
  21262. "SVGCircleElement",
  21263. "SVGClipPathElement",
  21264. "SVGColor",
  21265. "SVGComponentTransferFunctionElement",
  21266. "SVGCursorElement",
  21267. "SVGDefsElement",
  21268. "SVGDescElement",
  21269. "SVGDiscardElement",
  21270. "SVGDocument",
  21271. "SVGElement",
  21272. "SVGElementInstance",
  21273. "SVGElementInstanceList",
  21274. "SVGEllipseElement",
  21275. "SVGException",
  21276. "SVGFEBlendElement",
  21277. "SVGFEColorMatrixElement",
  21278. "SVGFEComponentTransferElement",
  21279. "SVGFECompositeElement",
  21280. "SVGFEConvolveMatrixElement",
  21281. "SVGFEDiffuseLightingElement",
  21282. "SVGFEDisplacementMapElement",
  21283. "SVGFEDistantLightElement",
  21284. "SVGFEDropShadowElement",
  21285. "SVGFEFloodElement",
  21286. "SVGFEFuncAElement",
  21287. "SVGFEFuncBElement",
  21288. "SVGFEFuncGElement",
  21289. "SVGFEFuncRElement",
  21290. "SVGFEGaussianBlurElement",
  21291. "SVGFEImageElement",
  21292. "SVGFEMergeElement",
  21293. "SVGFEMergeNodeElement",
  21294. "SVGFEMorphologyElement",
  21295. "SVGFEOffsetElement",
  21296. "SVGFEPointLightElement",
  21297. "SVGFESpecularLightingElement",
  21298. "SVGFESpotLightElement",
  21299. "SVGFETileElement",
  21300. "SVGFETurbulenceElement",
  21301. "SVGFilterElement",
  21302. "SVGFontElement",
  21303. "SVGFontFaceElement",
  21304. "SVGFontFaceFormatElement",
  21305. "SVGFontFaceNameElement",
  21306. "SVGFontFaceSrcElement",
  21307. "SVGFontFaceUriElement",
  21308. "SVGForeignObjectElement",
  21309. "SVGGElement",
  21310. "SVGGeometryElement",
  21311. "SVGGlyphElement",
  21312. "SVGGlyphRefElement",
  21313. "SVGGradientElement",
  21314. "SVGGraphicsElement",
  21315. "SVGHKernElement",
  21316. "SVGImageElement",
  21317. "SVGLength",
  21318. "SVGLengthList",
  21319. "SVGLineElement",
  21320. "SVGLinearGradientElement",
  21321. "SVGMPathElement",
  21322. "SVGMarkerElement",
  21323. "SVGMaskElement",
  21324. "SVGMatrix",
  21325. "SVGMetadataElement",
  21326. "SVGMissingGlyphElement",
  21327. "SVGNumber",
  21328. "SVGNumberList",
  21329. "SVGPaint",
  21330. "SVGPathElement",
  21331. "SVGPathSeg",
  21332. "SVGPathSegArcAbs",
  21333. "SVGPathSegArcRel",
  21334. "SVGPathSegClosePath",
  21335. "SVGPathSegCurvetoCubicAbs",
  21336. "SVGPathSegCurvetoCubicRel",
  21337. "SVGPathSegCurvetoCubicSmoothAbs",
  21338. "SVGPathSegCurvetoCubicSmoothRel",
  21339. "SVGPathSegCurvetoQuadraticAbs",
  21340. "SVGPathSegCurvetoQuadraticRel",
  21341. "SVGPathSegCurvetoQuadraticSmoothAbs",
  21342. "SVGPathSegCurvetoQuadraticSmoothRel",
  21343. "SVGPathSegLinetoAbs",
  21344. "SVGPathSegLinetoHorizontalAbs",
  21345. "SVGPathSegLinetoHorizontalRel",
  21346. "SVGPathSegLinetoRel",
  21347. "SVGPathSegLinetoVerticalAbs",
  21348. "SVGPathSegLinetoVerticalRel",
  21349. "SVGPathSegList",
  21350. "SVGPathSegMovetoAbs",
  21351. "SVGPathSegMovetoRel",
  21352. "SVGPatternElement",
  21353. "SVGPoint",
  21354. "SVGPointList",
  21355. "SVGPolygonElement",
  21356. "SVGPolylineElement",
  21357. "SVGPreserveAspectRatio",
  21358. "SVGRadialGradientElement",
  21359. "SVGRect",
  21360. "SVGRectElement",
  21361. "SVGRenderingIntent",
  21362. "SVGSVGElement",
  21363. "SVGScriptElement",
  21364. "SVGSetElement",
  21365. "SVGStopElement",
  21366. "SVGStringList",
  21367. "SVGStyleElement",
  21368. "SVGSwitchElement",
  21369. "SVGSymbolElement",
  21370. "SVGTRefElement",
  21371. "SVGTSpanElement",
  21372. "SVGTextContentElement",
  21373. "SVGTextElement",
  21374. "SVGTextPathElement",
  21375. "SVGTextPositioningElement",
  21376. "SVGTitleElement",
  21377. "SVGTransform",
  21378. "SVGTransformList",
  21379. "SVGUnitTypes",
  21380. "SVGUseElement",
  21381. "SVGVKernElement",
  21382. "SVGViewElement",
  21383. "SVGViewSpec",
  21384. "SVGZoomAndPan",
  21385. "SVGZoomEvent",
  21386. "SVG_ANGLETYPE_DEG",
  21387. "SVG_ANGLETYPE_GRAD",
  21388. "SVG_ANGLETYPE_RAD",
  21389. "SVG_ANGLETYPE_UNKNOWN",
  21390. "SVG_ANGLETYPE_UNSPECIFIED",
  21391. "SVG_CHANNEL_A",
  21392. "SVG_CHANNEL_B",
  21393. "SVG_CHANNEL_G",
  21394. "SVG_CHANNEL_R",
  21395. "SVG_CHANNEL_UNKNOWN",
  21396. "SVG_COLORTYPE_CURRENTCOLOR",
  21397. "SVG_COLORTYPE_RGBCOLOR",
  21398. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  21399. "SVG_COLORTYPE_UNKNOWN",
  21400. "SVG_EDGEMODE_DUPLICATE",
  21401. "SVG_EDGEMODE_NONE",
  21402. "SVG_EDGEMODE_UNKNOWN",
  21403. "SVG_EDGEMODE_WRAP",
  21404. "SVG_FEBLEND_MODE_COLOR",
  21405. "SVG_FEBLEND_MODE_COLOR_BURN",
  21406. "SVG_FEBLEND_MODE_COLOR_DODGE",
  21407. "SVG_FEBLEND_MODE_DARKEN",
  21408. "SVG_FEBLEND_MODE_DIFFERENCE",
  21409. "SVG_FEBLEND_MODE_EXCLUSION",
  21410. "SVG_FEBLEND_MODE_HARD_LIGHT",
  21411. "SVG_FEBLEND_MODE_HUE",
  21412. "SVG_FEBLEND_MODE_LIGHTEN",
  21413. "SVG_FEBLEND_MODE_LUMINOSITY",
  21414. "SVG_FEBLEND_MODE_MULTIPLY",
  21415. "SVG_FEBLEND_MODE_NORMAL",
  21416. "SVG_FEBLEND_MODE_OVERLAY",
  21417. "SVG_FEBLEND_MODE_SATURATION",
  21418. "SVG_FEBLEND_MODE_SCREEN",
  21419. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  21420. "SVG_FEBLEND_MODE_UNKNOWN",
  21421. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  21422. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  21423. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  21424. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  21425. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  21426. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  21427. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  21428. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  21429. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  21430. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  21431. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  21432. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  21433. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  21434. "SVG_FECOMPOSITE_OPERATOR_IN",
  21435. "SVG_FECOMPOSITE_OPERATOR_OUT",
  21436. "SVG_FECOMPOSITE_OPERATOR_OVER",
  21437. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  21438. "SVG_FECOMPOSITE_OPERATOR_XOR",
  21439. "SVG_INVALID_VALUE_ERR",
  21440. "SVG_LENGTHTYPE_CM",
  21441. "SVG_LENGTHTYPE_EMS",
  21442. "SVG_LENGTHTYPE_EXS",
  21443. "SVG_LENGTHTYPE_IN",
  21444. "SVG_LENGTHTYPE_MM",
  21445. "SVG_LENGTHTYPE_NUMBER",
  21446. "SVG_LENGTHTYPE_PC",
  21447. "SVG_LENGTHTYPE_PERCENTAGE",
  21448. "SVG_LENGTHTYPE_PT",
  21449. "SVG_LENGTHTYPE_PX",
  21450. "SVG_LENGTHTYPE_UNKNOWN",
  21451. "SVG_MARKERUNITS_STROKEWIDTH",
  21452. "SVG_MARKERUNITS_UNKNOWN",
  21453. "SVG_MARKERUNITS_USERSPACEONUSE",
  21454. "SVG_MARKER_ORIENT_ANGLE",
  21455. "SVG_MARKER_ORIENT_AUTO",
  21456. "SVG_MARKER_ORIENT_UNKNOWN",
  21457. "SVG_MASKTYPE_ALPHA",
  21458. "SVG_MASKTYPE_LUMINANCE",
  21459. "SVG_MATRIX_NOT_INVERTABLE",
  21460. "SVG_MEETORSLICE_MEET",
  21461. "SVG_MEETORSLICE_SLICE",
  21462. "SVG_MEETORSLICE_UNKNOWN",
  21463. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  21464. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  21465. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  21466. "SVG_PAINTTYPE_CURRENTCOLOR",
  21467. "SVG_PAINTTYPE_NONE",
  21468. "SVG_PAINTTYPE_RGBCOLOR",
  21469. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  21470. "SVG_PAINTTYPE_UNKNOWN",
  21471. "SVG_PAINTTYPE_URI",
  21472. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  21473. "SVG_PAINTTYPE_URI_NONE",
  21474. "SVG_PAINTTYPE_URI_RGBCOLOR",
  21475. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  21476. "SVG_PRESERVEASPECTRATIO_NONE",
  21477. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  21478. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  21479. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  21480. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  21481. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  21482. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  21483. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  21484. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  21485. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  21486. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  21487. "SVG_SPREADMETHOD_PAD",
  21488. "SVG_SPREADMETHOD_REFLECT",
  21489. "SVG_SPREADMETHOD_REPEAT",
  21490. "SVG_SPREADMETHOD_UNKNOWN",
  21491. "SVG_STITCHTYPE_NOSTITCH",
  21492. "SVG_STITCHTYPE_STITCH",
  21493. "SVG_STITCHTYPE_UNKNOWN",
  21494. "SVG_TRANSFORM_MATRIX",
  21495. "SVG_TRANSFORM_ROTATE",
  21496. "SVG_TRANSFORM_SCALE",
  21497. "SVG_TRANSFORM_SKEWX",
  21498. "SVG_TRANSFORM_SKEWY",
  21499. "SVG_TRANSFORM_TRANSLATE",
  21500. "SVG_TRANSFORM_UNKNOWN",
  21501. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  21502. "SVG_TURBULENCE_TYPE_TURBULENCE",
  21503. "SVG_TURBULENCE_TYPE_UNKNOWN",
  21504. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  21505. "SVG_UNIT_TYPE_UNKNOWN",
  21506. "SVG_UNIT_TYPE_USERSPACEONUSE",
  21507. "SVG_WRONG_TYPE_ERR",
  21508. "SVG_ZOOMANDPAN_DISABLE",
  21509. "SVG_ZOOMANDPAN_MAGNIFY",
  21510. "SVG_ZOOMANDPAN_UNKNOWN",
  21511. "SYNC_CONDITION",
  21512. "SYNC_FENCE",
  21513. "SYNC_FLAGS",
  21514. "SYNC_FLUSH_COMMANDS_BIT",
  21515. "SYNC_GPU_COMMANDS_COMPLETE",
  21516. "SYNC_STATUS",
  21517. "SYNTAX_ERR",
  21518. "SavedPages",
  21519. "Screen",
  21520. "ScreenOrientation",
  21521. "Script",
  21522. "ScriptProcessorNode",
  21523. "ScrollAreaEvent",
  21524. "SecurityPolicyViolationEvent",
  21525. "Selection",
  21526. "Sensor",
  21527. "SensorErrorEvent",
  21528. "ServiceWorker",
  21529. "ServiceWorkerContainer",
  21530. "ServiceWorkerRegistration",
  21531. "SessionDescription",
  21532. "Set",
  21533. "ShadowRoot",
  21534. "SharedArrayBuffer",
  21535. "SharedWorker",
  21536. "SimpleGestureEvent",
  21537. "SourceBuffer",
  21538. "SourceBufferList",
  21539. "SpeechSynthesis",
  21540. "SpeechSynthesisErrorEvent",
  21541. "SpeechSynthesisEvent",
  21542. "SpeechSynthesisUtterance",
  21543. "SpeechSynthesisVoice",
  21544. "StaticRange",
  21545. "StereoPannerNode",
  21546. "StopIteration",
  21547. "Storage",
  21548. "StorageEvent",
  21549. "StorageManager",
  21550. "String",
  21551. "StructType",
  21552. "StylePropertyMap",
  21553. "StylePropertyMapReadOnly",
  21554. "StyleSheet",
  21555. "StyleSheetList",
  21556. "SubmitEvent",
  21557. "SubtleCrypto",
  21558. "Symbol",
  21559. "SyncManager",
  21560. "SyntaxError",
  21561. "TEMPORARY",
  21562. "TEXTPATH_METHODTYPE_ALIGN",
  21563. "TEXTPATH_METHODTYPE_STRETCH",
  21564. "TEXTPATH_METHODTYPE_UNKNOWN",
  21565. "TEXTPATH_SPACINGTYPE_AUTO",
  21566. "TEXTPATH_SPACINGTYPE_EXACT",
  21567. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  21568. "TEXTURE",
  21569. "TEXTURE0",
  21570. "TEXTURE1",
  21571. "TEXTURE10",
  21572. "TEXTURE11",
  21573. "TEXTURE12",
  21574. "TEXTURE13",
  21575. "TEXTURE14",
  21576. "TEXTURE15",
  21577. "TEXTURE16",
  21578. "TEXTURE17",
  21579. "TEXTURE18",
  21580. "TEXTURE19",
  21581. "TEXTURE2",
  21582. "TEXTURE20",
  21583. "TEXTURE21",
  21584. "TEXTURE22",
  21585. "TEXTURE23",
  21586. "TEXTURE24",
  21587. "TEXTURE25",
  21588. "TEXTURE26",
  21589. "TEXTURE27",
  21590. "TEXTURE28",
  21591. "TEXTURE29",
  21592. "TEXTURE3",
  21593. "TEXTURE30",
  21594. "TEXTURE31",
  21595. "TEXTURE4",
  21596. "TEXTURE5",
  21597. "TEXTURE6",
  21598. "TEXTURE7",
  21599. "TEXTURE8",
  21600. "TEXTURE9",
  21601. "TEXTURE_2D",
  21602. "TEXTURE_2D_ARRAY",
  21603. "TEXTURE_3D",
  21604. "TEXTURE_BASE_LEVEL",
  21605. "TEXTURE_BINDING_2D",
  21606. "TEXTURE_BINDING_2D_ARRAY",
  21607. "TEXTURE_BINDING_3D",
  21608. "TEXTURE_BINDING_CUBE_MAP",
  21609. "TEXTURE_COMPARE_FUNC",
  21610. "TEXTURE_COMPARE_MODE",
  21611. "TEXTURE_CUBE_MAP",
  21612. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  21613. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  21614. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  21615. "TEXTURE_CUBE_MAP_POSITIVE_X",
  21616. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  21617. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  21618. "TEXTURE_IMMUTABLE_FORMAT",
  21619. "TEXTURE_IMMUTABLE_LEVELS",
  21620. "TEXTURE_MAG_FILTER",
  21621. "TEXTURE_MAX_ANISOTROPY_EXT",
  21622. "TEXTURE_MAX_LEVEL",
  21623. "TEXTURE_MAX_LOD",
  21624. "TEXTURE_MIN_FILTER",
  21625. "TEXTURE_MIN_LOD",
  21626. "TEXTURE_WRAP_R",
  21627. "TEXTURE_WRAP_S",
  21628. "TEXTURE_WRAP_T",
  21629. "TEXT_NODE",
  21630. "TIMEOUT",
  21631. "TIMEOUT_ERR",
  21632. "TIMEOUT_EXPIRED",
  21633. "TIMEOUT_IGNORED",
  21634. "TOO_LARGE_ERR",
  21635. "TRANSACTION_INACTIVE_ERR",
  21636. "TRANSFORM_FEEDBACK",
  21637. "TRANSFORM_FEEDBACK_ACTIVE",
  21638. "TRANSFORM_FEEDBACK_BINDING",
  21639. "TRANSFORM_FEEDBACK_BUFFER",
  21640. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  21641. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  21642. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  21643. "TRANSFORM_FEEDBACK_BUFFER_START",
  21644. "TRANSFORM_FEEDBACK_PAUSED",
  21645. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  21646. "TRANSFORM_FEEDBACK_VARYINGS",
  21647. "TRIANGLE",
  21648. "TRIANGLES",
  21649. "TRIANGLE_FAN",
  21650. "TRIANGLE_STRIP",
  21651. "TYPE_BACK_FORWARD",
  21652. "TYPE_ERR",
  21653. "TYPE_MISMATCH_ERR",
  21654. "TYPE_NAVIGATE",
  21655. "TYPE_RELOAD",
  21656. "TYPE_RESERVED",
  21657. "Table",
  21658. "TaskAttributionTiming",
  21659. "Text",
  21660. "TextDecoder",
  21661. "TextDecoderStream",
  21662. "TextEncoder",
  21663. "TextEncoderStream",
  21664. "TextEvent",
  21665. "TextMetrics",
  21666. "TextTrack",
  21667. "TextTrackCue",
  21668. "TextTrackCueList",
  21669. "TextTrackList",
  21670. "TimeEvent",
  21671. "TimeRanges",
  21672. "Touch",
  21673. "TouchEvent",
  21674. "TouchList",
  21675. "TrackEvent",
  21676. "TransformStream",
  21677. "TransitionEvent",
  21678. "TreeWalker",
  21679. "TrustedHTML",
  21680. "TrustedScript",
  21681. "TrustedScriptURL",
  21682. "TrustedTypePolicy",
  21683. "TrustedTypePolicyFactory",
  21684. "TypeError",
  21685. "TypedObject",
  21686. "U2F",
  21687. "UIEvent",
  21688. "UNCACHED",
  21689. "UNIFORM_ARRAY_STRIDE",
  21690. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  21691. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  21692. "UNIFORM_BLOCK_BINDING",
  21693. "UNIFORM_BLOCK_DATA_SIZE",
  21694. "UNIFORM_BLOCK_INDEX",
  21695. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  21696. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  21697. "UNIFORM_BUFFER",
  21698. "UNIFORM_BUFFER_BINDING",
  21699. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  21700. "UNIFORM_BUFFER_SIZE",
  21701. "UNIFORM_BUFFER_START",
  21702. "UNIFORM_IS_ROW_MAJOR",
  21703. "UNIFORM_MATRIX_STRIDE",
  21704. "UNIFORM_OFFSET",
  21705. "UNIFORM_SIZE",
  21706. "UNIFORM_TYPE",
  21707. "UNKNOWN_ERR",
  21708. "UNKNOWN_RULE",
  21709. "UNMASKED_RENDERER_WEBGL",
  21710. "UNMASKED_VENDOR_WEBGL",
  21711. "UNORDERED_NODE_ITERATOR_TYPE",
  21712. "UNORDERED_NODE_SNAPSHOT_TYPE",
  21713. "UNPACK_ALIGNMENT",
  21714. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  21715. "UNPACK_FLIP_Y_WEBGL",
  21716. "UNPACK_IMAGE_HEIGHT",
  21717. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  21718. "UNPACK_ROW_LENGTH",
  21719. "UNPACK_SKIP_IMAGES",
  21720. "UNPACK_SKIP_PIXELS",
  21721. "UNPACK_SKIP_ROWS",
  21722. "UNSCHEDULED_STATE",
  21723. "UNSENT",
  21724. "UNSIGNALED",
  21725. "UNSIGNED_BYTE",
  21726. "UNSIGNED_INT",
  21727. "UNSIGNED_INT_10F_11F_11F_REV",
  21728. "UNSIGNED_INT_24_8",
  21729. "UNSIGNED_INT_2_10_10_10_REV",
  21730. "UNSIGNED_INT_5_9_9_9_REV",
  21731. "UNSIGNED_INT_SAMPLER_2D",
  21732. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  21733. "UNSIGNED_INT_SAMPLER_3D",
  21734. "UNSIGNED_INT_SAMPLER_CUBE",
  21735. "UNSIGNED_INT_VEC2",
  21736. "UNSIGNED_INT_VEC3",
  21737. "UNSIGNED_INT_VEC4",
  21738. "UNSIGNED_NORMALIZED",
  21739. "UNSIGNED_SHORT",
  21740. "UNSIGNED_SHORT_4_4_4_4",
  21741. "UNSIGNED_SHORT_5_5_5_1",
  21742. "UNSIGNED_SHORT_5_6_5",
  21743. "UNSPECIFIED_EVENT_TYPE_ERR",
  21744. "UPDATEREADY",
  21745. "URIError",
  21746. "URL",
  21747. "URLSearchParams",
  21748. "URLUnencoded",
  21749. "URL_MISMATCH_ERR",
  21750. "USB",
  21751. "USBAlternateInterface",
  21752. "USBConfiguration",
  21753. "USBConnectionEvent",
  21754. "USBDevice",
  21755. "USBEndpoint",
  21756. "USBInTransferResult",
  21757. "USBInterface",
  21758. "USBIsochronousInTransferPacket",
  21759. "USBIsochronousInTransferResult",
  21760. "USBIsochronousOutTransferPacket",
  21761. "USBIsochronousOutTransferResult",
  21762. "USBOutTransferResult",
  21763. "UTC",
  21764. "Uint16Array",
  21765. "Uint32Array",
  21766. "Uint8Array",
  21767. "Uint8ClampedArray",
  21768. "UserActivation",
  21769. "UserMessageHandler",
  21770. "UserMessageHandlersNamespace",
  21771. "UserProximityEvent",
  21772. "VALIDATE_STATUS",
  21773. "VALIDATION_ERR",
  21774. "VARIABLES_RULE",
  21775. "VENDOR",
  21776. "VERSION",
  21777. "VERSION_CHANGE",
  21778. "VERSION_ERR",
  21779. "VERTEX_ARRAY_BINDING",
  21780. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  21781. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  21782. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  21783. "VERTEX_ATTRIB_ARRAY_ENABLED",
  21784. "VERTEX_ATTRIB_ARRAY_INTEGER",
  21785. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  21786. "VERTEX_ATTRIB_ARRAY_POINTER",
  21787. "VERTEX_ATTRIB_ARRAY_SIZE",
  21788. "VERTEX_ATTRIB_ARRAY_STRIDE",
  21789. "VERTEX_ATTRIB_ARRAY_TYPE",
  21790. "VERTEX_SHADER",
  21791. "VERTICAL",
  21792. "VERTICAL_AXIS",
  21793. "VER_ERR",
  21794. "VIEWPORT",
  21795. "VIEWPORT_RULE",
  21796. "VRDisplay",
  21797. "VRDisplayCapabilities",
  21798. "VRDisplayEvent",
  21799. "VREyeParameters",
  21800. "VRFieldOfView",
  21801. "VRFrameData",
  21802. "VRPose",
  21803. "VRStageParameters",
  21804. "VTTCue",
  21805. "VTTRegion",
  21806. "ValidityState",
  21807. "VideoPlaybackQuality",
  21808. "VideoStreamTrack",
  21809. "VisualViewport",
  21810. "WAIT_FAILED",
  21811. "WEBKIT_FILTER_RULE",
  21812. "WEBKIT_KEYFRAMES_RULE",
  21813. "WEBKIT_KEYFRAME_RULE",
  21814. "WEBKIT_REGION_RULE",
  21815. "WRONG_DOCUMENT_ERR",
  21816. "WakeLock",
  21817. "WakeLockSentinel",
  21818. "WasmAnyRef",
  21819. "WaveShaperNode",
  21820. "WeakMap",
  21821. "WeakRef",
  21822. "WeakSet",
  21823. "WebAssembly",
  21824. "WebGL2RenderingContext",
  21825. "WebGLActiveInfo",
  21826. "WebGLBuffer",
  21827. "WebGLContextEvent",
  21828. "WebGLFramebuffer",
  21829. "WebGLProgram",
  21830. "WebGLQuery",
  21831. "WebGLRenderbuffer",
  21832. "WebGLRenderingContext",
  21833. "WebGLSampler",
  21834. "WebGLShader",
  21835. "WebGLShaderPrecisionFormat",
  21836. "WebGLSync",
  21837. "WebGLTexture",
  21838. "WebGLTransformFeedback",
  21839. "WebGLUniformLocation",
  21840. "WebGLVertexArray",
  21841. "WebGLVertexArrayObject",
  21842. "WebKitAnimationEvent",
  21843. "WebKitBlobBuilder",
  21844. "WebKitCSSFilterRule",
  21845. "WebKitCSSFilterValue",
  21846. "WebKitCSSKeyframeRule",
  21847. "WebKitCSSKeyframesRule",
  21848. "WebKitCSSMatrix",
  21849. "WebKitCSSRegionRule",
  21850. "WebKitCSSTransformValue",
  21851. "WebKitDataCue",
  21852. "WebKitGamepad",
  21853. "WebKitMediaKeyError",
  21854. "WebKitMediaKeyMessageEvent",
  21855. "WebKitMediaKeySession",
  21856. "WebKitMediaKeys",
  21857. "WebKitMediaSource",
  21858. "WebKitMutationObserver",
  21859. "WebKitNamespace",
  21860. "WebKitPlaybackTargetAvailabilityEvent",
  21861. "WebKitPoint",
  21862. "WebKitShadowRoot",
  21863. "WebKitSourceBuffer",
  21864. "WebKitSourceBufferList",
  21865. "WebKitTransitionEvent",
  21866. "WebSocket",
  21867. "WebkitAlignContent",
  21868. "WebkitAlignItems",
  21869. "WebkitAlignSelf",
  21870. "WebkitAnimation",
  21871. "WebkitAnimationDelay",
  21872. "WebkitAnimationDirection",
  21873. "WebkitAnimationDuration",
  21874. "WebkitAnimationFillMode",
  21875. "WebkitAnimationIterationCount",
  21876. "WebkitAnimationName",
  21877. "WebkitAnimationPlayState",
  21878. "WebkitAnimationTimingFunction",
  21879. "WebkitAppearance",
  21880. "WebkitBackfaceVisibility",
  21881. "WebkitBackgroundClip",
  21882. "WebkitBackgroundOrigin",
  21883. "WebkitBackgroundSize",
  21884. "WebkitBorderBottomLeftRadius",
  21885. "WebkitBorderBottomRightRadius",
  21886. "WebkitBorderImage",
  21887. "WebkitBorderRadius",
  21888. "WebkitBorderTopLeftRadius",
  21889. "WebkitBorderTopRightRadius",
  21890. "WebkitBoxAlign",
  21891. "WebkitBoxDirection",
  21892. "WebkitBoxFlex",
  21893. "WebkitBoxOrdinalGroup",
  21894. "WebkitBoxOrient",
  21895. "WebkitBoxPack",
  21896. "WebkitBoxShadow",
  21897. "WebkitBoxSizing",
  21898. "WebkitFilter",
  21899. "WebkitFlex",
  21900. "WebkitFlexBasis",
  21901. "WebkitFlexDirection",
  21902. "WebkitFlexFlow",
  21903. "WebkitFlexGrow",
  21904. "WebkitFlexShrink",
  21905. "WebkitFlexWrap",
  21906. "WebkitJustifyContent",
  21907. "WebkitLineClamp",
  21908. "WebkitMask",
  21909. "WebkitMaskClip",
  21910. "WebkitMaskComposite",
  21911. "WebkitMaskImage",
  21912. "WebkitMaskOrigin",
  21913. "WebkitMaskPosition",
  21914. "WebkitMaskPositionX",
  21915. "WebkitMaskPositionY",
  21916. "WebkitMaskRepeat",
  21917. "WebkitMaskSize",
  21918. "WebkitOrder",
  21919. "WebkitPerspective",
  21920. "WebkitPerspectiveOrigin",
  21921. "WebkitTextFillColor",
  21922. "WebkitTextSizeAdjust",
  21923. "WebkitTextStroke",
  21924. "WebkitTextStrokeColor",
  21925. "WebkitTextStrokeWidth",
  21926. "WebkitTransform",
  21927. "WebkitTransformOrigin",
  21928. "WebkitTransformStyle",
  21929. "WebkitTransition",
  21930. "WebkitTransitionDelay",
  21931. "WebkitTransitionDuration",
  21932. "WebkitTransitionProperty",
  21933. "WebkitTransitionTimingFunction",
  21934. "WebkitUserSelect",
  21935. "WheelEvent",
  21936. "Window",
  21937. "Worker",
  21938. "Worklet",
  21939. "WritableStream",
  21940. "WritableStreamDefaultWriter",
  21941. "XMLDocument",
  21942. "XMLHttpRequest",
  21943. "XMLHttpRequestEventTarget",
  21944. "XMLHttpRequestException",
  21945. "XMLHttpRequestProgressEvent",
  21946. "XMLHttpRequestUpload",
  21947. "XMLSerializer",
  21948. "XMLStylesheetProcessingInstruction",
  21949. "XPathEvaluator",
  21950. "XPathException",
  21951. "XPathExpression",
  21952. "XPathNSResolver",
  21953. "XPathResult",
  21954. "XRBoundedReferenceSpace",
  21955. "XRDOMOverlayState",
  21956. "XRFrame",
  21957. "XRHitTestResult",
  21958. "XRHitTestSource",
  21959. "XRInputSource",
  21960. "XRInputSourceArray",
  21961. "XRInputSourceEvent",
  21962. "XRInputSourcesChangeEvent",
  21963. "XRLayer",
  21964. "XRPose",
  21965. "XRRay",
  21966. "XRReferenceSpace",
  21967. "XRReferenceSpaceEvent",
  21968. "XRRenderState",
  21969. "XRRigidTransform",
  21970. "XRSession",
  21971. "XRSessionEvent",
  21972. "XRSpace",
  21973. "XRSystem",
  21974. "XRTransientInputHitTestResult",
  21975. "XRTransientInputHitTestSource",
  21976. "XRView",
  21977. "XRViewerPose",
  21978. "XRViewport",
  21979. "XRWebGLLayer",
  21980. "XSLTProcessor",
  21981. "ZERO",
  21982. "_XD0M_",
  21983. "_YD0M_",
  21984. "__defineGetter__",
  21985. "__defineSetter__",
  21986. "__lookupGetter__",
  21987. "__lookupSetter__",
  21988. "__opera",
  21989. "__proto__",
  21990. "_browserjsran",
  21991. "a",
  21992. "aLink",
  21993. "abbr",
  21994. "abort",
  21995. "aborted",
  21996. "abs",
  21997. "absolute",
  21998. "acceleration",
  21999. "accelerationIncludingGravity",
  22000. "accelerator",
  22001. "accept",
  22002. "acceptCharset",
  22003. "acceptNode",
  22004. "accessKey",
  22005. "accessKeyLabel",
  22006. "accuracy",
  22007. "acos",
  22008. "acosh",
  22009. "action",
  22010. "actionURL",
  22011. "actions",
  22012. "activated",
  22013. "active",
  22014. "activeCues",
  22015. "activeElement",
  22016. "activeSourceBuffers",
  22017. "activeSourceCount",
  22018. "activeTexture",
  22019. "activeVRDisplays",
  22020. "actualBoundingBoxAscent",
  22021. "actualBoundingBoxDescent",
  22022. "actualBoundingBoxLeft",
  22023. "actualBoundingBoxRight",
  22024. "add",
  22025. "addAll",
  22026. "addBehavior",
  22027. "addCandidate",
  22028. "addColorStop",
  22029. "addCue",
  22030. "addElement",
  22031. "addEventListener",
  22032. "addFilter",
  22033. "addFromString",
  22034. "addFromUri",
  22035. "addIceCandidate",
  22036. "addImport",
  22037. "addListener",
  22038. "addModule",
  22039. "addNamed",
  22040. "addPageRule",
  22041. "addPath",
  22042. "addPointer",
  22043. "addRange",
  22044. "addRegion",
  22045. "addRule",
  22046. "addSearchEngine",
  22047. "addSourceBuffer",
  22048. "addStream",
  22049. "addTextTrack",
  22050. "addTrack",
  22051. "addTransceiver",
  22052. "addWakeLockListener",
  22053. "added",
  22054. "addedNodes",
  22055. "additionalName",
  22056. "additiveSymbols",
  22057. "addons",
  22058. "address",
  22059. "addressLine",
  22060. "adoptNode",
  22061. "adoptedStyleSheets",
  22062. "adr",
  22063. "advance",
  22064. "after",
  22065. "album",
  22066. "alert",
  22067. "algorithm",
  22068. "align",
  22069. "align-content",
  22070. "align-items",
  22071. "align-self",
  22072. "alignContent",
  22073. "alignItems",
  22074. "alignSelf",
  22075. "alignmentBaseline",
  22076. "alinkColor",
  22077. "all",
  22078. "allSettled",
  22079. "allow",
  22080. "allowFullscreen",
  22081. "allowPaymentRequest",
  22082. "allowedDirections",
  22083. "allowedFeatures",
  22084. "allowedToPlay",
  22085. "allowsFeature",
  22086. "alpha",
  22087. "alt",
  22088. "altGraphKey",
  22089. "altHtml",
  22090. "altKey",
  22091. "altLeft",
  22092. "alternate",
  22093. "alternateSetting",
  22094. "alternates",
  22095. "altitude",
  22096. "altitudeAccuracy",
  22097. "amplitude",
  22098. "ancestorOrigins",
  22099. "anchor",
  22100. "anchorNode",
  22101. "anchorOffset",
  22102. "anchors",
  22103. "and",
  22104. "angle",
  22105. "angularAcceleration",
  22106. "angularVelocity",
  22107. "animVal",
  22108. "animate",
  22109. "animatedInstanceRoot",
  22110. "animatedNormalizedPathSegList",
  22111. "animatedPathSegList",
  22112. "animatedPoints",
  22113. "animation",
  22114. "animation-delay",
  22115. "animation-direction",
  22116. "animation-duration",
  22117. "animation-fill-mode",
  22118. "animation-iteration-count",
  22119. "animation-name",
  22120. "animation-play-state",
  22121. "animation-timing-function",
  22122. "animationDelay",
  22123. "animationDirection",
  22124. "animationDuration",
  22125. "animationFillMode",
  22126. "animationIterationCount",
  22127. "animationName",
  22128. "animationPlayState",
  22129. "animationStartTime",
  22130. "animationTimingFunction",
  22131. "animationsPaused",
  22132. "anniversary",
  22133. "antialias",
  22134. "anticipatedRemoval",
  22135. "any",
  22136. "app",
  22137. "appCodeName",
  22138. "appMinorVersion",
  22139. "appName",
  22140. "appNotifications",
  22141. "appVersion",
  22142. "appearance",
  22143. "append",
  22144. "appendBuffer",
  22145. "appendChild",
  22146. "appendData",
  22147. "appendItem",
  22148. "appendMedium",
  22149. "appendNamed",
  22150. "appendRule",
  22151. "appendStream",
  22152. "appendWindowEnd",
  22153. "appendWindowStart",
  22154. "applets",
  22155. "applicationCache",
  22156. "applicationServerKey",
  22157. "apply",
  22158. "applyConstraints",
  22159. "applyElement",
  22160. "arc",
  22161. "arcTo",
  22162. "architecture",
  22163. "archive",
  22164. "areas",
  22165. "arguments",
  22166. "ariaAtomic",
  22167. "ariaAutoComplete",
  22168. "ariaBusy",
  22169. "ariaChecked",
  22170. "ariaColCount",
  22171. "ariaColIndex",
  22172. "ariaColSpan",
  22173. "ariaCurrent",
  22174. "ariaDescription",
  22175. "ariaDisabled",
  22176. "ariaExpanded",
  22177. "ariaHasPopup",
  22178. "ariaHidden",
  22179. "ariaKeyShortcuts",
  22180. "ariaLabel",
  22181. "ariaLevel",
  22182. "ariaLive",
  22183. "ariaModal",
  22184. "ariaMultiLine",
  22185. "ariaMultiSelectable",
  22186. "ariaOrientation",
  22187. "ariaPlaceholder",
  22188. "ariaPosInSet",
  22189. "ariaPressed",
  22190. "ariaReadOnly",
  22191. "ariaRelevant",
  22192. "ariaRequired",
  22193. "ariaRoleDescription",
  22194. "ariaRowCount",
  22195. "ariaRowIndex",
  22196. "ariaRowSpan",
  22197. "ariaSelected",
  22198. "ariaSetSize",
  22199. "ariaSort",
  22200. "ariaValueMax",
  22201. "ariaValueMin",
  22202. "ariaValueNow",
  22203. "ariaValueText",
  22204. "arrayBuffer",
  22205. "artist",
  22206. "artwork",
  22207. "as",
  22208. "asIntN",
  22209. "asUintN",
  22210. "asin",
  22211. "asinh",
  22212. "assert",
  22213. "assign",
  22214. "assignedElements",
  22215. "assignedNodes",
  22216. "assignedSlot",
  22217. "async",
  22218. "asyncIterator",
  22219. "atEnd",
  22220. "atan",
  22221. "atan2",
  22222. "atanh",
  22223. "atob",
  22224. "attachEvent",
  22225. "attachInternals",
  22226. "attachShader",
  22227. "attachShadow",
  22228. "attachments",
  22229. "attack",
  22230. "attestationObject",
  22231. "attrChange",
  22232. "attrName",
  22233. "attributeFilter",
  22234. "attributeName",
  22235. "attributeNamespace",
  22236. "attributeOldValue",
  22237. "attributeStyleMap",
  22238. "attributes",
  22239. "attribution",
  22240. "audioBitsPerSecond",
  22241. "audioTracks",
  22242. "audioWorklet",
  22243. "authenticatedSignedWrites",
  22244. "authenticatorData",
  22245. "autoIncrement",
  22246. "autobuffer",
  22247. "autocapitalize",
  22248. "autocomplete",
  22249. "autocorrect",
  22250. "autofocus",
  22251. "automationRate",
  22252. "autoplay",
  22253. "availHeight",
  22254. "availLeft",
  22255. "availTop",
  22256. "availWidth",
  22257. "availability",
  22258. "available",
  22259. "aversion",
  22260. "ax",
  22261. "axes",
  22262. "axis",
  22263. "ay",
  22264. "azimuth",
  22265. "b",
  22266. "back",
  22267. "backface-visibility",
  22268. "backfaceVisibility",
  22269. "background",
  22270. "background-attachment",
  22271. "background-blend-mode",
  22272. "background-clip",
  22273. "background-color",
  22274. "background-image",
  22275. "background-origin",
  22276. "background-position",
  22277. "background-position-x",
  22278. "background-position-y",
  22279. "background-repeat",
  22280. "background-size",
  22281. "backgroundAttachment",
  22282. "backgroundBlendMode",
  22283. "backgroundClip",
  22284. "backgroundColor",
  22285. "backgroundFetch",
  22286. "backgroundImage",
  22287. "backgroundOrigin",
  22288. "backgroundPosition",
  22289. "backgroundPositionX",
  22290. "backgroundPositionY",
  22291. "backgroundRepeat",
  22292. "backgroundSize",
  22293. "badInput",
  22294. "badge",
  22295. "balance",
  22296. "baseFrequencyX",
  22297. "baseFrequencyY",
  22298. "baseLatency",
  22299. "baseLayer",
  22300. "baseNode",
  22301. "baseOffset",
  22302. "baseURI",
  22303. "baseVal",
  22304. "baselineShift",
  22305. "battery",
  22306. "bday",
  22307. "before",
  22308. "beginElement",
  22309. "beginElementAt",
  22310. "beginPath",
  22311. "beginQuery",
  22312. "beginTransformFeedback",
  22313. "behavior",
  22314. "behaviorCookie",
  22315. "behaviorPart",
  22316. "behaviorUrns",
  22317. "beta",
  22318. "bezierCurveTo",
  22319. "bgColor",
  22320. "bgProperties",
  22321. "bias",
  22322. "big",
  22323. "bigint64",
  22324. "biguint64",
  22325. "binaryType",
  22326. "bind",
  22327. "bindAttribLocation",
  22328. "bindBuffer",
  22329. "bindBufferBase",
  22330. "bindBufferRange",
  22331. "bindFramebuffer",
  22332. "bindRenderbuffer",
  22333. "bindSampler",
  22334. "bindTexture",
  22335. "bindTransformFeedback",
  22336. "bindVertexArray",
  22337. "bitness",
  22338. "blendColor",
  22339. "blendEquation",
  22340. "blendEquationSeparate",
  22341. "blendFunc",
  22342. "blendFuncSeparate",
  22343. "blink",
  22344. "blitFramebuffer",
  22345. "blob",
  22346. "block-size",
  22347. "blockDirection",
  22348. "blockSize",
  22349. "blockedURI",
  22350. "blue",
  22351. "bluetooth",
  22352. "blur",
  22353. "body",
  22354. "bodyUsed",
  22355. "bold",
  22356. "bookmarks",
  22357. "booleanValue",
  22358. "border",
  22359. "border-block",
  22360. "border-block-color",
  22361. "border-block-end",
  22362. "border-block-end-color",
  22363. "border-block-end-style",
  22364. "border-block-end-width",
  22365. "border-block-start",
  22366. "border-block-start-color",
  22367. "border-block-start-style",
  22368. "border-block-start-width",
  22369. "border-block-style",
  22370. "border-block-width",
  22371. "border-bottom",
  22372. "border-bottom-color",
  22373. "border-bottom-left-radius",
  22374. "border-bottom-right-radius",
  22375. "border-bottom-style",
  22376. "border-bottom-width",
  22377. "border-collapse",
  22378. "border-color",
  22379. "border-end-end-radius",
  22380. "border-end-start-radius",
  22381. "border-image",
  22382. "border-image-outset",
  22383. "border-image-repeat",
  22384. "border-image-slice",
  22385. "border-image-source",
  22386. "border-image-width",
  22387. "border-inline",
  22388. "border-inline-color",
  22389. "border-inline-end",
  22390. "border-inline-end-color",
  22391. "border-inline-end-style",
  22392. "border-inline-end-width",
  22393. "border-inline-start",
  22394. "border-inline-start-color",
  22395. "border-inline-start-style",
  22396. "border-inline-start-width",
  22397. "border-inline-style",
  22398. "border-inline-width",
  22399. "border-left",
  22400. "border-left-color",
  22401. "border-left-style",
  22402. "border-left-width",
  22403. "border-radius",
  22404. "border-right",
  22405. "border-right-color",
  22406. "border-right-style",
  22407. "border-right-width",
  22408. "border-spacing",
  22409. "border-start-end-radius",
  22410. "border-start-start-radius",
  22411. "border-style",
  22412. "border-top",
  22413. "border-top-color",
  22414. "border-top-left-radius",
  22415. "border-top-right-radius",
  22416. "border-top-style",
  22417. "border-top-width",
  22418. "border-width",
  22419. "borderBlock",
  22420. "borderBlockColor",
  22421. "borderBlockEnd",
  22422. "borderBlockEndColor",
  22423. "borderBlockEndStyle",
  22424. "borderBlockEndWidth",
  22425. "borderBlockStart",
  22426. "borderBlockStartColor",
  22427. "borderBlockStartStyle",
  22428. "borderBlockStartWidth",
  22429. "borderBlockStyle",
  22430. "borderBlockWidth",
  22431. "borderBottom",
  22432. "borderBottomColor",
  22433. "borderBottomLeftRadius",
  22434. "borderBottomRightRadius",
  22435. "borderBottomStyle",
  22436. "borderBottomWidth",
  22437. "borderBoxSize",
  22438. "borderCollapse",
  22439. "borderColor",
  22440. "borderColorDark",
  22441. "borderColorLight",
  22442. "borderEndEndRadius",
  22443. "borderEndStartRadius",
  22444. "borderImage",
  22445. "borderImageOutset",
  22446. "borderImageRepeat",
  22447. "borderImageSlice",
  22448. "borderImageSource",
  22449. "borderImageWidth",
  22450. "borderInline",
  22451. "borderInlineColor",
  22452. "borderInlineEnd",
  22453. "borderInlineEndColor",
  22454. "borderInlineEndStyle",
  22455. "borderInlineEndWidth",
  22456. "borderInlineStart",
  22457. "borderInlineStartColor",
  22458. "borderInlineStartStyle",
  22459. "borderInlineStartWidth",
  22460. "borderInlineStyle",
  22461. "borderInlineWidth",
  22462. "borderLeft",
  22463. "borderLeftColor",
  22464. "borderLeftStyle",
  22465. "borderLeftWidth",
  22466. "borderRadius",
  22467. "borderRight",
  22468. "borderRightColor",
  22469. "borderRightStyle",
  22470. "borderRightWidth",
  22471. "borderSpacing",
  22472. "borderStartEndRadius",
  22473. "borderStartStartRadius",
  22474. "borderStyle",
  22475. "borderTop",
  22476. "borderTopColor",
  22477. "borderTopLeftRadius",
  22478. "borderTopRightRadius",
  22479. "borderTopStyle",
  22480. "borderTopWidth",
  22481. "borderWidth",
  22482. "bottom",
  22483. "bottomMargin",
  22484. "bound",
  22485. "boundElements",
  22486. "boundingClientRect",
  22487. "boundingHeight",
  22488. "boundingLeft",
  22489. "boundingTop",
  22490. "boundingWidth",
  22491. "bounds",
  22492. "boundsGeometry",
  22493. "box-decoration-break",
  22494. "box-shadow",
  22495. "box-sizing",
  22496. "boxDecorationBreak",
  22497. "boxShadow",
  22498. "boxSizing",
  22499. "brand",
  22500. "brands",
  22501. "break-after",
  22502. "break-before",
  22503. "break-inside",
  22504. "breakAfter",
  22505. "breakBefore",
  22506. "breakInside",
  22507. "broadcast",
  22508. "browserLanguage",
  22509. "btoa",
  22510. "bubbles",
  22511. "buffer",
  22512. "bufferData",
  22513. "bufferDepth",
  22514. "bufferSize",
  22515. "bufferSubData",
  22516. "buffered",
  22517. "bufferedAmount",
  22518. "bufferedAmountLowThreshold",
  22519. "buildID",
  22520. "buildNumber",
  22521. "button",
  22522. "buttonID",
  22523. "buttons",
  22524. "byteLength",
  22525. "byteOffset",
  22526. "bytesWritten",
  22527. "c",
  22528. "cache",
  22529. "caches",
  22530. "call",
  22531. "caller",
  22532. "canBeFormatted",
  22533. "canBeMounted",
  22534. "canBeShared",
  22535. "canHaveChildren",
  22536. "canHaveHTML",
  22537. "canInsertDTMF",
  22538. "canMakePayment",
  22539. "canPlayType",
  22540. "canPresent",
  22541. "canTrickleIceCandidates",
  22542. "cancel",
  22543. "cancelAndHoldAtTime",
  22544. "cancelAnimationFrame",
  22545. "cancelBubble",
  22546. "cancelIdleCallback",
  22547. "cancelScheduledValues",
  22548. "cancelVideoFrameCallback",
  22549. "cancelWatchAvailability",
  22550. "cancelable",
  22551. "candidate",
  22552. "canonicalUUID",
  22553. "canvas",
  22554. "capabilities",
  22555. "caption",
  22556. "caption-side",
  22557. "captionSide",
  22558. "capture",
  22559. "captureEvents",
  22560. "captureStackTrace",
  22561. "captureStream",
  22562. "caret-color",
  22563. "caretBidiLevel",
  22564. "caretColor",
  22565. "caretPositionFromPoint",
  22566. "caretRangeFromPoint",
  22567. "cast",
  22568. "catch",
  22569. "category",
  22570. "cbrt",
  22571. "cd",
  22572. "ceil",
  22573. "cellIndex",
  22574. "cellPadding",
  22575. "cellSpacing",
  22576. "cells",
  22577. "ch",
  22578. "chOff",
  22579. "chain",
  22580. "challenge",
  22581. "changeType",
  22582. "changedTouches",
  22583. "channel",
  22584. "channelCount",
  22585. "channelCountMode",
  22586. "channelInterpretation",
  22587. "char",
  22588. "charAt",
  22589. "charCode",
  22590. "charCodeAt",
  22591. "charIndex",
  22592. "charLength",
  22593. "characterData",
  22594. "characterDataOldValue",
  22595. "characterSet",
  22596. "characteristic",
  22597. "charging",
  22598. "chargingTime",
  22599. "charset",
  22600. "check",
  22601. "checkEnclosure",
  22602. "checkFramebufferStatus",
  22603. "checkIntersection",
  22604. "checkValidity",
  22605. "checked",
  22606. "childElementCount",
  22607. "childList",
  22608. "childNodes",
  22609. "children",
  22610. "chrome",
  22611. "ciphertext",
  22612. "cite",
  22613. "city",
  22614. "claimInterface",
  22615. "claimed",
  22616. "classList",
  22617. "className",
  22618. "classid",
  22619. "clear",
  22620. "clearAppBadge",
  22621. "clearAttributes",
  22622. "clearBufferfi",
  22623. "clearBufferfv",
  22624. "clearBufferiv",
  22625. "clearBufferuiv",
  22626. "clearColor",
  22627. "clearData",
  22628. "clearDepth",
  22629. "clearHalt",
  22630. "clearImmediate",
  22631. "clearInterval",
  22632. "clearLiveSeekableRange",
  22633. "clearMarks",
  22634. "clearMaxGCPauseAccumulator",
  22635. "clearMeasures",
  22636. "clearParameters",
  22637. "clearRect",
  22638. "clearResourceTimings",
  22639. "clearShadow",
  22640. "clearStencil",
  22641. "clearTimeout",
  22642. "clearWatch",
  22643. "click",
  22644. "clickCount",
  22645. "clientDataJSON",
  22646. "clientHeight",
  22647. "clientInformation",
  22648. "clientLeft",
  22649. "clientRect",
  22650. "clientRects",
  22651. "clientTop",
  22652. "clientWaitSync",
  22653. "clientWidth",
  22654. "clientX",
  22655. "clientY",
  22656. "clip",
  22657. "clip-path",
  22658. "clip-rule",
  22659. "clipBottom",
  22660. "clipLeft",
  22661. "clipPath",
  22662. "clipPathUnits",
  22663. "clipRight",
  22664. "clipRule",
  22665. "clipTop",
  22666. "clipboard",
  22667. "clipboardData",
  22668. "clone",
  22669. "cloneContents",
  22670. "cloneNode",
  22671. "cloneRange",
  22672. "close",
  22673. "closePath",
  22674. "closed",
  22675. "closest",
  22676. "clz",
  22677. "clz32",
  22678. "cm",
  22679. "cmp",
  22680. "code",
  22681. "codeBase",
  22682. "codePointAt",
  22683. "codeType",
  22684. "colSpan",
  22685. "collapse",
  22686. "collapseToEnd",
  22687. "collapseToStart",
  22688. "collapsed",
  22689. "collect",
  22690. "colno",
  22691. "color",
  22692. "color-adjust",
  22693. "color-interpolation",
  22694. "color-interpolation-filters",
  22695. "colorAdjust",
  22696. "colorDepth",
  22697. "colorInterpolation",
  22698. "colorInterpolationFilters",
  22699. "colorMask",
  22700. "colorType",
  22701. "cols",
  22702. "column-count",
  22703. "column-fill",
  22704. "column-gap",
  22705. "column-rule",
  22706. "column-rule-color",
  22707. "column-rule-style",
  22708. "column-rule-width",
  22709. "column-span",
  22710. "column-width",
  22711. "columnCount",
  22712. "columnFill",
  22713. "columnGap",
  22714. "columnNumber",
  22715. "columnRule",
  22716. "columnRuleColor",
  22717. "columnRuleStyle",
  22718. "columnRuleWidth",
  22719. "columnSpan",
  22720. "columnWidth",
  22721. "columns",
  22722. "command",
  22723. "commit",
  22724. "commitPreferences",
  22725. "commitStyles",
  22726. "commonAncestorContainer",
  22727. "compact",
  22728. "compareBoundaryPoints",
  22729. "compareDocumentPosition",
  22730. "compareEndPoints",
  22731. "compareExchange",
  22732. "compareNode",
  22733. "comparePoint",
  22734. "compatMode",
  22735. "compatible",
  22736. "compile",
  22737. "compileShader",
  22738. "compileStreaming",
  22739. "complete",
  22740. "component",
  22741. "componentFromPoint",
  22742. "composed",
  22743. "composedPath",
  22744. "composite",
  22745. "compositionEndOffset",
  22746. "compositionStartOffset",
  22747. "compressedTexImage2D",
  22748. "compressedTexImage3D",
  22749. "compressedTexSubImage2D",
  22750. "compressedTexSubImage3D",
  22751. "computedStyleMap",
  22752. "concat",
  22753. "conditionText",
  22754. "coneInnerAngle",
  22755. "coneOuterAngle",
  22756. "coneOuterGain",
  22757. "configuration",
  22758. "configurationName",
  22759. "configurationValue",
  22760. "configurations",
  22761. "confirm",
  22762. "confirmComposition",
  22763. "confirmSiteSpecificTrackingException",
  22764. "confirmWebWideTrackingException",
  22765. "connect",
  22766. "connectEnd",
  22767. "connectShark",
  22768. "connectStart",
  22769. "connected",
  22770. "connection",
  22771. "connectionList",
  22772. "connectionSpeed",
  22773. "connectionState",
  22774. "connections",
  22775. "console",
  22776. "consolidate",
  22777. "constraint",
  22778. "constrictionActive",
  22779. "construct",
  22780. "constructor",
  22781. "contactID",
  22782. "contain",
  22783. "containerId",
  22784. "containerName",
  22785. "containerSrc",
  22786. "containerType",
  22787. "contains",
  22788. "containsNode",
  22789. "content",
  22790. "contentBoxSize",
  22791. "contentDocument",
  22792. "contentEditable",
  22793. "contentHint",
  22794. "contentOverflow",
  22795. "contentRect",
  22796. "contentScriptType",
  22797. "contentStyleType",
  22798. "contentType",
  22799. "contentWindow",
  22800. "context",
  22801. "contextMenu",
  22802. "contextmenu",
  22803. "continue",
  22804. "continuePrimaryKey",
  22805. "continuous",
  22806. "control",
  22807. "controlTransferIn",
  22808. "controlTransferOut",
  22809. "controller",
  22810. "controls",
  22811. "controlsList",
  22812. "convertPointFromNode",
  22813. "convertQuadFromNode",
  22814. "convertRectFromNode",
  22815. "convertToBlob",
  22816. "convertToSpecifiedUnits",
  22817. "cookie",
  22818. "cookieEnabled",
  22819. "coords",
  22820. "copyBufferSubData",
  22821. "copyFromChannel",
  22822. "copyTexImage2D",
  22823. "copyTexSubImage2D",
  22824. "copyTexSubImage3D",
  22825. "copyToChannel",
  22826. "copyWithin",
  22827. "correspondingElement",
  22828. "correspondingUseElement",
  22829. "corruptedVideoFrames",
  22830. "cos",
  22831. "cosh",
  22832. "count",
  22833. "countReset",
  22834. "counter-increment",
  22835. "counter-reset",
  22836. "counter-set",
  22837. "counterIncrement",
  22838. "counterReset",
  22839. "counterSet",
  22840. "country",
  22841. "cpuClass",
  22842. "cpuSleepAllowed",
  22843. "create",
  22844. "createAnalyser",
  22845. "createAnswer",
  22846. "createAttribute",
  22847. "createAttributeNS",
  22848. "createBiquadFilter",
  22849. "createBuffer",
  22850. "createBufferSource",
  22851. "createCDATASection",
  22852. "createCSSStyleSheet",
  22853. "createCaption",
  22854. "createChannelMerger",
  22855. "createChannelSplitter",
  22856. "createComment",
  22857. "createConstantSource",
  22858. "createContextualFragment",
  22859. "createControlRange",
  22860. "createConvolver",
  22861. "createDTMFSender",
  22862. "createDataChannel",
  22863. "createDelay",
  22864. "createDelayNode",
  22865. "createDocument",
  22866. "createDocumentFragment",
  22867. "createDocumentType",
  22868. "createDynamicsCompressor",
  22869. "createElement",
  22870. "createElementNS",
  22871. "createEntityReference",
  22872. "createEvent",
  22873. "createEventObject",
  22874. "createExpression",
  22875. "createFramebuffer",
  22876. "createFunction",
  22877. "createGain",
  22878. "createGainNode",
  22879. "createHTML",
  22880. "createHTMLDocument",
  22881. "createIIRFilter",
  22882. "createImageBitmap",
  22883. "createImageData",
  22884. "createIndex",
  22885. "createJavaScriptNode",
  22886. "createLinearGradient",
  22887. "createMediaElementSource",
  22888. "createMediaKeys",
  22889. "createMediaStreamDestination",
  22890. "createMediaStreamSource",
  22891. "createMediaStreamTrackSource",
  22892. "createMutableFile",
  22893. "createNSResolver",
  22894. "createNodeIterator",
  22895. "createNotification",
  22896. "createObjectStore",
  22897. "createObjectURL",
  22898. "createOffer",
  22899. "createOscillator",
  22900. "createPanner",
  22901. "createPattern",
  22902. "createPeriodicWave",
  22903. "createPolicy",
  22904. "createPopup",
  22905. "createProcessingInstruction",
  22906. "createProgram",
  22907. "createQuery",
  22908. "createRadialGradient",
  22909. "createRange",
  22910. "createRangeCollection",
  22911. "createReader",
  22912. "createRenderbuffer",
  22913. "createSVGAngle",
  22914. "createSVGLength",
  22915. "createSVGMatrix",
  22916. "createSVGNumber",
  22917. "createSVGPathSegArcAbs",
  22918. "createSVGPathSegArcRel",
  22919. "createSVGPathSegClosePath",
  22920. "createSVGPathSegCurvetoCubicAbs",
  22921. "createSVGPathSegCurvetoCubicRel",
  22922. "createSVGPathSegCurvetoCubicSmoothAbs",
  22923. "createSVGPathSegCurvetoCubicSmoothRel",
  22924. "createSVGPathSegCurvetoQuadraticAbs",
  22925. "createSVGPathSegCurvetoQuadraticRel",
  22926. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  22927. "createSVGPathSegCurvetoQuadraticSmoothRel",
  22928. "createSVGPathSegLinetoAbs",
  22929. "createSVGPathSegLinetoHorizontalAbs",
  22930. "createSVGPathSegLinetoHorizontalRel",
  22931. "createSVGPathSegLinetoRel",
  22932. "createSVGPathSegLinetoVerticalAbs",
  22933. "createSVGPathSegLinetoVerticalRel",
  22934. "createSVGPathSegMovetoAbs",
  22935. "createSVGPathSegMovetoRel",
  22936. "createSVGPoint",
  22937. "createSVGRect",
  22938. "createSVGTransform",
  22939. "createSVGTransformFromMatrix",
  22940. "createSampler",
  22941. "createScript",
  22942. "createScriptProcessor",
  22943. "createScriptURL",
  22944. "createSession",
  22945. "createShader",
  22946. "createShadowRoot",
  22947. "createStereoPanner",
  22948. "createStyleSheet",
  22949. "createTBody",
  22950. "createTFoot",
  22951. "createTHead",
  22952. "createTextNode",
  22953. "createTextRange",
  22954. "createTexture",
  22955. "createTouch",
  22956. "createTouchList",
  22957. "createTransformFeedback",
  22958. "createTreeWalker",
  22959. "createVertexArray",
  22960. "createWaveShaper",
  22961. "creationTime",
  22962. "credentials",
  22963. "crossOrigin",
  22964. "crossOriginIsolated",
  22965. "crypto",
  22966. "csi",
  22967. "csp",
  22968. "cssFloat",
  22969. "cssRules",
  22970. "cssText",
  22971. "cssValueType",
  22972. "ctrlKey",
  22973. "ctrlLeft",
  22974. "cues",
  22975. "cullFace",
  22976. "currentDirection",
  22977. "currentLocalDescription",
  22978. "currentNode",
  22979. "currentPage",
  22980. "currentRect",
  22981. "currentRemoteDescription",
  22982. "currentScale",
  22983. "currentScript",
  22984. "currentSrc",
  22985. "currentState",
  22986. "currentStyle",
  22987. "currentTarget",
  22988. "currentTime",
  22989. "currentTranslate",
  22990. "currentView",
  22991. "cursor",
  22992. "curve",
  22993. "customElements",
  22994. "customError",
  22995. "cx",
  22996. "cy",
  22997. "d",
  22998. "data",
  22999. "dataFld",
  23000. "dataFormatAs",
  23001. "dataLoss",
  23002. "dataLossMessage",
  23003. "dataPageSize",
  23004. "dataSrc",
  23005. "dataTransfer",
  23006. "database",
  23007. "databases",
  23008. "dataset",
  23009. "dateTime",
  23010. "db",
  23011. "debug",
  23012. "debuggerEnabled",
  23013. "declare",
  23014. "decode",
  23015. "decodeAudioData",
  23016. "decodeURI",
  23017. "decodeURIComponent",
  23018. "decodedBodySize",
  23019. "decoding",
  23020. "decodingInfo",
  23021. "decrypt",
  23022. "default",
  23023. "defaultCharset",
  23024. "defaultChecked",
  23025. "defaultMuted",
  23026. "defaultPlaybackRate",
  23027. "defaultPolicy",
  23028. "defaultPrevented",
  23029. "defaultRequest",
  23030. "defaultSelected",
  23031. "defaultStatus",
  23032. "defaultURL",
  23033. "defaultValue",
  23034. "defaultView",
  23035. "defaultstatus",
  23036. "defer",
  23037. "define",
  23038. "defineMagicFunction",
  23039. "defineMagicVariable",
  23040. "defineProperties",
  23041. "defineProperty",
  23042. "deg",
  23043. "delay",
  23044. "delayTime",
  23045. "delegatesFocus",
  23046. "delete",
  23047. "deleteBuffer",
  23048. "deleteCaption",
  23049. "deleteCell",
  23050. "deleteContents",
  23051. "deleteData",
  23052. "deleteDatabase",
  23053. "deleteFramebuffer",
  23054. "deleteFromDocument",
  23055. "deleteIndex",
  23056. "deleteMedium",
  23057. "deleteObjectStore",
  23058. "deleteProgram",
  23059. "deleteProperty",
  23060. "deleteQuery",
  23061. "deleteRenderbuffer",
  23062. "deleteRow",
  23063. "deleteRule",
  23064. "deleteSampler",
  23065. "deleteShader",
  23066. "deleteSync",
  23067. "deleteTFoot",
  23068. "deleteTHead",
  23069. "deleteTexture",
  23070. "deleteTransformFeedback",
  23071. "deleteVertexArray",
  23072. "deliverChangeRecords",
  23073. "delivery",
  23074. "deliveryInfo",
  23075. "deliveryStatus",
  23076. "deliveryTimestamp",
  23077. "delta",
  23078. "deltaMode",
  23079. "deltaX",
  23080. "deltaY",
  23081. "deltaZ",
  23082. "dependentLocality",
  23083. "depthFar",
  23084. "depthFunc",
  23085. "depthMask",
  23086. "depthNear",
  23087. "depthRange",
  23088. "deref",
  23089. "deriveBits",
  23090. "deriveKey",
  23091. "description",
  23092. "deselectAll",
  23093. "designMode",
  23094. "desiredSize",
  23095. "destination",
  23096. "destinationURL",
  23097. "detach",
  23098. "detachEvent",
  23099. "detachShader",
  23100. "detail",
  23101. "details",
  23102. "detect",
  23103. "detune",
  23104. "device",
  23105. "deviceClass",
  23106. "deviceId",
  23107. "deviceMemory",
  23108. "devicePixelContentBoxSize",
  23109. "devicePixelRatio",
  23110. "deviceProtocol",
  23111. "deviceSubclass",
  23112. "deviceVersionMajor",
  23113. "deviceVersionMinor",
  23114. "deviceVersionSubminor",
  23115. "deviceXDPI",
  23116. "deviceYDPI",
  23117. "didTimeout",
  23118. "diffuseConstant",
  23119. "digest",
  23120. "dimensions",
  23121. "dir",
  23122. "dirName",
  23123. "direction",
  23124. "dirxml",
  23125. "disable",
  23126. "disablePictureInPicture",
  23127. "disableRemotePlayback",
  23128. "disableVertexAttribArray",
  23129. "disabled",
  23130. "dischargingTime",
  23131. "disconnect",
  23132. "disconnectShark",
  23133. "dispatchEvent",
  23134. "display",
  23135. "displayId",
  23136. "displayName",
  23137. "disposition",
  23138. "distanceModel",
  23139. "div",
  23140. "divisor",
  23141. "djsapi",
  23142. "djsproxy",
  23143. "doImport",
  23144. "doNotTrack",
  23145. "doScroll",
  23146. "doctype",
  23147. "document",
  23148. "documentElement",
  23149. "documentMode",
  23150. "documentURI",
  23151. "dolphin",
  23152. "dolphinGameCenter",
  23153. "dolphininfo",
  23154. "dolphinmeta",
  23155. "domComplete",
  23156. "domContentLoadedEventEnd",
  23157. "domContentLoadedEventStart",
  23158. "domInteractive",
  23159. "domLoading",
  23160. "domOverlayState",
  23161. "domain",
  23162. "domainLookupEnd",
  23163. "domainLookupStart",
  23164. "dominant-baseline",
  23165. "dominantBaseline",
  23166. "done",
  23167. "dopplerFactor",
  23168. "dotAll",
  23169. "downDegrees",
  23170. "downlink",
  23171. "download",
  23172. "downloadTotal",
  23173. "downloaded",
  23174. "dpcm",
  23175. "dpi",
  23176. "dppx",
  23177. "dragDrop",
  23178. "draggable",
  23179. "drawArrays",
  23180. "drawArraysInstanced",
  23181. "drawArraysInstancedANGLE",
  23182. "drawBuffers",
  23183. "drawCustomFocusRing",
  23184. "drawElements",
  23185. "drawElementsInstanced",
  23186. "drawElementsInstancedANGLE",
  23187. "drawFocusIfNeeded",
  23188. "drawImage",
  23189. "drawImageFromRect",
  23190. "drawRangeElements",
  23191. "drawSystemFocusRing",
  23192. "drawingBufferHeight",
  23193. "drawingBufferWidth",
  23194. "dropEffect",
  23195. "droppedVideoFrames",
  23196. "dropzone",
  23197. "dtmf",
  23198. "dump",
  23199. "dumpProfile",
  23200. "duplicate",
  23201. "durability",
  23202. "duration",
  23203. "dvname",
  23204. "dvnum",
  23205. "dx",
  23206. "dy",
  23207. "dynsrc",
  23208. "e",
  23209. "edgeMode",
  23210. "effect",
  23211. "effectAllowed",
  23212. "effectiveDirective",
  23213. "effectiveType",
  23214. "elapsedTime",
  23215. "element",
  23216. "elementFromPoint",
  23217. "elementTiming",
  23218. "elements",
  23219. "elementsFromPoint",
  23220. "elevation",
  23221. "ellipse",
  23222. "em",
  23223. "email",
  23224. "embeds",
  23225. "emma",
  23226. "empty",
  23227. "empty-cells",
  23228. "emptyCells",
  23229. "emptyHTML",
  23230. "emptyScript",
  23231. "emulatedPosition",
  23232. "enable",
  23233. "enableBackground",
  23234. "enableDelegations",
  23235. "enableStyleSheetsForSet",
  23236. "enableVertexAttribArray",
  23237. "enabled",
  23238. "enabledPlugin",
  23239. "encode",
  23240. "encodeInto",
  23241. "encodeURI",
  23242. "encodeURIComponent",
  23243. "encodedBodySize",
  23244. "encoding",
  23245. "encodingInfo",
  23246. "encrypt",
  23247. "enctype",
  23248. "end",
  23249. "endContainer",
  23250. "endElement",
  23251. "endElementAt",
  23252. "endOfStream",
  23253. "endOffset",
  23254. "endQuery",
  23255. "endTime",
  23256. "endTransformFeedback",
  23257. "ended",
  23258. "endpoint",
  23259. "endpointNumber",
  23260. "endpoints",
  23261. "endsWith",
  23262. "enterKeyHint",
  23263. "entities",
  23264. "entries",
  23265. "entryType",
  23266. "enumerate",
  23267. "enumerateDevices",
  23268. "enumerateEditable",
  23269. "environmentBlendMode",
  23270. "equals",
  23271. "error",
  23272. "errorCode",
  23273. "errorDetail",
  23274. "errorText",
  23275. "escape",
  23276. "estimate",
  23277. "eval",
  23278. "evaluate",
  23279. "event",
  23280. "eventPhase",
  23281. "every",
  23282. "ex",
  23283. "exception",
  23284. "exchange",
  23285. "exec",
  23286. "execCommand",
  23287. "execCommandShowHelp",
  23288. "execScript",
  23289. "exitFullscreen",
  23290. "exitPictureInPicture",
  23291. "exitPointerLock",
  23292. "exitPresent",
  23293. "exp",
  23294. "expand",
  23295. "expandEntityReferences",
  23296. "expando",
  23297. "expansion",
  23298. "expiration",
  23299. "expirationTime",
  23300. "expires",
  23301. "expiryDate",
  23302. "explicitOriginalTarget",
  23303. "expm1",
  23304. "exponent",
  23305. "exponentialRampToValueAtTime",
  23306. "exportKey",
  23307. "exports",
  23308. "extend",
  23309. "extensions",
  23310. "extentNode",
  23311. "extentOffset",
  23312. "external",
  23313. "externalResourcesRequired",
  23314. "extractContents",
  23315. "extractable",
  23316. "eye",
  23317. "f",
  23318. "face",
  23319. "factoryReset",
  23320. "failureReason",
  23321. "fallback",
  23322. "family",
  23323. "familyName",
  23324. "farthestViewportElement",
  23325. "fastSeek",
  23326. "fatal",
  23327. "featureId",
  23328. "featurePolicy",
  23329. "featureSettings",
  23330. "features",
  23331. "fenceSync",
  23332. "fetch",
  23333. "fetchStart",
  23334. "fftSize",
  23335. "fgColor",
  23336. "fieldOfView",
  23337. "file",
  23338. "fileCreatedDate",
  23339. "fileHandle",
  23340. "fileModifiedDate",
  23341. "fileName",
  23342. "fileSize",
  23343. "fileUpdatedDate",
  23344. "filename",
  23345. "files",
  23346. "filesystem",
  23347. "fill",
  23348. "fill-opacity",
  23349. "fill-rule",
  23350. "fillLightMode",
  23351. "fillOpacity",
  23352. "fillRect",
  23353. "fillRule",
  23354. "fillStyle",
  23355. "fillText",
  23356. "filter",
  23357. "filterResX",
  23358. "filterResY",
  23359. "filterUnits",
  23360. "filters",
  23361. "finally",
  23362. "find",
  23363. "findIndex",
  23364. "findRule",
  23365. "findText",
  23366. "finish",
  23367. "finished",
  23368. "fireEvent",
  23369. "firesTouchEvents",
  23370. "firstChild",
  23371. "firstElementChild",
  23372. "firstPage",
  23373. "fixed",
  23374. "flags",
  23375. "flat",
  23376. "flatMap",
  23377. "flex",
  23378. "flex-basis",
  23379. "flex-direction",
  23380. "flex-flow",
  23381. "flex-grow",
  23382. "flex-shrink",
  23383. "flex-wrap",
  23384. "flexBasis",
  23385. "flexDirection",
  23386. "flexFlow",
  23387. "flexGrow",
  23388. "flexShrink",
  23389. "flexWrap",
  23390. "flipX",
  23391. "flipY",
  23392. "float",
  23393. "float32",
  23394. "float64",
  23395. "flood-color",
  23396. "flood-opacity",
  23397. "floodColor",
  23398. "floodOpacity",
  23399. "floor",
  23400. "flush",
  23401. "focus",
  23402. "focusNode",
  23403. "focusOffset",
  23404. "font",
  23405. "font-family",
  23406. "font-feature-settings",
  23407. "font-kerning",
  23408. "font-language-override",
  23409. "font-optical-sizing",
  23410. "font-size",
  23411. "font-size-adjust",
  23412. "font-stretch",
  23413. "font-style",
  23414. "font-synthesis",
  23415. "font-variant",
  23416. "font-variant-alternates",
  23417. "font-variant-caps",
  23418. "font-variant-east-asian",
  23419. "font-variant-ligatures",
  23420. "font-variant-numeric",
  23421. "font-variant-position",
  23422. "font-variation-settings",
  23423. "font-weight",
  23424. "fontFamily",
  23425. "fontFeatureSettings",
  23426. "fontKerning",
  23427. "fontLanguageOverride",
  23428. "fontOpticalSizing",
  23429. "fontSize",
  23430. "fontSizeAdjust",
  23431. "fontSmoothingEnabled",
  23432. "fontStretch",
  23433. "fontStyle",
  23434. "fontSynthesis",
  23435. "fontVariant",
  23436. "fontVariantAlternates",
  23437. "fontVariantCaps",
  23438. "fontVariantEastAsian",
  23439. "fontVariantLigatures",
  23440. "fontVariantNumeric",
  23441. "fontVariantPosition",
  23442. "fontVariationSettings",
  23443. "fontWeight",
  23444. "fontcolor",
  23445. "fontfaces",
  23446. "fonts",
  23447. "fontsize",
  23448. "for",
  23449. "forEach",
  23450. "force",
  23451. "forceRedraw",
  23452. "form",
  23453. "formAction",
  23454. "formData",
  23455. "formEnctype",
  23456. "formMethod",
  23457. "formNoValidate",
  23458. "formTarget",
  23459. "format",
  23460. "formatToParts",
  23461. "forms",
  23462. "forward",
  23463. "forwardX",
  23464. "forwardY",
  23465. "forwardZ",
  23466. "foundation",
  23467. "fr",
  23468. "fragmentDirective",
  23469. "frame",
  23470. "frameBorder",
  23471. "frameElement",
  23472. "frameSpacing",
  23473. "framebuffer",
  23474. "framebufferHeight",
  23475. "framebufferRenderbuffer",
  23476. "framebufferTexture2D",
  23477. "framebufferTextureLayer",
  23478. "framebufferWidth",
  23479. "frames",
  23480. "freeSpace",
  23481. "freeze",
  23482. "frequency",
  23483. "frequencyBinCount",
  23484. "from",
  23485. "fromCharCode",
  23486. "fromCodePoint",
  23487. "fromElement",
  23488. "fromEntries",
  23489. "fromFloat32Array",
  23490. "fromFloat64Array",
  23491. "fromMatrix",
  23492. "fromPoint",
  23493. "fromQuad",
  23494. "fromRect",
  23495. "frontFace",
  23496. "fround",
  23497. "fullPath",
  23498. "fullScreen",
  23499. "fullVersionList",
  23500. "fullscreen",
  23501. "fullscreenElement",
  23502. "fullscreenEnabled",
  23503. "fx",
  23504. "fy",
  23505. "gain",
  23506. "gamepad",
  23507. "gamma",
  23508. "gap",
  23509. "gatheringState",
  23510. "gatt",
  23511. "genderIdentity",
  23512. "generateCertificate",
  23513. "generateKey",
  23514. "generateMipmap",
  23515. "generateRequest",
  23516. "geolocation",
  23517. "gestureObject",
  23518. "get",
  23519. "getActiveAttrib",
  23520. "getActiveUniform",
  23521. "getActiveUniformBlockName",
  23522. "getActiveUniformBlockParameter",
  23523. "getActiveUniforms",
  23524. "getAdjacentText",
  23525. "getAll",
  23526. "getAllKeys",
  23527. "getAllResponseHeaders",
  23528. "getAllowlistForFeature",
  23529. "getAnimations",
  23530. "getAsFile",
  23531. "getAsString",
  23532. "getAttachedShaders",
  23533. "getAttribLocation",
  23534. "getAttribute",
  23535. "getAttributeNS",
  23536. "getAttributeNames",
  23537. "getAttributeNode",
  23538. "getAttributeNodeNS",
  23539. "getAttributeType",
  23540. "getAudioTracks",
  23541. "getAvailability",
  23542. "getBBox",
  23543. "getBattery",
  23544. "getBigInt64",
  23545. "getBigUint64",
  23546. "getBlob",
  23547. "getBookmark",
  23548. "getBoundingClientRect",
  23549. "getBounds",
  23550. "getBoxQuads",
  23551. "getBufferParameter",
  23552. "getBufferSubData",
  23553. "getByteFrequencyData",
  23554. "getByteTimeDomainData",
  23555. "getCSSCanvasContext",
  23556. "getCTM",
  23557. "getCandidateWindowClientRect",
  23558. "getCanonicalLocales",
  23559. "getCapabilities",
  23560. "getChannelData",
  23561. "getCharNumAtPosition",
  23562. "getCharacteristic",
  23563. "getCharacteristics",
  23564. "getClientExtensionResults",
  23565. "getClientRect",
  23566. "getClientRects",
  23567. "getCoalescedEvents",
  23568. "getCompositionAlternatives",
  23569. "getComputedStyle",
  23570. "getComputedTextLength",
  23571. "getComputedTiming",
  23572. "getConfiguration",
  23573. "getConstraints",
  23574. "getContext",
  23575. "getContextAttributes",
  23576. "getContributingSources",
  23577. "getCounterValue",
  23578. "getCueAsHTML",
  23579. "getCueById",
  23580. "getCurrentPosition",
  23581. "getCurrentTime",
  23582. "getData",
  23583. "getDatabaseNames",
  23584. "getDate",
  23585. "getDay",
  23586. "getDefaultComputedStyle",
  23587. "getDescriptor",
  23588. "getDescriptors",
  23589. "getDestinationInsertionPoints",
  23590. "getDevices",
  23591. "getDirectory",
  23592. "getDisplayMedia",
  23593. "getDistributedNodes",
  23594. "getEditable",
  23595. "getElementById",
  23596. "getElementsByClassName",
  23597. "getElementsByName",
  23598. "getElementsByTagName",
  23599. "getElementsByTagNameNS",
  23600. "getEnclosureList",
  23601. "getEndPositionOfChar",
  23602. "getEntries",
  23603. "getEntriesByName",
  23604. "getEntriesByType",
  23605. "getError",
  23606. "getExtension",
  23607. "getExtentOfChar",
  23608. "getEyeParameters",
  23609. "getFeature",
  23610. "getFile",
  23611. "getFiles",
  23612. "getFilesAndDirectories",
  23613. "getFingerprints",
  23614. "getFloat32",
  23615. "getFloat64",
  23616. "getFloatFrequencyData",
  23617. "getFloatTimeDomainData",
  23618. "getFloatValue",
  23619. "getFragDataLocation",
  23620. "getFrameData",
  23621. "getFramebufferAttachmentParameter",
  23622. "getFrequencyResponse",
  23623. "getFullYear",
  23624. "getGamepads",
  23625. "getHighEntropyValues",
  23626. "getHitTestResults",
  23627. "getHitTestResultsForTransientInput",
  23628. "getHours",
  23629. "getIdentityAssertion",
  23630. "getIds",
  23631. "getImageData",
  23632. "getIndexedParameter",
  23633. "getInstalledRelatedApps",
  23634. "getInt16",
  23635. "getInt32",
  23636. "getInt8",
  23637. "getInternalformatParameter",
  23638. "getIntersectionList",
  23639. "getItem",
  23640. "getItems",
  23641. "getKey",
  23642. "getKeyframes",
  23643. "getLayers",
  23644. "getLayoutMap",
  23645. "getLineDash",
  23646. "getLocalCandidates",
  23647. "getLocalParameters",
  23648. "getLocalStreams",
  23649. "getMarks",
  23650. "getMatchedCSSRules",
  23651. "getMaxGCPauseSinceClear",
  23652. "getMeasures",
  23653. "getMetadata",
  23654. "getMilliseconds",
  23655. "getMinutes",
  23656. "getModifierState",
  23657. "getMonth",
  23658. "getNamedItem",
  23659. "getNamedItemNS",
  23660. "getNativeFramebufferScaleFactor",
  23661. "getNotifications",
  23662. "getNotifier",
  23663. "getNumberOfChars",
  23664. "getOffsetReferenceSpace",
  23665. "getOutputTimestamp",
  23666. "getOverrideHistoryNavigationMode",
  23667. "getOverrideStyle",
  23668. "getOwnPropertyDescriptor",
  23669. "getOwnPropertyDescriptors",
  23670. "getOwnPropertyNames",
  23671. "getOwnPropertySymbols",
  23672. "getParameter",
  23673. "getParameters",
  23674. "getParent",
  23675. "getPathSegAtLength",
  23676. "getPhotoCapabilities",
  23677. "getPhotoSettings",
  23678. "getPointAtLength",
  23679. "getPose",
  23680. "getPredictedEvents",
  23681. "getPreference",
  23682. "getPreferenceDefault",
  23683. "getPresentationAttribute",
  23684. "getPreventDefault",
  23685. "getPrimaryService",
  23686. "getPrimaryServices",
  23687. "getProgramInfoLog",
  23688. "getProgramParameter",
  23689. "getPropertyCSSValue",
  23690. "getPropertyPriority",
  23691. "getPropertyShorthand",
  23692. "getPropertyType",
  23693. "getPropertyValue",
  23694. "getPrototypeOf",
  23695. "getQuery",
  23696. "getQueryParameter",
  23697. "getRGBColorValue",
  23698. "getRandomValues",
  23699. "getRangeAt",
  23700. "getReader",
  23701. "getReceivers",
  23702. "getRectValue",
  23703. "getRegistration",
  23704. "getRegistrations",
  23705. "getRemoteCandidates",
  23706. "getRemoteCertificates",
  23707. "getRemoteParameters",
  23708. "getRemoteStreams",
  23709. "getRenderbufferParameter",
  23710. "getResponseHeader",
  23711. "getRoot",
  23712. "getRootNode",
  23713. "getRotationOfChar",
  23714. "getSVGDocument",
  23715. "getSamplerParameter",
  23716. "getScreenCTM",
  23717. "getSeconds",
  23718. "getSelectedCandidatePair",
  23719. "getSelection",
  23720. "getSenders",
  23721. "getService",
  23722. "getSettings",
  23723. "getShaderInfoLog",
  23724. "getShaderParameter",
  23725. "getShaderPrecisionFormat",
  23726. "getShaderSource",
  23727. "getSimpleDuration",
  23728. "getSiteIcons",
  23729. "getSources",
  23730. "getSpeculativeParserUrls",
  23731. "getStartPositionOfChar",
  23732. "getStartTime",
  23733. "getState",
  23734. "getStats",
  23735. "getStatusForPolicy",
  23736. "getStorageUpdates",
  23737. "getStreamById",
  23738. "getStringValue",
  23739. "getSubStringLength",
  23740. "getSubscription",
  23741. "getSupportedConstraints",
  23742. "getSupportedExtensions",
  23743. "getSupportedFormats",
  23744. "getSyncParameter",
  23745. "getSynchronizationSources",
  23746. "getTags",
  23747. "getTargetRanges",
  23748. "getTexParameter",
  23749. "getTime",
  23750. "getTimezoneOffset",
  23751. "getTiming",
  23752. "getTotalLength",
  23753. "getTrackById",
  23754. "getTracks",
  23755. "getTransceivers",
  23756. "getTransform",
  23757. "getTransformFeedbackVarying",
  23758. "getTransformToElement",
  23759. "getTransports",
  23760. "getType",
  23761. "getTypeMapping",
  23762. "getUTCDate",
  23763. "getUTCDay",
  23764. "getUTCFullYear",
  23765. "getUTCHours",
  23766. "getUTCMilliseconds",
  23767. "getUTCMinutes",
  23768. "getUTCMonth",
  23769. "getUTCSeconds",
  23770. "getUint16",
  23771. "getUint32",
  23772. "getUint8",
  23773. "getUniform",
  23774. "getUniformBlockIndex",
  23775. "getUniformIndices",
  23776. "getUniformLocation",
  23777. "getUserMedia",
  23778. "getVRDisplays",
  23779. "getValues",
  23780. "getVarDate",
  23781. "getVariableValue",
  23782. "getVertexAttrib",
  23783. "getVertexAttribOffset",
  23784. "getVideoPlaybackQuality",
  23785. "getVideoTracks",
  23786. "getViewerPose",
  23787. "getViewport",
  23788. "getVoices",
  23789. "getWakeLockState",
  23790. "getWriter",
  23791. "getYear",
  23792. "givenName",
  23793. "global",
  23794. "globalAlpha",
  23795. "globalCompositeOperation",
  23796. "globalThis",
  23797. "glyphOrientationHorizontal",
  23798. "glyphOrientationVertical",
  23799. "glyphRef",
  23800. "go",
  23801. "grabFrame",
  23802. "grad",
  23803. "gradientTransform",
  23804. "gradientUnits",
  23805. "grammars",
  23806. "green",
  23807. "grid",
  23808. "grid-area",
  23809. "grid-auto-columns",
  23810. "grid-auto-flow",
  23811. "grid-auto-rows",
  23812. "grid-column",
  23813. "grid-column-end",
  23814. "grid-column-gap",
  23815. "grid-column-start",
  23816. "grid-gap",
  23817. "grid-row",
  23818. "grid-row-end",
  23819. "grid-row-gap",
  23820. "grid-row-start",
  23821. "grid-template",
  23822. "grid-template-areas",
  23823. "grid-template-columns",
  23824. "grid-template-rows",
  23825. "gridArea",
  23826. "gridAutoColumns",
  23827. "gridAutoFlow",
  23828. "gridAutoRows",
  23829. "gridColumn",
  23830. "gridColumnEnd",
  23831. "gridColumnGap",
  23832. "gridColumnStart",
  23833. "gridGap",
  23834. "gridRow",
  23835. "gridRowEnd",
  23836. "gridRowGap",
  23837. "gridRowStart",
  23838. "gridTemplate",
  23839. "gridTemplateAreas",
  23840. "gridTemplateColumns",
  23841. "gridTemplateRows",
  23842. "gripSpace",
  23843. "group",
  23844. "groupCollapsed",
  23845. "groupEnd",
  23846. "groupId",
  23847. "hadRecentInput",
  23848. "hand",
  23849. "handedness",
  23850. "hapticActuators",
  23851. "hardwareConcurrency",
  23852. "has",
  23853. "hasAttribute",
  23854. "hasAttributeNS",
  23855. "hasAttributes",
  23856. "hasBeenActive",
  23857. "hasChildNodes",
  23858. "hasComposition",
  23859. "hasEnrolledInstrument",
  23860. "hasExtension",
  23861. "hasExternalDisplay",
  23862. "hasFeature",
  23863. "hasFocus",
  23864. "hasInstance",
  23865. "hasLayout",
  23866. "hasOrientation",
  23867. "hasOwnProperty",
  23868. "hasPointerCapture",
  23869. "hasPosition",
  23870. "hasReading",
  23871. "hasStorageAccess",
  23872. "hash",
  23873. "head",
  23874. "headers",
  23875. "heading",
  23876. "height",
  23877. "hidden",
  23878. "hide",
  23879. "hideFocus",
  23880. "high",
  23881. "highWaterMark",
  23882. "hint",
  23883. "history",
  23884. "honorificPrefix",
  23885. "honorificSuffix",
  23886. "horizontalOverflow",
  23887. "host",
  23888. "hostCandidate",
  23889. "hostname",
  23890. "href",
  23891. "hrefTranslate",
  23892. "hreflang",
  23893. "hspace",
  23894. "html5TagCheckInerface",
  23895. "htmlFor",
  23896. "htmlText",
  23897. "httpEquiv",
  23898. "httpRequestStatusCode",
  23899. "hwTimestamp",
  23900. "hyphens",
  23901. "hypot",
  23902. "iccId",
  23903. "iceConnectionState",
  23904. "iceGatheringState",
  23905. "iceTransport",
  23906. "icon",
  23907. "iconURL",
  23908. "id",
  23909. "identifier",
  23910. "identity",
  23911. "idpLoginUrl",
  23912. "ignoreBOM",
  23913. "ignoreCase",
  23914. "ignoreDepthValues",
  23915. "image-orientation",
  23916. "image-rendering",
  23917. "imageHeight",
  23918. "imageOrientation",
  23919. "imageRendering",
  23920. "imageSizes",
  23921. "imageSmoothingEnabled",
  23922. "imageSmoothingQuality",
  23923. "imageSrcset",
  23924. "imageWidth",
  23925. "images",
  23926. "ime-mode",
  23927. "imeMode",
  23928. "implementation",
  23929. "importKey",
  23930. "importNode",
  23931. "importStylesheet",
  23932. "imports",
  23933. "impp",
  23934. "imul",
  23935. "in",
  23936. "in1",
  23937. "in2",
  23938. "inBandMetadataTrackDispatchType",
  23939. "inRange",
  23940. "includes",
  23941. "incremental",
  23942. "indeterminate",
  23943. "index",
  23944. "indexNames",
  23945. "indexOf",
  23946. "indexedDB",
  23947. "indicate",
  23948. "inertiaDestinationX",
  23949. "inertiaDestinationY",
  23950. "info",
  23951. "init",
  23952. "initAnimationEvent",
  23953. "initBeforeLoadEvent",
  23954. "initClipboardEvent",
  23955. "initCloseEvent",
  23956. "initCommandEvent",
  23957. "initCompositionEvent",
  23958. "initCustomEvent",
  23959. "initData",
  23960. "initDataType",
  23961. "initDeviceMotionEvent",
  23962. "initDeviceOrientationEvent",
  23963. "initDragEvent",
  23964. "initErrorEvent",
  23965. "initEvent",
  23966. "initFocusEvent",
  23967. "initGestureEvent",
  23968. "initHashChangeEvent",
  23969. "initKeyEvent",
  23970. "initKeyboardEvent",
  23971. "initMSManipulationEvent",
  23972. "initMessageEvent",
  23973. "initMouseEvent",
  23974. "initMouseScrollEvent",
  23975. "initMouseWheelEvent",
  23976. "initMutationEvent",
  23977. "initNSMouseEvent",
  23978. "initOverflowEvent",
  23979. "initPageEvent",
  23980. "initPageTransitionEvent",
  23981. "initPointerEvent",
  23982. "initPopStateEvent",
  23983. "initProgressEvent",
  23984. "initScrollAreaEvent",
  23985. "initSimpleGestureEvent",
  23986. "initStorageEvent",
  23987. "initTextEvent",
  23988. "initTimeEvent",
  23989. "initTouchEvent",
  23990. "initTransitionEvent",
  23991. "initUIEvent",
  23992. "initWebKitAnimationEvent",
  23993. "initWebKitTransitionEvent",
  23994. "initWebKitWheelEvent",
  23995. "initWheelEvent",
  23996. "initialTime",
  23997. "initialize",
  23998. "initiatorType",
  23999. "inline-size",
  24000. "inlineSize",
  24001. "inlineVerticalFieldOfView",
  24002. "inner",
  24003. "innerHTML",
  24004. "innerHeight",
  24005. "innerText",
  24006. "innerWidth",
  24007. "input",
  24008. "inputBuffer",
  24009. "inputEncoding",
  24010. "inputMethod",
  24011. "inputMode",
  24012. "inputSource",
  24013. "inputSources",
  24014. "inputType",
  24015. "inputs",
  24016. "insertAdjacentElement",
  24017. "insertAdjacentHTML",
  24018. "insertAdjacentText",
  24019. "insertBefore",
  24020. "insertCell",
  24021. "insertDTMF",
  24022. "insertData",
  24023. "insertItemBefore",
  24024. "insertNode",
  24025. "insertRow",
  24026. "insertRule",
  24027. "inset",
  24028. "inset-block",
  24029. "inset-block-end",
  24030. "inset-block-start",
  24031. "inset-inline",
  24032. "inset-inline-end",
  24033. "inset-inline-start",
  24034. "insetBlock",
  24035. "insetBlockEnd",
  24036. "insetBlockStart",
  24037. "insetInline",
  24038. "insetInlineEnd",
  24039. "insetInlineStart",
  24040. "installing",
  24041. "instanceRoot",
  24042. "instantiate",
  24043. "instantiateStreaming",
  24044. "instruments",
  24045. "int16",
  24046. "int32",
  24047. "int8",
  24048. "integrity",
  24049. "interactionMode",
  24050. "intercept",
  24051. "interfaceClass",
  24052. "interfaceName",
  24053. "interfaceNumber",
  24054. "interfaceProtocol",
  24055. "interfaceSubclass",
  24056. "interfaces",
  24057. "interimResults",
  24058. "internalSubset",
  24059. "interpretation",
  24060. "intersectionRatio",
  24061. "intersectionRect",
  24062. "intersectsNode",
  24063. "interval",
  24064. "invalidIteratorState",
  24065. "invalidateFramebuffer",
  24066. "invalidateSubFramebuffer",
  24067. "inverse",
  24068. "invertSelf",
  24069. "is",
  24070. "is2D",
  24071. "isActive",
  24072. "isAlternate",
  24073. "isArray",
  24074. "isBingCurrentSearchDefault",
  24075. "isBuffer",
  24076. "isCandidateWindowVisible",
  24077. "isChar",
  24078. "isCollapsed",
  24079. "isComposing",
  24080. "isConcatSpreadable",
  24081. "isConnected",
  24082. "isContentEditable",
  24083. "isContentHandlerRegistered",
  24084. "isContextLost",
  24085. "isDefaultNamespace",
  24086. "isDirectory",
  24087. "isDisabled",
  24088. "isEnabled",
  24089. "isEqual",
  24090. "isEqualNode",
  24091. "isExtensible",
  24092. "isExternalCTAP2SecurityKeySupported",
  24093. "isFile",
  24094. "isFinite",
  24095. "isFramebuffer",
  24096. "isFrozen",
  24097. "isGenerator",
  24098. "isHTML",
  24099. "isHistoryNavigation",
  24100. "isId",
  24101. "isIdentity",
  24102. "isInjected",
  24103. "isInteger",
  24104. "isIntersecting",
  24105. "isLockFree",
  24106. "isMap",
  24107. "isMultiLine",
  24108. "isNaN",
  24109. "isOpen",
  24110. "isPointInFill",
  24111. "isPointInPath",
  24112. "isPointInRange",
  24113. "isPointInStroke",
  24114. "isPrefAlternate",
  24115. "isPresenting",
  24116. "isPrimary",
  24117. "isProgram",
  24118. "isPropertyImplicit",
  24119. "isProtocolHandlerRegistered",
  24120. "isPrototypeOf",
  24121. "isQuery",
  24122. "isRenderbuffer",
  24123. "isSafeInteger",
  24124. "isSameNode",
  24125. "isSampler",
  24126. "isScript",
  24127. "isScriptURL",
  24128. "isSealed",
  24129. "isSecureContext",
  24130. "isSessionSupported",
  24131. "isShader",
  24132. "isSupported",
  24133. "isSync",
  24134. "isTextEdit",
  24135. "isTexture",
  24136. "isTransformFeedback",
  24137. "isTrusted",
  24138. "isTypeSupported",
  24139. "isUserVerifyingPlatformAuthenticatorAvailable",
  24140. "isVertexArray",
  24141. "isView",
  24142. "isVisible",
  24143. "isochronousTransferIn",
  24144. "isochronousTransferOut",
  24145. "isolation",
  24146. "italics",
  24147. "item",
  24148. "itemId",
  24149. "itemProp",
  24150. "itemRef",
  24151. "itemScope",
  24152. "itemType",
  24153. "itemValue",
  24154. "items",
  24155. "iterateNext",
  24156. "iterationComposite",
  24157. "iterator",
  24158. "javaEnabled",
  24159. "jobTitle",
  24160. "join",
  24161. "json",
  24162. "justify-content",
  24163. "justify-items",
  24164. "justify-self",
  24165. "justifyContent",
  24166. "justifyItems",
  24167. "justifySelf",
  24168. "k1",
  24169. "k2",
  24170. "k3",
  24171. "k4",
  24172. "kHz",
  24173. "keepalive",
  24174. "kernelMatrix",
  24175. "kernelUnitLengthX",
  24176. "kernelUnitLengthY",
  24177. "kerning",
  24178. "key",
  24179. "keyCode",
  24180. "keyFor",
  24181. "keyIdentifier",
  24182. "keyLightEnabled",
  24183. "keyLocation",
  24184. "keyPath",
  24185. "keyStatuses",
  24186. "keySystem",
  24187. "keyText",
  24188. "keyUsage",
  24189. "keyboard",
  24190. "keys",
  24191. "keytype",
  24192. "kind",
  24193. "knee",
  24194. "label",
  24195. "labels",
  24196. "lang",
  24197. "language",
  24198. "languages",
  24199. "largeArcFlag",
  24200. "lastChild",
  24201. "lastElementChild",
  24202. "lastEventId",
  24203. "lastIndex",
  24204. "lastIndexOf",
  24205. "lastInputTime",
  24206. "lastMatch",
  24207. "lastMessageSubject",
  24208. "lastMessageType",
  24209. "lastModified",
  24210. "lastModifiedDate",
  24211. "lastPage",
  24212. "lastParen",
  24213. "lastState",
  24214. "lastStyleSheetSet",
  24215. "latitude",
  24216. "layerX",
  24217. "layerY",
  24218. "layoutFlow",
  24219. "layoutGrid",
  24220. "layoutGridChar",
  24221. "layoutGridLine",
  24222. "layoutGridMode",
  24223. "layoutGridType",
  24224. "lbound",
  24225. "left",
  24226. "leftContext",
  24227. "leftDegrees",
  24228. "leftMargin",
  24229. "leftProjectionMatrix",
  24230. "leftViewMatrix",
  24231. "length",
  24232. "lengthAdjust",
  24233. "lengthComputable",
  24234. "letter-spacing",
  24235. "letterSpacing",
  24236. "level",
  24237. "lighting-color",
  24238. "lightingColor",
  24239. "limitingConeAngle",
  24240. "line",
  24241. "line-break",
  24242. "line-height",
  24243. "lineAlign",
  24244. "lineBreak",
  24245. "lineCap",
  24246. "lineDashOffset",
  24247. "lineHeight",
  24248. "lineJoin",
  24249. "lineNumber",
  24250. "lineTo",
  24251. "lineWidth",
  24252. "linearAcceleration",
  24253. "linearRampToValueAtTime",
  24254. "linearVelocity",
  24255. "lineno",
  24256. "lines",
  24257. "link",
  24258. "linkColor",
  24259. "linkProgram",
  24260. "links",
  24261. "list",
  24262. "list-style",
  24263. "list-style-image",
  24264. "list-style-position",
  24265. "list-style-type",
  24266. "listStyle",
  24267. "listStyleImage",
  24268. "listStylePosition",
  24269. "listStyleType",
  24270. "listener",
  24271. "load",
  24272. "loadEventEnd",
  24273. "loadEventStart",
  24274. "loadTime",
  24275. "loadTimes",
  24276. "loaded",
  24277. "loading",
  24278. "localDescription",
  24279. "localName",
  24280. "localService",
  24281. "localStorage",
  24282. "locale",
  24283. "localeCompare",
  24284. "location",
  24285. "locationbar",
  24286. "lock",
  24287. "locked",
  24288. "lockedFile",
  24289. "locks",
  24290. "log",
  24291. "log10",
  24292. "log1p",
  24293. "log2",
  24294. "logicalXDPI",
  24295. "logicalYDPI",
  24296. "longDesc",
  24297. "longitude",
  24298. "lookupNamespaceURI",
  24299. "lookupPrefix",
  24300. "loop",
  24301. "loopEnd",
  24302. "loopStart",
  24303. "looping",
  24304. "low",
  24305. "lower",
  24306. "lowerBound",
  24307. "lowerOpen",
  24308. "lowsrc",
  24309. "m11",
  24310. "m12",
  24311. "m13",
  24312. "m14",
  24313. "m21",
  24314. "m22",
  24315. "m23",
  24316. "m24",
  24317. "m31",
  24318. "m32",
  24319. "m33",
  24320. "m34",
  24321. "m41",
  24322. "m42",
  24323. "m43",
  24324. "m44",
  24325. "makeXRCompatible",
  24326. "manifest",
  24327. "manufacturer",
  24328. "manufacturerName",
  24329. "map",
  24330. "mapping",
  24331. "margin",
  24332. "margin-block",
  24333. "margin-block-end",
  24334. "margin-block-start",
  24335. "margin-bottom",
  24336. "margin-inline",
  24337. "margin-inline-end",
  24338. "margin-inline-start",
  24339. "margin-left",
  24340. "margin-right",
  24341. "margin-top",
  24342. "marginBlock",
  24343. "marginBlockEnd",
  24344. "marginBlockStart",
  24345. "marginBottom",
  24346. "marginHeight",
  24347. "marginInline",
  24348. "marginInlineEnd",
  24349. "marginInlineStart",
  24350. "marginLeft",
  24351. "marginRight",
  24352. "marginTop",
  24353. "marginWidth",
  24354. "mark",
  24355. "marker",
  24356. "marker-end",
  24357. "marker-mid",
  24358. "marker-offset",
  24359. "marker-start",
  24360. "markerEnd",
  24361. "markerHeight",
  24362. "markerMid",
  24363. "markerOffset",
  24364. "markerStart",
  24365. "markerUnits",
  24366. "markerWidth",
  24367. "marks",
  24368. "mask",
  24369. "mask-clip",
  24370. "mask-composite",
  24371. "mask-image",
  24372. "mask-mode",
  24373. "mask-origin",
  24374. "mask-position",
  24375. "mask-position-x",
  24376. "mask-position-y",
  24377. "mask-repeat",
  24378. "mask-size",
  24379. "mask-type",
  24380. "maskClip",
  24381. "maskComposite",
  24382. "maskContentUnits",
  24383. "maskImage",
  24384. "maskMode",
  24385. "maskOrigin",
  24386. "maskPosition",
  24387. "maskPositionX",
  24388. "maskPositionY",
  24389. "maskRepeat",
  24390. "maskSize",
  24391. "maskType",
  24392. "maskUnits",
  24393. "match",
  24394. "matchAll",
  24395. "matchMedia",
  24396. "matchMedium",
  24397. "matches",
  24398. "matrix",
  24399. "matrixTransform",
  24400. "max",
  24401. "max-block-size",
  24402. "max-height",
  24403. "max-inline-size",
  24404. "max-width",
  24405. "maxActions",
  24406. "maxAlternatives",
  24407. "maxBlockSize",
  24408. "maxChannelCount",
  24409. "maxChannels",
  24410. "maxConnectionsPerServer",
  24411. "maxDecibels",
  24412. "maxDistance",
  24413. "maxHeight",
  24414. "maxInlineSize",
  24415. "maxLayers",
  24416. "maxLength",
  24417. "maxMessageSize",
  24418. "maxPacketLifeTime",
  24419. "maxRetransmits",
  24420. "maxTouchPoints",
  24421. "maxValue",
  24422. "maxWidth",
  24423. "measure",
  24424. "measureText",
  24425. "media",
  24426. "mediaCapabilities",
  24427. "mediaDevices",
  24428. "mediaElement",
  24429. "mediaGroup",
  24430. "mediaKeys",
  24431. "mediaSession",
  24432. "mediaStream",
  24433. "mediaText",
  24434. "meetOrSlice",
  24435. "memory",
  24436. "menubar",
  24437. "mergeAttributes",
  24438. "message",
  24439. "messageClass",
  24440. "messageHandlers",
  24441. "messageType",
  24442. "metaKey",
  24443. "metadata",
  24444. "method",
  24445. "methodDetails",
  24446. "methodName",
  24447. "mid",
  24448. "mimeType",
  24449. "mimeTypes",
  24450. "min",
  24451. "min-block-size",
  24452. "min-height",
  24453. "min-inline-size",
  24454. "min-width",
  24455. "minBlockSize",
  24456. "minDecibels",
  24457. "minHeight",
  24458. "minInlineSize",
  24459. "minLength",
  24460. "minValue",
  24461. "minWidth",
  24462. "miterLimit",
  24463. "mix-blend-mode",
  24464. "mixBlendMode",
  24465. "mm",
  24466. "mobile",
  24467. "mode",
  24468. "model",
  24469. "modify",
  24470. "mount",
  24471. "move",
  24472. "moveBy",
  24473. "moveEnd",
  24474. "moveFirst",
  24475. "moveFocusDown",
  24476. "moveFocusLeft",
  24477. "moveFocusRight",
  24478. "moveFocusUp",
  24479. "moveNext",
  24480. "moveRow",
  24481. "moveStart",
  24482. "moveTo",
  24483. "moveToBookmark",
  24484. "moveToElementText",
  24485. "moveToPoint",
  24486. "movementX",
  24487. "movementY",
  24488. "mozAdd",
  24489. "mozAnimationStartTime",
  24490. "mozAnon",
  24491. "mozApps",
  24492. "mozAudioCaptured",
  24493. "mozAudioChannelType",
  24494. "mozAutoplayEnabled",
  24495. "mozCancelAnimationFrame",
  24496. "mozCancelFullScreen",
  24497. "mozCancelRequestAnimationFrame",
  24498. "mozCaptureStream",
  24499. "mozCaptureStreamUntilEnded",
  24500. "mozClearDataAt",
  24501. "mozContact",
  24502. "mozContacts",
  24503. "mozCreateFileHandle",
  24504. "mozCurrentTransform",
  24505. "mozCurrentTransformInverse",
  24506. "mozCursor",
  24507. "mozDash",
  24508. "mozDashOffset",
  24509. "mozDecodedFrames",
  24510. "mozExitPointerLock",
  24511. "mozFillRule",
  24512. "mozFragmentEnd",
  24513. "mozFrameDelay",
  24514. "mozFullScreen",
  24515. "mozFullScreenElement",
  24516. "mozFullScreenEnabled",
  24517. "mozGetAll",
  24518. "mozGetAllKeys",
  24519. "mozGetAsFile",
  24520. "mozGetDataAt",
  24521. "mozGetMetadata",
  24522. "mozGetUserMedia",
  24523. "mozHasAudio",
  24524. "mozHasItem",
  24525. "mozHidden",
  24526. "mozImageSmoothingEnabled",
  24527. "mozIndexedDB",
  24528. "mozInnerScreenX",
  24529. "mozInnerScreenY",
  24530. "mozInputSource",
  24531. "mozIsTextField",
  24532. "mozItem",
  24533. "mozItemCount",
  24534. "mozItems",
  24535. "mozLength",
  24536. "mozLockOrientation",
  24537. "mozMatchesSelector",
  24538. "mozMovementX",
  24539. "mozMovementY",
  24540. "mozOpaque",
  24541. "mozOrientation",
  24542. "mozPaintCount",
  24543. "mozPaintedFrames",
  24544. "mozParsedFrames",
  24545. "mozPay",
  24546. "mozPointerLockElement",
  24547. "mozPresentedFrames",
  24548. "mozPreservesPitch",
  24549. "mozPressure",
  24550. "mozPrintCallback",
  24551. "mozRTCIceCandidate",
  24552. "mozRTCPeerConnection",
  24553. "mozRTCSessionDescription",
  24554. "mozRemove",
  24555. "mozRequestAnimationFrame",
  24556. "mozRequestFullScreen",
  24557. "mozRequestPointerLock",
  24558. "mozSetDataAt",
  24559. "mozSetImageElement",
  24560. "mozSourceNode",
  24561. "mozSrcObject",
  24562. "mozSystem",
  24563. "mozTCPSocket",
  24564. "mozTextStyle",
  24565. "mozTypesAt",
  24566. "mozUnlockOrientation",
  24567. "mozUserCancelled",
  24568. "mozVisibilityState",
  24569. "ms",
  24570. "msAnimation",
  24571. "msAnimationDelay",
  24572. "msAnimationDirection",
  24573. "msAnimationDuration",
  24574. "msAnimationFillMode",
  24575. "msAnimationIterationCount",
  24576. "msAnimationName",
  24577. "msAnimationPlayState",
  24578. "msAnimationStartTime",
  24579. "msAnimationTimingFunction",
  24580. "msBackfaceVisibility",
  24581. "msBlockProgression",
  24582. "msCSSOMElementFloatMetrics",
  24583. "msCaching",
  24584. "msCachingEnabled",
  24585. "msCancelRequestAnimationFrame",
  24586. "msCapsLockWarningOff",
  24587. "msClearImmediate",
  24588. "msClose",
  24589. "msContentZoomChaining",
  24590. "msContentZoomFactor",
  24591. "msContentZoomLimit",
  24592. "msContentZoomLimitMax",
  24593. "msContentZoomLimitMin",
  24594. "msContentZoomSnap",
  24595. "msContentZoomSnapPoints",
  24596. "msContentZoomSnapType",
  24597. "msContentZooming",
  24598. "msConvertURL",
  24599. "msCrypto",
  24600. "msDoNotTrack",
  24601. "msElementsFromPoint",
  24602. "msElementsFromRect",
  24603. "msExitFullscreen",
  24604. "msExtendedCode",
  24605. "msFillRule",
  24606. "msFirstPaint",
  24607. "msFlex",
  24608. "msFlexAlign",
  24609. "msFlexDirection",
  24610. "msFlexFlow",
  24611. "msFlexItemAlign",
  24612. "msFlexLinePack",
  24613. "msFlexNegative",
  24614. "msFlexOrder",
  24615. "msFlexPack",
  24616. "msFlexPositive",
  24617. "msFlexPreferredSize",
  24618. "msFlexWrap",
  24619. "msFlowFrom",
  24620. "msFlowInto",
  24621. "msFontFeatureSettings",
  24622. "msFullscreenElement",
  24623. "msFullscreenEnabled",
  24624. "msGetInputContext",
  24625. "msGetRegionContent",
  24626. "msGetUntransformedBounds",
  24627. "msGraphicsTrustStatus",
  24628. "msGridColumn",
  24629. "msGridColumnAlign",
  24630. "msGridColumnSpan",
  24631. "msGridColumns",
  24632. "msGridRow",
  24633. "msGridRowAlign",
  24634. "msGridRowSpan",
  24635. "msGridRows",
  24636. "msHidden",
  24637. "msHighContrastAdjust",
  24638. "msHyphenateLimitChars",
  24639. "msHyphenateLimitLines",
  24640. "msHyphenateLimitZone",
  24641. "msHyphens",
  24642. "msImageSmoothingEnabled",
  24643. "msImeAlign",
  24644. "msIndexedDB",
  24645. "msInterpolationMode",
  24646. "msIsStaticHTML",
  24647. "msKeySystem",
  24648. "msKeys",
  24649. "msLaunchUri",
  24650. "msLockOrientation",
  24651. "msManipulationViewsEnabled",
  24652. "msMatchMedia",
  24653. "msMatchesSelector",
  24654. "msMaxTouchPoints",
  24655. "msOrientation",
  24656. "msOverflowStyle",
  24657. "msPerspective",
  24658. "msPerspectiveOrigin",
  24659. "msPlayToDisabled",
  24660. "msPlayToPreferredSourceUri",
  24661. "msPlayToPrimary",
  24662. "msPointerEnabled",
  24663. "msRegionOverflow",
  24664. "msReleasePointerCapture",
  24665. "msRequestAnimationFrame",
  24666. "msRequestFullscreen",
  24667. "msSaveBlob",
  24668. "msSaveOrOpenBlob",
  24669. "msScrollChaining",
  24670. "msScrollLimit",
  24671. "msScrollLimitXMax",
  24672. "msScrollLimitXMin",
  24673. "msScrollLimitYMax",
  24674. "msScrollLimitYMin",
  24675. "msScrollRails",
  24676. "msScrollSnapPointsX",
  24677. "msScrollSnapPointsY",
  24678. "msScrollSnapType",
  24679. "msScrollSnapX",
  24680. "msScrollSnapY",
  24681. "msScrollTranslation",
  24682. "msSetImmediate",
  24683. "msSetMediaKeys",
  24684. "msSetPointerCapture",
  24685. "msTextCombineHorizontal",
  24686. "msTextSizeAdjust",
  24687. "msToBlob",
  24688. "msTouchAction",
  24689. "msTouchSelect",
  24690. "msTraceAsyncCallbackCompleted",
  24691. "msTraceAsyncCallbackStarting",
  24692. "msTraceAsyncOperationCompleted",
  24693. "msTraceAsyncOperationStarting",
  24694. "msTransform",
  24695. "msTransformOrigin",
  24696. "msTransformStyle",
  24697. "msTransition",
  24698. "msTransitionDelay",
  24699. "msTransitionDuration",
  24700. "msTransitionProperty",
  24701. "msTransitionTimingFunction",
  24702. "msUnlockOrientation",
  24703. "msUpdateAsyncCallbackRelation",
  24704. "msUserSelect",
  24705. "msVisibilityState",
  24706. "msWrapFlow",
  24707. "msWrapMargin",
  24708. "msWrapThrough",
  24709. "msWriteProfilerMark",
  24710. "msZoom",
  24711. "msZoomTo",
  24712. "mt",
  24713. "mul",
  24714. "multiEntry",
  24715. "multiSelectionObj",
  24716. "multiline",
  24717. "multiple",
  24718. "multiply",
  24719. "multiplySelf",
  24720. "mutableFile",
  24721. "muted",
  24722. "n",
  24723. "name",
  24724. "nameProp",
  24725. "namedItem",
  24726. "namedRecordset",
  24727. "names",
  24728. "namespaceURI",
  24729. "namespaces",
  24730. "naturalHeight",
  24731. "naturalWidth",
  24732. "navigate",
  24733. "navigation",
  24734. "navigationMode",
  24735. "navigationPreload",
  24736. "navigationStart",
  24737. "navigator",
  24738. "near",
  24739. "nearestViewportElement",
  24740. "negative",
  24741. "negotiated",
  24742. "netscape",
  24743. "networkState",
  24744. "newScale",
  24745. "newTranslate",
  24746. "newURL",
  24747. "newValue",
  24748. "newValueSpecifiedUnits",
  24749. "newVersion",
  24750. "newhome",
  24751. "next",
  24752. "nextElementSibling",
  24753. "nextHopProtocol",
  24754. "nextNode",
  24755. "nextPage",
  24756. "nextSibling",
  24757. "nickname",
  24758. "noHref",
  24759. "noModule",
  24760. "noResize",
  24761. "noShade",
  24762. "noValidate",
  24763. "noWrap",
  24764. "node",
  24765. "nodeName",
  24766. "nodeType",
  24767. "nodeValue",
  24768. "nonce",
  24769. "normalize",
  24770. "normalizedPathSegList",
  24771. "notationName",
  24772. "notations",
  24773. "note",
  24774. "noteGrainOn",
  24775. "noteOff",
  24776. "noteOn",
  24777. "notify",
  24778. "now",
  24779. "numOctaves",
  24780. "number",
  24781. "numberOfChannels",
  24782. "numberOfInputs",
  24783. "numberOfItems",
  24784. "numberOfOutputs",
  24785. "numberValue",
  24786. "oMatchesSelector",
  24787. "object",
  24788. "object-fit",
  24789. "object-position",
  24790. "objectFit",
  24791. "objectPosition",
  24792. "objectStore",
  24793. "objectStoreNames",
  24794. "objectType",
  24795. "observe",
  24796. "of",
  24797. "offscreenBuffering",
  24798. "offset",
  24799. "offset-anchor",
  24800. "offset-distance",
  24801. "offset-path",
  24802. "offset-rotate",
  24803. "offsetAnchor",
  24804. "offsetDistance",
  24805. "offsetHeight",
  24806. "offsetLeft",
  24807. "offsetNode",
  24808. "offsetParent",
  24809. "offsetPath",
  24810. "offsetRotate",
  24811. "offsetTop",
  24812. "offsetWidth",
  24813. "offsetX",
  24814. "offsetY",
  24815. "ok",
  24816. "oldURL",
  24817. "oldValue",
  24818. "oldVersion",
  24819. "olderShadowRoot",
  24820. "onLine",
  24821. "onabort",
  24822. "onabsolutedeviceorientation",
  24823. "onactivate",
  24824. "onactive",
  24825. "onaddsourcebuffer",
  24826. "onaddstream",
  24827. "onaddtrack",
  24828. "onafterprint",
  24829. "onafterscriptexecute",
  24830. "onafterupdate",
  24831. "onanimationcancel",
  24832. "onanimationend",
  24833. "onanimationiteration",
  24834. "onanimationstart",
  24835. "onappinstalled",
  24836. "onaudioend",
  24837. "onaudioprocess",
  24838. "onaudiostart",
  24839. "onautocomplete",
  24840. "onautocompleteerror",
  24841. "onauxclick",
  24842. "onbeforeactivate",
  24843. "onbeforecopy",
  24844. "onbeforecut",
  24845. "onbeforedeactivate",
  24846. "onbeforeeditfocus",
  24847. "onbeforeinstallprompt",
  24848. "onbeforepaste",
  24849. "onbeforeprint",
  24850. "onbeforescriptexecute",
  24851. "onbeforeunload",
  24852. "onbeforeupdate",
  24853. "onbeforexrselect",
  24854. "onbegin",
  24855. "onblocked",
  24856. "onblur",
  24857. "onbounce",
  24858. "onboundary",
  24859. "onbufferedamountlow",
  24860. "oncached",
  24861. "oncancel",
  24862. "oncandidatewindowhide",
  24863. "oncandidatewindowshow",
  24864. "oncandidatewindowupdate",
  24865. "oncanplay",
  24866. "oncanplaythrough",
  24867. "once",
  24868. "oncellchange",
  24869. "onchange",
  24870. "oncharacteristicvaluechanged",
  24871. "onchargingchange",
  24872. "onchargingtimechange",
  24873. "onchecking",
  24874. "onclick",
  24875. "onclose",
  24876. "onclosing",
  24877. "oncompassneedscalibration",
  24878. "oncomplete",
  24879. "onconnect",
  24880. "onconnecting",
  24881. "onconnectionavailable",
  24882. "onconnectionstatechange",
  24883. "oncontextmenu",
  24884. "oncontrollerchange",
  24885. "oncontrolselect",
  24886. "oncopy",
  24887. "oncuechange",
  24888. "oncut",
  24889. "ondataavailable",
  24890. "ondatachannel",
  24891. "ondatasetchanged",
  24892. "ondatasetcomplete",
  24893. "ondblclick",
  24894. "ondeactivate",
  24895. "ondevicechange",
  24896. "ondevicelight",
  24897. "ondevicemotion",
  24898. "ondeviceorientation",
  24899. "ondeviceorientationabsolute",
  24900. "ondeviceproximity",
  24901. "ondischargingtimechange",
  24902. "ondisconnect",
  24903. "ondisplay",
  24904. "ondownloading",
  24905. "ondrag",
  24906. "ondragend",
  24907. "ondragenter",
  24908. "ondragexit",
  24909. "ondragleave",
  24910. "ondragover",
  24911. "ondragstart",
  24912. "ondrop",
  24913. "ondurationchange",
  24914. "onemptied",
  24915. "onencrypted",
  24916. "onend",
  24917. "onended",
  24918. "onenter",
  24919. "onenterpictureinpicture",
  24920. "onerror",
  24921. "onerrorupdate",
  24922. "onexit",
  24923. "onfilterchange",
  24924. "onfinish",
  24925. "onfocus",
  24926. "onfocusin",
  24927. "onfocusout",
  24928. "onformdata",
  24929. "onfreeze",
  24930. "onfullscreenchange",
  24931. "onfullscreenerror",
  24932. "ongatheringstatechange",
  24933. "ongattserverdisconnected",
  24934. "ongesturechange",
  24935. "ongestureend",
  24936. "ongesturestart",
  24937. "ongotpointercapture",
  24938. "onhashchange",
  24939. "onhelp",
  24940. "onicecandidate",
  24941. "onicecandidateerror",
  24942. "oniceconnectionstatechange",
  24943. "onicegatheringstatechange",
  24944. "oninactive",
  24945. "oninput",
  24946. "oninputsourceschange",
  24947. "oninvalid",
  24948. "onkeydown",
  24949. "onkeypress",
  24950. "onkeystatuseschange",
  24951. "onkeyup",
  24952. "onlanguagechange",
  24953. "onlayoutcomplete",
  24954. "onleavepictureinpicture",
  24955. "onlevelchange",
  24956. "onload",
  24957. "onloadeddata",
  24958. "onloadedmetadata",
  24959. "onloadend",
  24960. "onloading",
  24961. "onloadingdone",
  24962. "onloadingerror",
  24963. "onloadstart",
  24964. "onlosecapture",
  24965. "onlostpointercapture",
  24966. "only",
  24967. "onmark",
  24968. "onmessage",
  24969. "onmessageerror",
  24970. "onmidimessage",
  24971. "onmousedown",
  24972. "onmouseenter",
  24973. "onmouseleave",
  24974. "onmousemove",
  24975. "onmouseout",
  24976. "onmouseover",
  24977. "onmouseup",
  24978. "onmousewheel",
  24979. "onmove",
  24980. "onmoveend",
  24981. "onmovestart",
  24982. "onmozfullscreenchange",
  24983. "onmozfullscreenerror",
  24984. "onmozorientationchange",
  24985. "onmozpointerlockchange",
  24986. "onmozpointerlockerror",
  24987. "onmscontentzoom",
  24988. "onmsfullscreenchange",
  24989. "onmsfullscreenerror",
  24990. "onmsgesturechange",
  24991. "onmsgesturedoubletap",
  24992. "onmsgestureend",
  24993. "onmsgesturehold",
  24994. "onmsgesturestart",
  24995. "onmsgesturetap",
  24996. "onmsgotpointercapture",
  24997. "onmsinertiastart",
  24998. "onmslostpointercapture",
  24999. "onmsmanipulationstatechanged",
  25000. "onmsneedkey",
  25001. "onmsorientationchange",
  25002. "onmspointercancel",
  25003. "onmspointerdown",
  25004. "onmspointerenter",
  25005. "onmspointerhover",
  25006. "onmspointerleave",
  25007. "onmspointermove",
  25008. "onmspointerout",
  25009. "onmspointerover",
  25010. "onmspointerup",
  25011. "onmssitemodejumplistitemremoved",
  25012. "onmsthumbnailclick",
  25013. "onmute",
  25014. "onnegotiationneeded",
  25015. "onnomatch",
  25016. "onnoupdate",
  25017. "onobsolete",
  25018. "onoffline",
  25019. "ononline",
  25020. "onopen",
  25021. "onorientationchange",
  25022. "onpagechange",
  25023. "onpagehide",
  25024. "onpageshow",
  25025. "onpaste",
  25026. "onpause",
  25027. "onpayerdetailchange",
  25028. "onpaymentmethodchange",
  25029. "onplay",
  25030. "onplaying",
  25031. "onpluginstreamstart",
  25032. "onpointercancel",
  25033. "onpointerdown",
  25034. "onpointerenter",
  25035. "onpointerleave",
  25036. "onpointerlockchange",
  25037. "onpointerlockerror",
  25038. "onpointermove",
  25039. "onpointerout",
  25040. "onpointerover",
  25041. "onpointerrawupdate",
  25042. "onpointerup",
  25043. "onpopstate",
  25044. "onprocessorerror",
  25045. "onprogress",
  25046. "onpropertychange",
  25047. "onratechange",
  25048. "onreading",
  25049. "onreadystatechange",
  25050. "onrejectionhandled",
  25051. "onrelease",
  25052. "onremove",
  25053. "onremovesourcebuffer",
  25054. "onremovestream",
  25055. "onremovetrack",
  25056. "onrepeat",
  25057. "onreset",
  25058. "onresize",
  25059. "onresizeend",
  25060. "onresizestart",
  25061. "onresourcetimingbufferfull",
  25062. "onresult",
  25063. "onresume",
  25064. "onrowenter",
  25065. "onrowexit",
  25066. "onrowsdelete",
  25067. "onrowsinserted",
  25068. "onscroll",
  25069. "onsearch",
  25070. "onsecuritypolicyviolation",
  25071. "onseeked",
  25072. "onseeking",
  25073. "onselect",
  25074. "onselectedcandidatepairchange",
  25075. "onselectend",
  25076. "onselectionchange",
  25077. "onselectstart",
  25078. "onshippingaddresschange",
  25079. "onshippingoptionchange",
  25080. "onshow",
  25081. "onsignalingstatechange",
  25082. "onsoundend",
  25083. "onsoundstart",
  25084. "onsourceclose",
  25085. "onsourceclosed",
  25086. "onsourceended",
  25087. "onsourceopen",
  25088. "onspeechend",
  25089. "onspeechstart",
  25090. "onsqueeze",
  25091. "onsqueezeend",
  25092. "onsqueezestart",
  25093. "onstalled",
  25094. "onstart",
  25095. "onstatechange",
  25096. "onstop",
  25097. "onstorage",
  25098. "onstoragecommit",
  25099. "onsubmit",
  25100. "onsuccess",
  25101. "onsuspend",
  25102. "onterminate",
  25103. "ontextinput",
  25104. "ontimeout",
  25105. "ontimeupdate",
  25106. "ontoggle",
  25107. "ontonechange",
  25108. "ontouchcancel",
  25109. "ontouchend",
  25110. "ontouchmove",
  25111. "ontouchstart",
  25112. "ontrack",
  25113. "ontransitioncancel",
  25114. "ontransitionend",
  25115. "ontransitionrun",
  25116. "ontransitionstart",
  25117. "onunhandledrejection",
  25118. "onunload",
  25119. "onunmute",
  25120. "onupdate",
  25121. "onupdateend",
  25122. "onupdatefound",
  25123. "onupdateready",
  25124. "onupdatestart",
  25125. "onupgradeneeded",
  25126. "onuserproximity",
  25127. "onversionchange",
  25128. "onvisibilitychange",
  25129. "onvoiceschanged",
  25130. "onvolumechange",
  25131. "onvrdisplayactivate",
  25132. "onvrdisplayconnect",
  25133. "onvrdisplaydeactivate",
  25134. "onvrdisplaydisconnect",
  25135. "onvrdisplaypresentchange",
  25136. "onwaiting",
  25137. "onwaitingforkey",
  25138. "onwarning",
  25139. "onwebkitanimationend",
  25140. "onwebkitanimationiteration",
  25141. "onwebkitanimationstart",
  25142. "onwebkitcurrentplaybacktargetiswirelesschanged",
  25143. "onwebkitfullscreenchange",
  25144. "onwebkitfullscreenerror",
  25145. "onwebkitkeyadded",
  25146. "onwebkitkeyerror",
  25147. "onwebkitkeymessage",
  25148. "onwebkitneedkey",
  25149. "onwebkitorientationchange",
  25150. "onwebkitplaybacktargetavailabilitychanged",
  25151. "onwebkitpointerlockchange",
  25152. "onwebkitpointerlockerror",
  25153. "onwebkitresourcetimingbufferfull",
  25154. "onwebkittransitionend",
  25155. "onwheel",
  25156. "onzoom",
  25157. "opacity",
  25158. "open",
  25159. "openCursor",
  25160. "openDatabase",
  25161. "openKeyCursor",
  25162. "opened",
  25163. "opener",
  25164. "opera",
  25165. "operationType",
  25166. "operator",
  25167. "opr",
  25168. "optimum",
  25169. "options",
  25170. "or",
  25171. "order",
  25172. "orderX",
  25173. "orderY",
  25174. "ordered",
  25175. "org",
  25176. "organization",
  25177. "orient",
  25178. "orientAngle",
  25179. "orientType",
  25180. "orientation",
  25181. "orientationX",
  25182. "orientationY",
  25183. "orientationZ",
  25184. "origin",
  25185. "originalPolicy",
  25186. "originalTarget",
  25187. "orphans",
  25188. "oscpu",
  25189. "outerHTML",
  25190. "outerHeight",
  25191. "outerText",
  25192. "outerWidth",
  25193. "outline",
  25194. "outline-color",
  25195. "outline-offset",
  25196. "outline-style",
  25197. "outline-width",
  25198. "outlineColor",
  25199. "outlineOffset",
  25200. "outlineStyle",
  25201. "outlineWidth",
  25202. "outputBuffer",
  25203. "outputLatency",
  25204. "outputs",
  25205. "overflow",
  25206. "overflow-anchor",
  25207. "overflow-block",
  25208. "overflow-inline",
  25209. "overflow-wrap",
  25210. "overflow-x",
  25211. "overflow-y",
  25212. "overflowAnchor",
  25213. "overflowBlock",
  25214. "overflowInline",
  25215. "overflowWrap",
  25216. "overflowX",
  25217. "overflowY",
  25218. "overrideMimeType",
  25219. "oversample",
  25220. "overscroll-behavior",
  25221. "overscroll-behavior-block",
  25222. "overscroll-behavior-inline",
  25223. "overscroll-behavior-x",
  25224. "overscroll-behavior-y",
  25225. "overscrollBehavior",
  25226. "overscrollBehaviorBlock",
  25227. "overscrollBehaviorInline",
  25228. "overscrollBehaviorX",
  25229. "overscrollBehaviorY",
  25230. "ownKeys",
  25231. "ownerDocument",
  25232. "ownerElement",
  25233. "ownerNode",
  25234. "ownerRule",
  25235. "ownerSVGElement",
  25236. "owningElement",
  25237. "p1",
  25238. "p2",
  25239. "p3",
  25240. "p4",
  25241. "packetSize",
  25242. "packets",
  25243. "pad",
  25244. "padEnd",
  25245. "padStart",
  25246. "padding",
  25247. "padding-block",
  25248. "padding-block-end",
  25249. "padding-block-start",
  25250. "padding-bottom",
  25251. "padding-inline",
  25252. "padding-inline-end",
  25253. "padding-inline-start",
  25254. "padding-left",
  25255. "padding-right",
  25256. "padding-top",
  25257. "paddingBlock",
  25258. "paddingBlockEnd",
  25259. "paddingBlockStart",
  25260. "paddingBottom",
  25261. "paddingInline",
  25262. "paddingInlineEnd",
  25263. "paddingInlineStart",
  25264. "paddingLeft",
  25265. "paddingRight",
  25266. "paddingTop",
  25267. "page",
  25268. "page-break-after",
  25269. "page-break-before",
  25270. "page-break-inside",
  25271. "pageBreakAfter",
  25272. "pageBreakBefore",
  25273. "pageBreakInside",
  25274. "pageCount",
  25275. "pageLeft",
  25276. "pageTop",
  25277. "pageX",
  25278. "pageXOffset",
  25279. "pageY",
  25280. "pageYOffset",
  25281. "pages",
  25282. "paint-order",
  25283. "paintOrder",
  25284. "paintRequests",
  25285. "paintType",
  25286. "paintWorklet",
  25287. "palette",
  25288. "pan",
  25289. "panningModel",
  25290. "parameters",
  25291. "parent",
  25292. "parentElement",
  25293. "parentNode",
  25294. "parentRule",
  25295. "parentStyleSheet",
  25296. "parentTextEdit",
  25297. "parentWindow",
  25298. "parse",
  25299. "parseAll",
  25300. "parseFloat",
  25301. "parseFromString",
  25302. "parseInt",
  25303. "part",
  25304. "participants",
  25305. "passive",
  25306. "password",
  25307. "pasteHTML",
  25308. "path",
  25309. "pathLength",
  25310. "pathSegList",
  25311. "pathSegType",
  25312. "pathSegTypeAsLetter",
  25313. "pathname",
  25314. "pattern",
  25315. "patternContentUnits",
  25316. "patternMismatch",
  25317. "patternTransform",
  25318. "patternUnits",
  25319. "pause",
  25320. "pauseAnimations",
  25321. "pauseOnExit",
  25322. "pauseProfilers",
  25323. "pauseTransformFeedback",
  25324. "paused",
  25325. "payerEmail",
  25326. "payerName",
  25327. "payerPhone",
  25328. "paymentManager",
  25329. "pc",
  25330. "peerIdentity",
  25331. "pending",
  25332. "pendingLocalDescription",
  25333. "pendingRemoteDescription",
  25334. "percent",
  25335. "performance",
  25336. "periodicSync",
  25337. "permission",
  25338. "permissionState",
  25339. "permissions",
  25340. "persist",
  25341. "persisted",
  25342. "personalbar",
  25343. "perspective",
  25344. "perspective-origin",
  25345. "perspectiveOrigin",
  25346. "phone",
  25347. "phoneticFamilyName",
  25348. "phoneticGivenName",
  25349. "photo",
  25350. "pictureInPictureElement",
  25351. "pictureInPictureEnabled",
  25352. "pictureInPictureWindow",
  25353. "ping",
  25354. "pipeThrough",
  25355. "pipeTo",
  25356. "pitch",
  25357. "pixelBottom",
  25358. "pixelDepth",
  25359. "pixelHeight",
  25360. "pixelLeft",
  25361. "pixelRight",
  25362. "pixelStorei",
  25363. "pixelTop",
  25364. "pixelUnitToMillimeterX",
  25365. "pixelUnitToMillimeterY",
  25366. "pixelWidth",
  25367. "place-content",
  25368. "place-items",
  25369. "place-self",
  25370. "placeContent",
  25371. "placeItems",
  25372. "placeSelf",
  25373. "placeholder",
  25374. "platformVersion",
  25375. "platform",
  25376. "platforms",
  25377. "play",
  25378. "playEffect",
  25379. "playState",
  25380. "playbackRate",
  25381. "playbackState",
  25382. "playbackTime",
  25383. "played",
  25384. "playoutDelayHint",
  25385. "playsInline",
  25386. "plugins",
  25387. "pluginspage",
  25388. "pname",
  25389. "pointer-events",
  25390. "pointerBeforeReferenceNode",
  25391. "pointerEnabled",
  25392. "pointerEvents",
  25393. "pointerId",
  25394. "pointerLockElement",
  25395. "pointerType",
  25396. "points",
  25397. "pointsAtX",
  25398. "pointsAtY",
  25399. "pointsAtZ",
  25400. "polygonOffset",
  25401. "pop",
  25402. "populateMatrix",
  25403. "popupWindowFeatures",
  25404. "popupWindowName",
  25405. "popupWindowURI",
  25406. "port",
  25407. "port1",
  25408. "port2",
  25409. "ports",
  25410. "posBottom",
  25411. "posHeight",
  25412. "posLeft",
  25413. "posRight",
  25414. "posTop",
  25415. "posWidth",
  25416. "pose",
  25417. "position",
  25418. "positionAlign",
  25419. "positionX",
  25420. "positionY",
  25421. "positionZ",
  25422. "postError",
  25423. "postMessage",
  25424. "postalCode",
  25425. "poster",
  25426. "pow",
  25427. "powerEfficient",
  25428. "powerOff",
  25429. "preMultiplySelf",
  25430. "precision",
  25431. "preferredStyleSheetSet",
  25432. "preferredStylesheetSet",
  25433. "prefix",
  25434. "preload",
  25435. "prepend",
  25436. "presentation",
  25437. "preserveAlpha",
  25438. "preserveAspectRatio",
  25439. "preserveAspectRatioString",
  25440. "pressed",
  25441. "pressure",
  25442. "prevValue",
  25443. "preventDefault",
  25444. "preventExtensions",
  25445. "preventSilentAccess",
  25446. "previousElementSibling",
  25447. "previousNode",
  25448. "previousPage",
  25449. "previousRect",
  25450. "previousScale",
  25451. "previousSibling",
  25452. "previousTranslate",
  25453. "primaryKey",
  25454. "primitiveType",
  25455. "primitiveUnits",
  25456. "principals",
  25457. "print",
  25458. "priority",
  25459. "privateKey",
  25460. "probablySupportsContext",
  25461. "process",
  25462. "processIceMessage",
  25463. "processingEnd",
  25464. "processingStart",
  25465. "product",
  25466. "productId",
  25467. "productName",
  25468. "productSub",
  25469. "profile",
  25470. "profileEnd",
  25471. "profiles",
  25472. "projectionMatrix",
  25473. "promise",
  25474. "prompt",
  25475. "properties",
  25476. "propertyIsEnumerable",
  25477. "propertyName",
  25478. "protocol",
  25479. "protocolLong",
  25480. "prototype",
  25481. "provider",
  25482. "pseudoClass",
  25483. "pseudoElement",
  25484. "pt",
  25485. "publicId",
  25486. "publicKey",
  25487. "published",
  25488. "pulse",
  25489. "push",
  25490. "pushManager",
  25491. "pushNotification",
  25492. "pushState",
  25493. "put",
  25494. "putImageData",
  25495. "px",
  25496. "quadraticCurveTo",
  25497. "qualifier",
  25498. "quaternion",
  25499. "query",
  25500. "queryCommandEnabled",
  25501. "queryCommandIndeterm",
  25502. "queryCommandState",
  25503. "queryCommandSupported",
  25504. "queryCommandText",
  25505. "queryCommandValue",
  25506. "querySelector",
  25507. "querySelectorAll",
  25508. "queueMicrotask",
  25509. "quote",
  25510. "quotes",
  25511. "r",
  25512. "r1",
  25513. "r2",
  25514. "race",
  25515. "rad",
  25516. "radiogroup",
  25517. "radiusX",
  25518. "radiusY",
  25519. "random",
  25520. "range",
  25521. "rangeCount",
  25522. "rangeMax",
  25523. "rangeMin",
  25524. "rangeOffset",
  25525. "rangeOverflow",
  25526. "rangeParent",
  25527. "rangeUnderflow",
  25528. "rate",
  25529. "ratio",
  25530. "raw",
  25531. "rawId",
  25532. "read",
  25533. "readAsArrayBuffer",
  25534. "readAsBinaryString",
  25535. "readAsBlob",
  25536. "readAsDataURL",
  25537. "readAsText",
  25538. "readBuffer",
  25539. "readEntries",
  25540. "readOnly",
  25541. "readPixels",
  25542. "readReportRequested",
  25543. "readText",
  25544. "readValue",
  25545. "readable",
  25546. "ready",
  25547. "readyState",
  25548. "reason",
  25549. "reboot",
  25550. "receivedAlert",
  25551. "receiver",
  25552. "receivers",
  25553. "recipient",
  25554. "reconnect",
  25555. "recordNumber",
  25556. "recordsAvailable",
  25557. "recordset",
  25558. "rect",
  25559. "red",
  25560. "redEyeReduction",
  25561. "redirect",
  25562. "redirectCount",
  25563. "redirectEnd",
  25564. "redirectStart",
  25565. "redirected",
  25566. "reduce",
  25567. "reduceRight",
  25568. "reduction",
  25569. "refDistance",
  25570. "refX",
  25571. "refY",
  25572. "referenceNode",
  25573. "referenceSpace",
  25574. "referrer",
  25575. "referrerPolicy",
  25576. "refresh",
  25577. "region",
  25578. "regionAnchorX",
  25579. "regionAnchorY",
  25580. "regionId",
  25581. "regions",
  25582. "register",
  25583. "registerContentHandler",
  25584. "registerElement",
  25585. "registerProperty",
  25586. "registerProtocolHandler",
  25587. "reject",
  25588. "rel",
  25589. "relList",
  25590. "relatedAddress",
  25591. "relatedNode",
  25592. "relatedPort",
  25593. "relatedTarget",
  25594. "release",
  25595. "releaseCapture",
  25596. "releaseEvents",
  25597. "releaseInterface",
  25598. "releaseLock",
  25599. "releasePointerCapture",
  25600. "releaseShaderCompiler",
  25601. "reliable",
  25602. "reliableWrite",
  25603. "reload",
  25604. "rem",
  25605. "remainingSpace",
  25606. "remote",
  25607. "remoteDescription",
  25608. "remove",
  25609. "removeAllRanges",
  25610. "removeAttribute",
  25611. "removeAttributeNS",
  25612. "removeAttributeNode",
  25613. "removeBehavior",
  25614. "removeChild",
  25615. "removeCue",
  25616. "removeEventListener",
  25617. "removeFilter",
  25618. "removeImport",
  25619. "removeItem",
  25620. "removeListener",
  25621. "removeNamedItem",
  25622. "removeNamedItemNS",
  25623. "removeNode",
  25624. "removeParameter",
  25625. "removeProperty",
  25626. "removeRange",
  25627. "removeRegion",
  25628. "removeRule",
  25629. "removeSiteSpecificTrackingException",
  25630. "removeSourceBuffer",
  25631. "removeStream",
  25632. "removeTrack",
  25633. "removeVariable",
  25634. "removeWakeLockListener",
  25635. "removeWebWideTrackingException",
  25636. "removed",
  25637. "removedNodes",
  25638. "renderHeight",
  25639. "renderState",
  25640. "renderTime",
  25641. "renderWidth",
  25642. "renderbufferStorage",
  25643. "renderbufferStorageMultisample",
  25644. "renderedBuffer",
  25645. "renderingMode",
  25646. "renotify",
  25647. "repeat",
  25648. "replace",
  25649. "replaceAdjacentText",
  25650. "replaceAll",
  25651. "replaceChild",
  25652. "replaceChildren",
  25653. "replaceData",
  25654. "replaceId",
  25655. "replaceItem",
  25656. "replaceNode",
  25657. "replaceState",
  25658. "replaceSync",
  25659. "replaceTrack",
  25660. "replaceWholeText",
  25661. "replaceWith",
  25662. "reportValidity",
  25663. "request",
  25664. "requestAnimationFrame",
  25665. "requestAutocomplete",
  25666. "requestData",
  25667. "requestDevice",
  25668. "requestFrame",
  25669. "requestFullscreen",
  25670. "requestHitTestSource",
  25671. "requestHitTestSourceForTransientInput",
  25672. "requestId",
  25673. "requestIdleCallback",
  25674. "requestMIDIAccess",
  25675. "requestMediaKeySystemAccess",
  25676. "requestPermission",
  25677. "requestPictureInPicture",
  25678. "requestPointerLock",
  25679. "requestPresent",
  25680. "requestReferenceSpace",
  25681. "requestSession",
  25682. "requestStart",
  25683. "requestStorageAccess",
  25684. "requestSubmit",
  25685. "requestVideoFrameCallback",
  25686. "requestingWindow",
  25687. "requireInteraction",
  25688. "required",
  25689. "requiredExtensions",
  25690. "requiredFeatures",
  25691. "reset",
  25692. "resetPose",
  25693. "resetTransform",
  25694. "resize",
  25695. "resizeBy",
  25696. "resizeTo",
  25697. "resolve",
  25698. "response",
  25699. "responseBody",
  25700. "responseEnd",
  25701. "responseReady",
  25702. "responseStart",
  25703. "responseText",
  25704. "responseType",
  25705. "responseURL",
  25706. "responseXML",
  25707. "restartIce",
  25708. "restore",
  25709. "result",
  25710. "resultIndex",
  25711. "resultType",
  25712. "results",
  25713. "resume",
  25714. "resumeProfilers",
  25715. "resumeTransformFeedback",
  25716. "retry",
  25717. "returnValue",
  25718. "rev",
  25719. "reverse",
  25720. "reversed",
  25721. "revocable",
  25722. "revokeObjectURL",
  25723. "rgbColor",
  25724. "right",
  25725. "rightContext",
  25726. "rightDegrees",
  25727. "rightMargin",
  25728. "rightProjectionMatrix",
  25729. "rightViewMatrix",
  25730. "role",
  25731. "rolloffFactor",
  25732. "root",
  25733. "rootBounds",
  25734. "rootElement",
  25735. "rootMargin",
  25736. "rotate",
  25737. "rotateAxisAngle",
  25738. "rotateAxisAngleSelf",
  25739. "rotateFromVector",
  25740. "rotateFromVectorSelf",
  25741. "rotateSelf",
  25742. "rotation",
  25743. "rotationAngle",
  25744. "rotationRate",
  25745. "round",
  25746. "row-gap",
  25747. "rowGap",
  25748. "rowIndex",
  25749. "rowSpan",
  25750. "rows",
  25751. "rtcpTransport",
  25752. "rtt",
  25753. "ruby-align",
  25754. "ruby-position",
  25755. "rubyAlign",
  25756. "rubyOverhang",
  25757. "rubyPosition",
  25758. "rules",
  25759. "runtime",
  25760. "runtimeStyle",
  25761. "rx",
  25762. "ry",
  25763. "s",
  25764. "safari",
  25765. "sample",
  25766. "sampleCoverage",
  25767. "sampleRate",
  25768. "samplerParameterf",
  25769. "samplerParameteri",
  25770. "sandbox",
  25771. "save",
  25772. "saveData",
  25773. "scale",
  25774. "scale3d",
  25775. "scale3dSelf",
  25776. "scaleNonUniform",
  25777. "scaleNonUniformSelf",
  25778. "scaleSelf",
  25779. "scheme",
  25780. "scissor",
  25781. "scope",
  25782. "scopeName",
  25783. "scoped",
  25784. "screen",
  25785. "screenBrightness",
  25786. "screenEnabled",
  25787. "screenLeft",
  25788. "screenPixelToMillimeterX",
  25789. "screenPixelToMillimeterY",
  25790. "screenTop",
  25791. "screenX",
  25792. "screenY",
  25793. "scriptURL",
  25794. "scripts",
  25795. "scroll",
  25796. "scroll-behavior",
  25797. "scroll-margin",
  25798. "scroll-margin-block",
  25799. "scroll-margin-block-end",
  25800. "scroll-margin-block-start",
  25801. "scroll-margin-bottom",
  25802. "scroll-margin-inline",
  25803. "scroll-margin-inline-end",
  25804. "scroll-margin-inline-start",
  25805. "scroll-margin-left",
  25806. "scroll-margin-right",
  25807. "scroll-margin-top",
  25808. "scroll-padding",
  25809. "scroll-padding-block",
  25810. "scroll-padding-block-end",
  25811. "scroll-padding-block-start",
  25812. "scroll-padding-bottom",
  25813. "scroll-padding-inline",
  25814. "scroll-padding-inline-end",
  25815. "scroll-padding-inline-start",
  25816. "scroll-padding-left",
  25817. "scroll-padding-right",
  25818. "scroll-padding-top",
  25819. "scroll-snap-align",
  25820. "scroll-snap-type",
  25821. "scrollAmount",
  25822. "scrollBehavior",
  25823. "scrollBy",
  25824. "scrollByLines",
  25825. "scrollByPages",
  25826. "scrollDelay",
  25827. "scrollHeight",
  25828. "scrollIntoView",
  25829. "scrollIntoViewIfNeeded",
  25830. "scrollLeft",
  25831. "scrollLeftMax",
  25832. "scrollMargin",
  25833. "scrollMarginBlock",
  25834. "scrollMarginBlockEnd",
  25835. "scrollMarginBlockStart",
  25836. "scrollMarginBottom",
  25837. "scrollMarginInline",
  25838. "scrollMarginInlineEnd",
  25839. "scrollMarginInlineStart",
  25840. "scrollMarginLeft",
  25841. "scrollMarginRight",
  25842. "scrollMarginTop",
  25843. "scrollMaxX",
  25844. "scrollMaxY",
  25845. "scrollPadding",
  25846. "scrollPaddingBlock",
  25847. "scrollPaddingBlockEnd",
  25848. "scrollPaddingBlockStart",
  25849. "scrollPaddingBottom",
  25850. "scrollPaddingInline",
  25851. "scrollPaddingInlineEnd",
  25852. "scrollPaddingInlineStart",
  25853. "scrollPaddingLeft",
  25854. "scrollPaddingRight",
  25855. "scrollPaddingTop",
  25856. "scrollRestoration",
  25857. "scrollSnapAlign",
  25858. "scrollSnapType",
  25859. "scrollTo",
  25860. "scrollTop",
  25861. "scrollTopMax",
  25862. "scrollWidth",
  25863. "scrollX",
  25864. "scrollY",
  25865. "scrollbar-color",
  25866. "scrollbar-width",
  25867. "scrollbar3dLightColor",
  25868. "scrollbarArrowColor",
  25869. "scrollbarBaseColor",
  25870. "scrollbarColor",
  25871. "scrollbarDarkShadowColor",
  25872. "scrollbarFaceColor",
  25873. "scrollbarHighlightColor",
  25874. "scrollbarShadowColor",
  25875. "scrollbarTrackColor",
  25876. "scrollbarWidth",
  25877. "scrollbars",
  25878. "scrolling",
  25879. "scrollingElement",
  25880. "sctp",
  25881. "sctpCauseCode",
  25882. "sdp",
  25883. "sdpLineNumber",
  25884. "sdpMLineIndex",
  25885. "sdpMid",
  25886. "seal",
  25887. "search",
  25888. "searchBox",
  25889. "searchBoxJavaBridge_",
  25890. "searchParams",
  25891. "sectionRowIndex",
  25892. "secureConnectionStart",
  25893. "security",
  25894. "seed",
  25895. "seekToNextFrame",
  25896. "seekable",
  25897. "seeking",
  25898. "select",
  25899. "selectAllChildren",
  25900. "selectAlternateInterface",
  25901. "selectConfiguration",
  25902. "selectNode",
  25903. "selectNodeContents",
  25904. "selectNodes",
  25905. "selectSingleNode",
  25906. "selectSubString",
  25907. "selected",
  25908. "selectedIndex",
  25909. "selectedOptions",
  25910. "selectedStyleSheetSet",
  25911. "selectedStylesheetSet",
  25912. "selection",
  25913. "selectionDirection",
  25914. "selectionEnd",
  25915. "selectionStart",
  25916. "selector",
  25917. "selectorText",
  25918. "self",
  25919. "send",
  25920. "sendAsBinary",
  25921. "sendBeacon",
  25922. "sender",
  25923. "sentAlert",
  25924. "sentTimestamp",
  25925. "separator",
  25926. "serialNumber",
  25927. "serializeToString",
  25928. "serverTiming",
  25929. "service",
  25930. "serviceWorker",
  25931. "session",
  25932. "sessionId",
  25933. "sessionStorage",
  25934. "set",
  25935. "setActionHandler",
  25936. "setActive",
  25937. "setAlpha",
  25938. "setAppBadge",
  25939. "setAttribute",
  25940. "setAttributeNS",
  25941. "setAttributeNode",
  25942. "setAttributeNodeNS",
  25943. "setBaseAndExtent",
  25944. "setBigInt64",
  25945. "setBigUint64",
  25946. "setBingCurrentSearchDefault",
  25947. "setCapture",
  25948. "setCodecPreferences",
  25949. "setColor",
  25950. "setCompositeOperation",
  25951. "setConfiguration",
  25952. "setCurrentTime",
  25953. "setCustomValidity",
  25954. "setData",
  25955. "setDate",
  25956. "setDragImage",
  25957. "setEnd",
  25958. "setEndAfter",
  25959. "setEndBefore",
  25960. "setEndPoint",
  25961. "setFillColor",
  25962. "setFilterRes",
  25963. "setFloat32",
  25964. "setFloat64",
  25965. "setFloatValue",
  25966. "setFormValue",
  25967. "setFullYear",
  25968. "setHeaderValue",
  25969. "setHours",
  25970. "setIdentityProvider",
  25971. "setImmediate",
  25972. "setInt16",
  25973. "setInt32",
  25974. "setInt8",
  25975. "setInterval",
  25976. "setItem",
  25977. "setKeyframes",
  25978. "setLineCap",
  25979. "setLineDash",
  25980. "setLineJoin",
  25981. "setLineWidth",
  25982. "setLiveSeekableRange",
  25983. "setLocalDescription",
  25984. "setMatrix",
  25985. "setMatrixValue",
  25986. "setMediaKeys",
  25987. "setMilliseconds",
  25988. "setMinutes",
  25989. "setMiterLimit",
  25990. "setMonth",
  25991. "setNamedItem",
  25992. "setNamedItemNS",
  25993. "setNonUserCodeExceptions",
  25994. "setOrientToAngle",
  25995. "setOrientToAuto",
  25996. "setOrientation",
  25997. "setOverrideHistoryNavigationMode",
  25998. "setPaint",
  25999. "setParameter",
  26000. "setParameters",
  26001. "setPeriodicWave",
  26002. "setPointerCapture",
  26003. "setPosition",
  26004. "setPositionState",
  26005. "setPreference",
  26006. "setProperty",
  26007. "setPrototypeOf",
  26008. "setRGBColor",
  26009. "setRGBColorICCColor",
  26010. "setRadius",
  26011. "setRangeText",
  26012. "setRemoteDescription",
  26013. "setRequestHeader",
  26014. "setResizable",
  26015. "setResourceTimingBufferSize",
  26016. "setRotate",
  26017. "setScale",
  26018. "setSeconds",
  26019. "setSelectionRange",
  26020. "setServerCertificate",
  26021. "setShadow",
  26022. "setSinkId",
  26023. "setSkewX",
  26024. "setSkewY",
  26025. "setStart",
  26026. "setStartAfter",
  26027. "setStartBefore",
  26028. "setStdDeviation",
  26029. "setStreams",
  26030. "setStringValue",
  26031. "setStrokeColor",
  26032. "setSuggestResult",
  26033. "setTargetAtTime",
  26034. "setTargetValueAtTime",
  26035. "setTime",
  26036. "setTimeout",
  26037. "setTransform",
  26038. "setTranslate",
  26039. "setUTCDate",
  26040. "setUTCFullYear",
  26041. "setUTCHours",
  26042. "setUTCMilliseconds",
  26043. "setUTCMinutes",
  26044. "setUTCMonth",
  26045. "setUTCSeconds",
  26046. "setUint16",
  26047. "setUint32",
  26048. "setUint8",
  26049. "setUri",
  26050. "setValidity",
  26051. "setValueAtTime",
  26052. "setValueCurveAtTime",
  26053. "setVariable",
  26054. "setVelocity",
  26055. "setVersion",
  26056. "setYear",
  26057. "settingName",
  26058. "settingValue",
  26059. "sex",
  26060. "shaderSource",
  26061. "shadowBlur",
  26062. "shadowColor",
  26063. "shadowOffsetX",
  26064. "shadowOffsetY",
  26065. "shadowRoot",
  26066. "shape",
  26067. "shape-image-threshold",
  26068. "shape-margin",
  26069. "shape-outside",
  26070. "shape-rendering",
  26071. "shapeImageThreshold",
  26072. "shapeMargin",
  26073. "shapeOutside",
  26074. "shapeRendering",
  26075. "sheet",
  26076. "shift",
  26077. "shiftKey",
  26078. "shiftLeft",
  26079. "shippingAddress",
  26080. "shippingOption",
  26081. "shippingType",
  26082. "show",
  26083. "showHelp",
  26084. "showModal",
  26085. "showModalDialog",
  26086. "showModelessDialog",
  26087. "showNotification",
  26088. "sidebar",
  26089. "sign",
  26090. "signal",
  26091. "signalingState",
  26092. "signature",
  26093. "silent",
  26094. "sin",
  26095. "singleNodeValue",
  26096. "sinh",
  26097. "sinkId",
  26098. "sittingToStandingTransform",
  26099. "size",
  26100. "sizeToContent",
  26101. "sizeX",
  26102. "sizeZ",
  26103. "sizes",
  26104. "skewX",
  26105. "skewXSelf",
  26106. "skewY",
  26107. "skewYSelf",
  26108. "slice",
  26109. "slope",
  26110. "slot",
  26111. "small",
  26112. "smil",
  26113. "smooth",
  26114. "smoothingTimeConstant",
  26115. "snapToLines",
  26116. "snapshotItem",
  26117. "snapshotLength",
  26118. "some",
  26119. "sort",
  26120. "sortingCode",
  26121. "source",
  26122. "sourceBuffer",
  26123. "sourceBuffers",
  26124. "sourceCapabilities",
  26125. "sourceFile",
  26126. "sourceIndex",
  26127. "sources",
  26128. "spacing",
  26129. "span",
  26130. "speak",
  26131. "speakAs",
  26132. "speaking",
  26133. "species",
  26134. "specified",
  26135. "specularConstant",
  26136. "specularExponent",
  26137. "speechSynthesis",
  26138. "speed",
  26139. "speedOfSound",
  26140. "spellcheck",
  26141. "splice",
  26142. "split",
  26143. "splitText",
  26144. "spreadMethod",
  26145. "sqrt",
  26146. "src",
  26147. "srcElement",
  26148. "srcFilter",
  26149. "srcObject",
  26150. "srcUrn",
  26151. "srcdoc",
  26152. "srclang",
  26153. "srcset",
  26154. "stack",
  26155. "stackTraceLimit",
  26156. "stacktrace",
  26157. "stageParameters",
  26158. "standalone",
  26159. "standby",
  26160. "start",
  26161. "startContainer",
  26162. "startIce",
  26163. "startMessages",
  26164. "startNotifications",
  26165. "startOffset",
  26166. "startProfiling",
  26167. "startRendering",
  26168. "startShark",
  26169. "startTime",
  26170. "startsWith",
  26171. "state",
  26172. "status",
  26173. "statusCode",
  26174. "statusMessage",
  26175. "statusText",
  26176. "statusbar",
  26177. "stdDeviationX",
  26178. "stdDeviationY",
  26179. "stencilFunc",
  26180. "stencilFuncSeparate",
  26181. "stencilMask",
  26182. "stencilMaskSeparate",
  26183. "stencilOp",
  26184. "stencilOpSeparate",
  26185. "step",
  26186. "stepDown",
  26187. "stepMismatch",
  26188. "stepUp",
  26189. "sticky",
  26190. "stitchTiles",
  26191. "stop",
  26192. "stop-color",
  26193. "stop-opacity",
  26194. "stopColor",
  26195. "stopImmediatePropagation",
  26196. "stopNotifications",
  26197. "stopOpacity",
  26198. "stopProfiling",
  26199. "stopPropagation",
  26200. "stopShark",
  26201. "stopped",
  26202. "storage",
  26203. "storageArea",
  26204. "storageName",
  26205. "storageStatus",
  26206. "store",
  26207. "storeSiteSpecificTrackingException",
  26208. "storeWebWideTrackingException",
  26209. "stpVersion",
  26210. "stream",
  26211. "streams",
  26212. "stretch",
  26213. "strike",
  26214. "string",
  26215. "stringValue",
  26216. "stringify",
  26217. "stroke",
  26218. "stroke-dasharray",
  26219. "stroke-dashoffset",
  26220. "stroke-linecap",
  26221. "stroke-linejoin",
  26222. "stroke-miterlimit",
  26223. "stroke-opacity",
  26224. "stroke-width",
  26225. "strokeDasharray",
  26226. "strokeDashoffset",
  26227. "strokeLinecap",
  26228. "strokeLinejoin",
  26229. "strokeMiterlimit",
  26230. "strokeOpacity",
  26231. "strokeRect",
  26232. "strokeStyle",
  26233. "strokeText",
  26234. "strokeWidth",
  26235. "style",
  26236. "styleFloat",
  26237. "styleMap",
  26238. "styleMedia",
  26239. "styleSheet",
  26240. "styleSheetSets",
  26241. "styleSheets",
  26242. "sub",
  26243. "subarray",
  26244. "subject",
  26245. "submit",
  26246. "submitFrame",
  26247. "submitter",
  26248. "subscribe",
  26249. "substr",
  26250. "substring",
  26251. "substringData",
  26252. "subtle",
  26253. "subtree",
  26254. "suffix",
  26255. "suffixes",
  26256. "summary",
  26257. "sup",
  26258. "supported",
  26259. "supportedContentEncodings",
  26260. "supportedEntryTypes",
  26261. "supports",
  26262. "supportsSession",
  26263. "surfaceScale",
  26264. "surroundContents",
  26265. "suspend",
  26266. "suspendRedraw",
  26267. "swapCache",
  26268. "swapNode",
  26269. "sweepFlag",
  26270. "symbols",
  26271. "sync",
  26272. "sysexEnabled",
  26273. "system",
  26274. "systemCode",
  26275. "systemId",
  26276. "systemLanguage",
  26277. "systemXDPI",
  26278. "systemYDPI",
  26279. "tBodies",
  26280. "tFoot",
  26281. "tHead",
  26282. "tabIndex",
  26283. "table",
  26284. "table-layout",
  26285. "tableLayout",
  26286. "tableValues",
  26287. "tag",
  26288. "tagName",
  26289. "tagUrn",
  26290. "tags",
  26291. "taintEnabled",
  26292. "takePhoto",
  26293. "takeRecords",
  26294. "tan",
  26295. "tangentialPressure",
  26296. "tanh",
  26297. "target",
  26298. "targetElement",
  26299. "targetRayMode",
  26300. "targetRaySpace",
  26301. "targetTouches",
  26302. "targetX",
  26303. "targetY",
  26304. "tcpType",
  26305. "tee",
  26306. "tel",
  26307. "terminate",
  26308. "test",
  26309. "texImage2D",
  26310. "texImage3D",
  26311. "texParameterf",
  26312. "texParameteri",
  26313. "texStorage2D",
  26314. "texStorage3D",
  26315. "texSubImage2D",
  26316. "texSubImage3D",
  26317. "text",
  26318. "text-align",
  26319. "text-align-last",
  26320. "text-anchor",
  26321. "text-combine-upright",
  26322. "text-decoration",
  26323. "text-decoration-color",
  26324. "text-decoration-line",
  26325. "text-decoration-skip-ink",
  26326. "text-decoration-style",
  26327. "text-decoration-thickness",
  26328. "text-emphasis",
  26329. "text-emphasis-color",
  26330. "text-emphasis-position",
  26331. "text-emphasis-style",
  26332. "text-indent",
  26333. "text-justify",
  26334. "text-orientation",
  26335. "text-overflow",
  26336. "text-rendering",
  26337. "text-shadow",
  26338. "text-transform",
  26339. "text-underline-offset",
  26340. "text-underline-position",
  26341. "textAlign",
  26342. "textAlignLast",
  26343. "textAnchor",
  26344. "textAutospace",
  26345. "textBaseline",
  26346. "textCombineUpright",
  26347. "textContent",
  26348. "textDecoration",
  26349. "textDecorationBlink",
  26350. "textDecorationColor",
  26351. "textDecorationLine",
  26352. "textDecorationLineThrough",
  26353. "textDecorationNone",
  26354. "textDecorationOverline",
  26355. "textDecorationSkipInk",
  26356. "textDecorationStyle",
  26357. "textDecorationThickness",
  26358. "textDecorationUnderline",
  26359. "textEmphasis",
  26360. "textEmphasisColor",
  26361. "textEmphasisPosition",
  26362. "textEmphasisStyle",
  26363. "textIndent",
  26364. "textJustify",
  26365. "textJustifyTrim",
  26366. "textKashida",
  26367. "textKashidaSpace",
  26368. "textLength",
  26369. "textOrientation",
  26370. "textOverflow",
  26371. "textRendering",
  26372. "textShadow",
  26373. "textTracks",
  26374. "textTransform",
  26375. "textUnderlineOffset",
  26376. "textUnderlinePosition",
  26377. "then",
  26378. "threadId",
  26379. "threshold",
  26380. "thresholds",
  26381. "tiltX",
  26382. "tiltY",
  26383. "time",
  26384. "timeEnd",
  26385. "timeLog",
  26386. "timeOrigin",
  26387. "timeRemaining",
  26388. "timeStamp",
  26389. "timecode",
  26390. "timeline",
  26391. "timelineTime",
  26392. "timeout",
  26393. "timestamp",
  26394. "timestampOffset",
  26395. "timing",
  26396. "title",
  26397. "to",
  26398. "toArray",
  26399. "toBlob",
  26400. "toDataURL",
  26401. "toDateString",
  26402. "toElement",
  26403. "toExponential",
  26404. "toFixed",
  26405. "toFloat32Array",
  26406. "toFloat64Array",
  26407. "toGMTString",
  26408. "toISOString",
  26409. "toJSON",
  26410. "toLocaleDateString",
  26411. "toLocaleFormat",
  26412. "toLocaleLowerCase",
  26413. "toLocaleString",
  26414. "toLocaleTimeString",
  26415. "toLocaleUpperCase",
  26416. "toLowerCase",
  26417. "toMatrix",
  26418. "toMethod",
  26419. "toPrecision",
  26420. "toPrimitive",
  26421. "toSdp",
  26422. "toSource",
  26423. "toStaticHTML",
  26424. "toString",
  26425. "toStringTag",
  26426. "toSum",
  26427. "toTimeString",
  26428. "toUTCString",
  26429. "toUpperCase",
  26430. "toggle",
  26431. "toggleAttribute",
  26432. "toggleLongPressEnabled",
  26433. "tone",
  26434. "toneBuffer",
  26435. "tooLong",
  26436. "tooShort",
  26437. "toolbar",
  26438. "top",
  26439. "topMargin",
  26440. "total",
  26441. "totalFrameDelay",
  26442. "totalVideoFrames",
  26443. "touch-action",
  26444. "touchAction",
  26445. "touched",
  26446. "touches",
  26447. "trace",
  26448. "track",
  26449. "trackVisibility",
  26450. "transaction",
  26451. "transactions",
  26452. "transceiver",
  26453. "transferControlToOffscreen",
  26454. "transferFromImageBitmap",
  26455. "transferImageBitmap",
  26456. "transferIn",
  26457. "transferOut",
  26458. "transferSize",
  26459. "transferToImageBitmap",
  26460. "transform",
  26461. "transform-box",
  26462. "transform-origin",
  26463. "transform-style",
  26464. "transformBox",
  26465. "transformFeedbackVaryings",
  26466. "transformOrigin",
  26467. "transformPoint",
  26468. "transformString",
  26469. "transformStyle",
  26470. "transformToDocument",
  26471. "transformToFragment",
  26472. "transition",
  26473. "transition-delay",
  26474. "transition-duration",
  26475. "transition-property",
  26476. "transition-timing-function",
  26477. "transitionDelay",
  26478. "transitionDuration",
  26479. "transitionProperty",
  26480. "transitionTimingFunction",
  26481. "translate",
  26482. "translateSelf",
  26483. "translationX",
  26484. "translationY",
  26485. "transport",
  26486. "trim",
  26487. "trimEnd",
  26488. "trimLeft",
  26489. "trimRight",
  26490. "trimStart",
  26491. "trueSpeed",
  26492. "trunc",
  26493. "truncate",
  26494. "trustedTypes",
  26495. "turn",
  26496. "twist",
  26497. "type",
  26498. "typeDetail",
  26499. "typeMismatch",
  26500. "typeMustMatch",
  26501. "types",
  26502. "u2f",
  26503. "ubound",
  26504. "uint16",
  26505. "uint32",
  26506. "uint8",
  26507. "uint8Clamped",
  26508. "undefined",
  26509. "unescape",
  26510. "uneval",
  26511. "unicode",
  26512. "unicode-bidi",
  26513. "unicodeBidi",
  26514. "unicodeRange",
  26515. "uniform1f",
  26516. "uniform1fv",
  26517. "uniform1i",
  26518. "uniform1iv",
  26519. "uniform1ui",
  26520. "uniform1uiv",
  26521. "uniform2f",
  26522. "uniform2fv",
  26523. "uniform2i",
  26524. "uniform2iv",
  26525. "uniform2ui",
  26526. "uniform2uiv",
  26527. "uniform3f",
  26528. "uniform3fv",
  26529. "uniform3i",
  26530. "uniform3iv",
  26531. "uniform3ui",
  26532. "uniform3uiv",
  26533. "uniform4f",
  26534. "uniform4fv",
  26535. "uniform4i",
  26536. "uniform4iv",
  26537. "uniform4ui",
  26538. "uniform4uiv",
  26539. "uniformBlockBinding",
  26540. "uniformMatrix2fv",
  26541. "uniformMatrix2x3fv",
  26542. "uniformMatrix2x4fv",
  26543. "uniformMatrix3fv",
  26544. "uniformMatrix3x2fv",
  26545. "uniformMatrix3x4fv",
  26546. "uniformMatrix4fv",
  26547. "uniformMatrix4x2fv",
  26548. "uniformMatrix4x3fv",
  26549. "unique",
  26550. "uniqueID",
  26551. "uniqueNumber",
  26552. "unit",
  26553. "unitType",
  26554. "units",
  26555. "unloadEventEnd",
  26556. "unloadEventStart",
  26557. "unlock",
  26558. "unmount",
  26559. "unobserve",
  26560. "unpause",
  26561. "unpauseAnimations",
  26562. "unreadCount",
  26563. "unregister",
  26564. "unregisterContentHandler",
  26565. "unregisterProtocolHandler",
  26566. "unscopables",
  26567. "unselectable",
  26568. "unshift",
  26569. "unsubscribe",
  26570. "unsuspendRedraw",
  26571. "unsuspendRedrawAll",
  26572. "unwatch",
  26573. "unwrapKey",
  26574. "upDegrees",
  26575. "upX",
  26576. "upY",
  26577. "upZ",
  26578. "update",
  26579. "updateCommands",
  26580. "updateIce",
  26581. "updateInterval",
  26582. "updatePlaybackRate",
  26583. "updateRenderState",
  26584. "updateSettings",
  26585. "updateTiming",
  26586. "updateViaCache",
  26587. "updateWith",
  26588. "updated",
  26589. "updating",
  26590. "upgrade",
  26591. "upload",
  26592. "uploadTotal",
  26593. "uploaded",
  26594. "upper",
  26595. "upperBound",
  26596. "upperOpen",
  26597. "uri",
  26598. "url",
  26599. "urn",
  26600. "urns",
  26601. "usages",
  26602. "usb",
  26603. "usbVersionMajor",
  26604. "usbVersionMinor",
  26605. "usbVersionSubminor",
  26606. "useCurrentView",
  26607. "useMap",
  26608. "useProgram",
  26609. "usedSpace",
  26610. "user-select",
  26611. "userActivation",
  26612. "userAgent",
  26613. "userAgentData",
  26614. "userChoice",
  26615. "userHandle",
  26616. "userHint",
  26617. "userLanguage",
  26618. "userSelect",
  26619. "userVisibleOnly",
  26620. "username",
  26621. "usernameFragment",
  26622. "utterance",
  26623. "uuid",
  26624. "v8BreakIterator",
  26625. "vAlign",
  26626. "vLink",
  26627. "valid",
  26628. "validate",
  26629. "validateProgram",
  26630. "validationMessage",
  26631. "validity",
  26632. "value",
  26633. "valueAsDate",
  26634. "valueAsNumber",
  26635. "valueAsString",
  26636. "valueInSpecifiedUnits",
  26637. "valueMissing",
  26638. "valueOf",
  26639. "valueText",
  26640. "valueType",
  26641. "values",
  26642. "variable",
  26643. "variant",
  26644. "variationSettings",
  26645. "vector-effect",
  26646. "vectorEffect",
  26647. "velocityAngular",
  26648. "velocityExpansion",
  26649. "velocityX",
  26650. "velocityY",
  26651. "vendor",
  26652. "vendorId",
  26653. "vendorSub",
  26654. "verify",
  26655. "version",
  26656. "vertexAttrib1f",
  26657. "vertexAttrib1fv",
  26658. "vertexAttrib2f",
  26659. "vertexAttrib2fv",
  26660. "vertexAttrib3f",
  26661. "vertexAttrib3fv",
  26662. "vertexAttrib4f",
  26663. "vertexAttrib4fv",
  26664. "vertexAttribDivisor",
  26665. "vertexAttribDivisorANGLE",
  26666. "vertexAttribI4i",
  26667. "vertexAttribI4iv",
  26668. "vertexAttribI4ui",
  26669. "vertexAttribI4uiv",
  26670. "vertexAttribIPointer",
  26671. "vertexAttribPointer",
  26672. "vertical",
  26673. "vertical-align",
  26674. "verticalAlign",
  26675. "verticalOverflow",
  26676. "vh",
  26677. "vibrate",
  26678. "vibrationActuator",
  26679. "videoBitsPerSecond",
  26680. "videoHeight",
  26681. "videoTracks",
  26682. "videoWidth",
  26683. "view",
  26684. "viewBox",
  26685. "viewBoxString",
  26686. "viewTarget",
  26687. "viewTargetString",
  26688. "viewport",
  26689. "viewportAnchorX",
  26690. "viewportAnchorY",
  26691. "viewportElement",
  26692. "views",
  26693. "violatedDirective",
  26694. "visibility",
  26695. "visibilityState",
  26696. "visible",
  26697. "visualViewport",
  26698. "vlinkColor",
  26699. "vmax",
  26700. "vmin",
  26701. "voice",
  26702. "voiceURI",
  26703. "volume",
  26704. "vrml",
  26705. "vspace",
  26706. "vw",
  26707. "w",
  26708. "wait",
  26709. "waitSync",
  26710. "waiting",
  26711. "wake",
  26712. "wakeLock",
  26713. "wand",
  26714. "warn",
  26715. "wasClean",
  26716. "wasDiscarded",
  26717. "watch",
  26718. "watchAvailability",
  26719. "watchPosition",
  26720. "webdriver",
  26721. "webkitAddKey",
  26722. "webkitAlignContent",
  26723. "webkitAlignItems",
  26724. "webkitAlignSelf",
  26725. "webkitAnimation",
  26726. "webkitAnimationDelay",
  26727. "webkitAnimationDirection",
  26728. "webkitAnimationDuration",
  26729. "webkitAnimationFillMode",
  26730. "webkitAnimationIterationCount",
  26731. "webkitAnimationName",
  26732. "webkitAnimationPlayState",
  26733. "webkitAnimationTimingFunction",
  26734. "webkitAppearance",
  26735. "webkitAudioContext",
  26736. "webkitAudioDecodedByteCount",
  26737. "webkitAudioPannerNode",
  26738. "webkitBackfaceVisibility",
  26739. "webkitBackground",
  26740. "webkitBackgroundAttachment",
  26741. "webkitBackgroundClip",
  26742. "webkitBackgroundColor",
  26743. "webkitBackgroundImage",
  26744. "webkitBackgroundOrigin",
  26745. "webkitBackgroundPosition",
  26746. "webkitBackgroundPositionX",
  26747. "webkitBackgroundPositionY",
  26748. "webkitBackgroundRepeat",
  26749. "webkitBackgroundSize",
  26750. "webkitBackingStorePixelRatio",
  26751. "webkitBorderBottomLeftRadius",
  26752. "webkitBorderBottomRightRadius",
  26753. "webkitBorderImage",
  26754. "webkitBorderImageOutset",
  26755. "webkitBorderImageRepeat",
  26756. "webkitBorderImageSlice",
  26757. "webkitBorderImageSource",
  26758. "webkitBorderImageWidth",
  26759. "webkitBorderRadius",
  26760. "webkitBorderTopLeftRadius",
  26761. "webkitBorderTopRightRadius",
  26762. "webkitBoxAlign",
  26763. "webkitBoxDirection",
  26764. "webkitBoxFlex",
  26765. "webkitBoxOrdinalGroup",
  26766. "webkitBoxOrient",
  26767. "webkitBoxPack",
  26768. "webkitBoxShadow",
  26769. "webkitBoxSizing",
  26770. "webkitCancelAnimationFrame",
  26771. "webkitCancelFullScreen",
  26772. "webkitCancelKeyRequest",
  26773. "webkitCancelRequestAnimationFrame",
  26774. "webkitClearResourceTimings",
  26775. "webkitClosedCaptionsVisible",
  26776. "webkitConvertPointFromNodeToPage",
  26777. "webkitConvertPointFromPageToNode",
  26778. "webkitCreateShadowRoot",
  26779. "webkitCurrentFullScreenElement",
  26780. "webkitCurrentPlaybackTargetIsWireless",
  26781. "webkitDecodedFrameCount",
  26782. "webkitDirectionInvertedFromDevice",
  26783. "webkitDisplayingFullscreen",
  26784. "webkitDroppedFrameCount",
  26785. "webkitEnterFullScreen",
  26786. "webkitEnterFullscreen",
  26787. "webkitEntries",
  26788. "webkitExitFullScreen",
  26789. "webkitExitFullscreen",
  26790. "webkitExitPointerLock",
  26791. "webkitFilter",
  26792. "webkitFlex",
  26793. "webkitFlexBasis",
  26794. "webkitFlexDirection",
  26795. "webkitFlexFlow",
  26796. "webkitFlexGrow",
  26797. "webkitFlexShrink",
  26798. "webkitFlexWrap",
  26799. "webkitFullScreenKeyboardInputAllowed",
  26800. "webkitFullscreenElement",
  26801. "webkitFullscreenEnabled",
  26802. "webkitGenerateKeyRequest",
  26803. "webkitGetAsEntry",
  26804. "webkitGetDatabaseNames",
  26805. "webkitGetEntries",
  26806. "webkitGetEntriesByName",
  26807. "webkitGetEntriesByType",
  26808. "webkitGetFlowByName",
  26809. "webkitGetGamepads",
  26810. "webkitGetImageDataHD",
  26811. "webkitGetNamedFlows",
  26812. "webkitGetRegionFlowRanges",
  26813. "webkitGetUserMedia",
  26814. "webkitHasClosedCaptions",
  26815. "webkitHidden",
  26816. "webkitIDBCursor",
  26817. "webkitIDBDatabase",
  26818. "webkitIDBDatabaseError",
  26819. "webkitIDBDatabaseException",
  26820. "webkitIDBFactory",
  26821. "webkitIDBIndex",
  26822. "webkitIDBKeyRange",
  26823. "webkitIDBObjectStore",
  26824. "webkitIDBRequest",
  26825. "webkitIDBTransaction",
  26826. "webkitImageSmoothingEnabled",
  26827. "webkitIndexedDB",
  26828. "webkitInitMessageEvent",
  26829. "webkitIsFullScreen",
  26830. "webkitJustifyContent",
  26831. "webkitKeys",
  26832. "webkitLineClamp",
  26833. "webkitLineDashOffset",
  26834. "webkitLockOrientation",
  26835. "webkitMask",
  26836. "webkitMaskClip",
  26837. "webkitMaskComposite",
  26838. "webkitMaskImage",
  26839. "webkitMaskOrigin",
  26840. "webkitMaskPosition",
  26841. "webkitMaskPositionX",
  26842. "webkitMaskPositionY",
  26843. "webkitMaskRepeat",
  26844. "webkitMaskSize",
  26845. "webkitMatchesSelector",
  26846. "webkitMediaStream",
  26847. "webkitNotifications",
  26848. "webkitOfflineAudioContext",
  26849. "webkitOrder",
  26850. "webkitOrientation",
  26851. "webkitPeerConnection00",
  26852. "webkitPersistentStorage",
  26853. "webkitPerspective",
  26854. "webkitPerspectiveOrigin",
  26855. "webkitPointerLockElement",
  26856. "webkitPostMessage",
  26857. "webkitPreservesPitch",
  26858. "webkitPutImageDataHD",
  26859. "webkitRTCPeerConnection",
  26860. "webkitRegionOverset",
  26861. "webkitRelativePath",
  26862. "webkitRequestAnimationFrame",
  26863. "webkitRequestFileSystem",
  26864. "webkitRequestFullScreen",
  26865. "webkitRequestFullscreen",
  26866. "webkitRequestPointerLock",
  26867. "webkitResolveLocalFileSystemURL",
  26868. "webkitSetMediaKeys",
  26869. "webkitSetResourceTimingBufferSize",
  26870. "webkitShadowRoot",
  26871. "webkitShowPlaybackTargetPicker",
  26872. "webkitSlice",
  26873. "webkitSpeechGrammar",
  26874. "webkitSpeechGrammarList",
  26875. "webkitSpeechRecognition",
  26876. "webkitSpeechRecognitionError",
  26877. "webkitSpeechRecognitionEvent",
  26878. "webkitStorageInfo",
  26879. "webkitSupportsFullscreen",
  26880. "webkitTemporaryStorage",
  26881. "webkitTextFillColor",
  26882. "webkitTextSizeAdjust",
  26883. "webkitTextStroke",
  26884. "webkitTextStrokeColor",
  26885. "webkitTextStrokeWidth",
  26886. "webkitTransform",
  26887. "webkitTransformOrigin",
  26888. "webkitTransformStyle",
  26889. "webkitTransition",
  26890. "webkitTransitionDelay",
  26891. "webkitTransitionDuration",
  26892. "webkitTransitionProperty",
  26893. "webkitTransitionTimingFunction",
  26894. "webkitURL",
  26895. "webkitUnlockOrientation",
  26896. "webkitUserSelect",
  26897. "webkitVideoDecodedByteCount",
  26898. "webkitVisibilityState",
  26899. "webkitWirelessVideoPlaybackDisabled",
  26900. "webkitdirectory",
  26901. "webkitdropzone",
  26902. "webstore",
  26903. "weight",
  26904. "whatToShow",
  26905. "wheelDelta",
  26906. "wheelDeltaX",
  26907. "wheelDeltaY",
  26908. "whenDefined",
  26909. "which",
  26910. "white-space",
  26911. "whiteSpace",
  26912. "wholeText",
  26913. "widows",
  26914. "width",
  26915. "will-change",
  26916. "willChange",
  26917. "willValidate",
  26918. "window",
  26919. "withCredentials",
  26920. "word-break",
  26921. "word-spacing",
  26922. "word-wrap",
  26923. "wordBreak",
  26924. "wordSpacing",
  26925. "wordWrap",
  26926. "workerStart",
  26927. "wow64",
  26928. "wrap",
  26929. "wrapKey",
  26930. "writable",
  26931. "writableAuxiliaries",
  26932. "write",
  26933. "writeText",
  26934. "writeValue",
  26935. "writeWithoutResponse",
  26936. "writeln",
  26937. "writing-mode",
  26938. "writingMode",
  26939. "x",
  26940. "x1",
  26941. "x2",
  26942. "xChannelSelector",
  26943. "xmlEncoding",
  26944. "xmlStandalone",
  26945. "xmlVersion",
  26946. "xmlbase",
  26947. "xmllang",
  26948. "xmlspace",
  26949. "xor",
  26950. "xr",
  26951. "y",
  26952. "y1",
  26953. "y2",
  26954. "yChannelSelector",
  26955. "yandex",
  26956. "z",
  26957. "z-index",
  26958. "zIndex",
  26959. "zoom",
  26960. "zoomAndPan",
  26961. "zoomRectScreen",
  26962. ];
  26963. /***********************************************************************
  26964. A JavaScript tokenizer / parser / beautifier / compressor.
  26965. https://github.com/mishoo/UglifyJS2
  26966. -------------------------------- (C) ---------------------------------
  26967. Author: Mihai Bazon
  26968. <mihai.bazon@gmail.com>
  26969. http://mihai.bazon.net/blog
  26970. Distributed under the BSD license:
  26971. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  26972. Redistribution and use in source and binary forms, with or without
  26973. modification, are permitted provided that the following conditions
  26974. are met:
  26975. * Redistributions of source code must retain the above
  26976. copyright notice, this list of conditions and the following
  26977. disclaimer.
  26978. * Redistributions in binary form must reproduce the above
  26979. copyright notice, this list of conditions and the following
  26980. disclaimer in the documentation and/or other materials
  26981. provided with the distribution.
  26982. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  26983. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26984. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  26985. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  26986. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  26987. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26988. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26989. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26990. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  26991. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  26992. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26993. SUCH DAMAGE.
  26994. ***********************************************************************/
  26995. function find_builtins(reserved) {
  26996. domprops.forEach(add);
  26997. // Compatibility fix for some standard defined globals not defined on every js environment
  26998. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  26999. var objects = {};
  27000. var global_ref = typeof global === "object" ? global : self;
  27001. new_globals.forEach(function (new_global) {
  27002. objects[new_global] = global_ref[new_global] || function() {};
  27003. });
  27004. [
  27005. "null",
  27006. "true",
  27007. "false",
  27008. "NaN",
  27009. "Infinity",
  27010. "-Infinity",
  27011. "undefined",
  27012. ].forEach(add);
  27013. [ Object, Array, Function, Number,
  27014. String, Boolean, Error, Math,
  27015. Date, RegExp, objects.Symbol, ArrayBuffer,
  27016. DataView, decodeURI, decodeURIComponent,
  27017. encodeURI, encodeURIComponent, eval, EvalError,
  27018. Float32Array, Float64Array, Int8Array, Int16Array,
  27019. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  27020. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  27021. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  27022. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  27023. objects.WeakMap, objects.WeakSet
  27024. ].forEach(function(ctor) {
  27025. Object.getOwnPropertyNames(ctor).map(add);
  27026. if (ctor.prototype) {
  27027. Object.getOwnPropertyNames(ctor.prototype).map(add);
  27028. }
  27029. });
  27030. function add(name) {
  27031. reserved.add(name);
  27032. }
  27033. }
  27034. function reserve_quoted_keys(ast, reserved) {
  27035. function add(name) {
  27036. push_uniq(reserved, name);
  27037. }
  27038. ast.walk(new TreeWalker(function(node) {
  27039. if (node instanceof AST_ObjectKeyVal && node.quote) {
  27040. add(node.key);
  27041. } else if (node instanceof AST_ObjectProperty && node.quote) {
  27042. add(node.key.name);
  27043. } else if (node instanceof AST_Sub) {
  27044. addStrings(node.property, add);
  27045. }
  27046. }));
  27047. }
  27048. function addStrings(node, add) {
  27049. node.walk(new TreeWalker(function(node) {
  27050. if (node instanceof AST_Sequence) {
  27051. addStrings(node.tail_node(), add);
  27052. } else if (node instanceof AST_String) {
  27053. add(node.value);
  27054. } else if (node instanceof AST_Conditional) {
  27055. addStrings(node.consequent, add);
  27056. addStrings(node.alternative, add);
  27057. }
  27058. return true;
  27059. }));
  27060. }
  27061. function mangle_private_properties(ast, options) {
  27062. var cprivate = -1;
  27063. var private_cache = new Map();
  27064. var nth_identifier = options.nth_identifier || base54;
  27065. ast = ast.transform(new TreeTransformer(function(node) {
  27066. if (
  27067. node instanceof AST_ClassPrivateProperty
  27068. || node instanceof AST_PrivateMethod
  27069. || node instanceof AST_PrivateGetter
  27070. || node instanceof AST_PrivateSetter
  27071. ) {
  27072. node.key.name = mangle_private(node.key.name);
  27073. } else if (node instanceof AST_DotHash) {
  27074. node.property = mangle_private(node.property);
  27075. }
  27076. }));
  27077. return ast;
  27078. function mangle_private(name) {
  27079. let mangled = private_cache.get(name);
  27080. if (!mangled) {
  27081. mangled = nth_identifier.get(++cprivate);
  27082. private_cache.set(name, mangled);
  27083. }
  27084. return mangled;
  27085. }
  27086. }
  27087. function mangle_properties(ast, options) {
  27088. options = defaults(options, {
  27089. builtins: false,
  27090. cache: null,
  27091. debug: false,
  27092. keep_quoted: false,
  27093. nth_identifier: base54,
  27094. only_cache: false,
  27095. regex: null,
  27096. reserved: null,
  27097. undeclared: false,
  27098. }, true);
  27099. var nth_identifier = options.nth_identifier;
  27100. var reserved_option = options.reserved;
  27101. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  27102. var reserved = new Set(reserved_option);
  27103. if (!options.builtins) find_builtins(reserved);
  27104. var cname = -1;
  27105. var cache;
  27106. if (options.cache) {
  27107. cache = options.cache.props;
  27108. } else {
  27109. cache = new Map();
  27110. }
  27111. var regex = options.regex && new RegExp(options.regex);
  27112. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  27113. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  27114. // the same as passing an empty string.
  27115. var debug = options.debug !== false;
  27116. var debug_name_suffix;
  27117. if (debug) {
  27118. debug_name_suffix = (options.debug === true ? "" : options.debug);
  27119. }
  27120. var names_to_mangle = new Set();
  27121. var unmangleable = new Set();
  27122. // Track each already-mangled name to prevent nth_identifier from generating
  27123. // the same name.
  27124. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  27125. var keep_quoted = !!options.keep_quoted;
  27126. // step 1: find candidates to mangle
  27127. ast.walk(new TreeWalker(function(node) {
  27128. if (
  27129. node instanceof AST_ClassPrivateProperty
  27130. || node instanceof AST_PrivateMethod
  27131. || node instanceof AST_PrivateGetter
  27132. || node instanceof AST_PrivateSetter
  27133. || node instanceof AST_DotHash
  27134. ) ; else if (node instanceof AST_ObjectKeyVal) {
  27135. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  27136. add(node.key);
  27137. }
  27138. } else if (node instanceof AST_ObjectProperty) {
  27139. // setter or getter, since KeyVal is handled above
  27140. if (!keep_quoted || !node.quote) {
  27141. add(node.key.name);
  27142. }
  27143. } else if (node instanceof AST_Dot) {
  27144. var declared = !!options.undeclared;
  27145. if (!declared) {
  27146. var root = node;
  27147. while (root.expression) {
  27148. root = root.expression;
  27149. }
  27150. declared = !(root.thedef && root.thedef.undeclared);
  27151. }
  27152. if (declared &&
  27153. (!keep_quoted || !node.quote)) {
  27154. add(node.property);
  27155. }
  27156. } else if (node instanceof AST_Sub) {
  27157. if (!keep_quoted) {
  27158. addStrings(node.property, add);
  27159. }
  27160. } else if (node instanceof AST_Call
  27161. && node.expression.print_to_string() == "Object.defineProperty") {
  27162. addStrings(node.args[1], add);
  27163. } else if (node instanceof AST_Binary && node.operator === "in") {
  27164. addStrings(node.left, add);
  27165. }
  27166. }));
  27167. // step 2: transform the tree, renaming properties
  27168. return ast.transform(new TreeTransformer(function(node) {
  27169. if (
  27170. node instanceof AST_ClassPrivateProperty
  27171. || node instanceof AST_PrivateMethod
  27172. || node instanceof AST_PrivateGetter
  27173. || node instanceof AST_PrivateSetter
  27174. || node instanceof AST_DotHash
  27175. ) ; else if (node instanceof AST_ObjectKeyVal) {
  27176. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  27177. node.key = mangle(node.key);
  27178. }
  27179. } else if (node instanceof AST_ObjectProperty) {
  27180. // setter, getter, method or class field
  27181. if (!keep_quoted || !node.quote) {
  27182. node.key.name = mangle(node.key.name);
  27183. }
  27184. } else if (node instanceof AST_Dot) {
  27185. if (!keep_quoted || !node.quote) {
  27186. node.property = mangle(node.property);
  27187. }
  27188. } else if (!keep_quoted && node instanceof AST_Sub) {
  27189. node.property = mangleStrings(node.property);
  27190. } else if (node instanceof AST_Call
  27191. && node.expression.print_to_string() == "Object.defineProperty") {
  27192. node.args[1] = mangleStrings(node.args[1]);
  27193. } else if (node instanceof AST_Binary && node.operator === "in") {
  27194. node.left = mangleStrings(node.left);
  27195. }
  27196. }));
  27197. // only function declarations after this line
  27198. function can_mangle(name) {
  27199. if (unmangleable.has(name)) return false;
  27200. if (reserved.has(name)) return false;
  27201. if (options.only_cache) {
  27202. return cache.has(name);
  27203. }
  27204. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  27205. return true;
  27206. }
  27207. function should_mangle(name) {
  27208. if (regex && !regex.test(name)) return false;
  27209. if (reserved.has(name)) return false;
  27210. return cache.has(name)
  27211. || names_to_mangle.has(name);
  27212. }
  27213. function add(name) {
  27214. if (can_mangle(name))
  27215. names_to_mangle.add(name);
  27216. if (!should_mangle(name)) {
  27217. unmangleable.add(name);
  27218. }
  27219. }
  27220. function mangle(name) {
  27221. if (!should_mangle(name)) {
  27222. return name;
  27223. }
  27224. var mangled = cache.get(name);
  27225. if (!mangled) {
  27226. if (debug) {
  27227. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  27228. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  27229. if (can_mangle(debug_mangled)) {
  27230. mangled = debug_mangled;
  27231. }
  27232. }
  27233. // either debug mode is off, or it is on and we could not use the mangled name
  27234. if (!mangled) {
  27235. do {
  27236. mangled = nth_identifier.get(++cname);
  27237. } while (!can_mangle(mangled));
  27238. }
  27239. cache.set(name, mangled);
  27240. }
  27241. return mangled;
  27242. }
  27243. function mangleStrings(node) {
  27244. return node.transform(new TreeTransformer(function(node) {
  27245. if (node instanceof AST_Sequence) {
  27246. var last = node.expressions.length - 1;
  27247. node.expressions[last] = mangleStrings(node.expressions[last]);
  27248. } else if (node instanceof AST_String) {
  27249. node.value = mangle(node.value);
  27250. } else if (node instanceof AST_Conditional) {
  27251. node.consequent = mangleStrings(node.consequent);
  27252. node.alternative = mangleStrings(node.alternative);
  27253. }
  27254. return node;
  27255. }));
  27256. }
  27257. }
  27258. var to_ascii = typeof atob == "undefined" ? function(b64) {
  27259. return Buffer.from(b64, "base64").toString();
  27260. } : atob;
  27261. var to_base64 = typeof btoa == "undefined" ? function(str) {
  27262. return Buffer.from(str).toString("base64");
  27263. } : btoa;
  27264. function read_source_map(code) {
  27265. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  27266. if (!match) {
  27267. console.warn("inline source map not found");
  27268. return null;
  27269. }
  27270. return to_ascii(match[2]);
  27271. }
  27272. function set_shorthand(name, options, keys) {
  27273. if (options[name]) {
  27274. keys.forEach(function(key) {
  27275. if (options[key]) {
  27276. if (typeof options[key] != "object") options[key] = {};
  27277. if (!(name in options[key])) options[key][name] = options[name];
  27278. }
  27279. });
  27280. }
  27281. }
  27282. function init_cache(cache) {
  27283. if (!cache) return;
  27284. if (!("props" in cache)) {
  27285. cache.props = new Map();
  27286. } else if (!(cache.props instanceof Map)) {
  27287. cache.props = map_from_object(cache.props);
  27288. }
  27289. }
  27290. function cache_to_json(cache) {
  27291. return {
  27292. props: map_to_object(cache.props)
  27293. };
  27294. }
  27295. function log_input(files, options, fs, debug_folder) {
  27296. if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
  27297. return;
  27298. }
  27299. try {
  27300. fs.mkdirSync(debug_folder);
  27301. } catch (e) {
  27302. if (e.code !== "EEXIST") throw e;
  27303. }
  27304. const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
  27305. options = options || {};
  27306. const options_str = JSON.stringify(options, (_key, thing) => {
  27307. if (typeof thing === "function") return "[Function " + thing.toString() + "]";
  27308. if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
  27309. return thing;
  27310. }, 4);
  27311. const files_str = (file) => {
  27312. if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
  27313. return JSON.stringify(file, null, 2);
  27314. } else if (typeof file === "object") {
  27315. return Object.keys(file)
  27316. .map((key) => key + ": " + files_str(file[key]))
  27317. .join("\n\n");
  27318. } else if (typeof file === "string") {
  27319. return "```\n" + file + "\n```";
  27320. } else {
  27321. return file; // What do?
  27322. }
  27323. };
  27324. fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
  27325. }
  27326. async function minify(files, options, _fs_module) {
  27327. if (
  27328. _fs_module
  27329. && typeof process === "object"
  27330. && process.env
  27331. && typeof process.env.TERSER_DEBUG_DIR === "string"
  27332. ) {
  27333. log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
  27334. }
  27335. options = defaults(options, {
  27336. compress: {},
  27337. ecma: undefined,
  27338. enclose: false,
  27339. ie8: false,
  27340. keep_classnames: undefined,
  27341. keep_fnames: false,
  27342. mangle: {},
  27343. module: false,
  27344. nameCache: null,
  27345. output: null,
  27346. format: null,
  27347. parse: {},
  27348. rename: undefined,
  27349. safari10: false,
  27350. sourceMap: false,
  27351. spidermonkey: false,
  27352. timings: false,
  27353. toplevel: false,
  27354. warnings: false,
  27355. wrap: false,
  27356. }, true);
  27357. var timings = options.timings && {
  27358. start: Date.now()
  27359. };
  27360. if (options.keep_classnames === undefined) {
  27361. options.keep_classnames = options.keep_fnames;
  27362. }
  27363. if (options.rename === undefined) {
  27364. options.rename = options.compress && options.mangle;
  27365. }
  27366. if (options.output && options.format) {
  27367. throw new Error("Please only specify either output or format option, preferrably format.");
  27368. }
  27369. options.format = options.format || options.output || {};
  27370. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  27371. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  27372. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  27373. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  27374. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  27375. set_shorthand("safari10", options, [ "mangle", "format" ]);
  27376. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  27377. set_shorthand("warnings", options, [ "compress" ]); // legacy
  27378. var quoted_props;
  27379. if (options.mangle) {
  27380. options.mangle = defaults(options.mangle, {
  27381. cache: options.nameCache && (options.nameCache.vars || {}),
  27382. eval: false,
  27383. ie8: false,
  27384. keep_classnames: false,
  27385. keep_fnames: false,
  27386. module: false,
  27387. nth_identifier: base54,
  27388. properties: false,
  27389. reserved: [],
  27390. safari10: false,
  27391. toplevel: false,
  27392. }, true);
  27393. if (options.mangle.properties) {
  27394. if (typeof options.mangle.properties != "object") {
  27395. options.mangle.properties = {};
  27396. }
  27397. if (options.mangle.properties.keep_quoted) {
  27398. quoted_props = options.mangle.properties.reserved;
  27399. if (!Array.isArray(quoted_props)) quoted_props = [];
  27400. options.mangle.properties.reserved = quoted_props;
  27401. }
  27402. if (options.nameCache && !("cache" in options.mangle.properties)) {
  27403. options.mangle.properties.cache = options.nameCache.props || {};
  27404. }
  27405. }
  27406. init_cache(options.mangle.cache);
  27407. init_cache(options.mangle.properties.cache);
  27408. }
  27409. if (options.sourceMap) {
  27410. options.sourceMap = defaults(options.sourceMap, {
  27411. asObject: false,
  27412. content: null,
  27413. filename: null,
  27414. includeSources: false,
  27415. root: null,
  27416. url: null,
  27417. }, true);
  27418. }
  27419. if (timings) timings.parse = Date.now();
  27420. var toplevel;
  27421. if (files instanceof AST_Toplevel) {
  27422. toplevel = files;
  27423. } else {
  27424. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  27425. files = [ files ];
  27426. }
  27427. options.parse = options.parse || {};
  27428. options.parse.toplevel = null;
  27429. if (options.parse.spidermonkey) {
  27430. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  27431. if (!toplevel) return files[name];
  27432. toplevel.body = toplevel.body.concat(files[name].body);
  27433. return toplevel;
  27434. }, null));
  27435. } else {
  27436. delete options.parse.spidermonkey;
  27437. for (var name in files) if (HOP(files, name)) {
  27438. options.parse.filename = name;
  27439. options.parse.toplevel = parse(files[name], options.parse);
  27440. if (options.sourceMap && options.sourceMap.content == "inline") {
  27441. if (Object.keys(files).length > 1)
  27442. throw new Error("inline source map only works with singular input");
  27443. options.sourceMap.content = read_source_map(files[name]);
  27444. }
  27445. }
  27446. }
  27447. toplevel = options.parse.toplevel;
  27448. }
  27449. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  27450. reserve_quoted_keys(toplevel, quoted_props);
  27451. }
  27452. if (options.wrap) {
  27453. toplevel = toplevel.wrap_commonjs(options.wrap);
  27454. }
  27455. if (options.enclose) {
  27456. toplevel = toplevel.wrap_enclose(options.enclose);
  27457. }
  27458. if (timings) timings.rename = Date.now();
  27459. if (timings) timings.compress = Date.now();
  27460. if (options.compress) {
  27461. toplevel = new Compressor(options.compress, {
  27462. mangle_options: options.mangle
  27463. }).compress(toplevel);
  27464. }
  27465. if (timings) timings.scope = Date.now();
  27466. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  27467. if (timings) timings.mangle = Date.now();
  27468. if (options.mangle) {
  27469. toplevel.compute_char_frequency(options.mangle);
  27470. toplevel.mangle_names(options.mangle);
  27471. toplevel = mangle_private_properties(toplevel, options.mangle);
  27472. }
  27473. if (timings) timings.properties = Date.now();
  27474. if (options.mangle && options.mangle.properties) {
  27475. toplevel = mangle_properties(toplevel, options.mangle.properties);
  27476. }
  27477. if (timings) timings.format = Date.now();
  27478. var result = {};
  27479. if (options.format.ast) {
  27480. result.ast = toplevel;
  27481. }
  27482. if (options.format.spidermonkey) {
  27483. result.ast = toplevel.to_mozilla_ast();
  27484. }
  27485. if (!HOP(options.format, "code") || options.format.code) {
  27486. if (options.sourceMap) {
  27487. options.format.source_map = await SourceMap({
  27488. file: options.sourceMap.filename,
  27489. orig: options.sourceMap.content,
  27490. root: options.sourceMap.root
  27491. });
  27492. if (options.sourceMap.includeSources) {
  27493. if (files instanceof AST_Toplevel) {
  27494. throw new Error("original source content unavailable");
  27495. } else for (var name in files) if (HOP(files, name)) {
  27496. options.format.source_map.get().setSourceContent(name, files[name]);
  27497. }
  27498. }
  27499. }
  27500. delete options.format.ast;
  27501. delete options.format.code;
  27502. delete options.format.spidermonkey;
  27503. var stream = OutputStream(options.format);
  27504. toplevel.print(stream);
  27505. result.code = stream.get();
  27506. if (options.sourceMap) {
  27507. if(options.sourceMap.asObject) {
  27508. result.map = options.format.source_map.get().toJSON();
  27509. } else {
  27510. result.map = options.format.source_map.toString();
  27511. }
  27512. if (options.sourceMap.url == "inline") {
  27513. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  27514. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  27515. } else if (options.sourceMap.url) {
  27516. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  27517. }
  27518. }
  27519. }
  27520. if (options.nameCache && options.mangle) {
  27521. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  27522. if (options.mangle.properties && options.mangle.properties.cache) {
  27523. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  27524. }
  27525. }
  27526. if (options.format && options.format.source_map) {
  27527. options.format.source_map.destroy();
  27528. }
  27529. if (timings) {
  27530. timings.end = Date.now();
  27531. result.timings = {
  27532. parse: 1e-3 * (timings.rename - timings.parse),
  27533. rename: 1e-3 * (timings.compress - timings.rename),
  27534. compress: 1e-3 * (timings.scope - timings.compress),
  27535. scope: 1e-3 * (timings.mangle - timings.scope),
  27536. mangle: 1e-3 * (timings.properties - timings.mangle),
  27537. properties: 1e-3 * (timings.format - timings.properties),
  27538. format: 1e-3 * (timings.end - timings.format),
  27539. total: 1e-3 * (timings.end - timings.start)
  27540. };
  27541. }
  27542. return result;
  27543. }
  27544. async function run_cli({ program, packageJson, fs, path }) {
  27545. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  27546. var files = {};
  27547. var options = {
  27548. compress: false,
  27549. mangle: false
  27550. };
  27551. const default_options = await _default_options();
  27552. program.version(packageJson.name + " " + packageJson.version);
  27553. program.parseArgv = program.parse;
  27554. program.parse = undefined;
  27555. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  27556. else if (process.argv.includes("options")) program.helpInformation = function() {
  27557. var text = [];
  27558. for (var option in default_options) {
  27559. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  27560. text.push(format_object(default_options[option]));
  27561. text.push("");
  27562. }
  27563. return text.join("\n");
  27564. };
  27565. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  27566. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  27567. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  27568. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  27569. program.option("-f, --format [options]", "Format options.", parse_js());
  27570. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  27571. program.option("-o, --output <file>", "Output file (default STDOUT).");
  27572. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  27573. program.option("--config-file <file>", "Read minify() options from JSON file.");
  27574. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  27575. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  27576. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  27577. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  27578. program.option("--keep-classnames", "Do not mangle/drop class names.");
  27579. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  27580. program.option("--module", "Input is an ES6 module");
  27581. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  27582. program.option("--rename", "Force symbol expansion.");
  27583. program.option("--no-rename", "Disable symbol expansion.");
  27584. program.option("--safari10", "Support non-standard Safari 10.");
  27585. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  27586. program.option("--timings", "Display operations run time on STDERR.");
  27587. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  27588. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  27589. program.arguments("[files...]").parseArgv(process.argv);
  27590. if (program.configFile) {
  27591. options = JSON.parse(read_file(program.configFile));
  27592. }
  27593. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  27594. fatal("ERROR: cannot write source map to STDOUT");
  27595. }
  27596. [
  27597. "compress",
  27598. "enclose",
  27599. "ie8",
  27600. "mangle",
  27601. "module",
  27602. "safari10",
  27603. "sourceMap",
  27604. "toplevel",
  27605. "wrap"
  27606. ].forEach(function(name) {
  27607. if (name in program) {
  27608. options[name] = program[name];
  27609. }
  27610. });
  27611. if ("ecma" in program) {
  27612. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  27613. const ecma = program.ecma | 0;
  27614. if (ecma > 5 && ecma < 2015)
  27615. options.ecma = ecma + 2009;
  27616. else
  27617. options.ecma = ecma;
  27618. }
  27619. if (program.format || program.beautify) {
  27620. const chosenOption = program.format || program.beautify;
  27621. options.format = typeof chosenOption === "object" ? chosenOption : {};
  27622. }
  27623. if (program.comments) {
  27624. if (typeof options.format != "object") options.format = {};
  27625. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  27626. }
  27627. if (program.define) {
  27628. if (typeof options.compress != "object") options.compress = {};
  27629. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  27630. for (var expr in program.define) {
  27631. options.compress.global_defs[expr] = program.define[expr];
  27632. }
  27633. }
  27634. if (program.keepClassnames) {
  27635. options.keep_classnames = true;
  27636. }
  27637. if (program.keepFnames) {
  27638. options.keep_fnames = true;
  27639. }
  27640. if (program.mangleProps) {
  27641. if (program.mangleProps.domprops) {
  27642. delete program.mangleProps.domprops;
  27643. } else {
  27644. if (typeof program.mangleProps != "object") program.mangleProps = {};
  27645. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  27646. }
  27647. if (typeof options.mangle != "object") options.mangle = {};
  27648. options.mangle.properties = program.mangleProps;
  27649. }
  27650. if (program.nameCache) {
  27651. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  27652. }
  27653. if (program.output == "ast") {
  27654. options.format = {
  27655. ast: true,
  27656. code: false
  27657. };
  27658. }
  27659. if (program.parse) {
  27660. if (!program.parse.acorn && !program.parse.spidermonkey) {
  27661. options.parse = program.parse;
  27662. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  27663. fatal("ERROR: inline source map only works with built-in parser");
  27664. }
  27665. }
  27666. if (~program.rawArgs.indexOf("--rename")) {
  27667. options.rename = true;
  27668. } else if (!program.rename) {
  27669. options.rename = false;
  27670. }
  27671. let convert_path = name => name;
  27672. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  27673. convert_path = function() {
  27674. var base = program.sourceMap.base;
  27675. delete options.sourceMap.base;
  27676. return function(name) {
  27677. return path.relative(base, name);
  27678. };
  27679. }();
  27680. }
  27681. let filesList;
  27682. if (options.files && options.files.length) {
  27683. filesList = options.files;
  27684. delete options.files;
  27685. } else if (program.args.length) {
  27686. filesList = program.args;
  27687. }
  27688. if (filesList) {
  27689. simple_glob(filesList).forEach(function(name) {
  27690. files[convert_path(name)] = read_file(name);
  27691. });
  27692. } else {
  27693. await new Promise((resolve) => {
  27694. var chunks = [];
  27695. process.stdin.setEncoding("utf8");
  27696. process.stdin.on("data", function(chunk) {
  27697. chunks.push(chunk);
  27698. }).on("end", function() {
  27699. files = [ chunks.join("") ];
  27700. resolve();
  27701. });
  27702. process.stdin.resume();
  27703. });
  27704. }
  27705. await run_cli();
  27706. function convert_ast(fn) {
  27707. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  27708. }
  27709. async function run_cli() {
  27710. var content = program.sourceMap && program.sourceMap.content;
  27711. if (content && content !== "inline") {
  27712. options.sourceMap.content = read_file(content, content);
  27713. }
  27714. if (program.timings) options.timings = true;
  27715. try {
  27716. if (program.parse) {
  27717. if (program.parse.acorn) {
  27718. files = convert_ast(function(toplevel, name) {
  27719. return require("acorn").parse(files[name], {
  27720. ecmaVersion: 2018,
  27721. locations: true,
  27722. program: toplevel,
  27723. sourceFile: name,
  27724. sourceType: options.module || program.parse.module ? "module" : "script"
  27725. });
  27726. });
  27727. } else if (program.parse.spidermonkey) {
  27728. files = convert_ast(function(toplevel, name) {
  27729. var obj = JSON.parse(files[name]);
  27730. if (!toplevel) return obj;
  27731. toplevel.body = toplevel.body.concat(obj.body);
  27732. return toplevel;
  27733. });
  27734. }
  27735. }
  27736. } catch (ex) {
  27737. fatal(ex);
  27738. }
  27739. let result;
  27740. try {
  27741. result = await minify(files, options, fs);
  27742. } catch (ex) {
  27743. if (ex.name == "SyntaxError") {
  27744. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  27745. var col = ex.col;
  27746. var lines = files[ex.filename].split(/\r?\n/);
  27747. var line = lines[ex.line - 1];
  27748. if (!line && !col) {
  27749. line = lines[ex.line - 2];
  27750. col = line.length;
  27751. }
  27752. if (line) {
  27753. var limit = 70;
  27754. if (col > limit) {
  27755. line = line.slice(col - limit);
  27756. col = limit;
  27757. }
  27758. print_error(line.slice(0, 80));
  27759. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  27760. }
  27761. }
  27762. if (ex.defs) {
  27763. print_error("Supported options:");
  27764. print_error(format_object(ex.defs));
  27765. }
  27766. fatal(ex);
  27767. return;
  27768. }
  27769. if (program.output == "ast") {
  27770. if (!options.compress && !options.mangle) {
  27771. result.ast.figure_out_scope({});
  27772. }
  27773. console.log(JSON.stringify(result.ast, function(key, value) {
  27774. if (value) switch (key) {
  27775. case "thedef":
  27776. return symdef(value);
  27777. case "enclosed":
  27778. return value.length ? value.map(symdef) : undefined;
  27779. case "variables":
  27780. case "globals":
  27781. return value.size ? collect_from_map(value, symdef) : undefined;
  27782. }
  27783. if (skip_keys.has(key)) return;
  27784. if (value instanceof AST_Token) return;
  27785. if (value instanceof Map) return;
  27786. if (value instanceof AST_Node) {
  27787. var result = {
  27788. _class: "AST_" + value.TYPE
  27789. };
  27790. if (value.block_scope) {
  27791. result.variables = value.block_scope.variables;
  27792. result.enclosed = value.block_scope.enclosed;
  27793. }
  27794. value.CTOR.PROPS.forEach(function(prop) {
  27795. result[prop] = value[prop];
  27796. });
  27797. return result;
  27798. }
  27799. return value;
  27800. }, 2));
  27801. } else if (program.output == "spidermonkey") {
  27802. try {
  27803. const minified = await minify(
  27804. result.code,
  27805. {
  27806. compress: false,
  27807. mangle: false,
  27808. format: {
  27809. ast: true,
  27810. code: false
  27811. }
  27812. },
  27813. fs
  27814. );
  27815. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  27816. } catch (ex) {
  27817. fatal(ex);
  27818. return;
  27819. }
  27820. } else if (program.output) {
  27821. fs.writeFileSync(program.output, result.code);
  27822. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  27823. fs.writeFileSync(program.output + ".map", result.map);
  27824. }
  27825. } else {
  27826. console.log(result.code);
  27827. }
  27828. if (program.nameCache) {
  27829. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  27830. }
  27831. if (result.timings) for (var phase in result.timings) {
  27832. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  27833. }
  27834. }
  27835. function fatal(message) {
  27836. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  27837. print_error(message);
  27838. process.exit(1);
  27839. }
  27840. // A file glob function that only supports "*" and "?" wildcards in the basename.
  27841. // Example: "foo/bar/*baz??.*.js"
  27842. // Argument `glob` may be a string or an array of strings.
  27843. // Returns an array of strings. Garbage in, garbage out.
  27844. function simple_glob(glob) {
  27845. if (Array.isArray(glob)) {
  27846. return [].concat.apply([], glob.map(simple_glob));
  27847. }
  27848. if (glob && glob.match(/[*?]/)) {
  27849. var dir = path.dirname(glob);
  27850. try {
  27851. var entries = fs.readdirSync(dir);
  27852. } catch (ex) {}
  27853. if (entries) {
  27854. var pattern = "^" + path.basename(glob)
  27855. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  27856. .replace(/\*/g, "[^/\\\\]*")
  27857. .replace(/\?/g, "[^/\\\\]") + "$";
  27858. var mod = process.platform === "win32" ? "i" : "";
  27859. var rx = new RegExp(pattern, mod);
  27860. var results = entries.filter(function(name) {
  27861. return rx.test(name);
  27862. }).map(function(name) {
  27863. return path.join(dir, name);
  27864. });
  27865. if (results.length) return results;
  27866. }
  27867. }
  27868. return [ glob ];
  27869. }
  27870. function read_file(path, default_value) {
  27871. try {
  27872. return fs.readFileSync(path, "utf8");
  27873. } catch (ex) {
  27874. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  27875. fatal(ex);
  27876. }
  27877. }
  27878. function parse_js(flag) {
  27879. return function(value, options) {
  27880. options = options || {};
  27881. try {
  27882. walk(parse(value, { expression: true }), node => {
  27883. if (node instanceof AST_Assign) {
  27884. var name = node.left.print_to_string();
  27885. var value = node.right;
  27886. if (flag) {
  27887. options[name] = value;
  27888. } else if (value instanceof AST_Array) {
  27889. options[name] = value.elements.map(to_string);
  27890. } else if (value instanceof AST_RegExp) {
  27891. value = value.value;
  27892. options[name] = new RegExp(value.source, value.flags);
  27893. } else {
  27894. options[name] = to_string(value);
  27895. }
  27896. return true;
  27897. }
  27898. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  27899. var name = node.print_to_string();
  27900. options[name] = true;
  27901. return true;
  27902. }
  27903. if (!(node instanceof AST_Sequence)) throw node;
  27904. function to_string(value) {
  27905. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  27906. quote_keys: true
  27907. });
  27908. }
  27909. });
  27910. } catch(ex) {
  27911. if (flag) {
  27912. fatal("Error parsing arguments for '" + flag + "': " + value);
  27913. } else {
  27914. options[value] = null;
  27915. }
  27916. }
  27917. return options;
  27918. };
  27919. }
  27920. function symdef(def) {
  27921. var ret = (1e6 + def.id) + " " + def.name;
  27922. if (def.mangled_name) ret += " " + def.mangled_name;
  27923. return ret;
  27924. }
  27925. function collect_from_map(map, callback) {
  27926. var result = [];
  27927. map.forEach(function (def) {
  27928. result.push(callback(def));
  27929. });
  27930. return result;
  27931. }
  27932. function format_object(obj) {
  27933. var lines = [];
  27934. var padding = "";
  27935. Object.keys(obj).map(function(name) {
  27936. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  27937. return [ name, JSON.stringify(obj[name]) ];
  27938. }).forEach(function(tokens) {
  27939. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  27940. });
  27941. return lines.join("\n");
  27942. }
  27943. function print_error(msg) {
  27944. process.stderr.write(msg);
  27945. process.stderr.write("\n");
  27946. }
  27947. function describe_ast() {
  27948. var out = OutputStream({ beautify: true });
  27949. function doitem(ctor) {
  27950. out.print("AST_" + ctor.TYPE);
  27951. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  27952. if (props.length > 0) {
  27953. out.space();
  27954. out.with_parens(function() {
  27955. props.forEach(function(prop, i) {
  27956. if (i) out.space();
  27957. out.print(prop);
  27958. });
  27959. });
  27960. }
  27961. if (ctor.documentation) {
  27962. out.space();
  27963. out.print_string(ctor.documentation);
  27964. }
  27965. if (ctor.SUBCLASSES.length > 0) {
  27966. out.space();
  27967. out.with_block(function() {
  27968. ctor.SUBCLASSES.forEach(function(ctor) {
  27969. out.indent();
  27970. doitem(ctor);
  27971. out.newline();
  27972. });
  27973. });
  27974. }
  27975. }
  27976. doitem(AST_Node);
  27977. return out + "\n";
  27978. }
  27979. }
  27980. async function _default_options() {
  27981. const defs = {};
  27982. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  27983. const options = infer_options({
  27984. [component]: {0: 0}
  27985. });
  27986. if (options) defs[component] = options;
  27987. });
  27988. return defs;
  27989. }
  27990. async function infer_options(options) {
  27991. try {
  27992. await minify("", options);
  27993. } catch (error) {
  27994. return error.defs;
  27995. }
  27996. }
  27997. exports._default_options = _default_options;
  27998. exports._run_cli = run_cli;
  27999. exports.minify = minify;
  28000. })));