bundle.min.js 884 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257
  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. function track_used_binding_identifiers(is_parameter, strict) {
  1525. var parameters = new Set();
  1526. var duplicate = false;
  1527. var default_assignment = false;
  1528. var spread = false;
  1529. var strict_mode = !!strict;
  1530. var tracker = {
  1531. add_parameter: function(token) {
  1532. if (parameters.has(token.value)) {
  1533. if (duplicate === false) {
  1534. duplicate = token;
  1535. }
  1536. tracker.check_strict();
  1537. } else {
  1538. parameters.add(token.value);
  1539. if (is_parameter) {
  1540. switch (token.value) {
  1541. case "arguments":
  1542. case "eval":
  1543. case "yield":
  1544. if (strict_mode) {
  1545. token_error(token, "Unexpected " + token.value + " identifier as parameter inside strict mode");
  1546. }
  1547. break;
  1548. default:
  1549. if (RESERVED_WORDS.has(token.value)) {
  1550. unexpected();
  1551. }
  1552. }
  1553. }
  1554. }
  1555. },
  1556. mark_default_assignment: function(token) {
  1557. if (default_assignment === false) {
  1558. default_assignment = token;
  1559. }
  1560. },
  1561. mark_spread: function(token) {
  1562. if (spread === false) {
  1563. spread = token;
  1564. }
  1565. },
  1566. mark_strict_mode: function() {
  1567. strict_mode = true;
  1568. },
  1569. is_strict: function() {
  1570. return default_assignment !== false || spread !== false || strict_mode;
  1571. },
  1572. check_strict: function() {
  1573. if (tracker.is_strict() && duplicate !== false) {
  1574. token_error(duplicate, "Parameter " + duplicate.value + " was used already");
  1575. }
  1576. }
  1577. };
  1578. return tracker;
  1579. }
  1580. function parameters(params) {
  1581. var used_parameters = track_used_binding_identifiers(true, S.input.has_directive("use strict"));
  1582. expect("(");
  1583. while (!is("punc", ")")) {
  1584. var param = parameter(used_parameters);
  1585. params.push(param);
  1586. if (!is("punc", ")")) {
  1587. expect(",");
  1588. }
  1589. if (param instanceof AST_Expansion) {
  1590. break;
  1591. }
  1592. }
  1593. next();
  1594. }
  1595. function parameter(used_parameters, symbol_type) {
  1596. var param;
  1597. var expand = false;
  1598. if (used_parameters === undefined) {
  1599. used_parameters = track_used_binding_identifiers(true, S.input.has_directive("use strict"));
  1600. }
  1601. if (is("expand", "...")) {
  1602. expand = S.token;
  1603. used_parameters.mark_spread(S.token);
  1604. next();
  1605. }
  1606. param = binding_element(used_parameters, symbol_type);
  1607. if (is("operator", "=") && expand === false) {
  1608. used_parameters.mark_default_assignment(S.token);
  1609. next();
  1610. param = new AST_DefaultAssign({
  1611. start: param.start,
  1612. left: param,
  1613. operator: "=",
  1614. right: expression(false),
  1615. end: S.token
  1616. });
  1617. }
  1618. if (expand !== false) {
  1619. if (!is("punc", ")")) {
  1620. unexpected();
  1621. }
  1622. param = new AST_Expansion({
  1623. start: expand,
  1624. expression: param,
  1625. end: expand
  1626. });
  1627. }
  1628. used_parameters.check_strict();
  1629. return param;
  1630. }
  1631. function binding_element(used_parameters, symbol_type) {
  1632. var elements = [];
  1633. var first = true;
  1634. var is_expand = false;
  1635. var expand_token;
  1636. var first_token = S.token;
  1637. if (used_parameters === undefined) {
  1638. used_parameters = track_used_binding_identifiers(false, S.input.has_directive("use strict"));
  1639. }
  1640. symbol_type = symbol_type === undefined ? AST_SymbolFunarg : symbol_type;
  1641. if (is("punc", "[")) {
  1642. next();
  1643. while (!is("punc", "]")) {
  1644. if (first) {
  1645. first = false;
  1646. } else {
  1647. expect(",");
  1648. }
  1649. if (is("expand", "...")) {
  1650. is_expand = true;
  1651. expand_token = S.token;
  1652. used_parameters.mark_spread(S.token);
  1653. next();
  1654. }
  1655. if (is("punc")) {
  1656. switch (S.token.value) {
  1657. case ",":
  1658. elements.push(new AST_Hole({
  1659. start: S.token,
  1660. end: S.token
  1661. }));
  1662. continue;
  1663. case "]": // Trailing comma after last element
  1664. break;
  1665. case "[":
  1666. case "{":
  1667. elements.push(binding_element(used_parameters, symbol_type));
  1668. break;
  1669. default:
  1670. unexpected();
  1671. }
  1672. } else if (is("name")) {
  1673. used_parameters.add_parameter(S.token);
  1674. elements.push(as_symbol(symbol_type));
  1675. } else {
  1676. croak("Invalid function parameter");
  1677. }
  1678. if (is("operator", "=") && is_expand === false) {
  1679. used_parameters.mark_default_assignment(S.token);
  1680. next();
  1681. elements[elements.length - 1] = new AST_DefaultAssign({
  1682. start: elements[elements.length - 1].start,
  1683. left: elements[elements.length - 1],
  1684. operator: "=",
  1685. right: expression(false),
  1686. end: S.token
  1687. });
  1688. }
  1689. if (is_expand) {
  1690. if (!is("punc", "]")) {
  1691. croak("Rest element must be last element");
  1692. }
  1693. elements[elements.length - 1] = new AST_Expansion({
  1694. start: expand_token,
  1695. expression: elements[elements.length - 1],
  1696. end: expand_token
  1697. });
  1698. }
  1699. }
  1700. expect("]");
  1701. used_parameters.check_strict();
  1702. return new AST_Destructuring({
  1703. start: first_token,
  1704. names: elements,
  1705. is_array: true,
  1706. end: prev()
  1707. });
  1708. } else if (is("punc", "{")) {
  1709. next();
  1710. while (!is("punc", "}")) {
  1711. if (first) {
  1712. first = false;
  1713. } else {
  1714. expect(",");
  1715. }
  1716. if (is("expand", "...")) {
  1717. is_expand = true;
  1718. expand_token = S.token;
  1719. used_parameters.mark_spread(S.token);
  1720. next();
  1721. }
  1722. if (is("name") && (is_token(peek(), "punc") || is_token(peek(), "operator")) && [",", "}", "="].includes(peek().value)) {
  1723. used_parameters.add_parameter(S.token);
  1724. var start = prev();
  1725. var value = as_symbol(symbol_type);
  1726. if (is_expand) {
  1727. elements.push(new AST_Expansion({
  1728. start: expand_token,
  1729. expression: value,
  1730. end: value.end,
  1731. }));
  1732. } else {
  1733. elements.push(new AST_ObjectKeyVal({
  1734. start: start,
  1735. key: value.name,
  1736. value: value,
  1737. end: value.end,
  1738. }));
  1739. }
  1740. } else if (is("punc", "}")) {
  1741. continue; // Allow trailing hole
  1742. } else {
  1743. var property_token = S.token;
  1744. var property = as_property_name();
  1745. if (property === null) {
  1746. unexpected(prev());
  1747. } else if (prev().type === "name" && !is("punc", ":")) {
  1748. elements.push(new AST_ObjectKeyVal({
  1749. start: prev(),
  1750. key: property,
  1751. value: new symbol_type({
  1752. start: prev(),
  1753. name: property,
  1754. end: prev()
  1755. }),
  1756. end: prev()
  1757. }));
  1758. } else {
  1759. expect(":");
  1760. elements.push(new AST_ObjectKeyVal({
  1761. start: property_token,
  1762. quote: property_token.quote,
  1763. key: property,
  1764. value: binding_element(used_parameters, symbol_type),
  1765. end: prev()
  1766. }));
  1767. }
  1768. }
  1769. if (is_expand) {
  1770. if (!is("punc", "}")) {
  1771. croak("Rest element must be last element");
  1772. }
  1773. } else if (is("operator", "=")) {
  1774. used_parameters.mark_default_assignment(S.token);
  1775. next();
  1776. elements[elements.length - 1].value = new AST_DefaultAssign({
  1777. start: elements[elements.length - 1].value.start,
  1778. left: elements[elements.length - 1].value,
  1779. operator: "=",
  1780. right: expression(false),
  1781. end: S.token
  1782. });
  1783. }
  1784. }
  1785. expect("}");
  1786. used_parameters.check_strict();
  1787. return new AST_Destructuring({
  1788. start: first_token,
  1789. names: elements,
  1790. is_array: false,
  1791. end: prev()
  1792. });
  1793. } else if (is("name")) {
  1794. used_parameters.add_parameter(S.token);
  1795. return as_symbol(symbol_type);
  1796. } else {
  1797. croak("Invalid function parameter");
  1798. }
  1799. }
  1800. function params_or_seq_(allow_arrows, maybe_sequence) {
  1801. var spread_token;
  1802. var invalid_sequence;
  1803. var trailing_comma;
  1804. var a = [];
  1805. expect("(");
  1806. while (!is("punc", ")")) {
  1807. if (spread_token) unexpected(spread_token);
  1808. if (is("expand", "...")) {
  1809. spread_token = S.token;
  1810. if (maybe_sequence) invalid_sequence = S.token;
  1811. next();
  1812. a.push(new AST_Expansion({
  1813. start: prev(),
  1814. expression: expression(),
  1815. end: S.token,
  1816. }));
  1817. } else {
  1818. a.push(expression());
  1819. }
  1820. if (!is("punc", ")")) {
  1821. expect(",");
  1822. if (is("punc", ")")) {
  1823. trailing_comma = prev();
  1824. if (maybe_sequence) invalid_sequence = trailing_comma;
  1825. }
  1826. }
  1827. }
  1828. expect(")");
  1829. if (allow_arrows && is("arrow", "=>")) {
  1830. if (spread_token && trailing_comma) unexpected(trailing_comma);
  1831. } else if (invalid_sequence) {
  1832. unexpected(invalid_sequence);
  1833. }
  1834. return a;
  1835. }
  1836. function _function_body(block, generator, is_async, name, args) {
  1837. var loop = S.in_loop;
  1838. var labels = S.labels;
  1839. var current_generator = S.in_generator;
  1840. var current_async = S.in_async;
  1841. ++S.in_function;
  1842. if (generator)
  1843. S.in_generator = S.in_function;
  1844. if (is_async)
  1845. S.in_async = S.in_function;
  1846. if (args) parameters(args);
  1847. if (block)
  1848. S.in_directives = true;
  1849. S.in_loop = 0;
  1850. S.labels = [];
  1851. if (block) {
  1852. S.input.push_directives_stack();
  1853. var a = block_();
  1854. if (name) _verify_symbol(name);
  1855. if (args) args.forEach(_verify_symbol);
  1856. S.input.pop_directives_stack();
  1857. } else {
  1858. var a = [new AST_Return({
  1859. start: S.token,
  1860. value: expression(false),
  1861. end: S.token
  1862. })];
  1863. }
  1864. --S.in_function;
  1865. S.in_loop = loop;
  1866. S.labels = labels;
  1867. S.in_generator = current_generator;
  1868. S.in_async = current_async;
  1869. return a;
  1870. }
  1871. function _await_expression() {
  1872. // Previous token must be "await" and not be interpreted as an identifier
  1873. if (!can_await()) {
  1874. croak("Unexpected await expression outside async function",
  1875. S.prev.line, S.prev.col, S.prev.pos);
  1876. }
  1877. // the await expression is parsed as a unary expression in Babel
  1878. return new AST_Await({
  1879. start: prev(),
  1880. end: S.token,
  1881. expression : maybe_unary(true),
  1882. });
  1883. }
  1884. function _yield_expression() {
  1885. // Previous token must be keyword yield and not be interpret as an identifier
  1886. if (!is_in_generator()) {
  1887. croak("Unexpected yield expression outside generator function",
  1888. S.prev.line, S.prev.col, S.prev.pos);
  1889. }
  1890. var start = S.token;
  1891. var star = false;
  1892. var has_expression = true;
  1893. // Attempt to get expression or star (and then the mandatory expression)
  1894. // behind yield on the same line.
  1895. //
  1896. // If nothing follows on the same line of the yieldExpression,
  1897. // it should default to the value `undefined` for yield to return.
  1898. // In that case, the `undefined` stored as `null` in ast.
  1899. //
  1900. // Note 1: It isn't allowed for yield* to close without an expression
  1901. // Note 2: If there is a nlb between yield and star, it is interpret as
  1902. // yield <explicit undefined> <inserted automatic semicolon> *
  1903. if (can_insert_semicolon() ||
  1904. (is("punc") && PUNC_AFTER_EXPRESSION.has(S.token.value))) {
  1905. has_expression = false;
  1906. } else if (is("operator", "*")) {
  1907. star = true;
  1908. next();
  1909. }
  1910. return new AST_Yield({
  1911. start : start,
  1912. is_star : star,
  1913. expression : has_expression ? expression() : null,
  1914. end : prev()
  1915. });
  1916. }
  1917. function if_() {
  1918. var cond = parenthesised(), body = statement(false, false, true), belse = null;
  1919. if (is("keyword", "else")) {
  1920. next();
  1921. belse = statement(false, false, true);
  1922. }
  1923. return new AST_If({
  1924. condition : cond,
  1925. body : body,
  1926. alternative : belse
  1927. });
  1928. }
  1929. function block_() {
  1930. expect("{");
  1931. var a = [];
  1932. while (!is("punc", "}")) {
  1933. if (is("eof")) unexpected();
  1934. a.push(statement());
  1935. }
  1936. next();
  1937. return a;
  1938. }
  1939. function switch_body_() {
  1940. expect("{");
  1941. var a = [], cur = null, branch = null, tmp;
  1942. while (!is("punc", "}")) {
  1943. if (is("eof")) unexpected();
  1944. if (is("keyword", "case")) {
  1945. if (branch) branch.end = prev();
  1946. cur = [];
  1947. branch = new AST_Case({
  1948. start : (tmp = S.token, next(), tmp),
  1949. expression : expression(true),
  1950. body : cur
  1951. });
  1952. a.push(branch);
  1953. expect(":");
  1954. } else if (is("keyword", "default")) {
  1955. if (branch) branch.end = prev();
  1956. cur = [];
  1957. branch = new AST_Default({
  1958. start : (tmp = S.token, next(), expect(":"), tmp),
  1959. body : cur
  1960. });
  1961. a.push(branch);
  1962. } else {
  1963. if (!cur) unexpected();
  1964. cur.push(statement());
  1965. }
  1966. }
  1967. if (branch) branch.end = prev();
  1968. next();
  1969. return a;
  1970. }
  1971. function try_() {
  1972. var body = block_(), bcatch = null, bfinally = null;
  1973. if (is("keyword", "catch")) {
  1974. var start = S.token;
  1975. next();
  1976. if (is("punc", "{")) {
  1977. var name = null;
  1978. } else {
  1979. expect("(");
  1980. var name = parameter(undefined, AST_SymbolCatch);
  1981. expect(")");
  1982. }
  1983. bcatch = new AST_Catch({
  1984. start : start,
  1985. argname : name,
  1986. body : block_(),
  1987. end : prev()
  1988. });
  1989. }
  1990. if (is("keyword", "finally")) {
  1991. var start = S.token;
  1992. next();
  1993. bfinally = new AST_Finally({
  1994. start : start,
  1995. body : block_(),
  1996. end : prev()
  1997. });
  1998. }
  1999. if (!bcatch && !bfinally)
  2000. croak("Missing catch/finally blocks");
  2001. return new AST_Try({
  2002. body : body,
  2003. bcatch : bcatch,
  2004. bfinally : bfinally
  2005. });
  2006. }
  2007. function vardefs(no_in, kind) {
  2008. var a = [];
  2009. var def;
  2010. for (;;) {
  2011. var sym_type =
  2012. kind === "var" ? AST_SymbolVar :
  2013. kind === "const" ? AST_SymbolConst :
  2014. kind === "let" ? AST_SymbolLet : null;
  2015. if (is("punc", "{") || is("punc", "[")) {
  2016. def = new AST_VarDef({
  2017. start: S.token,
  2018. name: binding_element(undefined ,sym_type),
  2019. value: is("operator", "=") ? (expect_token("operator", "="), expression(false, no_in)) : null,
  2020. end: prev()
  2021. });
  2022. } else {
  2023. def = new AST_VarDef({
  2024. start : S.token,
  2025. name : as_symbol(sym_type),
  2026. value : is("operator", "=")
  2027. ? (next(), expression(false, no_in))
  2028. : !no_in && kind === "const"
  2029. ? croak("Missing initializer in const declaration") : null,
  2030. end : prev()
  2031. });
  2032. if (def.name.name == "import") croak("Unexpected token: import");
  2033. }
  2034. a.push(def);
  2035. if (!is("punc", ","))
  2036. break;
  2037. next();
  2038. }
  2039. return a;
  2040. }
  2041. var var_ = function(no_in) {
  2042. return new AST_Var({
  2043. start : prev(),
  2044. definitions : vardefs(no_in, "var"),
  2045. end : prev()
  2046. });
  2047. };
  2048. var let_ = function(no_in) {
  2049. return new AST_Let({
  2050. start : prev(),
  2051. definitions : vardefs(no_in, "let"),
  2052. end : prev()
  2053. });
  2054. };
  2055. var const_ = function(no_in) {
  2056. return new AST_Const({
  2057. start : prev(),
  2058. definitions : vardefs(no_in, "const"),
  2059. end : prev()
  2060. });
  2061. };
  2062. var new_ = function(allow_calls) {
  2063. var start = S.token;
  2064. expect_token("operator", "new");
  2065. if (is("punc", ".")) {
  2066. next();
  2067. expect_token("name", "target");
  2068. return subscripts(new AST_NewTarget({
  2069. start : start,
  2070. end : prev()
  2071. }), allow_calls);
  2072. }
  2073. var newexp = expr_atom(false), args;
  2074. if (is("punc", "(")) {
  2075. next();
  2076. args = expr_list(")", true);
  2077. } else {
  2078. args = [];
  2079. }
  2080. var call = new AST_New({
  2081. start : start,
  2082. expression : newexp,
  2083. args : args,
  2084. end : prev()
  2085. });
  2086. annotate(call);
  2087. return subscripts(call, allow_calls);
  2088. };
  2089. function as_atom_node() {
  2090. var tok = S.token, ret;
  2091. switch (tok.type) {
  2092. case "name":
  2093. ret = _make_symbol(AST_SymbolRef);
  2094. break;
  2095. case "num":
  2096. ret = new AST_Number({
  2097. start: tok,
  2098. end: tok,
  2099. value: tok.value,
  2100. raw: LATEST_RAW
  2101. });
  2102. break;
  2103. case "big_int":
  2104. ret = new AST_BigInt({ start: tok, end: tok, value: tok.value });
  2105. break;
  2106. case "string":
  2107. ret = new AST_String({
  2108. start : tok,
  2109. end : tok,
  2110. value : tok.value,
  2111. quote : tok.quote
  2112. });
  2113. break;
  2114. case "regexp":
  2115. const [_, source, flags] = tok.value.match(/^\/(.*)\/(\w*)$/);
  2116. ret = new AST_RegExp({ start: tok, end: tok, value: { source, flags } });
  2117. break;
  2118. case "atom":
  2119. switch (tok.value) {
  2120. case "false":
  2121. ret = new AST_False({ start: tok, end: tok });
  2122. break;
  2123. case "true":
  2124. ret = new AST_True({ start: tok, end: tok });
  2125. break;
  2126. case "null":
  2127. ret = new AST_Null({ start: tok, end: tok });
  2128. break;
  2129. }
  2130. break;
  2131. }
  2132. next();
  2133. return ret;
  2134. }
  2135. function to_fun_args(ex, default_seen_above) {
  2136. var insert_default = function(ex, default_value) {
  2137. if (default_value) {
  2138. return new AST_DefaultAssign({
  2139. start: ex.start,
  2140. left: ex,
  2141. operator: "=",
  2142. right: default_value,
  2143. end: default_value.end
  2144. });
  2145. }
  2146. return ex;
  2147. };
  2148. if (ex instanceof AST_Object) {
  2149. return insert_default(new AST_Destructuring({
  2150. start: ex.start,
  2151. end: ex.end,
  2152. is_array: false,
  2153. names: ex.properties.map(prop => to_fun_args(prop))
  2154. }), default_seen_above);
  2155. } else if (ex instanceof AST_ObjectKeyVal) {
  2156. ex.value = to_fun_args(ex.value);
  2157. return insert_default(ex, default_seen_above);
  2158. } else if (ex instanceof AST_Hole) {
  2159. return ex;
  2160. } else if (ex instanceof AST_Destructuring) {
  2161. ex.names = ex.names.map(name => to_fun_args(name));
  2162. return insert_default(ex, default_seen_above);
  2163. } else if (ex instanceof AST_SymbolRef) {
  2164. return insert_default(new AST_SymbolFunarg({
  2165. name: ex.name,
  2166. start: ex.start,
  2167. end: ex.end
  2168. }), default_seen_above);
  2169. } else if (ex instanceof AST_Expansion) {
  2170. ex.expression = to_fun_args(ex.expression);
  2171. return insert_default(ex, default_seen_above);
  2172. } else if (ex instanceof AST_Array) {
  2173. return insert_default(new AST_Destructuring({
  2174. start: ex.start,
  2175. end: ex.end,
  2176. is_array: true,
  2177. names: ex.elements.map(elm => to_fun_args(elm))
  2178. }), default_seen_above);
  2179. } else if (ex instanceof AST_Assign) {
  2180. return insert_default(to_fun_args(ex.left, ex.right), default_seen_above);
  2181. } else if (ex instanceof AST_DefaultAssign) {
  2182. ex.left = to_fun_args(ex.left);
  2183. return ex;
  2184. } else {
  2185. croak("Invalid function parameter", ex.start.line, ex.start.col);
  2186. }
  2187. }
  2188. var expr_atom = function(allow_calls, allow_arrows) {
  2189. if (is("operator", "new")) {
  2190. return new_(allow_calls);
  2191. }
  2192. if (is("operator", "import")) {
  2193. return import_meta();
  2194. }
  2195. var start = S.token;
  2196. var peeked;
  2197. var async = is("name", "async")
  2198. && (peeked = peek()).value != "["
  2199. && peeked.type != "arrow"
  2200. && as_atom_node();
  2201. if (is("punc")) {
  2202. switch (S.token.value) {
  2203. case "(":
  2204. if (async && !allow_calls) break;
  2205. var exprs = params_or_seq_(allow_arrows, !async);
  2206. if (allow_arrows && is("arrow", "=>")) {
  2207. return arrow_function(start, exprs.map(e => to_fun_args(e)), !!async);
  2208. }
  2209. var ex = async ? new AST_Call({
  2210. expression: async,
  2211. args: exprs
  2212. }) : exprs.length == 1 ? exprs[0] : new AST_Sequence({
  2213. expressions: exprs
  2214. });
  2215. if (ex.start) {
  2216. const outer_comments_before = start.comments_before.length;
  2217. outer_comments_before_counts.set(start, outer_comments_before);
  2218. ex.start.comments_before.unshift(...start.comments_before);
  2219. start.comments_before = ex.start.comments_before;
  2220. if (outer_comments_before == 0 && start.comments_before.length > 0) {
  2221. var comment = start.comments_before[0];
  2222. if (!comment.nlb) {
  2223. comment.nlb = start.nlb;
  2224. start.nlb = false;
  2225. }
  2226. }
  2227. start.comments_after = ex.start.comments_after;
  2228. }
  2229. ex.start = start;
  2230. var end = prev();
  2231. if (ex.end) {
  2232. end.comments_before = ex.end.comments_before;
  2233. ex.end.comments_after.push(...end.comments_after);
  2234. end.comments_after = ex.end.comments_after;
  2235. }
  2236. ex.end = end;
  2237. if (ex instanceof AST_Call) annotate(ex);
  2238. return subscripts(ex, allow_calls);
  2239. case "[":
  2240. return subscripts(array_(), allow_calls);
  2241. case "{":
  2242. return subscripts(object_or_destructuring_(), allow_calls);
  2243. }
  2244. if (!async) unexpected();
  2245. }
  2246. if (allow_arrows && is("name") && is_token(peek(), "arrow")) {
  2247. var param = new AST_SymbolFunarg({
  2248. name: S.token.value,
  2249. start: start,
  2250. end: start,
  2251. });
  2252. next();
  2253. return arrow_function(start, [param], !!async);
  2254. }
  2255. if (is("keyword", "function")) {
  2256. next();
  2257. var func = function_(AST_Function, false, !!async);
  2258. func.start = start;
  2259. func.end = prev();
  2260. return subscripts(func, allow_calls);
  2261. }
  2262. if (async) return subscripts(async, allow_calls);
  2263. if (is("keyword", "class")) {
  2264. next();
  2265. var cls = class_(AST_ClassExpression);
  2266. cls.start = start;
  2267. cls.end = prev();
  2268. return subscripts(cls, allow_calls);
  2269. }
  2270. if (is("template_head")) {
  2271. return subscripts(template_string(), allow_calls);
  2272. }
  2273. if (ATOMIC_START_TOKEN.has(S.token.type)) {
  2274. return subscripts(as_atom_node(), allow_calls);
  2275. }
  2276. unexpected();
  2277. };
  2278. function template_string() {
  2279. var segments = [], start = S.token;
  2280. segments.push(new AST_TemplateSegment({
  2281. start: S.token,
  2282. raw: LATEST_RAW,
  2283. value: S.token.value,
  2284. end: S.token
  2285. }));
  2286. while (!LATEST_TEMPLATE_END) {
  2287. next();
  2288. handle_regexp();
  2289. segments.push(expression(true));
  2290. segments.push(new AST_TemplateSegment({
  2291. start: S.token,
  2292. raw: LATEST_RAW,
  2293. value: S.token.value,
  2294. end: S.token
  2295. }));
  2296. }
  2297. next();
  2298. return new AST_TemplateString({
  2299. start: start,
  2300. segments: segments,
  2301. end: S.token
  2302. });
  2303. }
  2304. function expr_list(closing, allow_trailing_comma, allow_empty) {
  2305. var first = true, a = [];
  2306. while (!is("punc", closing)) {
  2307. if (first) first = false; else expect(",");
  2308. if (allow_trailing_comma && is("punc", closing)) break;
  2309. if (is("punc", ",") && allow_empty) {
  2310. a.push(new AST_Hole({ start: S.token, end: S.token }));
  2311. } else if (is("expand", "...")) {
  2312. next();
  2313. a.push(new AST_Expansion({start: prev(), expression: expression(),end: S.token}));
  2314. } else {
  2315. a.push(expression(false));
  2316. }
  2317. }
  2318. next();
  2319. return a;
  2320. }
  2321. var array_ = embed_tokens(function() {
  2322. expect("[");
  2323. return new AST_Array({
  2324. elements: expr_list("]", !options.strict, true)
  2325. });
  2326. });
  2327. var create_accessor = embed_tokens((is_generator, is_async) => {
  2328. return function_(AST_Accessor, is_generator, is_async);
  2329. });
  2330. var object_or_destructuring_ = embed_tokens(function object_or_destructuring_() {
  2331. var start = S.token, first = true, a = [];
  2332. expect("{");
  2333. while (!is("punc", "}")) {
  2334. if (first) first = false; else expect(",");
  2335. if (!options.strict && is("punc", "}"))
  2336. // allow trailing comma
  2337. break;
  2338. start = S.token;
  2339. if (start.type == "expand") {
  2340. next();
  2341. a.push(new AST_Expansion({
  2342. start: start,
  2343. expression: expression(false),
  2344. end: prev(),
  2345. }));
  2346. continue;
  2347. }
  2348. var name = as_property_name();
  2349. var value;
  2350. // Check property and fetch value
  2351. if (!is("punc", ":")) {
  2352. var concise = concise_method_or_getset(name, start);
  2353. if (concise) {
  2354. a.push(concise);
  2355. continue;
  2356. }
  2357. value = new AST_SymbolRef({
  2358. start: prev(),
  2359. name: name,
  2360. end: prev()
  2361. });
  2362. } else if (name === null) {
  2363. unexpected(prev());
  2364. } else {
  2365. next(); // `:` - see first condition
  2366. value = expression(false);
  2367. }
  2368. // Check for default value and alter value accordingly if necessary
  2369. if (is("operator", "=")) {
  2370. next();
  2371. value = new AST_Assign({
  2372. start: start,
  2373. left: value,
  2374. operator: "=",
  2375. right: expression(false),
  2376. logical: false,
  2377. end: prev()
  2378. });
  2379. }
  2380. // Create property
  2381. a.push(new AST_ObjectKeyVal({
  2382. start: start,
  2383. quote: start.quote,
  2384. key: name instanceof AST_Node ? name : "" + name,
  2385. value: value,
  2386. end: prev()
  2387. }));
  2388. }
  2389. next();
  2390. return new AST_Object({ properties: a });
  2391. });
  2392. function class_(KindOfClass, is_export_default) {
  2393. var start, method, class_name, extends_, a = [];
  2394. S.input.push_directives_stack(); // Push directive stack, but not scope stack
  2395. S.input.add_directive("use strict");
  2396. if (S.token.type == "name" && S.token.value != "extends") {
  2397. class_name = as_symbol(KindOfClass === AST_DefClass ? AST_SymbolDefClass : AST_SymbolClass);
  2398. }
  2399. if (KindOfClass === AST_DefClass && !class_name) {
  2400. if (is_export_default) {
  2401. KindOfClass = AST_ClassExpression;
  2402. } else {
  2403. unexpected();
  2404. }
  2405. }
  2406. if (S.token.value == "extends") {
  2407. next();
  2408. extends_ = expression(true);
  2409. }
  2410. expect("{");
  2411. while (is("punc", ";")) { next(); } // Leading semicolons are okay in class bodies.
  2412. while (!is("punc", "}")) {
  2413. start = S.token;
  2414. method = concise_method_or_getset(as_property_name(), start, true);
  2415. if (!method) { unexpected(); }
  2416. a.push(method);
  2417. while (is("punc", ";")) { next(); }
  2418. }
  2419. S.input.pop_directives_stack();
  2420. next();
  2421. return new KindOfClass({
  2422. start: start,
  2423. name: class_name,
  2424. extends: extends_,
  2425. properties: a,
  2426. end: prev(),
  2427. });
  2428. }
  2429. function concise_method_or_getset(name, start, is_class) {
  2430. const get_symbol_ast = (name, SymbolClass = AST_SymbolMethod) => {
  2431. if (typeof name === "string" || typeof name === "number") {
  2432. return new SymbolClass({
  2433. start,
  2434. name: "" + name,
  2435. end: prev()
  2436. });
  2437. } else if (name === null) {
  2438. unexpected();
  2439. }
  2440. return name;
  2441. };
  2442. const is_not_method_start = () =>
  2443. !is("punc", "(") && !is("punc", ",") && !is("punc", "}") && !is("punc", ";") && !is("operator", "=");
  2444. var is_async = false;
  2445. var is_static = false;
  2446. var is_generator = false;
  2447. var is_private = false;
  2448. var accessor_type = null;
  2449. if (is_class && name === "static" && is_not_method_start()) {
  2450. is_static = true;
  2451. name = as_property_name();
  2452. }
  2453. if (name === "async" && is_not_method_start()) {
  2454. is_async = true;
  2455. name = as_property_name();
  2456. }
  2457. if (prev().type === "operator" && prev().value === "*") {
  2458. is_generator = true;
  2459. name = as_property_name();
  2460. }
  2461. if ((name === "get" || name === "set") && is_not_method_start()) {
  2462. accessor_type = name;
  2463. name = as_property_name();
  2464. }
  2465. if (prev().type === "privatename") {
  2466. is_private = true;
  2467. }
  2468. const property_token = prev();
  2469. if (accessor_type != null) {
  2470. if (!is_private) {
  2471. const AccessorClass = accessor_type === "get"
  2472. ? AST_ObjectGetter
  2473. : AST_ObjectSetter;
  2474. name = get_symbol_ast(name);
  2475. return new AccessorClass({
  2476. start,
  2477. static: is_static,
  2478. key: name,
  2479. quote: name instanceof AST_SymbolMethod ? property_token.quote : undefined,
  2480. value: create_accessor(),
  2481. end: prev()
  2482. });
  2483. } else {
  2484. const AccessorClass = accessor_type === "get"
  2485. ? AST_PrivateGetter
  2486. : AST_PrivateSetter;
  2487. return new AccessorClass({
  2488. start,
  2489. static: is_static,
  2490. key: get_symbol_ast(name),
  2491. value: create_accessor(),
  2492. end: prev(),
  2493. });
  2494. }
  2495. }
  2496. if (is("punc", "(")) {
  2497. name = get_symbol_ast(name);
  2498. const AST_MethodVariant = is_private
  2499. ? AST_PrivateMethod
  2500. : AST_ConciseMethod;
  2501. var node = new AST_MethodVariant({
  2502. start : start,
  2503. static : is_static,
  2504. is_generator: is_generator,
  2505. async : is_async,
  2506. key : name,
  2507. quote : name instanceof AST_SymbolMethod ?
  2508. property_token.quote : undefined,
  2509. value : create_accessor(is_generator, is_async),
  2510. end : prev()
  2511. });
  2512. return node;
  2513. }
  2514. if (is_class) {
  2515. const key = get_symbol_ast(name, AST_SymbolClassProperty);
  2516. const quote = key instanceof AST_SymbolClassProperty
  2517. ? property_token.quote
  2518. : undefined;
  2519. const AST_ClassPropertyVariant = is_private
  2520. ? AST_ClassPrivateProperty
  2521. : AST_ClassProperty;
  2522. if (is("operator", "=")) {
  2523. next();
  2524. return new AST_ClassPropertyVariant({
  2525. start,
  2526. static: is_static,
  2527. quote,
  2528. key,
  2529. value: expression(false),
  2530. end: prev()
  2531. });
  2532. } else if (
  2533. is("name")
  2534. || is("privatename")
  2535. || is("operator", "*")
  2536. || is("punc", ";")
  2537. || is("punc", "}")
  2538. ) {
  2539. return new AST_ClassPropertyVariant({
  2540. start,
  2541. static: is_static,
  2542. quote,
  2543. key,
  2544. end: prev()
  2545. });
  2546. }
  2547. }
  2548. }
  2549. function maybe_import_assertion() {
  2550. if (is("name", "assert") && !has_newline_before(S.token)) {
  2551. next();
  2552. return object_or_destructuring_();
  2553. }
  2554. return null;
  2555. }
  2556. function import_statement() {
  2557. var start = prev();
  2558. var imported_name;
  2559. var imported_names;
  2560. if (is("name")) {
  2561. imported_name = as_symbol(AST_SymbolImport);
  2562. }
  2563. if (is("punc", ",")) {
  2564. next();
  2565. }
  2566. imported_names = map_names(true);
  2567. if (imported_names || imported_name) {
  2568. expect_token("name", "from");
  2569. }
  2570. var mod_str = S.token;
  2571. if (mod_str.type !== "string") {
  2572. unexpected();
  2573. }
  2574. next();
  2575. const assert_clause = maybe_import_assertion();
  2576. return new AST_Import({
  2577. start,
  2578. imported_name,
  2579. imported_names,
  2580. module_name: new AST_String({
  2581. start: mod_str,
  2582. value: mod_str.value,
  2583. quote: mod_str.quote,
  2584. end: mod_str,
  2585. }),
  2586. assert_clause,
  2587. end: S.token,
  2588. });
  2589. }
  2590. function import_meta() {
  2591. var start = S.token;
  2592. expect_token("operator", "import");
  2593. expect_token("punc", ".");
  2594. expect_token("name", "meta");
  2595. return subscripts(new AST_ImportMeta({
  2596. start: start,
  2597. end: prev()
  2598. }), false);
  2599. }
  2600. function map_name(is_import) {
  2601. function make_symbol(type) {
  2602. return new type({
  2603. name: as_property_name(),
  2604. start: prev(),
  2605. end: prev()
  2606. });
  2607. }
  2608. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2609. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2610. var start = S.token;
  2611. var foreign_name;
  2612. var name;
  2613. if (is_import) {
  2614. foreign_name = make_symbol(foreign_type);
  2615. } else {
  2616. name = make_symbol(type);
  2617. }
  2618. if (is("name", "as")) {
  2619. next(); // The "as" word
  2620. if (is_import) {
  2621. name = make_symbol(type);
  2622. } else {
  2623. foreign_name = make_symbol(foreign_type);
  2624. }
  2625. } else if (is_import) {
  2626. name = new type(foreign_name);
  2627. } else {
  2628. foreign_name = new foreign_type(name);
  2629. }
  2630. return new AST_NameMapping({
  2631. start: start,
  2632. foreign_name: foreign_name,
  2633. name: name,
  2634. end: prev(),
  2635. });
  2636. }
  2637. function map_nameAsterisk(is_import, name) {
  2638. var foreign_type = is_import ? AST_SymbolImportForeign : AST_SymbolExportForeign;
  2639. var type = is_import ? AST_SymbolImport : AST_SymbolExport;
  2640. var start = S.token;
  2641. var foreign_name;
  2642. var end = prev();
  2643. name = name || new type({
  2644. name: "*",
  2645. start: start,
  2646. end: end,
  2647. });
  2648. foreign_name = new foreign_type({
  2649. name: "*",
  2650. start: start,
  2651. end: end,
  2652. });
  2653. return new AST_NameMapping({
  2654. start: start,
  2655. foreign_name: foreign_name,
  2656. name: name,
  2657. end: end,
  2658. });
  2659. }
  2660. function map_names(is_import) {
  2661. var names;
  2662. if (is("punc", "{")) {
  2663. next();
  2664. names = [];
  2665. while (!is("punc", "}")) {
  2666. names.push(map_name(is_import));
  2667. if (is("punc", ",")) {
  2668. next();
  2669. }
  2670. }
  2671. next();
  2672. } else if (is("operator", "*")) {
  2673. var name;
  2674. next();
  2675. if (is_import && is("name", "as")) {
  2676. next(); // The "as" word
  2677. name = as_symbol(is_import ? AST_SymbolImport : AST_SymbolExportForeign);
  2678. }
  2679. names = [map_nameAsterisk(is_import, name)];
  2680. }
  2681. return names;
  2682. }
  2683. function export_statement() {
  2684. var start = S.token;
  2685. var is_default;
  2686. var exported_names;
  2687. if (is("keyword", "default")) {
  2688. is_default = true;
  2689. next();
  2690. } else if (exported_names = map_names(false)) {
  2691. if (is("name", "from")) {
  2692. next();
  2693. var mod_str = S.token;
  2694. if (mod_str.type !== "string") {
  2695. unexpected();
  2696. }
  2697. next();
  2698. const assert_clause = maybe_import_assertion();
  2699. return new AST_Export({
  2700. start: start,
  2701. is_default: is_default,
  2702. exported_names: exported_names,
  2703. module_name: new AST_String({
  2704. start: mod_str,
  2705. value: mod_str.value,
  2706. quote: mod_str.quote,
  2707. end: mod_str,
  2708. }),
  2709. end: prev(),
  2710. assert_clause
  2711. });
  2712. } else {
  2713. return new AST_Export({
  2714. start: start,
  2715. is_default: is_default,
  2716. exported_names: exported_names,
  2717. end: prev(),
  2718. });
  2719. }
  2720. }
  2721. var node;
  2722. var exported_value;
  2723. var exported_definition;
  2724. if (is("punc", "{")
  2725. || is_default
  2726. && (is("keyword", "class") || is("keyword", "function"))
  2727. && is_token(peek(), "punc")) {
  2728. exported_value = expression(false);
  2729. semicolon();
  2730. } else if ((node = statement(is_default)) instanceof AST_Definitions && is_default) {
  2731. unexpected(node.start);
  2732. } else if (
  2733. node instanceof AST_Definitions
  2734. || node instanceof AST_Defun
  2735. || node instanceof AST_DefClass
  2736. ) {
  2737. exported_definition = node;
  2738. } else if (
  2739. node instanceof AST_ClassExpression
  2740. || node instanceof AST_Function
  2741. ) {
  2742. exported_value = node;
  2743. } else if (node instanceof AST_SimpleStatement) {
  2744. exported_value = node.body;
  2745. } else {
  2746. unexpected(node.start);
  2747. }
  2748. return new AST_Export({
  2749. start: start,
  2750. is_default: is_default,
  2751. exported_value: exported_value,
  2752. exported_definition: exported_definition,
  2753. end: prev(),
  2754. assert_clause: null
  2755. });
  2756. }
  2757. function as_property_name() {
  2758. var tmp = S.token;
  2759. switch (tmp.type) {
  2760. case "punc":
  2761. if (tmp.value === "[") {
  2762. next();
  2763. var ex = expression(false);
  2764. expect("]");
  2765. return ex;
  2766. } else unexpected(tmp);
  2767. case "operator":
  2768. if (tmp.value === "*") {
  2769. next();
  2770. return null;
  2771. }
  2772. if (!["delete", "in", "instanceof", "new", "typeof", "void"].includes(tmp.value)) {
  2773. unexpected(tmp);
  2774. }
  2775. /* falls through */
  2776. case "name":
  2777. case "privatename":
  2778. case "string":
  2779. case "num":
  2780. case "big_int":
  2781. case "keyword":
  2782. case "atom":
  2783. next();
  2784. return tmp.value;
  2785. default:
  2786. unexpected(tmp);
  2787. }
  2788. }
  2789. function as_name() {
  2790. var tmp = S.token;
  2791. if (tmp.type != "name" && tmp.type != "privatename") unexpected();
  2792. next();
  2793. return tmp.value;
  2794. }
  2795. function _make_symbol(type) {
  2796. var name = S.token.value;
  2797. return new (name == "this" ? AST_This :
  2798. name == "super" ? AST_Super :
  2799. type)({
  2800. name : String(name),
  2801. start : S.token,
  2802. end : S.token
  2803. });
  2804. }
  2805. function _verify_symbol(sym) {
  2806. var name = sym.name;
  2807. if (is_in_generator() && name == "yield") {
  2808. token_error(sym.start, "Yield cannot be used as identifier inside generators");
  2809. }
  2810. if (S.input.has_directive("use strict")) {
  2811. if (name == "yield") {
  2812. token_error(sym.start, "Unexpected yield identifier inside strict mode");
  2813. }
  2814. if (sym instanceof AST_SymbolDeclaration && (name == "arguments" || name == "eval")) {
  2815. token_error(sym.start, "Unexpected " + name + " in strict mode");
  2816. }
  2817. }
  2818. }
  2819. function as_symbol(type, noerror) {
  2820. if (!is("name")) {
  2821. if (!noerror) croak("Name expected");
  2822. return null;
  2823. }
  2824. var sym = _make_symbol(type);
  2825. _verify_symbol(sym);
  2826. next();
  2827. return sym;
  2828. }
  2829. // Annotate AST_Call, AST_Lambda or AST_New with the special comments
  2830. function annotate(node) {
  2831. var start = node.start;
  2832. var comments = start.comments_before;
  2833. const comments_outside_parens = outer_comments_before_counts.get(start);
  2834. var i = comments_outside_parens != null ? comments_outside_parens : comments.length;
  2835. while (--i >= 0) {
  2836. var comment = comments[i];
  2837. if (/[@#]__/.test(comment.value)) {
  2838. if (/[@#]__PURE__/.test(comment.value)) {
  2839. set_annotation(node, _PURE);
  2840. break;
  2841. }
  2842. if (/[@#]__INLINE__/.test(comment.value)) {
  2843. set_annotation(node, _INLINE);
  2844. break;
  2845. }
  2846. if (/[@#]__NOINLINE__/.test(comment.value)) {
  2847. set_annotation(node, _NOINLINE);
  2848. break;
  2849. }
  2850. }
  2851. }
  2852. }
  2853. var subscripts = function(expr, allow_calls, is_chain) {
  2854. var start = expr.start;
  2855. if (is("punc", ".")) {
  2856. next();
  2857. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2858. return subscripts(new AST_DotVariant({
  2859. start : start,
  2860. expression : expr,
  2861. optional : false,
  2862. property : as_name(),
  2863. end : prev()
  2864. }), allow_calls, is_chain);
  2865. }
  2866. if (is("punc", "[")) {
  2867. next();
  2868. var prop = expression(true);
  2869. expect("]");
  2870. return subscripts(new AST_Sub({
  2871. start : start,
  2872. expression : expr,
  2873. optional : false,
  2874. property : prop,
  2875. end : prev()
  2876. }), allow_calls, is_chain);
  2877. }
  2878. if (allow_calls && is("punc", "(")) {
  2879. next();
  2880. var call = new AST_Call({
  2881. start : start,
  2882. expression : expr,
  2883. optional : false,
  2884. args : call_args(),
  2885. end : prev()
  2886. });
  2887. annotate(call);
  2888. return subscripts(call, true, is_chain);
  2889. }
  2890. if (is("punc", "?.")) {
  2891. next();
  2892. let chain_contents;
  2893. if (allow_calls && is("punc", "(")) {
  2894. next();
  2895. const call = new AST_Call({
  2896. start,
  2897. optional: true,
  2898. expression: expr,
  2899. args: call_args(),
  2900. end: prev()
  2901. });
  2902. annotate(call);
  2903. chain_contents = subscripts(call, true, true);
  2904. } else if (is("name") || is("privatename")) {
  2905. const AST_DotVariant = is("privatename") ? AST_DotHash : AST_Dot;
  2906. chain_contents = subscripts(new AST_DotVariant({
  2907. start,
  2908. expression: expr,
  2909. optional: true,
  2910. property: as_name(),
  2911. end: prev()
  2912. }), allow_calls, true);
  2913. } else if (is("punc", "[")) {
  2914. next();
  2915. const property = expression(true);
  2916. expect("]");
  2917. chain_contents = subscripts(new AST_Sub({
  2918. start,
  2919. expression: expr,
  2920. optional: true,
  2921. property,
  2922. end: prev()
  2923. }), allow_calls, true);
  2924. }
  2925. if (!chain_contents) unexpected();
  2926. if (chain_contents instanceof AST_Chain) return chain_contents;
  2927. return new AST_Chain({
  2928. start,
  2929. expression: chain_contents,
  2930. end: prev()
  2931. });
  2932. }
  2933. if (is("template_head")) {
  2934. if (is_chain) {
  2935. // a?.b`c` is a syntax error
  2936. unexpected();
  2937. }
  2938. return subscripts(new AST_PrefixedTemplateString({
  2939. start: start,
  2940. prefix: expr,
  2941. template_string: template_string(),
  2942. end: prev()
  2943. }), allow_calls);
  2944. }
  2945. return expr;
  2946. };
  2947. function call_args() {
  2948. var args = [];
  2949. while (!is("punc", ")")) {
  2950. if (is("expand", "...")) {
  2951. next();
  2952. args.push(new AST_Expansion({
  2953. start: prev(),
  2954. expression: expression(false),
  2955. end: prev()
  2956. }));
  2957. } else {
  2958. args.push(expression(false));
  2959. }
  2960. if (!is("punc", ")")) {
  2961. expect(",");
  2962. }
  2963. }
  2964. next();
  2965. return args;
  2966. }
  2967. var maybe_unary = function(allow_calls, allow_arrows) {
  2968. var start = S.token;
  2969. if (start.type == "name" && start.value == "await" && can_await()) {
  2970. next();
  2971. return _await_expression();
  2972. }
  2973. if (is("operator") && UNARY_PREFIX.has(start.value)) {
  2974. next();
  2975. handle_regexp();
  2976. var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls));
  2977. ex.start = start;
  2978. ex.end = prev();
  2979. return ex;
  2980. }
  2981. var val = expr_atom(allow_calls, allow_arrows);
  2982. while (is("operator") && UNARY_POSTFIX.has(S.token.value) && !has_newline_before(S.token)) {
  2983. if (val instanceof AST_Arrow) unexpected();
  2984. val = make_unary(AST_UnaryPostfix, S.token, val);
  2985. val.start = start;
  2986. val.end = S.token;
  2987. next();
  2988. }
  2989. return val;
  2990. };
  2991. function make_unary(ctor, token, expr) {
  2992. var op = token.value;
  2993. switch (op) {
  2994. case "++":
  2995. case "--":
  2996. if (!is_assignable(expr))
  2997. croak("Invalid use of " + op + " operator", token.line, token.col, token.pos);
  2998. break;
  2999. case "delete":
  3000. if (expr instanceof AST_SymbolRef && S.input.has_directive("use strict"))
  3001. croak("Calling delete on expression not allowed in strict mode", expr.start.line, expr.start.col, expr.start.pos);
  3002. break;
  3003. }
  3004. return new ctor({ operator: op, expression: expr });
  3005. }
  3006. var expr_op = function(left, min_prec, no_in) {
  3007. var op = is("operator") ? S.token.value : null;
  3008. if (op == "in" && no_in) op = null;
  3009. if (op == "**" && left instanceof AST_UnaryPrefix
  3010. /* unary token in front not allowed - parenthesis required */
  3011. && !is_token(left.start, "punc", "(")
  3012. && left.operator !== "--" && left.operator !== "++")
  3013. unexpected(left.start);
  3014. var prec = op != null ? PRECEDENCE[op] : null;
  3015. if (prec != null && (prec > min_prec || (op === "**" && min_prec === prec))) {
  3016. next();
  3017. var right = expr_op(maybe_unary(true), prec, no_in);
  3018. return expr_op(new AST_Binary({
  3019. start : left.start,
  3020. left : left,
  3021. operator : op,
  3022. right : right,
  3023. end : right.end
  3024. }), min_prec, no_in);
  3025. }
  3026. return left;
  3027. };
  3028. function expr_ops(no_in) {
  3029. return expr_op(maybe_unary(true, true), 0, no_in);
  3030. }
  3031. var maybe_conditional = function(no_in) {
  3032. var start = S.token;
  3033. var expr = expr_ops(no_in);
  3034. if (is("operator", "?")) {
  3035. next();
  3036. var yes = expression(false);
  3037. expect(":");
  3038. return new AST_Conditional({
  3039. start : start,
  3040. condition : expr,
  3041. consequent : yes,
  3042. alternative : expression(false, no_in),
  3043. end : prev()
  3044. });
  3045. }
  3046. return expr;
  3047. };
  3048. function is_assignable(expr) {
  3049. return expr instanceof AST_PropAccess || expr instanceof AST_SymbolRef;
  3050. }
  3051. function to_destructuring(node) {
  3052. if (node instanceof AST_Object) {
  3053. node = new AST_Destructuring({
  3054. start: node.start,
  3055. names: node.properties.map(to_destructuring),
  3056. is_array: false,
  3057. end: node.end
  3058. });
  3059. } else if (node instanceof AST_Array) {
  3060. var names = [];
  3061. for (var i = 0; i < node.elements.length; i++) {
  3062. // Only allow expansion as last element
  3063. if (node.elements[i] instanceof AST_Expansion) {
  3064. if (i + 1 !== node.elements.length) {
  3065. token_error(node.elements[i].start, "Spread must the be last element in destructuring array");
  3066. }
  3067. node.elements[i].expression = to_destructuring(node.elements[i].expression);
  3068. }
  3069. names.push(to_destructuring(node.elements[i]));
  3070. }
  3071. node = new AST_Destructuring({
  3072. start: node.start,
  3073. names: names,
  3074. is_array: true,
  3075. end: node.end
  3076. });
  3077. } else if (node instanceof AST_ObjectProperty) {
  3078. node.value = to_destructuring(node.value);
  3079. } else if (node instanceof AST_Assign) {
  3080. node = new AST_DefaultAssign({
  3081. start: node.start,
  3082. left: node.left,
  3083. operator: "=",
  3084. right: node.right,
  3085. end: node.end
  3086. });
  3087. }
  3088. return node;
  3089. }
  3090. // In ES6, AssignmentExpression can also be an ArrowFunction
  3091. var maybe_assign = function(no_in) {
  3092. handle_regexp();
  3093. var start = S.token;
  3094. if (start.type == "name" && start.value == "yield") {
  3095. if (is_in_generator()) {
  3096. next();
  3097. return _yield_expression();
  3098. } else if (S.input.has_directive("use strict")) {
  3099. token_error(S.token, "Unexpected yield identifier inside strict mode");
  3100. }
  3101. }
  3102. var left = maybe_conditional(no_in);
  3103. var val = S.token.value;
  3104. if (is("operator") && ASSIGNMENT.has(val)) {
  3105. if (is_assignable(left) || (left = to_destructuring(left)) instanceof AST_Destructuring) {
  3106. next();
  3107. return new AST_Assign({
  3108. start : start,
  3109. left : left,
  3110. operator : val,
  3111. right : maybe_assign(no_in),
  3112. logical : LOGICAL_ASSIGNMENT.has(val),
  3113. end : prev()
  3114. });
  3115. }
  3116. croak("Invalid assignment");
  3117. }
  3118. return left;
  3119. };
  3120. var expression = function(commas, no_in) {
  3121. var start = S.token;
  3122. var exprs = [];
  3123. while (true) {
  3124. exprs.push(maybe_assign(no_in));
  3125. if (!commas || !is("punc", ",")) break;
  3126. next();
  3127. commas = true;
  3128. }
  3129. return exprs.length == 1 ? exprs[0] : new AST_Sequence({
  3130. start : start,
  3131. expressions : exprs,
  3132. end : peek()
  3133. });
  3134. };
  3135. function in_loop(cont) {
  3136. ++S.in_loop;
  3137. var ret = cont();
  3138. --S.in_loop;
  3139. return ret;
  3140. }
  3141. if (options.expression) {
  3142. return expression(true);
  3143. }
  3144. return (function parse_toplevel() {
  3145. var start = S.token;
  3146. var body = [];
  3147. S.input.push_directives_stack();
  3148. if (options.module) S.input.add_directive("use strict");
  3149. while (!is("eof")) {
  3150. body.push(statement());
  3151. }
  3152. S.input.pop_directives_stack();
  3153. var end = prev();
  3154. var toplevel = options.toplevel;
  3155. if (toplevel) {
  3156. toplevel.body = toplevel.body.concat(body);
  3157. toplevel.end = end;
  3158. } else {
  3159. toplevel = new AST_Toplevel({ start: start, body: body, end: end });
  3160. }
  3161. return toplevel;
  3162. })();
  3163. }
  3164. /***********************************************************************
  3165. A JavaScript tokenizer / parser / beautifier / compressor.
  3166. https://github.com/mishoo/UglifyJS2
  3167. -------------------------------- (C) ---------------------------------
  3168. Author: Mihai Bazon
  3169. <mihai.bazon@gmail.com>
  3170. http://mihai.bazon.net/blog
  3171. Distributed under the BSD license:
  3172. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  3173. Redistribution and use in source and binary forms, with or without
  3174. modification, are permitted provided that the following conditions
  3175. are met:
  3176. * Redistributions of source code must retain the above
  3177. copyright notice, this list of conditions and the following
  3178. disclaimer.
  3179. * Redistributions in binary form must reproduce the above
  3180. copyright notice, this list of conditions and the following
  3181. disclaimer in the documentation and/or other materials
  3182. provided with the distribution.
  3183. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  3184. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3185. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3186. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  3187. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  3188. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  3189. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  3190. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3191. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  3192. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  3193. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3194. SUCH DAMAGE.
  3195. ***********************************************************************/
  3196. function DEFNODE(type, props, methods, base = AST_Node) {
  3197. if (!props) props = [];
  3198. else props = props.split(/\s+/);
  3199. var self_props = props;
  3200. if (base && base.PROPS)
  3201. props = props.concat(base.PROPS);
  3202. var code = "return function AST_" + type + "(props){ if (props) { ";
  3203. for (var i = props.length; --i >= 0;) {
  3204. code += "this." + props[i] + " = props." + props[i] + ";";
  3205. }
  3206. const proto = base && Object.create(base.prototype);
  3207. if (proto && proto.initialize || (methods && methods.initialize))
  3208. code += "this.initialize();";
  3209. code += "}";
  3210. code += "this.flags = 0;";
  3211. code += "}";
  3212. var ctor = new Function(code)();
  3213. if (proto) {
  3214. ctor.prototype = proto;
  3215. ctor.BASE = base;
  3216. }
  3217. if (base) base.SUBCLASSES.push(ctor);
  3218. ctor.prototype.CTOR = ctor;
  3219. ctor.prototype.constructor = ctor;
  3220. ctor.PROPS = props || null;
  3221. ctor.SELF_PROPS = self_props;
  3222. ctor.SUBCLASSES = [];
  3223. if (type) {
  3224. ctor.prototype.TYPE = ctor.TYPE = type;
  3225. }
  3226. if (methods) for (i in methods) if (HOP(methods, i)) {
  3227. if (i[0] === "$") {
  3228. ctor[i.substr(1)] = methods[i];
  3229. } else {
  3230. ctor.prototype[i] = methods[i];
  3231. }
  3232. }
  3233. ctor.DEFMETHOD = function(name, method) {
  3234. this.prototype[name] = method;
  3235. };
  3236. return ctor;
  3237. }
  3238. const has_tok_flag = (tok, flag) => Boolean(tok.flags & flag);
  3239. const set_tok_flag = (tok, flag, truth) => {
  3240. if (truth) {
  3241. tok.flags |= flag;
  3242. } else {
  3243. tok.flags &= ~flag;
  3244. }
  3245. };
  3246. const TOK_FLAG_NLB = 0b0001;
  3247. const TOK_FLAG_QUOTE_SINGLE = 0b0010;
  3248. const TOK_FLAG_QUOTE_EXISTS = 0b0100;
  3249. class AST_Token {
  3250. constructor(type, value, line, col, pos, nlb, comments_before, comments_after, file) {
  3251. this.flags = (nlb ? 1 : 0);
  3252. this.type = type;
  3253. this.value = value;
  3254. this.line = line;
  3255. this.col = col;
  3256. this.pos = pos;
  3257. this.comments_before = comments_before;
  3258. this.comments_after = comments_after;
  3259. this.file = file;
  3260. Object.seal(this);
  3261. }
  3262. get nlb() {
  3263. return has_tok_flag(this, TOK_FLAG_NLB);
  3264. }
  3265. set nlb(new_nlb) {
  3266. set_tok_flag(this, TOK_FLAG_NLB, new_nlb);
  3267. }
  3268. get quote() {
  3269. return !has_tok_flag(this, TOK_FLAG_QUOTE_EXISTS)
  3270. ? ""
  3271. : (has_tok_flag(this, TOK_FLAG_QUOTE_SINGLE) ? "'" : '"');
  3272. }
  3273. set quote(quote_type) {
  3274. set_tok_flag(this, TOK_FLAG_QUOTE_SINGLE, quote_type === "'");
  3275. set_tok_flag(this, TOK_FLAG_QUOTE_EXISTS, !!quote_type);
  3276. }
  3277. }
  3278. var AST_Node = DEFNODE("Node", "start end", {
  3279. _clone: function(deep) {
  3280. if (deep) {
  3281. var self = this.clone();
  3282. return self.transform(new TreeTransformer(function(node) {
  3283. if (node !== self) {
  3284. return node.clone(true);
  3285. }
  3286. }));
  3287. }
  3288. return new this.CTOR(this);
  3289. },
  3290. clone: function(deep) {
  3291. return this._clone(deep);
  3292. },
  3293. $documentation: "Base class of all AST nodes",
  3294. $propdoc: {
  3295. start: "[AST_Token] The first token of this node",
  3296. end: "[AST_Token] The last token of this node"
  3297. },
  3298. _walk: function(visitor) {
  3299. return visitor._visit(this);
  3300. },
  3301. walk: function(visitor) {
  3302. return this._walk(visitor); // not sure the indirection will be any help
  3303. },
  3304. _children_backwards: () => {}
  3305. }, null);
  3306. /* -----[ statements ]----- */
  3307. var AST_Statement = DEFNODE("Statement", null, {
  3308. $documentation: "Base class of all statements",
  3309. });
  3310. var AST_Debugger = DEFNODE("Debugger", null, {
  3311. $documentation: "Represents a debugger statement",
  3312. }, AST_Statement);
  3313. var AST_Directive = DEFNODE("Directive", "value quote", {
  3314. $documentation: "Represents a directive, like \"use strict\";",
  3315. $propdoc: {
  3316. value: "[string] The value of this directive as a plain string (it's not an AST_String!)",
  3317. quote: "[string] the original quote character"
  3318. },
  3319. }, AST_Statement);
  3320. var AST_SimpleStatement = DEFNODE("SimpleStatement", "body", {
  3321. $documentation: "A statement consisting of an expression, i.e. a = 1 + 2",
  3322. $propdoc: {
  3323. body: "[AST_Node] an expression node (should not be instanceof AST_Statement)"
  3324. },
  3325. _walk: function(visitor) {
  3326. return visitor._visit(this, function() {
  3327. this.body._walk(visitor);
  3328. });
  3329. },
  3330. _children_backwards(push) {
  3331. push(this.body);
  3332. }
  3333. }, AST_Statement);
  3334. function walk_body(node, visitor) {
  3335. const body = node.body;
  3336. for (var i = 0, len = body.length; i < len; i++) {
  3337. body[i]._walk(visitor);
  3338. }
  3339. }
  3340. function clone_block_scope(deep) {
  3341. var clone = this._clone(deep);
  3342. if (this.block_scope) {
  3343. clone.block_scope = this.block_scope.clone();
  3344. }
  3345. return clone;
  3346. }
  3347. var AST_Block = DEFNODE("Block", "body block_scope", {
  3348. $documentation: "A body of statements (usually braced)",
  3349. $propdoc: {
  3350. body: "[AST_Statement*] an array of statements",
  3351. block_scope: "[AST_Scope] the block scope"
  3352. },
  3353. _walk: function(visitor) {
  3354. return visitor._visit(this, function() {
  3355. walk_body(this, visitor);
  3356. });
  3357. },
  3358. _children_backwards(push) {
  3359. let i = this.body.length;
  3360. while (i--) push(this.body[i]);
  3361. },
  3362. clone: clone_block_scope
  3363. }, AST_Statement);
  3364. var AST_BlockStatement = DEFNODE("BlockStatement", null, {
  3365. $documentation: "A block statement",
  3366. }, AST_Block);
  3367. var AST_EmptyStatement = DEFNODE("EmptyStatement", null, {
  3368. $documentation: "The empty statement (empty block or simply a semicolon)"
  3369. }, AST_Statement);
  3370. var AST_StatementWithBody = DEFNODE("StatementWithBody", "body", {
  3371. $documentation: "Base class for all statements that contain one nested body: `For`, `ForIn`, `Do`, `While`, `With`",
  3372. $propdoc: {
  3373. body: "[AST_Statement] the body; this should always be present, even if it's an AST_EmptyStatement"
  3374. }
  3375. }, AST_Statement);
  3376. var AST_LabeledStatement = DEFNODE("LabeledStatement", "label", {
  3377. $documentation: "Statement with a label",
  3378. $propdoc: {
  3379. label: "[AST_Label] a label definition"
  3380. },
  3381. _walk: function(visitor) {
  3382. return visitor._visit(this, function() {
  3383. this.label._walk(visitor);
  3384. this.body._walk(visitor);
  3385. });
  3386. },
  3387. _children_backwards(push) {
  3388. push(this.body);
  3389. push(this.label);
  3390. },
  3391. clone: function(deep) {
  3392. var node = this._clone(deep);
  3393. if (deep) {
  3394. var label = node.label;
  3395. var def = this.label;
  3396. node.walk(new TreeWalker(function(node) {
  3397. if (node instanceof AST_LoopControl
  3398. && node.label && node.label.thedef === def) {
  3399. node.label.thedef = label;
  3400. label.references.push(node);
  3401. }
  3402. }));
  3403. }
  3404. return node;
  3405. }
  3406. }, AST_StatementWithBody);
  3407. var AST_IterationStatement = DEFNODE("IterationStatement", "block_scope", {
  3408. $documentation: "Internal class. All loops inherit from it.",
  3409. $propdoc: {
  3410. block_scope: "[AST_Scope] the block scope for this iteration statement."
  3411. },
  3412. clone: clone_block_scope
  3413. }, AST_StatementWithBody);
  3414. var AST_DWLoop = DEFNODE("DWLoop", "condition", {
  3415. $documentation: "Base class for do/while statements",
  3416. $propdoc: {
  3417. condition: "[AST_Node] the loop condition. Should not be instanceof AST_Statement"
  3418. }
  3419. }, AST_IterationStatement);
  3420. var AST_Do = DEFNODE("Do", null, {
  3421. $documentation: "A `do` statement",
  3422. _walk: function(visitor) {
  3423. return visitor._visit(this, function() {
  3424. this.body._walk(visitor);
  3425. this.condition._walk(visitor);
  3426. });
  3427. },
  3428. _children_backwards(push) {
  3429. push(this.condition);
  3430. push(this.body);
  3431. }
  3432. }, AST_DWLoop);
  3433. var AST_While = DEFNODE("While", null, {
  3434. $documentation: "A `while` statement",
  3435. _walk: function(visitor) {
  3436. return visitor._visit(this, function() {
  3437. this.condition._walk(visitor);
  3438. this.body._walk(visitor);
  3439. });
  3440. },
  3441. _children_backwards(push) {
  3442. push(this.body);
  3443. push(this.condition);
  3444. },
  3445. }, AST_DWLoop);
  3446. var AST_For = DEFNODE("For", "init condition step", {
  3447. $documentation: "A `for` statement",
  3448. $propdoc: {
  3449. init: "[AST_Node?] the `for` initialization code, or null if empty",
  3450. condition: "[AST_Node?] the `for` termination clause, or null if empty",
  3451. step: "[AST_Node?] the `for` update clause, or null if empty"
  3452. },
  3453. _walk: function(visitor) {
  3454. return visitor._visit(this, function() {
  3455. if (this.init) this.init._walk(visitor);
  3456. if (this.condition) this.condition._walk(visitor);
  3457. if (this.step) this.step._walk(visitor);
  3458. this.body._walk(visitor);
  3459. });
  3460. },
  3461. _children_backwards(push) {
  3462. push(this.body);
  3463. if (this.step) push(this.step);
  3464. if (this.condition) push(this.condition);
  3465. if (this.init) push(this.init);
  3466. },
  3467. }, AST_IterationStatement);
  3468. var AST_ForIn = DEFNODE("ForIn", "init object", {
  3469. $documentation: "A `for ... in` statement",
  3470. $propdoc: {
  3471. init: "[AST_Node] the `for/in` initialization code",
  3472. object: "[AST_Node] the object that we're looping through"
  3473. },
  3474. _walk: function(visitor) {
  3475. return visitor._visit(this, function() {
  3476. this.init._walk(visitor);
  3477. this.object._walk(visitor);
  3478. this.body._walk(visitor);
  3479. });
  3480. },
  3481. _children_backwards(push) {
  3482. push(this.body);
  3483. if (this.object) push(this.object);
  3484. if (this.init) push(this.init);
  3485. },
  3486. }, AST_IterationStatement);
  3487. var AST_ForOf = DEFNODE("ForOf", "await", {
  3488. $documentation: "A `for ... of` statement",
  3489. }, AST_ForIn);
  3490. var AST_With = DEFNODE("With", "expression", {
  3491. $documentation: "A `with` statement",
  3492. $propdoc: {
  3493. expression: "[AST_Node] the `with` expression"
  3494. },
  3495. _walk: function(visitor) {
  3496. return visitor._visit(this, function() {
  3497. this.expression._walk(visitor);
  3498. this.body._walk(visitor);
  3499. });
  3500. },
  3501. _children_backwards(push) {
  3502. push(this.body);
  3503. push(this.expression);
  3504. },
  3505. }, AST_StatementWithBody);
  3506. /* -----[ scope and functions ]----- */
  3507. var AST_Scope = DEFNODE("Scope", "variables functions uses_with uses_eval parent_scope enclosed cname", {
  3508. $documentation: "Base class for all statements introducing a lexical scope",
  3509. $propdoc: {
  3510. variables: "[Map/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
  3511. uses_with: "[boolean/S] tells whether this scope uses the `with` statement",
  3512. uses_eval: "[boolean/S] tells whether this scope contains a direct call to the global `eval`",
  3513. parent_scope: "[AST_Scope?/S] link to the parent scope",
  3514. enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",
  3515. cname: "[integer/S] current index for mangling variables (used internally by the mangler)",
  3516. },
  3517. get_defun_scope: function() {
  3518. var self = this;
  3519. while (self.is_block_scope()) {
  3520. self = self.parent_scope;
  3521. }
  3522. return self;
  3523. },
  3524. clone: function(deep, toplevel) {
  3525. var node = this._clone(deep);
  3526. if (deep && this.variables && toplevel && !this._block_scope) {
  3527. node.figure_out_scope({}, {
  3528. toplevel: toplevel,
  3529. parent_scope: this.parent_scope
  3530. });
  3531. } else {
  3532. if (this.variables) node.variables = new Map(this.variables);
  3533. if (this.enclosed) node.enclosed = this.enclosed.slice();
  3534. if (this._block_scope) node._block_scope = this._block_scope;
  3535. }
  3536. return node;
  3537. },
  3538. pinned: function() {
  3539. return this.uses_eval || this.uses_with;
  3540. }
  3541. }, AST_Block);
  3542. var AST_Toplevel = DEFNODE("Toplevel", "globals", {
  3543. $documentation: "The toplevel scope",
  3544. $propdoc: {
  3545. globals: "[Map/S] a map of name -> SymbolDef for all undeclared names",
  3546. },
  3547. wrap_commonjs: function(name) {
  3548. var body = this.body;
  3549. var wrapped_tl = "(function(exports){'$ORIG';})(typeof " + name + "=='undefined'?(" + name + "={}):" + name + ");";
  3550. wrapped_tl = parse(wrapped_tl);
  3551. wrapped_tl = wrapped_tl.transform(new TreeTransformer(function(node) {
  3552. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3553. return MAP.splice(body);
  3554. }
  3555. }));
  3556. return wrapped_tl;
  3557. },
  3558. wrap_enclose: function(args_values) {
  3559. if (typeof args_values != "string") args_values = "";
  3560. var index = args_values.indexOf(":");
  3561. if (index < 0) index = args_values.length;
  3562. var body = this.body;
  3563. return parse([
  3564. "(function(",
  3565. args_values.slice(0, index),
  3566. '){"$ORIG"})(',
  3567. args_values.slice(index + 1),
  3568. ")"
  3569. ].join("")).transform(new TreeTransformer(function(node) {
  3570. if (node instanceof AST_Directive && node.value == "$ORIG") {
  3571. return MAP.splice(body);
  3572. }
  3573. }));
  3574. }
  3575. }, AST_Scope);
  3576. var AST_Expansion = DEFNODE("Expansion", "expression", {
  3577. $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",
  3578. $propdoc: {
  3579. expression: "[AST_Node] the thing to be expanded"
  3580. },
  3581. _walk: function(visitor) {
  3582. return visitor._visit(this, function() {
  3583. this.expression.walk(visitor);
  3584. });
  3585. },
  3586. _children_backwards(push) {
  3587. push(this.expression);
  3588. },
  3589. });
  3590. var AST_Lambda = DEFNODE("Lambda", "name argnames uses_arguments is_generator async", {
  3591. $documentation: "Base class for functions",
  3592. $propdoc: {
  3593. name: "[AST_SymbolDeclaration?] the name of this function",
  3594. argnames: "[AST_SymbolFunarg|AST_Destructuring|AST_Expansion|AST_DefaultAssign*] array of function arguments, destructurings, or expanding arguments",
  3595. uses_arguments: "[boolean/S] tells whether this function accesses the arguments array",
  3596. is_generator: "[boolean] is this a generator method",
  3597. async: "[boolean] is this method async",
  3598. },
  3599. args_as_names: function () {
  3600. var out = [];
  3601. for (var i = 0; i < this.argnames.length; i++) {
  3602. if (this.argnames[i] instanceof AST_Destructuring) {
  3603. out.push(...this.argnames[i].all_symbols());
  3604. } else {
  3605. out.push(this.argnames[i]);
  3606. }
  3607. }
  3608. return out;
  3609. },
  3610. _walk: function(visitor) {
  3611. return visitor._visit(this, function() {
  3612. if (this.name) this.name._walk(visitor);
  3613. var argnames = this.argnames;
  3614. for (var i = 0, len = argnames.length; i < len; i++) {
  3615. argnames[i]._walk(visitor);
  3616. }
  3617. walk_body(this, visitor);
  3618. });
  3619. },
  3620. _children_backwards(push) {
  3621. let i = this.body.length;
  3622. while (i--) push(this.body[i]);
  3623. i = this.argnames.length;
  3624. while (i--) push(this.argnames[i]);
  3625. if (this.name) push(this.name);
  3626. },
  3627. is_braceless() {
  3628. return this.body[0] instanceof AST_Return && this.body[0].value;
  3629. },
  3630. // Default args and expansion don't count, so .argnames.length doesn't cut it
  3631. length_property() {
  3632. let length = 0;
  3633. for (const arg of this.argnames) {
  3634. if (arg instanceof AST_SymbolFunarg || arg instanceof AST_Destructuring) {
  3635. length++;
  3636. }
  3637. }
  3638. return length;
  3639. }
  3640. }, AST_Scope);
  3641. var AST_Accessor = DEFNODE("Accessor", null, {
  3642. $documentation: "A setter/getter function. The `name` property is always null."
  3643. }, AST_Lambda);
  3644. var AST_Function = DEFNODE("Function", null, {
  3645. $documentation: "A function expression"
  3646. }, AST_Lambda);
  3647. var AST_Arrow = DEFNODE("Arrow", null, {
  3648. $documentation: "An ES6 Arrow function ((a) => b)"
  3649. }, AST_Lambda);
  3650. var AST_Defun = DEFNODE("Defun", null, {
  3651. $documentation: "A function definition"
  3652. }, AST_Lambda);
  3653. /* -----[ DESTRUCTURING ]----- */
  3654. var AST_Destructuring = DEFNODE("Destructuring", "names is_array", {
  3655. $documentation: "A destructuring of several names. Used in destructuring assignment and with destructuring function argument names",
  3656. $propdoc: {
  3657. "names": "[AST_Node*] Array of properties or elements",
  3658. "is_array": "[Boolean] Whether the destructuring represents an object or array"
  3659. },
  3660. _walk: function(visitor) {
  3661. return visitor._visit(this, function() {
  3662. this.names.forEach(function(name) {
  3663. name._walk(visitor);
  3664. });
  3665. });
  3666. },
  3667. _children_backwards(push) {
  3668. let i = this.names.length;
  3669. while (i--) push(this.names[i]);
  3670. },
  3671. all_symbols: function() {
  3672. var out = [];
  3673. this.walk(new TreeWalker(function (node) {
  3674. if (node instanceof AST_Symbol) {
  3675. out.push(node);
  3676. }
  3677. }));
  3678. return out;
  3679. }
  3680. });
  3681. var AST_PrefixedTemplateString = DEFNODE("PrefixedTemplateString", "template_string prefix", {
  3682. $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
  3683. $propdoc: {
  3684. template_string: "[AST_TemplateString] The template string",
  3685. prefix: "[AST_Node] The prefix, which will get called."
  3686. },
  3687. _walk: function(visitor) {
  3688. return visitor._visit(this, function () {
  3689. this.prefix._walk(visitor);
  3690. this.template_string._walk(visitor);
  3691. });
  3692. },
  3693. _children_backwards(push) {
  3694. push(this.template_string);
  3695. push(this.prefix);
  3696. },
  3697. });
  3698. var AST_TemplateString = DEFNODE("TemplateString", "segments", {
  3699. $documentation: "A template string literal",
  3700. $propdoc: {
  3701. 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."
  3702. },
  3703. _walk: function(visitor) {
  3704. return visitor._visit(this, function() {
  3705. this.segments.forEach(function(seg) {
  3706. seg._walk(visitor);
  3707. });
  3708. });
  3709. },
  3710. _children_backwards(push) {
  3711. let i = this.segments.length;
  3712. while (i--) push(this.segments[i]);
  3713. }
  3714. });
  3715. var AST_TemplateSegment = DEFNODE("TemplateSegment", "value raw", {
  3716. $documentation: "A segment of a template string literal",
  3717. $propdoc: {
  3718. value: "Content of the segment",
  3719. raw: "Raw source of the segment",
  3720. }
  3721. });
  3722. /* -----[ JUMPS ]----- */
  3723. var AST_Jump = DEFNODE("Jump", null, {
  3724. $documentation: "Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"
  3725. }, AST_Statement);
  3726. var AST_Exit = DEFNODE("Exit", "value", {
  3727. $documentation: "Base class for “exits” (`return` and `throw`)",
  3728. $propdoc: {
  3729. value: "[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"
  3730. },
  3731. _walk: function(visitor) {
  3732. return visitor._visit(this, this.value && function() {
  3733. this.value._walk(visitor);
  3734. });
  3735. },
  3736. _children_backwards(push) {
  3737. if (this.value) push(this.value);
  3738. },
  3739. }, AST_Jump);
  3740. var AST_Return = DEFNODE("Return", null, {
  3741. $documentation: "A `return` statement"
  3742. }, AST_Exit);
  3743. var AST_Throw = DEFNODE("Throw", null, {
  3744. $documentation: "A `throw` statement"
  3745. }, AST_Exit);
  3746. var AST_LoopControl = DEFNODE("LoopControl", "label", {
  3747. $documentation: "Base class for loop control statements (`break` and `continue`)",
  3748. $propdoc: {
  3749. label: "[AST_LabelRef?] the label, or null if none",
  3750. },
  3751. _walk: function(visitor) {
  3752. return visitor._visit(this, this.label && function() {
  3753. this.label._walk(visitor);
  3754. });
  3755. },
  3756. _children_backwards(push) {
  3757. if (this.label) push(this.label);
  3758. },
  3759. }, AST_Jump);
  3760. var AST_Break = DEFNODE("Break", null, {
  3761. $documentation: "A `break` statement"
  3762. }, AST_LoopControl);
  3763. var AST_Continue = DEFNODE("Continue", null, {
  3764. $documentation: "A `continue` statement"
  3765. }, AST_LoopControl);
  3766. var AST_Await = DEFNODE("Await", "expression", {
  3767. $documentation: "An `await` statement",
  3768. $propdoc: {
  3769. expression: "[AST_Node] the mandatory expression being awaited",
  3770. },
  3771. _walk: function(visitor) {
  3772. return visitor._visit(this, function() {
  3773. this.expression._walk(visitor);
  3774. });
  3775. },
  3776. _children_backwards(push) {
  3777. push(this.expression);
  3778. },
  3779. });
  3780. var AST_Yield = DEFNODE("Yield", "expression is_star", {
  3781. $documentation: "A `yield` statement",
  3782. $propdoc: {
  3783. 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",
  3784. is_star: "[Boolean] Whether this is a yield or yield* statement"
  3785. },
  3786. _walk: function(visitor) {
  3787. return visitor._visit(this, this.expression && function() {
  3788. this.expression._walk(visitor);
  3789. });
  3790. },
  3791. _children_backwards(push) {
  3792. if (this.expression) push(this.expression);
  3793. }
  3794. });
  3795. /* -----[ IF ]----- */
  3796. var AST_If = DEFNODE("If", "condition alternative", {
  3797. $documentation: "A `if` statement",
  3798. $propdoc: {
  3799. condition: "[AST_Node] the `if` condition",
  3800. alternative: "[AST_Statement?] the `else` part, or null if not present"
  3801. },
  3802. _walk: function(visitor) {
  3803. return visitor._visit(this, function() {
  3804. this.condition._walk(visitor);
  3805. this.body._walk(visitor);
  3806. if (this.alternative) this.alternative._walk(visitor);
  3807. });
  3808. },
  3809. _children_backwards(push) {
  3810. if (this.alternative) {
  3811. push(this.alternative);
  3812. }
  3813. push(this.body);
  3814. push(this.condition);
  3815. }
  3816. }, AST_StatementWithBody);
  3817. /* -----[ SWITCH ]----- */
  3818. var AST_Switch = DEFNODE("Switch", "expression", {
  3819. $documentation: "A `switch` statement",
  3820. $propdoc: {
  3821. expression: "[AST_Node] the `switch` “discriminant”"
  3822. },
  3823. _walk: function(visitor) {
  3824. return visitor._visit(this, function() {
  3825. this.expression._walk(visitor);
  3826. walk_body(this, visitor);
  3827. });
  3828. },
  3829. _children_backwards(push) {
  3830. let i = this.body.length;
  3831. while (i--) push(this.body[i]);
  3832. push(this.expression);
  3833. }
  3834. }, AST_Block);
  3835. var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
  3836. $documentation: "Base class for `switch` branches",
  3837. }, AST_Block);
  3838. var AST_Default = DEFNODE("Default", null, {
  3839. $documentation: "A `default` switch branch",
  3840. }, AST_SwitchBranch);
  3841. var AST_Case = DEFNODE("Case", "expression", {
  3842. $documentation: "A `case` switch branch",
  3843. $propdoc: {
  3844. expression: "[AST_Node] the `case` expression"
  3845. },
  3846. _walk: function(visitor) {
  3847. return visitor._visit(this, function() {
  3848. this.expression._walk(visitor);
  3849. walk_body(this, visitor);
  3850. });
  3851. },
  3852. _children_backwards(push) {
  3853. let i = this.body.length;
  3854. while (i--) push(this.body[i]);
  3855. push(this.expression);
  3856. },
  3857. }, AST_SwitchBranch);
  3858. /* -----[ EXCEPTIONS ]----- */
  3859. var AST_Try = DEFNODE("Try", "bcatch bfinally", {
  3860. $documentation: "A `try` statement",
  3861. $propdoc: {
  3862. bcatch: "[AST_Catch?] the catch block, or null if not present",
  3863. bfinally: "[AST_Finally?] the finally block, or null if not present"
  3864. },
  3865. _walk: function(visitor) {
  3866. return visitor._visit(this, function() {
  3867. walk_body(this, visitor);
  3868. if (this.bcatch) this.bcatch._walk(visitor);
  3869. if (this.bfinally) this.bfinally._walk(visitor);
  3870. });
  3871. },
  3872. _children_backwards(push) {
  3873. if (this.bfinally) push(this.bfinally);
  3874. if (this.bcatch) push(this.bcatch);
  3875. let i = this.body.length;
  3876. while (i--) push(this.body[i]);
  3877. },
  3878. }, AST_Block);
  3879. var AST_Catch = DEFNODE("Catch", "argname", {
  3880. $documentation: "A `catch` node; only makes sense as part of a `try` statement",
  3881. $propdoc: {
  3882. argname: "[AST_SymbolCatch|AST_Destructuring|AST_Expansion|AST_DefaultAssign] symbol for the exception"
  3883. },
  3884. _walk: function(visitor) {
  3885. return visitor._visit(this, function() {
  3886. if (this.argname) this.argname._walk(visitor);
  3887. walk_body(this, visitor);
  3888. });
  3889. },
  3890. _children_backwards(push) {
  3891. let i = this.body.length;
  3892. while (i--) push(this.body[i]);
  3893. if (this.argname) push(this.argname);
  3894. },
  3895. }, AST_Block);
  3896. var AST_Finally = DEFNODE("Finally", null, {
  3897. $documentation: "A `finally` node; only makes sense as part of a `try` statement"
  3898. }, AST_Block);
  3899. /* -----[ VAR/CONST ]----- */
  3900. var AST_Definitions = DEFNODE("Definitions", "definitions", {
  3901. $documentation: "Base class for `var` or `const` nodes (variable declarations/initializations)",
  3902. $propdoc: {
  3903. definitions: "[AST_VarDef*] array of variable definitions"
  3904. },
  3905. _walk: function(visitor) {
  3906. return visitor._visit(this, function() {
  3907. var definitions = this.definitions;
  3908. for (var i = 0, len = definitions.length; i < len; i++) {
  3909. definitions[i]._walk(visitor);
  3910. }
  3911. });
  3912. },
  3913. _children_backwards(push) {
  3914. let i = this.definitions.length;
  3915. while (i--) push(this.definitions[i]);
  3916. },
  3917. }, AST_Statement);
  3918. var AST_Var = DEFNODE("Var", null, {
  3919. $documentation: "A `var` statement"
  3920. }, AST_Definitions);
  3921. var AST_Let = DEFNODE("Let", null, {
  3922. $documentation: "A `let` statement"
  3923. }, AST_Definitions);
  3924. var AST_Const = DEFNODE("Const", null, {
  3925. $documentation: "A `const` statement"
  3926. }, AST_Definitions);
  3927. var AST_VarDef = DEFNODE("VarDef", "name value", {
  3928. $documentation: "A variable declaration; only appears in a AST_Definitions node",
  3929. $propdoc: {
  3930. name: "[AST_Destructuring|AST_SymbolConst|AST_SymbolLet|AST_SymbolVar] name of the variable",
  3931. value: "[AST_Node?] initializer, or null of there's no initializer"
  3932. },
  3933. _walk: function(visitor) {
  3934. return visitor._visit(this, function() {
  3935. this.name._walk(visitor);
  3936. if (this.value) this.value._walk(visitor);
  3937. });
  3938. },
  3939. _children_backwards(push) {
  3940. if (this.value) push(this.value);
  3941. push(this.name);
  3942. },
  3943. });
  3944. var AST_NameMapping = DEFNODE("NameMapping", "foreign_name name", {
  3945. $documentation: "The part of the export/import statement that declare names from a module.",
  3946. $propdoc: {
  3947. foreign_name: "[AST_SymbolExportForeign|AST_SymbolImportForeign] The name being exported/imported (as specified in the module)",
  3948. name: "[AST_SymbolExport|AST_SymbolImport] The name as it is visible to this module."
  3949. },
  3950. _walk: function (visitor) {
  3951. return visitor._visit(this, function() {
  3952. this.foreign_name._walk(visitor);
  3953. this.name._walk(visitor);
  3954. });
  3955. },
  3956. _children_backwards(push) {
  3957. push(this.name);
  3958. push(this.foreign_name);
  3959. },
  3960. });
  3961. var AST_Import = DEFNODE("Import", "imported_name imported_names module_name assert_clause", {
  3962. $documentation: "An `import` statement",
  3963. $propdoc: {
  3964. imported_name: "[AST_SymbolImport] The name of the variable holding the module's default export.",
  3965. imported_names: "[AST_NameMapping*] The names of non-default imported variables",
  3966. module_name: "[AST_String] String literal describing where this module came from",
  3967. assert_clause: "[AST_Object?] The import assertion"
  3968. },
  3969. _walk: function(visitor) {
  3970. return visitor._visit(this, function() {
  3971. if (this.imported_name) {
  3972. this.imported_name._walk(visitor);
  3973. }
  3974. if (this.imported_names) {
  3975. this.imported_names.forEach(function(name_import) {
  3976. name_import._walk(visitor);
  3977. });
  3978. }
  3979. this.module_name._walk(visitor);
  3980. });
  3981. },
  3982. _children_backwards(push) {
  3983. push(this.module_name);
  3984. if (this.imported_names) {
  3985. let i = this.imported_names.length;
  3986. while (i--) push(this.imported_names[i]);
  3987. }
  3988. if (this.imported_name) push(this.imported_name);
  3989. },
  3990. });
  3991. var AST_ImportMeta = DEFNODE("ImportMeta", null, {
  3992. $documentation: "A reference to import.meta",
  3993. });
  3994. var AST_Export = DEFNODE("Export", "exported_definition exported_value is_default exported_names module_name assert_clause", {
  3995. $documentation: "An `export` statement",
  3996. $propdoc: {
  3997. exported_definition: "[AST_Defun|AST_Definitions|AST_DefClass?] An exported definition",
  3998. exported_value: "[AST_Node?] An exported value",
  3999. exported_names: "[AST_NameMapping*?] List of exported names",
  4000. module_name: "[AST_String?] Name of the file to load exports from",
  4001. is_default: "[Boolean] Whether this is the default exported value of this module",
  4002. assert_clause: "[AST_Object?] The import assertion"
  4003. },
  4004. _walk: function (visitor) {
  4005. return visitor._visit(this, function () {
  4006. if (this.exported_definition) {
  4007. this.exported_definition._walk(visitor);
  4008. }
  4009. if (this.exported_value) {
  4010. this.exported_value._walk(visitor);
  4011. }
  4012. if (this.exported_names) {
  4013. this.exported_names.forEach(function(name_export) {
  4014. name_export._walk(visitor);
  4015. });
  4016. }
  4017. if (this.module_name) {
  4018. this.module_name._walk(visitor);
  4019. }
  4020. });
  4021. },
  4022. _children_backwards(push) {
  4023. if (this.module_name) push(this.module_name);
  4024. if (this.exported_names) {
  4025. let i = this.exported_names.length;
  4026. while (i--) push(this.exported_names[i]);
  4027. }
  4028. if (this.exported_value) push(this.exported_value);
  4029. if (this.exported_definition) push(this.exported_definition);
  4030. }
  4031. }, AST_Statement);
  4032. /* -----[ OTHER ]----- */
  4033. var AST_Call = DEFNODE("Call", "expression args optional _annotations", {
  4034. $documentation: "A function call expression",
  4035. $propdoc: {
  4036. expression: "[AST_Node] expression to invoke as function",
  4037. args: "[AST_Node*] array of arguments",
  4038. optional: "[boolean] whether this is an optional call (IE ?.() )",
  4039. _annotations: "[number] bitfield containing information about the call"
  4040. },
  4041. initialize() {
  4042. if (this._annotations == null) this._annotations = 0;
  4043. },
  4044. _walk(visitor) {
  4045. return visitor._visit(this, function() {
  4046. var args = this.args;
  4047. for (var i = 0, len = args.length; i < len; i++) {
  4048. args[i]._walk(visitor);
  4049. }
  4050. this.expression._walk(visitor); // TODO why do we need to crawl this last?
  4051. });
  4052. },
  4053. _children_backwards(push) {
  4054. let i = this.args.length;
  4055. while (i--) push(this.args[i]);
  4056. push(this.expression);
  4057. },
  4058. });
  4059. var AST_New = DEFNODE("New", null, {
  4060. $documentation: "An object instantiation. Derives from a function call since it has exactly the same properties"
  4061. }, AST_Call);
  4062. var AST_Sequence = DEFNODE("Sequence", "expressions", {
  4063. $documentation: "A sequence expression (comma-separated expressions)",
  4064. $propdoc: {
  4065. expressions: "[AST_Node*] array of expressions (at least two)"
  4066. },
  4067. _walk: function(visitor) {
  4068. return visitor._visit(this, function() {
  4069. this.expressions.forEach(function(node) {
  4070. node._walk(visitor);
  4071. });
  4072. });
  4073. },
  4074. _children_backwards(push) {
  4075. let i = this.expressions.length;
  4076. while (i--) push(this.expressions[i]);
  4077. },
  4078. });
  4079. var AST_PropAccess = DEFNODE("PropAccess", "expression property optional", {
  4080. $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
  4081. $propdoc: {
  4082. expression: "[AST_Node] the “container” expression",
  4083. 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",
  4084. optional: "[boolean] whether this is an optional property access (IE ?.)"
  4085. }
  4086. });
  4087. var AST_Dot = DEFNODE("Dot", "quote", {
  4088. $documentation: "A dotted property access expression",
  4089. $propdoc: {
  4090. quote: "[string] the original quote character when transformed from AST_Sub",
  4091. },
  4092. _walk: function(visitor) {
  4093. return visitor._visit(this, function() {
  4094. this.expression._walk(visitor);
  4095. });
  4096. },
  4097. _children_backwards(push) {
  4098. push(this.expression);
  4099. },
  4100. }, AST_PropAccess);
  4101. var AST_DotHash = DEFNODE("DotHash", "", {
  4102. $documentation: "A dotted property access to a private property",
  4103. _walk: function(visitor) {
  4104. return visitor._visit(this, function() {
  4105. this.expression._walk(visitor);
  4106. });
  4107. },
  4108. _children_backwards(push) {
  4109. push(this.expression);
  4110. },
  4111. }, AST_PropAccess);
  4112. var AST_Sub = DEFNODE("Sub", null, {
  4113. $documentation: "Index-style property access, i.e. `a[\"foo\"]`",
  4114. _walk: function(visitor) {
  4115. return visitor._visit(this, function() {
  4116. this.expression._walk(visitor);
  4117. this.property._walk(visitor);
  4118. });
  4119. },
  4120. _children_backwards(push) {
  4121. push(this.property);
  4122. push(this.expression);
  4123. },
  4124. }, AST_PropAccess);
  4125. var AST_Chain = DEFNODE("Chain", "expression", {
  4126. $documentation: "A chain expression like a?.b?.(c)?.[d]",
  4127. $propdoc: {
  4128. expression: "[AST_Call|AST_Dot|AST_DotHash|AST_Sub] chain element."
  4129. },
  4130. _walk: function (visitor) {
  4131. return visitor._visit(this, function() {
  4132. this.expression._walk(visitor);
  4133. });
  4134. },
  4135. _children_backwards(push) {
  4136. push(this.expression);
  4137. },
  4138. });
  4139. var AST_Unary = DEFNODE("Unary", "operator expression", {
  4140. $documentation: "Base class for unary expressions",
  4141. $propdoc: {
  4142. operator: "[string] the operator",
  4143. expression: "[AST_Node] expression that this unary operator applies to"
  4144. },
  4145. _walk: function(visitor) {
  4146. return visitor._visit(this, function() {
  4147. this.expression._walk(visitor);
  4148. });
  4149. },
  4150. _children_backwards(push) {
  4151. push(this.expression);
  4152. },
  4153. });
  4154. var AST_UnaryPrefix = DEFNODE("UnaryPrefix", null, {
  4155. $documentation: "Unary prefix expression, i.e. `typeof i` or `++i`"
  4156. }, AST_Unary);
  4157. var AST_UnaryPostfix = DEFNODE("UnaryPostfix", null, {
  4158. $documentation: "Unary postfix expression, i.e. `i++`"
  4159. }, AST_Unary);
  4160. var AST_Binary = DEFNODE("Binary", "operator left right", {
  4161. $documentation: "Binary expression, i.e. `a + b`",
  4162. $propdoc: {
  4163. left: "[AST_Node] left-hand side expression",
  4164. operator: "[string] the operator",
  4165. right: "[AST_Node] right-hand side expression"
  4166. },
  4167. _walk: function(visitor) {
  4168. return visitor._visit(this, function() {
  4169. this.left._walk(visitor);
  4170. this.right._walk(visitor);
  4171. });
  4172. },
  4173. _children_backwards(push) {
  4174. push(this.right);
  4175. push(this.left);
  4176. },
  4177. });
  4178. var AST_Conditional = DEFNODE("Conditional", "condition consequent alternative", {
  4179. $documentation: "Conditional expression using the ternary operator, i.e. `a ? b : c`",
  4180. $propdoc: {
  4181. condition: "[AST_Node]",
  4182. consequent: "[AST_Node]",
  4183. alternative: "[AST_Node]"
  4184. },
  4185. _walk: function(visitor) {
  4186. return visitor._visit(this, function() {
  4187. this.condition._walk(visitor);
  4188. this.consequent._walk(visitor);
  4189. this.alternative._walk(visitor);
  4190. });
  4191. },
  4192. _children_backwards(push) {
  4193. push(this.alternative);
  4194. push(this.consequent);
  4195. push(this.condition);
  4196. },
  4197. });
  4198. var AST_Assign = DEFNODE("Assign", "logical", {
  4199. $documentation: "An assignment expression — `a = b + 5`",
  4200. $propdoc: {
  4201. logical: "Whether it's a logical assignment"
  4202. }
  4203. }, AST_Binary);
  4204. var AST_DefaultAssign = DEFNODE("DefaultAssign", null, {
  4205. $documentation: "A default assignment expression like in `(a = 3) => a`"
  4206. }, AST_Binary);
  4207. /* -----[ LITERALS ]----- */
  4208. var AST_Array = DEFNODE("Array", "elements", {
  4209. $documentation: "An array literal",
  4210. $propdoc: {
  4211. elements: "[AST_Node*] array of elements"
  4212. },
  4213. _walk: function(visitor) {
  4214. return visitor._visit(this, function() {
  4215. var elements = this.elements;
  4216. for (var i = 0, len = elements.length; i < len; i++) {
  4217. elements[i]._walk(visitor);
  4218. }
  4219. });
  4220. },
  4221. _children_backwards(push) {
  4222. let i = this.elements.length;
  4223. while (i--) push(this.elements[i]);
  4224. },
  4225. });
  4226. var AST_Object = DEFNODE("Object", "properties", {
  4227. $documentation: "An object literal",
  4228. $propdoc: {
  4229. properties: "[AST_ObjectProperty*] array of properties"
  4230. },
  4231. _walk: function(visitor) {
  4232. return visitor._visit(this, function() {
  4233. var properties = this.properties;
  4234. for (var i = 0, len = properties.length; i < len; i++) {
  4235. properties[i]._walk(visitor);
  4236. }
  4237. });
  4238. },
  4239. _children_backwards(push) {
  4240. let i = this.properties.length;
  4241. while (i--) push(this.properties[i]);
  4242. },
  4243. });
  4244. var AST_ObjectProperty = DEFNODE("ObjectProperty", "key value", {
  4245. $documentation: "Base class for literal object properties",
  4246. $propdoc: {
  4247. key: "[string|AST_Node] property name. For ObjectKeyVal this is a string. For getters, setters and computed property this is an AST_Node.",
  4248. value: "[AST_Node] property value. For getters and setters this is an AST_Accessor."
  4249. },
  4250. _walk: function(visitor) {
  4251. return visitor._visit(this, function() {
  4252. if (this.key instanceof AST_Node)
  4253. this.key._walk(visitor);
  4254. this.value._walk(visitor);
  4255. });
  4256. },
  4257. _children_backwards(push) {
  4258. push(this.value);
  4259. if (this.key instanceof AST_Node) push(this.key);
  4260. }
  4261. });
  4262. var AST_ObjectKeyVal = DEFNODE("ObjectKeyVal", "quote", {
  4263. $documentation: "A key: value object property",
  4264. $propdoc: {
  4265. quote: "[string] the original quote character"
  4266. },
  4267. computed_key() {
  4268. return this.key instanceof AST_Node;
  4269. }
  4270. }, AST_ObjectProperty);
  4271. var AST_PrivateSetter = DEFNODE("PrivateSetter", "static", {
  4272. $propdoc: {
  4273. static: "[boolean] whether this is a static private setter"
  4274. },
  4275. $documentation: "A private setter property",
  4276. computed_key() {
  4277. return false;
  4278. }
  4279. }, AST_ObjectProperty);
  4280. var AST_PrivateGetter = DEFNODE("PrivateGetter", "static", {
  4281. $propdoc: {
  4282. static: "[boolean] whether this is a static private getter"
  4283. },
  4284. $documentation: "A private getter property",
  4285. computed_key() {
  4286. return false;
  4287. }
  4288. }, AST_ObjectProperty);
  4289. var AST_ObjectSetter = DEFNODE("ObjectSetter", "quote static", {
  4290. $propdoc: {
  4291. quote: "[string|undefined] the original quote character, if any",
  4292. static: "[boolean] whether this is a static setter (classes only)"
  4293. },
  4294. $documentation: "An object setter property",
  4295. computed_key() {
  4296. return !(this.key instanceof AST_SymbolMethod);
  4297. }
  4298. }, AST_ObjectProperty);
  4299. var AST_ObjectGetter = DEFNODE("ObjectGetter", "quote static", {
  4300. $propdoc: {
  4301. quote: "[string|undefined] the original quote character, if any",
  4302. static: "[boolean] whether this is a static getter (classes only)"
  4303. },
  4304. $documentation: "An object getter property",
  4305. computed_key() {
  4306. return !(this.key instanceof AST_SymbolMethod);
  4307. }
  4308. }, AST_ObjectProperty);
  4309. var AST_ConciseMethod = DEFNODE("ConciseMethod", "quote static is_generator async", {
  4310. $propdoc: {
  4311. quote: "[string|undefined] the original quote character, if any",
  4312. static: "[boolean] is this method static (classes only)",
  4313. is_generator: "[boolean] is this a generator method",
  4314. async: "[boolean] is this method async",
  4315. },
  4316. $documentation: "An ES6 concise method inside an object or class",
  4317. computed_key() {
  4318. return !(this.key instanceof AST_SymbolMethod);
  4319. }
  4320. }, AST_ObjectProperty);
  4321. var AST_PrivateMethod = DEFNODE("PrivateMethod", "", {
  4322. $documentation: "A private class method inside a class",
  4323. }, AST_ConciseMethod);
  4324. var AST_Class = DEFNODE("Class", "name extends properties", {
  4325. $propdoc: {
  4326. name: "[AST_SymbolClass|AST_SymbolDefClass?] optional class name.",
  4327. extends: "[AST_Node]? optional parent class",
  4328. properties: "[AST_ObjectProperty*] array of properties"
  4329. },
  4330. $documentation: "An ES6 class",
  4331. _walk: function(visitor) {
  4332. return visitor._visit(this, function() {
  4333. if (this.name) {
  4334. this.name._walk(visitor);
  4335. }
  4336. if (this.extends) {
  4337. this.extends._walk(visitor);
  4338. }
  4339. this.properties.forEach((prop) => prop._walk(visitor));
  4340. });
  4341. },
  4342. _children_backwards(push) {
  4343. let i = this.properties.length;
  4344. while (i--) push(this.properties[i]);
  4345. if (this.extends) push(this.extends);
  4346. if (this.name) push(this.name);
  4347. },
  4348. }, AST_Scope /* TODO a class might have a scope but it's not a scope */);
  4349. var AST_ClassProperty = DEFNODE("ClassProperty", "static quote", {
  4350. $documentation: "A class property",
  4351. $propdoc: {
  4352. static: "[boolean] whether this is a static key",
  4353. quote: "[string] which quote is being used"
  4354. },
  4355. _walk: function(visitor) {
  4356. return visitor._visit(this, function() {
  4357. if (this.key instanceof AST_Node)
  4358. this.key._walk(visitor);
  4359. if (this.value instanceof AST_Node)
  4360. this.value._walk(visitor);
  4361. });
  4362. },
  4363. _children_backwards(push) {
  4364. if (this.value instanceof AST_Node) push(this.value);
  4365. if (this.key instanceof AST_Node) push(this.key);
  4366. },
  4367. computed_key() {
  4368. return !(this.key instanceof AST_SymbolClassProperty);
  4369. }
  4370. }, AST_ObjectProperty);
  4371. var AST_ClassPrivateProperty = DEFNODE("ClassPrivateProperty", "", {
  4372. $documentation: "A class property for a private property",
  4373. }, AST_ClassProperty);
  4374. var AST_DefClass = DEFNODE("DefClass", null, {
  4375. $documentation: "A class definition",
  4376. }, AST_Class);
  4377. var AST_ClassExpression = DEFNODE("ClassExpression", null, {
  4378. $documentation: "A class expression."
  4379. }, AST_Class);
  4380. var AST_Symbol = DEFNODE("Symbol", "scope name thedef", {
  4381. $propdoc: {
  4382. name: "[string] name of this symbol",
  4383. scope: "[AST_Scope/S] the current scope (not necessarily the definition scope)",
  4384. thedef: "[SymbolDef/S] the definition of this symbol"
  4385. },
  4386. $documentation: "Base class for all symbols"
  4387. });
  4388. var AST_NewTarget = DEFNODE("NewTarget", null, {
  4389. $documentation: "A reference to new.target"
  4390. });
  4391. var AST_SymbolDeclaration = DEFNODE("SymbolDeclaration", "init", {
  4392. $documentation: "A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",
  4393. }, AST_Symbol);
  4394. var AST_SymbolVar = DEFNODE("SymbolVar", null, {
  4395. $documentation: "Symbol defining a variable",
  4396. }, AST_SymbolDeclaration);
  4397. var AST_SymbolBlockDeclaration = DEFNODE("SymbolBlockDeclaration", null, {
  4398. $documentation: "Base class for block-scoped declaration symbols"
  4399. }, AST_SymbolDeclaration);
  4400. var AST_SymbolConst = DEFNODE("SymbolConst", null, {
  4401. $documentation: "A constant declaration"
  4402. }, AST_SymbolBlockDeclaration);
  4403. var AST_SymbolLet = DEFNODE("SymbolLet", null, {
  4404. $documentation: "A block-scoped `let` declaration"
  4405. }, AST_SymbolBlockDeclaration);
  4406. var AST_SymbolFunarg = DEFNODE("SymbolFunarg", null, {
  4407. $documentation: "Symbol naming a function argument",
  4408. }, AST_SymbolVar);
  4409. var AST_SymbolDefun = DEFNODE("SymbolDefun", null, {
  4410. $documentation: "Symbol defining a function",
  4411. }, AST_SymbolDeclaration);
  4412. var AST_SymbolMethod = DEFNODE("SymbolMethod", null, {
  4413. $documentation: "Symbol in an object defining a method",
  4414. }, AST_Symbol);
  4415. var AST_SymbolClassProperty = DEFNODE("SymbolClassProperty", null, {
  4416. $documentation: "Symbol for a class property",
  4417. }, AST_Symbol);
  4418. var AST_SymbolLambda = DEFNODE("SymbolLambda", null, {
  4419. $documentation: "Symbol naming a function expression",
  4420. }, AST_SymbolDeclaration);
  4421. var AST_SymbolDefClass = DEFNODE("SymbolDefClass", null, {
  4422. $documentation: "Symbol naming a class's name in a class declaration. Lexically scoped to its containing scope, and accessible within the class."
  4423. }, AST_SymbolBlockDeclaration);
  4424. var AST_SymbolClass = DEFNODE("SymbolClass", null, {
  4425. $documentation: "Symbol naming a class's name. Lexically scoped to the class."
  4426. }, AST_SymbolDeclaration);
  4427. var AST_SymbolCatch = DEFNODE("SymbolCatch", null, {
  4428. $documentation: "Symbol naming the exception in catch",
  4429. }, AST_SymbolBlockDeclaration);
  4430. var AST_SymbolImport = DEFNODE("SymbolImport", null, {
  4431. $documentation: "Symbol referring to an imported name",
  4432. }, AST_SymbolBlockDeclaration);
  4433. var AST_SymbolImportForeign = DEFNODE("SymbolImportForeign", null, {
  4434. $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",
  4435. }, AST_Symbol);
  4436. var AST_Label = DEFNODE("Label", "references", {
  4437. $documentation: "Symbol naming a label (declaration)",
  4438. $propdoc: {
  4439. references: "[AST_LoopControl*] a list of nodes referring to this label"
  4440. },
  4441. initialize: function() {
  4442. this.references = [];
  4443. this.thedef = this;
  4444. }
  4445. }, AST_Symbol);
  4446. var AST_SymbolRef = DEFNODE("SymbolRef", null, {
  4447. $documentation: "Reference to some symbol (not definition/declaration)",
  4448. }, AST_Symbol);
  4449. var AST_SymbolExport = DEFNODE("SymbolExport", null, {
  4450. $documentation: "Symbol referring to a name to export",
  4451. }, AST_SymbolRef);
  4452. var AST_SymbolExportForeign = DEFNODE("SymbolExportForeign", null, {
  4453. $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",
  4454. }, AST_Symbol);
  4455. var AST_LabelRef = DEFNODE("LabelRef", null, {
  4456. $documentation: "Reference to a label symbol",
  4457. }, AST_Symbol);
  4458. var AST_This = DEFNODE("This", null, {
  4459. $documentation: "The `this` symbol",
  4460. }, AST_Symbol);
  4461. var AST_Super = DEFNODE("Super", null, {
  4462. $documentation: "The `super` symbol",
  4463. }, AST_This);
  4464. var AST_Constant = DEFNODE("Constant", null, {
  4465. $documentation: "Base class for all constants",
  4466. getValue: function() {
  4467. return this.value;
  4468. }
  4469. });
  4470. var AST_String = DEFNODE("String", "value quote", {
  4471. $documentation: "A string literal",
  4472. $propdoc: {
  4473. value: "[string] the contents of this string",
  4474. quote: "[string] the original quote character"
  4475. }
  4476. }, AST_Constant);
  4477. var AST_Number = DEFNODE("Number", "value raw", {
  4478. $documentation: "A number literal",
  4479. $propdoc: {
  4480. value: "[number] the numeric value",
  4481. raw: "[string] numeric value as string"
  4482. }
  4483. }, AST_Constant);
  4484. var AST_BigInt = DEFNODE("BigInt", "value", {
  4485. $documentation: "A big int literal",
  4486. $propdoc: {
  4487. value: "[string] big int value"
  4488. }
  4489. }, AST_Constant);
  4490. var AST_RegExp = DEFNODE("RegExp", "value", {
  4491. $documentation: "A regexp literal",
  4492. $propdoc: {
  4493. value: "[RegExp] the actual regexp",
  4494. }
  4495. }, AST_Constant);
  4496. var AST_Atom = DEFNODE("Atom", null, {
  4497. $documentation: "Base class for atoms",
  4498. }, AST_Constant);
  4499. var AST_Null = DEFNODE("Null", null, {
  4500. $documentation: "The `null` atom",
  4501. value: null
  4502. }, AST_Atom);
  4503. var AST_NaN = DEFNODE("NaN", null, {
  4504. $documentation: "The impossible value",
  4505. value: 0/0
  4506. }, AST_Atom);
  4507. var AST_Undefined = DEFNODE("Undefined", null, {
  4508. $documentation: "The `undefined` value",
  4509. value: (function() {}())
  4510. }, AST_Atom);
  4511. var AST_Hole = DEFNODE("Hole", null, {
  4512. $documentation: "A hole in an array",
  4513. value: (function() {}())
  4514. }, AST_Atom);
  4515. var AST_Infinity = DEFNODE("Infinity", null, {
  4516. $documentation: "The `Infinity` value",
  4517. value: 1/0
  4518. }, AST_Atom);
  4519. var AST_Boolean = DEFNODE("Boolean", null, {
  4520. $documentation: "Base class for booleans",
  4521. }, AST_Atom);
  4522. var AST_False = DEFNODE("False", null, {
  4523. $documentation: "The `false` atom",
  4524. value: false
  4525. }, AST_Boolean);
  4526. var AST_True = DEFNODE("True", null, {
  4527. $documentation: "The `true` atom",
  4528. value: true
  4529. }, AST_Boolean);
  4530. /* -----[ Walk function ]---- */
  4531. /**
  4532. * Walk nodes in depth-first search fashion.
  4533. * Callback can return `walk_abort` symbol to stop iteration.
  4534. * It can also return `true` to stop iteration just for child nodes.
  4535. * Iteration can be stopped and continued by passing the `to_visit` argument,
  4536. * which is given to the callback in the second argument.
  4537. **/
  4538. function walk(node, cb, to_visit = [node]) {
  4539. const push = to_visit.push.bind(to_visit);
  4540. while (to_visit.length) {
  4541. const node = to_visit.pop();
  4542. const ret = cb(node, to_visit);
  4543. if (ret) {
  4544. if (ret === walk_abort) return true;
  4545. continue;
  4546. }
  4547. node._children_backwards(push);
  4548. }
  4549. return false;
  4550. }
  4551. function walk_parent(node, cb, initial_stack) {
  4552. const to_visit = [node];
  4553. const push = to_visit.push.bind(to_visit);
  4554. const stack = initial_stack ? initial_stack.slice() : [];
  4555. const parent_pop_indices = [];
  4556. let current;
  4557. const info = {
  4558. parent: (n = 0) => {
  4559. if (n === -1) {
  4560. return current;
  4561. }
  4562. // [ p1 p0 ] [ 1 0 ]
  4563. if (initial_stack && n >= stack.length) {
  4564. n -= stack.length;
  4565. return initial_stack[
  4566. initial_stack.length - (n + 1)
  4567. ];
  4568. }
  4569. return stack[stack.length - (1 + n)];
  4570. },
  4571. };
  4572. while (to_visit.length) {
  4573. current = to_visit.pop();
  4574. while (
  4575. parent_pop_indices.length &&
  4576. to_visit.length == parent_pop_indices[parent_pop_indices.length - 1]
  4577. ) {
  4578. stack.pop();
  4579. parent_pop_indices.pop();
  4580. }
  4581. const ret = cb(current, info);
  4582. if (ret) {
  4583. if (ret === walk_abort) return true;
  4584. continue;
  4585. }
  4586. const visit_length = to_visit.length;
  4587. current._children_backwards(push);
  4588. // Push only if we're going to traverse the children
  4589. if (to_visit.length > visit_length) {
  4590. stack.push(current);
  4591. parent_pop_indices.push(visit_length - 1);
  4592. }
  4593. }
  4594. return false;
  4595. }
  4596. const walk_abort = Symbol("abort walk");
  4597. /* -----[ TreeWalker ]----- */
  4598. class TreeWalker {
  4599. constructor(callback) {
  4600. this.visit = callback;
  4601. this.stack = [];
  4602. this.directives = Object.create(null);
  4603. }
  4604. _visit(node, descend) {
  4605. this.push(node);
  4606. var ret = this.visit(node, descend ? function() {
  4607. descend.call(node);
  4608. } : noop);
  4609. if (!ret && descend) {
  4610. descend.call(node);
  4611. }
  4612. this.pop();
  4613. return ret;
  4614. }
  4615. parent(n) {
  4616. return this.stack[this.stack.length - 2 - (n || 0)];
  4617. }
  4618. push(node) {
  4619. if (node instanceof AST_Lambda) {
  4620. this.directives = Object.create(this.directives);
  4621. } else if (node instanceof AST_Directive && !this.directives[node.value]) {
  4622. this.directives[node.value] = node;
  4623. } else if (node instanceof AST_Class) {
  4624. this.directives = Object.create(this.directives);
  4625. if (!this.directives["use strict"]) {
  4626. this.directives["use strict"] = node;
  4627. }
  4628. }
  4629. this.stack.push(node);
  4630. }
  4631. pop() {
  4632. var node = this.stack.pop();
  4633. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  4634. this.directives = Object.getPrototypeOf(this.directives);
  4635. }
  4636. }
  4637. self() {
  4638. return this.stack[this.stack.length - 1];
  4639. }
  4640. find_parent(type) {
  4641. var stack = this.stack;
  4642. for (var i = stack.length; --i >= 0;) {
  4643. var x = stack[i];
  4644. if (x instanceof type) return x;
  4645. }
  4646. }
  4647. has_directive(type) {
  4648. var dir = this.directives[type];
  4649. if (dir) return dir;
  4650. var node = this.stack[this.stack.length - 1];
  4651. if (node instanceof AST_Scope && node.body) {
  4652. for (var i = 0; i < node.body.length; ++i) {
  4653. var st = node.body[i];
  4654. if (!(st instanceof AST_Directive)) break;
  4655. if (st.value == type) return st;
  4656. }
  4657. }
  4658. }
  4659. loopcontrol_target(node) {
  4660. var stack = this.stack;
  4661. if (node.label) for (var i = stack.length; --i >= 0;) {
  4662. var x = stack[i];
  4663. if (x instanceof AST_LabeledStatement && x.label.name == node.label.name)
  4664. return x.body;
  4665. } else for (var i = stack.length; --i >= 0;) {
  4666. var x = stack[i];
  4667. if (x instanceof AST_IterationStatement
  4668. || node instanceof AST_Break && x instanceof AST_Switch)
  4669. return x;
  4670. }
  4671. }
  4672. }
  4673. // Tree transformer helpers.
  4674. class TreeTransformer extends TreeWalker {
  4675. constructor(before, after) {
  4676. super();
  4677. this.before = before;
  4678. this.after = after;
  4679. }
  4680. }
  4681. const _PURE = 0b00000001;
  4682. const _INLINE = 0b00000010;
  4683. const _NOINLINE = 0b00000100;
  4684. var ast = /*#__PURE__*/Object.freeze({
  4685. __proto__: null,
  4686. AST_Accessor: AST_Accessor,
  4687. AST_Array: AST_Array,
  4688. AST_Arrow: AST_Arrow,
  4689. AST_Assign: AST_Assign,
  4690. AST_Atom: AST_Atom,
  4691. AST_Await: AST_Await,
  4692. AST_BigInt: AST_BigInt,
  4693. AST_Binary: AST_Binary,
  4694. AST_Block: AST_Block,
  4695. AST_BlockStatement: AST_BlockStatement,
  4696. AST_Boolean: AST_Boolean,
  4697. AST_Break: AST_Break,
  4698. AST_Call: AST_Call,
  4699. AST_Case: AST_Case,
  4700. AST_Catch: AST_Catch,
  4701. AST_Chain: AST_Chain,
  4702. AST_Class: AST_Class,
  4703. AST_ClassExpression: AST_ClassExpression,
  4704. AST_ClassPrivateProperty: AST_ClassPrivateProperty,
  4705. AST_ClassProperty: AST_ClassProperty,
  4706. AST_ConciseMethod: AST_ConciseMethod,
  4707. AST_Conditional: AST_Conditional,
  4708. AST_Const: AST_Const,
  4709. AST_Constant: AST_Constant,
  4710. AST_Continue: AST_Continue,
  4711. AST_Debugger: AST_Debugger,
  4712. AST_Default: AST_Default,
  4713. AST_DefaultAssign: AST_DefaultAssign,
  4714. AST_DefClass: AST_DefClass,
  4715. AST_Definitions: AST_Definitions,
  4716. AST_Defun: AST_Defun,
  4717. AST_Destructuring: AST_Destructuring,
  4718. AST_Directive: AST_Directive,
  4719. AST_Do: AST_Do,
  4720. AST_Dot: AST_Dot,
  4721. AST_DotHash: AST_DotHash,
  4722. AST_DWLoop: AST_DWLoop,
  4723. AST_EmptyStatement: AST_EmptyStatement,
  4724. AST_Exit: AST_Exit,
  4725. AST_Expansion: AST_Expansion,
  4726. AST_Export: AST_Export,
  4727. AST_False: AST_False,
  4728. AST_Finally: AST_Finally,
  4729. AST_For: AST_For,
  4730. AST_ForIn: AST_ForIn,
  4731. AST_ForOf: AST_ForOf,
  4732. AST_Function: AST_Function,
  4733. AST_Hole: AST_Hole,
  4734. AST_If: AST_If,
  4735. AST_Import: AST_Import,
  4736. AST_ImportMeta: AST_ImportMeta,
  4737. AST_Infinity: AST_Infinity,
  4738. AST_IterationStatement: AST_IterationStatement,
  4739. AST_Jump: AST_Jump,
  4740. AST_Label: AST_Label,
  4741. AST_LabeledStatement: AST_LabeledStatement,
  4742. AST_LabelRef: AST_LabelRef,
  4743. AST_Lambda: AST_Lambda,
  4744. AST_Let: AST_Let,
  4745. AST_LoopControl: AST_LoopControl,
  4746. AST_NameMapping: AST_NameMapping,
  4747. AST_NaN: AST_NaN,
  4748. AST_New: AST_New,
  4749. AST_NewTarget: AST_NewTarget,
  4750. AST_Node: AST_Node,
  4751. AST_Null: AST_Null,
  4752. AST_Number: AST_Number,
  4753. AST_Object: AST_Object,
  4754. AST_ObjectGetter: AST_ObjectGetter,
  4755. AST_ObjectKeyVal: AST_ObjectKeyVal,
  4756. AST_ObjectProperty: AST_ObjectProperty,
  4757. AST_ObjectSetter: AST_ObjectSetter,
  4758. AST_PrefixedTemplateString: AST_PrefixedTemplateString,
  4759. AST_PrivateGetter: AST_PrivateGetter,
  4760. AST_PrivateMethod: AST_PrivateMethod,
  4761. AST_PrivateSetter: AST_PrivateSetter,
  4762. AST_PropAccess: AST_PropAccess,
  4763. AST_RegExp: AST_RegExp,
  4764. AST_Return: AST_Return,
  4765. AST_Scope: AST_Scope,
  4766. AST_Sequence: AST_Sequence,
  4767. AST_SimpleStatement: AST_SimpleStatement,
  4768. AST_Statement: AST_Statement,
  4769. AST_StatementWithBody: AST_StatementWithBody,
  4770. AST_String: AST_String,
  4771. AST_Sub: AST_Sub,
  4772. AST_Super: AST_Super,
  4773. AST_Switch: AST_Switch,
  4774. AST_SwitchBranch: AST_SwitchBranch,
  4775. AST_Symbol: AST_Symbol,
  4776. AST_SymbolBlockDeclaration: AST_SymbolBlockDeclaration,
  4777. AST_SymbolCatch: AST_SymbolCatch,
  4778. AST_SymbolClass: AST_SymbolClass,
  4779. AST_SymbolClassProperty: AST_SymbolClassProperty,
  4780. AST_SymbolConst: AST_SymbolConst,
  4781. AST_SymbolDeclaration: AST_SymbolDeclaration,
  4782. AST_SymbolDefClass: AST_SymbolDefClass,
  4783. AST_SymbolDefun: AST_SymbolDefun,
  4784. AST_SymbolExport: AST_SymbolExport,
  4785. AST_SymbolExportForeign: AST_SymbolExportForeign,
  4786. AST_SymbolFunarg: AST_SymbolFunarg,
  4787. AST_SymbolImport: AST_SymbolImport,
  4788. AST_SymbolImportForeign: AST_SymbolImportForeign,
  4789. AST_SymbolLambda: AST_SymbolLambda,
  4790. AST_SymbolLet: AST_SymbolLet,
  4791. AST_SymbolMethod: AST_SymbolMethod,
  4792. AST_SymbolRef: AST_SymbolRef,
  4793. AST_SymbolVar: AST_SymbolVar,
  4794. AST_TemplateSegment: AST_TemplateSegment,
  4795. AST_TemplateString: AST_TemplateString,
  4796. AST_This: AST_This,
  4797. AST_Throw: AST_Throw,
  4798. AST_Token: AST_Token,
  4799. AST_Toplevel: AST_Toplevel,
  4800. AST_True: AST_True,
  4801. AST_Try: AST_Try,
  4802. AST_Unary: AST_Unary,
  4803. AST_UnaryPostfix: AST_UnaryPostfix,
  4804. AST_UnaryPrefix: AST_UnaryPrefix,
  4805. AST_Undefined: AST_Undefined,
  4806. AST_Var: AST_Var,
  4807. AST_VarDef: AST_VarDef,
  4808. AST_While: AST_While,
  4809. AST_With: AST_With,
  4810. AST_Yield: AST_Yield,
  4811. TreeTransformer: TreeTransformer,
  4812. TreeWalker: TreeWalker,
  4813. walk: walk,
  4814. walk_abort: walk_abort,
  4815. walk_body: walk_body,
  4816. walk_parent: walk_parent,
  4817. _INLINE: _INLINE,
  4818. _NOINLINE: _NOINLINE,
  4819. _PURE: _PURE
  4820. });
  4821. /***********************************************************************
  4822. A JavaScript tokenizer / parser / beautifier / compressor.
  4823. https://github.com/mishoo/UglifyJS2
  4824. -------------------------------- (C) ---------------------------------
  4825. Author: Mihai Bazon
  4826. <mihai.bazon@gmail.com>
  4827. http://mihai.bazon.net/blog
  4828. Distributed under the BSD license:
  4829. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  4830. Redistribution and use in source and binary forms, with or without
  4831. modification, are permitted provided that the following conditions
  4832. are met:
  4833. * Redistributions of source code must retain the above
  4834. copyright notice, this list of conditions and the following
  4835. disclaimer.
  4836. * Redistributions in binary form must reproduce the above
  4837. copyright notice, this list of conditions and the following
  4838. disclaimer in the documentation and/or other materials
  4839. provided with the distribution.
  4840. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  4841. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4842. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  4843. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  4844. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  4845. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  4846. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  4847. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  4848. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  4849. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  4850. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4851. SUCH DAMAGE.
  4852. ***********************************************************************/
  4853. function def_transform(node, descend) {
  4854. node.DEFMETHOD("transform", function(tw, in_list) {
  4855. let transformed = undefined;
  4856. tw.push(this);
  4857. if (tw.before) transformed = tw.before(this, descend, in_list);
  4858. if (transformed === undefined) {
  4859. transformed = this;
  4860. descend(transformed, tw);
  4861. if (tw.after) {
  4862. const after_ret = tw.after(transformed, in_list);
  4863. if (after_ret !== undefined) transformed = after_ret;
  4864. }
  4865. }
  4866. tw.pop();
  4867. return transformed;
  4868. });
  4869. }
  4870. function do_list(list, tw) {
  4871. return MAP(list, function(node) {
  4872. return node.transform(tw, true);
  4873. });
  4874. }
  4875. def_transform(AST_Node, noop);
  4876. def_transform(AST_LabeledStatement, function(self, tw) {
  4877. self.label = self.label.transform(tw);
  4878. self.body = self.body.transform(tw);
  4879. });
  4880. def_transform(AST_SimpleStatement, function(self, tw) {
  4881. self.body = self.body.transform(tw);
  4882. });
  4883. def_transform(AST_Block, function(self, tw) {
  4884. self.body = do_list(self.body, tw);
  4885. });
  4886. def_transform(AST_Do, function(self, tw) {
  4887. self.body = self.body.transform(tw);
  4888. self.condition = self.condition.transform(tw);
  4889. });
  4890. def_transform(AST_While, function(self, tw) {
  4891. self.condition = self.condition.transform(tw);
  4892. self.body = self.body.transform(tw);
  4893. });
  4894. def_transform(AST_For, function(self, tw) {
  4895. if (self.init) self.init = self.init.transform(tw);
  4896. if (self.condition) self.condition = self.condition.transform(tw);
  4897. if (self.step) self.step = self.step.transform(tw);
  4898. self.body = self.body.transform(tw);
  4899. });
  4900. def_transform(AST_ForIn, function(self, tw) {
  4901. self.init = self.init.transform(tw);
  4902. self.object = self.object.transform(tw);
  4903. self.body = self.body.transform(tw);
  4904. });
  4905. def_transform(AST_With, function(self, tw) {
  4906. self.expression = self.expression.transform(tw);
  4907. self.body = self.body.transform(tw);
  4908. });
  4909. def_transform(AST_Exit, function(self, tw) {
  4910. if (self.value) self.value = self.value.transform(tw);
  4911. });
  4912. def_transform(AST_LoopControl, function(self, tw) {
  4913. if (self.label) self.label = self.label.transform(tw);
  4914. });
  4915. def_transform(AST_If, function(self, tw) {
  4916. self.condition = self.condition.transform(tw);
  4917. self.body = self.body.transform(tw);
  4918. if (self.alternative) self.alternative = self.alternative.transform(tw);
  4919. });
  4920. def_transform(AST_Switch, function(self, tw) {
  4921. self.expression = self.expression.transform(tw);
  4922. self.body = do_list(self.body, tw);
  4923. });
  4924. def_transform(AST_Case, function(self, tw) {
  4925. self.expression = self.expression.transform(tw);
  4926. self.body = do_list(self.body, tw);
  4927. });
  4928. def_transform(AST_Try, function(self, tw) {
  4929. self.body = do_list(self.body, tw);
  4930. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  4931. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  4932. });
  4933. def_transform(AST_Catch, function(self, tw) {
  4934. if (self.argname) self.argname = self.argname.transform(tw);
  4935. self.body = do_list(self.body, tw);
  4936. });
  4937. def_transform(AST_Definitions, function(self, tw) {
  4938. self.definitions = do_list(self.definitions, tw);
  4939. });
  4940. def_transform(AST_VarDef, function(self, tw) {
  4941. self.name = self.name.transform(tw);
  4942. if (self.value) self.value = self.value.transform(tw);
  4943. });
  4944. def_transform(AST_Destructuring, function(self, tw) {
  4945. self.names = do_list(self.names, tw);
  4946. });
  4947. def_transform(AST_Lambda, function(self, tw) {
  4948. if (self.name) self.name = self.name.transform(tw);
  4949. self.argnames = do_list(self.argnames, tw);
  4950. if (self.body instanceof AST_Node) {
  4951. self.body = self.body.transform(tw);
  4952. } else {
  4953. self.body = do_list(self.body, tw);
  4954. }
  4955. });
  4956. def_transform(AST_Call, function(self, tw) {
  4957. self.expression = self.expression.transform(tw);
  4958. self.args = do_list(self.args, tw);
  4959. });
  4960. def_transform(AST_Sequence, function(self, tw) {
  4961. const result = do_list(self.expressions, tw);
  4962. self.expressions = result.length
  4963. ? result
  4964. : [new AST_Number({ value: 0 })];
  4965. });
  4966. def_transform(AST_PropAccess, function(self, tw) {
  4967. self.expression = self.expression.transform(tw);
  4968. });
  4969. def_transform(AST_Sub, function(self, tw) {
  4970. self.expression = self.expression.transform(tw);
  4971. self.property = self.property.transform(tw);
  4972. });
  4973. def_transform(AST_Chain, function(self, tw) {
  4974. self.expression = self.expression.transform(tw);
  4975. });
  4976. def_transform(AST_Yield, function(self, tw) {
  4977. if (self.expression) self.expression = self.expression.transform(tw);
  4978. });
  4979. def_transform(AST_Await, function(self, tw) {
  4980. self.expression = self.expression.transform(tw);
  4981. });
  4982. def_transform(AST_Unary, function(self, tw) {
  4983. self.expression = self.expression.transform(tw);
  4984. });
  4985. def_transform(AST_Binary, function(self, tw) {
  4986. self.left = self.left.transform(tw);
  4987. self.right = self.right.transform(tw);
  4988. });
  4989. def_transform(AST_Conditional, function(self, tw) {
  4990. self.condition = self.condition.transform(tw);
  4991. self.consequent = self.consequent.transform(tw);
  4992. self.alternative = self.alternative.transform(tw);
  4993. });
  4994. def_transform(AST_Array, function(self, tw) {
  4995. self.elements = do_list(self.elements, tw);
  4996. });
  4997. def_transform(AST_Object, function(self, tw) {
  4998. self.properties = do_list(self.properties, tw);
  4999. });
  5000. def_transform(AST_ObjectProperty, function(self, tw) {
  5001. if (self.key instanceof AST_Node) {
  5002. self.key = self.key.transform(tw);
  5003. }
  5004. if (self.value) self.value = self.value.transform(tw);
  5005. });
  5006. def_transform(AST_Class, function(self, tw) {
  5007. if (self.name) self.name = self.name.transform(tw);
  5008. if (self.extends) self.extends = self.extends.transform(tw);
  5009. self.properties = do_list(self.properties, tw);
  5010. });
  5011. def_transform(AST_Expansion, function(self, tw) {
  5012. self.expression = self.expression.transform(tw);
  5013. });
  5014. def_transform(AST_NameMapping, function(self, tw) {
  5015. self.foreign_name = self.foreign_name.transform(tw);
  5016. self.name = self.name.transform(tw);
  5017. });
  5018. def_transform(AST_Import, function(self, tw) {
  5019. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  5020. if (self.imported_names) do_list(self.imported_names, tw);
  5021. self.module_name = self.module_name.transform(tw);
  5022. });
  5023. def_transform(AST_Export, function(self, tw) {
  5024. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  5025. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  5026. if (self.exported_names) do_list(self.exported_names, tw);
  5027. if (self.module_name) self.module_name = self.module_name.transform(tw);
  5028. });
  5029. def_transform(AST_TemplateString, function(self, tw) {
  5030. self.segments = do_list(self.segments, tw);
  5031. });
  5032. def_transform(AST_PrefixedTemplateString, function(self, tw) {
  5033. self.prefix = self.prefix.transform(tw);
  5034. self.template_string = self.template_string.transform(tw);
  5035. });
  5036. /***********************************************************************
  5037. A JavaScript tokenizer / parser / beautifier / compressor.
  5038. https://github.com/mishoo/UglifyJS2
  5039. -------------------------------- (C) ---------------------------------
  5040. Author: Mihai Bazon
  5041. <mihai.bazon@gmail.com>
  5042. http://mihai.bazon.net/blog
  5043. Distributed under the BSD license:
  5044. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  5045. Redistribution and use in source and binary forms, with or without
  5046. modification, are permitted provided that the following conditions
  5047. are met:
  5048. * Redistributions of source code must retain the above
  5049. copyright notice, this list of conditions and the following
  5050. disclaimer.
  5051. * Redistributions in binary form must reproduce the above
  5052. copyright notice, this list of conditions and the following
  5053. disclaimer in the documentation and/or other materials
  5054. provided with the distribution.
  5055. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  5056. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  5057. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  5058. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  5059. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  5060. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  5061. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  5062. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  5063. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  5064. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  5065. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  5066. SUCH DAMAGE.
  5067. ***********************************************************************/
  5068. (function() {
  5069. var normalize_directives = function(body) {
  5070. var in_directive = true;
  5071. for (var i = 0; i < body.length; i++) {
  5072. if (in_directive && body[i] instanceof AST_Statement && body[i].body instanceof AST_String) {
  5073. body[i] = new AST_Directive({
  5074. start: body[i].start,
  5075. end: body[i].end,
  5076. value: body[i].body.value
  5077. });
  5078. } else if (in_directive && !(body[i] instanceof AST_Statement && body[i].body instanceof AST_String)) {
  5079. in_directive = false;
  5080. }
  5081. }
  5082. return body;
  5083. };
  5084. const assert_clause_from_moz = (assertions) => {
  5085. if (assertions && assertions.length > 0) {
  5086. return new AST_Object({
  5087. start: my_start_token(assertions),
  5088. end: my_end_token(assertions),
  5089. properties: assertions.map((assertion_kv) =>
  5090. new AST_ObjectKeyVal({
  5091. start: my_start_token(assertion_kv),
  5092. end: my_end_token(assertion_kv),
  5093. key: assertion_kv.key.name || assertion_kv.key.value,
  5094. value: from_moz(assertion_kv.value)
  5095. })
  5096. )
  5097. });
  5098. }
  5099. return null;
  5100. };
  5101. var MOZ_TO_ME = {
  5102. Program: function(M) {
  5103. return new AST_Toplevel({
  5104. start: my_start_token(M),
  5105. end: my_end_token(M),
  5106. body: normalize_directives(M.body.map(from_moz))
  5107. });
  5108. },
  5109. ArrayPattern: function(M) {
  5110. return new AST_Destructuring({
  5111. start: my_start_token(M),
  5112. end: my_end_token(M),
  5113. names: M.elements.map(function(elm) {
  5114. if (elm === null) {
  5115. return new AST_Hole();
  5116. }
  5117. return from_moz(elm);
  5118. }),
  5119. is_array: true
  5120. });
  5121. },
  5122. ObjectPattern: function(M) {
  5123. return new AST_Destructuring({
  5124. start: my_start_token(M),
  5125. end: my_end_token(M),
  5126. names: M.properties.map(from_moz),
  5127. is_array: false
  5128. });
  5129. },
  5130. AssignmentPattern: function(M) {
  5131. return new AST_DefaultAssign({
  5132. start: my_start_token(M),
  5133. end: my_end_token(M),
  5134. left: from_moz(M.left),
  5135. operator: "=",
  5136. right: from_moz(M.right)
  5137. });
  5138. },
  5139. SpreadElement: function(M) {
  5140. return new AST_Expansion({
  5141. start: my_start_token(M),
  5142. end: my_end_token(M),
  5143. expression: from_moz(M.argument)
  5144. });
  5145. },
  5146. RestElement: function(M) {
  5147. return new AST_Expansion({
  5148. start: my_start_token(M),
  5149. end: my_end_token(M),
  5150. expression: from_moz(M.argument)
  5151. });
  5152. },
  5153. TemplateElement: function(M) {
  5154. return new AST_TemplateSegment({
  5155. start: my_start_token(M),
  5156. end: my_end_token(M),
  5157. value: M.value.cooked,
  5158. raw: M.value.raw
  5159. });
  5160. },
  5161. TemplateLiteral: function(M) {
  5162. var segments = [];
  5163. for (var i = 0; i < M.quasis.length; i++) {
  5164. segments.push(from_moz(M.quasis[i]));
  5165. if (M.expressions[i]) {
  5166. segments.push(from_moz(M.expressions[i]));
  5167. }
  5168. }
  5169. return new AST_TemplateString({
  5170. start: my_start_token(M),
  5171. end: my_end_token(M),
  5172. segments: segments
  5173. });
  5174. },
  5175. TaggedTemplateExpression: function(M) {
  5176. return new AST_PrefixedTemplateString({
  5177. start: my_start_token(M),
  5178. end: my_end_token(M),
  5179. template_string: from_moz(M.quasi),
  5180. prefix: from_moz(M.tag)
  5181. });
  5182. },
  5183. FunctionDeclaration: function(M) {
  5184. return new AST_Defun({
  5185. start: my_start_token(M),
  5186. end: my_end_token(M),
  5187. name: from_moz(M.id),
  5188. argnames: M.params.map(from_moz),
  5189. is_generator: M.generator,
  5190. async: M.async,
  5191. body: normalize_directives(from_moz(M.body).body)
  5192. });
  5193. },
  5194. FunctionExpression: function(M) {
  5195. return new AST_Function({
  5196. start: my_start_token(M),
  5197. end: my_end_token(M),
  5198. name: from_moz(M.id),
  5199. argnames: M.params.map(from_moz),
  5200. is_generator: M.generator,
  5201. async: M.async,
  5202. body: normalize_directives(from_moz(M.body).body)
  5203. });
  5204. },
  5205. ArrowFunctionExpression: function(M) {
  5206. const body = M.body.type === "BlockStatement"
  5207. ? from_moz(M.body).body
  5208. : [make_node(AST_Return, {}, { value: from_moz(M.body) })];
  5209. return new AST_Arrow({
  5210. start: my_start_token(M),
  5211. end: my_end_token(M),
  5212. argnames: M.params.map(from_moz),
  5213. body,
  5214. async: M.async,
  5215. });
  5216. },
  5217. ExpressionStatement: function(M) {
  5218. return new AST_SimpleStatement({
  5219. start: my_start_token(M),
  5220. end: my_end_token(M),
  5221. body: from_moz(M.expression)
  5222. });
  5223. },
  5224. TryStatement: function(M) {
  5225. var handlers = M.handlers || [M.handler];
  5226. if (handlers.length > 1 || M.guardedHandlers && M.guardedHandlers.length) {
  5227. throw new Error("Multiple catch clauses are not supported.");
  5228. }
  5229. return new AST_Try({
  5230. start : my_start_token(M),
  5231. end : my_end_token(M),
  5232. body : from_moz(M.block).body,
  5233. bcatch : from_moz(handlers[0]),
  5234. bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null
  5235. });
  5236. },
  5237. Property: function(M) {
  5238. var key = M.key;
  5239. var args = {
  5240. start : my_start_token(key || M.value),
  5241. end : my_end_token(M.value),
  5242. key : key.type == "Identifier" ? key.name : key.value,
  5243. value : from_moz(M.value)
  5244. };
  5245. if (M.computed) {
  5246. args.key = from_moz(M.key);
  5247. }
  5248. if (M.method) {
  5249. args.is_generator = M.value.generator;
  5250. args.async = M.value.async;
  5251. if (!M.computed) {
  5252. args.key = new AST_SymbolMethod({ name: args.key });
  5253. } else {
  5254. args.key = from_moz(M.key);
  5255. }
  5256. return new AST_ConciseMethod(args);
  5257. }
  5258. if (M.kind == "init") {
  5259. if (key.type != "Identifier" && key.type != "Literal") {
  5260. args.key = from_moz(key);
  5261. }
  5262. return new AST_ObjectKeyVal(args);
  5263. }
  5264. if (typeof args.key === "string" || typeof args.key === "number") {
  5265. args.key = new AST_SymbolMethod({
  5266. name: args.key
  5267. });
  5268. }
  5269. args.value = new AST_Accessor(args.value);
  5270. if (M.kind == "get") return new AST_ObjectGetter(args);
  5271. if (M.kind == "set") return new AST_ObjectSetter(args);
  5272. if (M.kind == "method") {
  5273. args.async = M.value.async;
  5274. args.is_generator = M.value.generator;
  5275. args.quote = M.computed ? "\"" : null;
  5276. return new AST_ConciseMethod(args);
  5277. }
  5278. },
  5279. MethodDefinition: function(M) {
  5280. var args = {
  5281. start : my_start_token(M),
  5282. end : my_end_token(M),
  5283. key : M.computed ? from_moz(M.key) : new AST_SymbolMethod({ name: M.key.name || M.key.value }),
  5284. value : from_moz(M.value),
  5285. static : M.static,
  5286. };
  5287. if (M.kind == "get") {
  5288. return new AST_ObjectGetter(args);
  5289. }
  5290. if (M.kind == "set") {
  5291. return new AST_ObjectSetter(args);
  5292. }
  5293. args.is_generator = M.value.generator;
  5294. args.async = M.value.async;
  5295. return new AST_ConciseMethod(args);
  5296. },
  5297. FieldDefinition: function(M) {
  5298. let key;
  5299. if (M.computed) {
  5300. key = from_moz(M.key);
  5301. } else {
  5302. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in FieldDefinition");
  5303. key = from_moz(M.key);
  5304. }
  5305. return new AST_ClassProperty({
  5306. start : my_start_token(M),
  5307. end : my_end_token(M),
  5308. key,
  5309. value : from_moz(M.value),
  5310. static : M.static,
  5311. });
  5312. },
  5313. PropertyDefinition: function(M) {
  5314. let key;
  5315. if (M.computed) {
  5316. key = from_moz(M.key);
  5317. } else {
  5318. if (M.key.type !== "Identifier") throw new Error("Non-Identifier key in PropertyDefinition");
  5319. key = from_moz(M.key);
  5320. }
  5321. return new AST_ClassProperty({
  5322. start : my_start_token(M),
  5323. end : my_end_token(M),
  5324. key,
  5325. value : from_moz(M.value),
  5326. static : M.static,
  5327. });
  5328. },
  5329. ArrayExpression: function(M) {
  5330. return new AST_Array({
  5331. start : my_start_token(M),
  5332. end : my_end_token(M),
  5333. elements : M.elements.map(function(elem) {
  5334. return elem === null ? new AST_Hole() : from_moz(elem);
  5335. })
  5336. });
  5337. },
  5338. ObjectExpression: function(M) {
  5339. return new AST_Object({
  5340. start : my_start_token(M),
  5341. end : my_end_token(M),
  5342. properties : M.properties.map(function(prop) {
  5343. if (prop.type === "SpreadElement") {
  5344. return from_moz(prop);
  5345. }
  5346. prop.type = "Property";
  5347. return from_moz(prop);
  5348. })
  5349. });
  5350. },
  5351. SequenceExpression: function(M) {
  5352. return new AST_Sequence({
  5353. start : my_start_token(M),
  5354. end : my_end_token(M),
  5355. expressions: M.expressions.map(from_moz)
  5356. });
  5357. },
  5358. MemberExpression: function(M) {
  5359. return new (M.computed ? AST_Sub : AST_Dot)({
  5360. start : my_start_token(M),
  5361. end : my_end_token(M),
  5362. property : M.computed ? from_moz(M.property) : M.property.name,
  5363. expression : from_moz(M.object),
  5364. optional : M.optional || false
  5365. });
  5366. },
  5367. ChainExpression: function(M) {
  5368. return new AST_Chain({
  5369. start : my_start_token(M),
  5370. end : my_end_token(M),
  5371. expression : from_moz(M.expression)
  5372. });
  5373. },
  5374. SwitchCase: function(M) {
  5375. return new (M.test ? AST_Case : AST_Default)({
  5376. start : my_start_token(M),
  5377. end : my_end_token(M),
  5378. expression : from_moz(M.test),
  5379. body : M.consequent.map(from_moz)
  5380. });
  5381. },
  5382. VariableDeclaration: function(M) {
  5383. return new (M.kind === "const" ? AST_Const :
  5384. M.kind === "let" ? AST_Let : AST_Var)({
  5385. start : my_start_token(M),
  5386. end : my_end_token(M),
  5387. definitions : M.declarations.map(from_moz)
  5388. });
  5389. },
  5390. ImportDeclaration: function(M) {
  5391. var imported_name = null;
  5392. var imported_names = null;
  5393. M.specifiers.forEach(function (specifier) {
  5394. if (specifier.type === "ImportSpecifier") {
  5395. if (!imported_names) { imported_names = []; }
  5396. imported_names.push(new AST_NameMapping({
  5397. start: my_start_token(specifier),
  5398. end: my_end_token(specifier),
  5399. foreign_name: from_moz(specifier.imported),
  5400. name: from_moz(specifier.local)
  5401. }));
  5402. } else if (specifier.type === "ImportDefaultSpecifier") {
  5403. imported_name = from_moz(specifier.local);
  5404. } else if (specifier.type === "ImportNamespaceSpecifier") {
  5405. if (!imported_names) { imported_names = []; }
  5406. imported_names.push(new AST_NameMapping({
  5407. start: my_start_token(specifier),
  5408. end: my_end_token(specifier),
  5409. foreign_name: new AST_SymbolImportForeign({ name: "*" }),
  5410. name: from_moz(specifier.local)
  5411. }));
  5412. }
  5413. });
  5414. return new AST_Import({
  5415. start : my_start_token(M),
  5416. end : my_end_token(M),
  5417. imported_name: imported_name,
  5418. imported_names : imported_names,
  5419. module_name : from_moz(M.source),
  5420. assert_clause: assert_clause_from_moz(M.assertions)
  5421. });
  5422. },
  5423. ExportAllDeclaration: function(M) {
  5424. return new AST_Export({
  5425. start: my_start_token(M),
  5426. end: my_end_token(M),
  5427. exported_names: [
  5428. new AST_NameMapping({
  5429. name: new AST_SymbolExportForeign({ name: "*" }),
  5430. foreign_name: new AST_SymbolExportForeign({ name: "*" })
  5431. })
  5432. ],
  5433. module_name: from_moz(M.source),
  5434. assert_clause: assert_clause_from_moz(M.assertions)
  5435. });
  5436. },
  5437. ExportNamedDeclaration: function(M) {
  5438. return new AST_Export({
  5439. start: my_start_token(M),
  5440. end: my_end_token(M),
  5441. exported_definition: from_moz(M.declaration),
  5442. exported_names: M.specifiers && M.specifiers.length ? M.specifiers.map(function (specifier) {
  5443. return new AST_NameMapping({
  5444. foreign_name: from_moz(specifier.exported),
  5445. name: from_moz(specifier.local)
  5446. });
  5447. }) : null,
  5448. module_name: from_moz(M.source),
  5449. assert_clause: assert_clause_from_moz(M.assertions)
  5450. });
  5451. },
  5452. ExportDefaultDeclaration: function(M) {
  5453. return new AST_Export({
  5454. start: my_start_token(M),
  5455. end: my_end_token(M),
  5456. exported_value: from_moz(M.declaration),
  5457. is_default: true
  5458. });
  5459. },
  5460. Literal: function(M) {
  5461. var val = M.value, args = {
  5462. start : my_start_token(M),
  5463. end : my_end_token(M)
  5464. };
  5465. var rx = M.regex;
  5466. if (rx && rx.pattern) {
  5467. // RegExpLiteral as per ESTree AST spec
  5468. args.value = {
  5469. source: rx.pattern,
  5470. flags: rx.flags
  5471. };
  5472. return new AST_RegExp(args);
  5473. } else if (rx) {
  5474. // support legacy RegExp
  5475. const rx_source = M.raw || val;
  5476. const match = rx_source.match(/^\/(.*)\/(\w*)$/);
  5477. if (!match) throw new Error("Invalid regex source " + rx_source);
  5478. const [_, source, flags] = match;
  5479. args.value = { source, flags };
  5480. return new AST_RegExp(args);
  5481. }
  5482. if (val === null) return new AST_Null(args);
  5483. switch (typeof val) {
  5484. case "string":
  5485. args.value = val;
  5486. return new AST_String(args);
  5487. case "number":
  5488. args.value = val;
  5489. args.raw = M.raw || val.toString();
  5490. return new AST_Number(args);
  5491. case "boolean":
  5492. return new (val ? AST_True : AST_False)(args);
  5493. }
  5494. },
  5495. MetaProperty: function(M) {
  5496. if (M.meta.name === "new" && M.property.name === "target") {
  5497. return new AST_NewTarget({
  5498. start: my_start_token(M),
  5499. end: my_end_token(M)
  5500. });
  5501. } else if (M.meta.name === "import" && M.property.name === "meta") {
  5502. return new AST_ImportMeta({
  5503. start: my_start_token(M),
  5504. end: my_end_token(M)
  5505. });
  5506. }
  5507. },
  5508. Identifier: function(M) {
  5509. var p = FROM_MOZ_STACK[FROM_MOZ_STACK.length - 2];
  5510. return new ( p.type == "LabeledStatement" ? AST_Label
  5511. : p.type == "VariableDeclarator" && p.id === M ? (p.kind == "const" ? AST_SymbolConst : p.kind == "let" ? AST_SymbolLet : AST_SymbolVar)
  5512. : /Import.*Specifier/.test(p.type) ? (p.local === M ? AST_SymbolImport : AST_SymbolImportForeign)
  5513. : p.type == "ExportSpecifier" ? (p.local === M ? AST_SymbolExport : AST_SymbolExportForeign)
  5514. : p.type == "FunctionExpression" ? (p.id === M ? AST_SymbolLambda : AST_SymbolFunarg)
  5515. : p.type == "FunctionDeclaration" ? (p.id === M ? AST_SymbolDefun : AST_SymbolFunarg)
  5516. : p.type == "ArrowFunctionExpression" ? (p.params.includes(M)) ? AST_SymbolFunarg : AST_SymbolRef
  5517. : p.type == "ClassExpression" ? (p.id === M ? AST_SymbolClass : AST_SymbolRef)
  5518. : p.type == "Property" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolMethod)
  5519. : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty)
  5520. : p.type == "ClassDeclaration" ? (p.id === M ? AST_SymbolDefClass : AST_SymbolRef)
  5521. : p.type == "MethodDefinition" ? (p.computed ? AST_SymbolRef : AST_SymbolMethod)
  5522. : p.type == "CatchClause" ? AST_SymbolCatch
  5523. : p.type == "BreakStatement" || p.type == "ContinueStatement" ? AST_LabelRef
  5524. : AST_SymbolRef)({
  5525. start : my_start_token(M),
  5526. end : my_end_token(M),
  5527. name : M.name
  5528. });
  5529. },
  5530. BigIntLiteral(M) {
  5531. return new AST_BigInt({
  5532. start : my_start_token(M),
  5533. end : my_end_token(M),
  5534. value : M.value
  5535. });
  5536. }
  5537. };
  5538. MOZ_TO_ME.UpdateExpression =
  5539. MOZ_TO_ME.UnaryExpression = function To_Moz_Unary(M) {
  5540. var prefix = "prefix" in M ? M.prefix
  5541. : M.type == "UnaryExpression" ? true : false;
  5542. return new (prefix ? AST_UnaryPrefix : AST_UnaryPostfix)({
  5543. start : my_start_token(M),
  5544. end : my_end_token(M),
  5545. operator : M.operator,
  5546. expression : from_moz(M.argument)
  5547. });
  5548. };
  5549. MOZ_TO_ME.ClassDeclaration =
  5550. MOZ_TO_ME.ClassExpression = function From_Moz_Class(M) {
  5551. return new (M.type === "ClassDeclaration" ? AST_DefClass : AST_ClassExpression)({
  5552. start : my_start_token(M),
  5553. end : my_end_token(M),
  5554. name : from_moz(M.id),
  5555. extends : from_moz(M.superClass),
  5556. properties: M.body.body.map(from_moz)
  5557. });
  5558. };
  5559. map("EmptyStatement", AST_EmptyStatement);
  5560. map("BlockStatement", AST_BlockStatement, "body@body");
  5561. map("IfStatement", AST_If, "test>condition, consequent>body, alternate>alternative");
  5562. map("LabeledStatement", AST_LabeledStatement, "label>label, body>body");
  5563. map("BreakStatement", AST_Break, "label>label");
  5564. map("ContinueStatement", AST_Continue, "label>label");
  5565. map("WithStatement", AST_With, "object>expression, body>body");
  5566. map("SwitchStatement", AST_Switch, "discriminant>expression, cases@body");
  5567. map("ReturnStatement", AST_Return, "argument>value");
  5568. map("ThrowStatement", AST_Throw, "argument>value");
  5569. map("WhileStatement", AST_While, "test>condition, body>body");
  5570. map("DoWhileStatement", AST_Do, "test>condition, body>body");
  5571. map("ForStatement", AST_For, "init>init, test>condition, update>step, body>body");
  5572. map("ForInStatement", AST_ForIn, "left>init, right>object, body>body");
  5573. map("ForOfStatement", AST_ForOf, "left>init, right>object, body>body, await=await");
  5574. map("AwaitExpression", AST_Await, "argument>expression");
  5575. map("YieldExpression", AST_Yield, "argument>expression, delegate=is_star");
  5576. map("DebuggerStatement", AST_Debugger);
  5577. map("VariableDeclarator", AST_VarDef, "id>name, init>value");
  5578. map("CatchClause", AST_Catch, "param>argname, body%body");
  5579. map("ThisExpression", AST_This);
  5580. map("Super", AST_Super);
  5581. map("BinaryExpression", AST_Binary, "operator=operator, left>left, right>right");
  5582. map("LogicalExpression", AST_Binary, "operator=operator, left>left, right>right");
  5583. map("AssignmentExpression", AST_Assign, "operator=operator, left>left, right>right");
  5584. map("ConditionalExpression", AST_Conditional, "test>condition, consequent>consequent, alternate>alternative");
  5585. map("NewExpression", AST_New, "callee>expression, arguments@args");
  5586. map("CallExpression", AST_Call, "callee>expression, optional=optional, arguments@args");
  5587. def_to_moz(AST_Toplevel, function To_Moz_Program(M) {
  5588. return to_moz_scope("Program", M);
  5589. });
  5590. def_to_moz(AST_Expansion, function To_Moz_Spread(M) {
  5591. return {
  5592. type: to_moz_in_destructuring() ? "RestElement" : "SpreadElement",
  5593. argument: to_moz(M.expression)
  5594. };
  5595. });
  5596. def_to_moz(AST_PrefixedTemplateString, function To_Moz_TaggedTemplateExpression(M) {
  5597. return {
  5598. type: "TaggedTemplateExpression",
  5599. tag: to_moz(M.prefix),
  5600. quasi: to_moz(M.template_string)
  5601. };
  5602. });
  5603. def_to_moz(AST_TemplateString, function To_Moz_TemplateLiteral(M) {
  5604. var quasis = [];
  5605. var expressions = [];
  5606. for (var i = 0; i < M.segments.length; i++) {
  5607. if (i % 2 !== 0) {
  5608. expressions.push(to_moz(M.segments[i]));
  5609. } else {
  5610. quasis.push({
  5611. type: "TemplateElement",
  5612. value: {
  5613. raw: M.segments[i].raw,
  5614. cooked: M.segments[i].value
  5615. },
  5616. tail: i === M.segments.length - 1
  5617. });
  5618. }
  5619. }
  5620. return {
  5621. type: "TemplateLiteral",
  5622. quasis: quasis,
  5623. expressions: expressions
  5624. };
  5625. });
  5626. def_to_moz(AST_Defun, function To_Moz_FunctionDeclaration(M) {
  5627. return {
  5628. type: "FunctionDeclaration",
  5629. id: to_moz(M.name),
  5630. params: M.argnames.map(to_moz),
  5631. generator: M.is_generator,
  5632. async: M.async,
  5633. body: to_moz_scope("BlockStatement", M)
  5634. };
  5635. });
  5636. def_to_moz(AST_Function, function To_Moz_FunctionExpression(M, parent) {
  5637. var is_generator = parent.is_generator !== undefined ?
  5638. parent.is_generator : M.is_generator;
  5639. return {
  5640. type: "FunctionExpression",
  5641. id: to_moz(M.name),
  5642. params: M.argnames.map(to_moz),
  5643. generator: is_generator,
  5644. async: M.async,
  5645. body: to_moz_scope("BlockStatement", M)
  5646. };
  5647. });
  5648. def_to_moz(AST_Arrow, function To_Moz_ArrowFunctionExpression(M) {
  5649. var body = {
  5650. type: "BlockStatement",
  5651. body: M.body.map(to_moz)
  5652. };
  5653. return {
  5654. type: "ArrowFunctionExpression",
  5655. params: M.argnames.map(to_moz),
  5656. async: M.async,
  5657. body: body
  5658. };
  5659. });
  5660. def_to_moz(AST_Destructuring, function To_Moz_ObjectPattern(M) {
  5661. if (M.is_array) {
  5662. return {
  5663. type: "ArrayPattern",
  5664. elements: M.names.map(to_moz)
  5665. };
  5666. }
  5667. return {
  5668. type: "ObjectPattern",
  5669. properties: M.names.map(to_moz)
  5670. };
  5671. });
  5672. def_to_moz(AST_Directive, function To_Moz_Directive(M) {
  5673. return {
  5674. type: "ExpressionStatement",
  5675. expression: {
  5676. type: "Literal",
  5677. value: M.value,
  5678. raw: M.print_to_string()
  5679. },
  5680. directive: M.value
  5681. };
  5682. });
  5683. def_to_moz(AST_SimpleStatement, function To_Moz_ExpressionStatement(M) {
  5684. return {
  5685. type: "ExpressionStatement",
  5686. expression: to_moz(M.body)
  5687. };
  5688. });
  5689. def_to_moz(AST_SwitchBranch, function To_Moz_SwitchCase(M) {
  5690. return {
  5691. type: "SwitchCase",
  5692. test: to_moz(M.expression),
  5693. consequent: M.body.map(to_moz)
  5694. };
  5695. });
  5696. def_to_moz(AST_Try, function To_Moz_TryStatement(M) {
  5697. return {
  5698. type: "TryStatement",
  5699. block: to_moz_block(M),
  5700. handler: to_moz(M.bcatch),
  5701. guardedHandlers: [],
  5702. finalizer: to_moz(M.bfinally)
  5703. };
  5704. });
  5705. def_to_moz(AST_Catch, function To_Moz_CatchClause(M) {
  5706. return {
  5707. type: "CatchClause",
  5708. param: to_moz(M.argname),
  5709. guard: null,
  5710. body: to_moz_block(M)
  5711. };
  5712. });
  5713. def_to_moz(AST_Definitions, function To_Moz_VariableDeclaration(M) {
  5714. return {
  5715. type: "VariableDeclaration",
  5716. kind:
  5717. M instanceof AST_Const ? "const" :
  5718. M instanceof AST_Let ? "let" : "var",
  5719. declarations: M.definitions.map(to_moz)
  5720. };
  5721. });
  5722. const assert_clause_to_moz = assert_clause => {
  5723. const assertions = [];
  5724. if (assert_clause) {
  5725. for (const { key, value } of assert_clause.properties) {
  5726. const key_moz = is_basic_identifier_string(key)
  5727. ? { type: "Identifier", name: key }
  5728. : { type: "Literal", value: key, raw: JSON.stringify(key) };
  5729. assertions.push({
  5730. type: "ImportAttribute",
  5731. key: key_moz,
  5732. value: to_moz(value)
  5733. });
  5734. }
  5735. }
  5736. return assertions;
  5737. };
  5738. def_to_moz(AST_Export, function To_Moz_ExportDeclaration(M) {
  5739. if (M.exported_names) {
  5740. if (M.exported_names[0].name.name === "*") {
  5741. return {
  5742. type: "ExportAllDeclaration",
  5743. source: to_moz(M.module_name),
  5744. assertions: assert_clause_to_moz(M.assert_clause)
  5745. };
  5746. }
  5747. return {
  5748. type: "ExportNamedDeclaration",
  5749. specifiers: M.exported_names.map(function (name_mapping) {
  5750. return {
  5751. type: "ExportSpecifier",
  5752. exported: to_moz(name_mapping.foreign_name),
  5753. local: to_moz(name_mapping.name)
  5754. };
  5755. }),
  5756. declaration: to_moz(M.exported_definition),
  5757. source: to_moz(M.module_name),
  5758. assertions: assert_clause_to_moz(M.assert_clause)
  5759. };
  5760. }
  5761. return {
  5762. type: M.is_default ? "ExportDefaultDeclaration" : "ExportNamedDeclaration",
  5763. declaration: to_moz(M.exported_value || M.exported_definition)
  5764. };
  5765. });
  5766. def_to_moz(AST_Import, function To_Moz_ImportDeclaration(M) {
  5767. var specifiers = [];
  5768. if (M.imported_name) {
  5769. specifiers.push({
  5770. type: "ImportDefaultSpecifier",
  5771. local: to_moz(M.imported_name)
  5772. });
  5773. }
  5774. if (M.imported_names && M.imported_names[0].foreign_name.name === "*") {
  5775. specifiers.push({
  5776. type: "ImportNamespaceSpecifier",
  5777. local: to_moz(M.imported_names[0].name)
  5778. });
  5779. } else if (M.imported_names) {
  5780. M.imported_names.forEach(function(name_mapping) {
  5781. specifiers.push({
  5782. type: "ImportSpecifier",
  5783. local: to_moz(name_mapping.name),
  5784. imported: to_moz(name_mapping.foreign_name)
  5785. });
  5786. });
  5787. }
  5788. return {
  5789. type: "ImportDeclaration",
  5790. specifiers: specifiers,
  5791. source: to_moz(M.module_name),
  5792. assertions: assert_clause_to_moz(M.assert_clause)
  5793. };
  5794. });
  5795. def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
  5796. return {
  5797. type: "MetaProperty",
  5798. meta: {
  5799. type: "Identifier",
  5800. name: "import"
  5801. },
  5802. property: {
  5803. type: "Identifier",
  5804. name: "meta"
  5805. }
  5806. };
  5807. });
  5808. def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
  5809. return {
  5810. type: "SequenceExpression",
  5811. expressions: M.expressions.map(to_moz)
  5812. };
  5813. });
  5814. def_to_moz(AST_DotHash, function To_Moz_PrivateMemberExpression(M) {
  5815. return {
  5816. type: "MemberExpression",
  5817. object: to_moz(M.expression),
  5818. computed: false,
  5819. property: {
  5820. type: "PrivateIdentifier",
  5821. name: M.property
  5822. },
  5823. optional: M.optional
  5824. };
  5825. });
  5826. def_to_moz(AST_PropAccess, function To_Moz_MemberExpression(M) {
  5827. var isComputed = M instanceof AST_Sub;
  5828. return {
  5829. type: "MemberExpression",
  5830. object: to_moz(M.expression),
  5831. computed: isComputed,
  5832. property: isComputed ? to_moz(M.property) : {type: "Identifier", name: M.property},
  5833. optional: M.optional
  5834. };
  5835. });
  5836. def_to_moz(AST_Chain, function To_Moz_ChainExpression(M) {
  5837. return {
  5838. type: "ChainExpression",
  5839. expression: to_moz(M.expression)
  5840. };
  5841. });
  5842. def_to_moz(AST_Unary, function To_Moz_Unary(M) {
  5843. return {
  5844. type: M.operator == "++" || M.operator == "--" ? "UpdateExpression" : "UnaryExpression",
  5845. operator: M.operator,
  5846. prefix: M instanceof AST_UnaryPrefix,
  5847. argument: to_moz(M.expression)
  5848. };
  5849. });
  5850. def_to_moz(AST_Binary, function To_Moz_BinaryExpression(M) {
  5851. if (M.operator == "=" && to_moz_in_destructuring()) {
  5852. return {
  5853. type: "AssignmentPattern",
  5854. left: to_moz(M.left),
  5855. right: to_moz(M.right)
  5856. };
  5857. }
  5858. const type = M.operator == "&&" || M.operator == "||" || M.operator === "??"
  5859. ? "LogicalExpression"
  5860. : "BinaryExpression";
  5861. return {
  5862. type,
  5863. left: to_moz(M.left),
  5864. operator: M.operator,
  5865. right: to_moz(M.right)
  5866. };
  5867. });
  5868. def_to_moz(AST_Array, function To_Moz_ArrayExpression(M) {
  5869. return {
  5870. type: "ArrayExpression",
  5871. elements: M.elements.map(to_moz)
  5872. };
  5873. });
  5874. def_to_moz(AST_Object, function To_Moz_ObjectExpression(M) {
  5875. return {
  5876. type: "ObjectExpression",
  5877. properties: M.properties.map(to_moz)
  5878. };
  5879. });
  5880. def_to_moz(AST_ObjectProperty, function To_Moz_Property(M, parent) {
  5881. var key = M.key instanceof AST_Node ? to_moz(M.key) : {
  5882. type: "Identifier",
  5883. value: M.key
  5884. };
  5885. if (typeof M.key === "number") {
  5886. key = {
  5887. type: "Literal",
  5888. value: Number(M.key)
  5889. };
  5890. }
  5891. if (typeof M.key === "string") {
  5892. key = {
  5893. type: "Identifier",
  5894. name: M.key
  5895. };
  5896. }
  5897. var kind;
  5898. var string_or_num = typeof M.key === "string" || typeof M.key === "number";
  5899. var computed = string_or_num ? false : !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef;
  5900. if (M instanceof AST_ObjectKeyVal) {
  5901. kind = "init";
  5902. computed = !string_or_num;
  5903. } else
  5904. if (M instanceof AST_ObjectGetter) {
  5905. kind = "get";
  5906. } else
  5907. if (M instanceof AST_ObjectSetter) {
  5908. kind = "set";
  5909. }
  5910. if (M instanceof AST_PrivateGetter || M instanceof AST_PrivateSetter) {
  5911. const kind = M instanceof AST_PrivateGetter ? "get" : "set";
  5912. return {
  5913. type: "MethodDefinition",
  5914. computed: false,
  5915. kind: kind,
  5916. static: M.static,
  5917. key: {
  5918. type: "PrivateIdentifier",
  5919. name: M.key.name
  5920. },
  5921. value: to_moz(M.value)
  5922. };
  5923. }
  5924. if (M instanceof AST_ClassPrivateProperty) {
  5925. return {
  5926. type: "PropertyDefinition",
  5927. key: {
  5928. type: "PrivateIdentifier",
  5929. name: M.key.name
  5930. },
  5931. value: to_moz(M.value),
  5932. computed: false,
  5933. static: M.static
  5934. };
  5935. }
  5936. if (M instanceof AST_ClassProperty) {
  5937. return {
  5938. type: "PropertyDefinition",
  5939. key,
  5940. value: to_moz(M.value),
  5941. computed,
  5942. static: M.static
  5943. };
  5944. }
  5945. if (parent instanceof AST_Class) {
  5946. return {
  5947. type: "MethodDefinition",
  5948. computed: computed,
  5949. kind: kind,
  5950. static: M.static,
  5951. key: to_moz(M.key),
  5952. value: to_moz(M.value)
  5953. };
  5954. }
  5955. return {
  5956. type: "Property",
  5957. computed: computed,
  5958. kind: kind,
  5959. key: key,
  5960. value: to_moz(M.value)
  5961. };
  5962. });
  5963. def_to_moz(AST_ConciseMethod, function To_Moz_MethodDefinition(M, parent) {
  5964. if (parent instanceof AST_Object) {
  5965. return {
  5966. type: "Property",
  5967. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  5968. kind: "init",
  5969. method: true,
  5970. shorthand: false,
  5971. key: to_moz(M.key),
  5972. value: to_moz(M.value)
  5973. };
  5974. }
  5975. const key = M instanceof AST_PrivateMethod
  5976. ? {
  5977. type: "PrivateIdentifier",
  5978. name: M.key.name
  5979. }
  5980. : to_moz(M.key);
  5981. return {
  5982. type: "MethodDefinition",
  5983. kind: M.key === "constructor" ? "constructor" : "method",
  5984. key,
  5985. value: to_moz(M.value),
  5986. computed: !(M.key instanceof AST_Symbol) || M.key instanceof AST_SymbolRef,
  5987. static: M.static,
  5988. };
  5989. });
  5990. def_to_moz(AST_Class, function To_Moz_Class(M) {
  5991. var type = M instanceof AST_ClassExpression ? "ClassExpression" : "ClassDeclaration";
  5992. return {
  5993. type: type,
  5994. superClass: to_moz(M.extends),
  5995. id: M.name ? to_moz(M.name) : null,
  5996. body: {
  5997. type: "ClassBody",
  5998. body: M.properties.map(to_moz)
  5999. }
  6000. };
  6001. });
  6002. def_to_moz(AST_NewTarget, function To_Moz_MetaProperty() {
  6003. return {
  6004. type: "MetaProperty",
  6005. meta: {
  6006. type: "Identifier",
  6007. name: "new"
  6008. },
  6009. property: {
  6010. type: "Identifier",
  6011. name: "target"
  6012. }
  6013. };
  6014. });
  6015. def_to_moz(AST_Symbol, function To_Moz_Identifier(M, parent) {
  6016. if (M instanceof AST_SymbolMethod && parent.quote) {
  6017. return {
  6018. type: "Literal",
  6019. value: M.name
  6020. };
  6021. }
  6022. var def = M.definition();
  6023. return {
  6024. type: "Identifier",
  6025. name: def ? def.mangled_name || def.name : M.name
  6026. };
  6027. });
  6028. def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
  6029. const pattern = M.value.source;
  6030. const flags = M.value.flags;
  6031. return {
  6032. type: "Literal",
  6033. value: null,
  6034. raw: M.print_to_string(),
  6035. regex: { pattern, flags }
  6036. };
  6037. });
  6038. def_to_moz(AST_Constant, function To_Moz_Literal(M) {
  6039. var value = M.value;
  6040. return {
  6041. type: "Literal",
  6042. value: value,
  6043. raw: M.raw || M.print_to_string()
  6044. };
  6045. });
  6046. def_to_moz(AST_Atom, function To_Moz_Atom(M) {
  6047. return {
  6048. type: "Identifier",
  6049. name: String(M.value)
  6050. };
  6051. });
  6052. def_to_moz(AST_BigInt, M => ({
  6053. type: "BigIntLiteral",
  6054. value: M.value
  6055. }));
  6056. AST_Boolean.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  6057. AST_Null.DEFMETHOD("to_mozilla_ast", AST_Constant.prototype.to_mozilla_ast);
  6058. AST_Hole.DEFMETHOD("to_mozilla_ast", function To_Moz_ArrayHole() { return null; });
  6059. AST_Block.DEFMETHOD("to_mozilla_ast", AST_BlockStatement.prototype.to_mozilla_ast);
  6060. AST_Lambda.DEFMETHOD("to_mozilla_ast", AST_Function.prototype.to_mozilla_ast);
  6061. /* -----[ tools ]----- */
  6062. function my_start_token(moznode) {
  6063. var loc = moznode.loc, start = loc && loc.start;
  6064. var range = moznode.range;
  6065. return new AST_Token(
  6066. "",
  6067. "",
  6068. start && start.line || 0,
  6069. start && start.column || 0,
  6070. range ? range [0] : moznode.start,
  6071. false,
  6072. [],
  6073. [],
  6074. loc && loc.source,
  6075. );
  6076. }
  6077. function my_end_token(moznode) {
  6078. var loc = moznode.loc, end = loc && loc.end;
  6079. var range = moznode.range;
  6080. return new AST_Token(
  6081. "",
  6082. "",
  6083. end && end.line || 0,
  6084. end && end.column || 0,
  6085. range ? range [0] : moznode.end,
  6086. false,
  6087. [],
  6088. [],
  6089. loc && loc.source,
  6090. );
  6091. }
  6092. function map(moztype, mytype, propmap) {
  6093. var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
  6094. moz_to_me += "return new U2." + mytype.name + "({\n" +
  6095. "start: my_start_token(M),\n" +
  6096. "end: my_end_token(M)";
  6097. var me_to_moz = "function To_Moz_" + moztype + "(M){\n";
  6098. me_to_moz += "return {\n" +
  6099. "type: " + JSON.stringify(moztype);
  6100. if (propmap) propmap.split(/\s*,\s*/).forEach(function(prop) {
  6101. var m = /([a-z0-9$_]+)([=@>%])([a-z0-9$_]+)/i.exec(prop);
  6102. if (!m) throw new Error("Can't understand property map: " + prop);
  6103. var moz = m[1], how = m[2], my = m[3];
  6104. moz_to_me += ",\n" + my + ": ";
  6105. me_to_moz += ",\n" + moz + ": ";
  6106. switch (how) {
  6107. case "@":
  6108. moz_to_me += "M." + moz + ".map(from_moz)";
  6109. me_to_moz += "M." + my + ".map(to_moz)";
  6110. break;
  6111. case ">":
  6112. moz_to_me += "from_moz(M." + moz + ")";
  6113. me_to_moz += "to_moz(M." + my + ")";
  6114. break;
  6115. case "=":
  6116. moz_to_me += "M." + moz;
  6117. me_to_moz += "M." + my;
  6118. break;
  6119. case "%":
  6120. moz_to_me += "from_moz(M." + moz + ").body";
  6121. me_to_moz += "to_moz_block(M)";
  6122. break;
  6123. default:
  6124. throw new Error("Can't understand operator in propmap: " + prop);
  6125. }
  6126. });
  6127. moz_to_me += "\n})\n}";
  6128. me_to_moz += "\n}\n}";
  6129. moz_to_me = new Function("U2", "my_start_token", "my_end_token", "from_moz", "return(" + moz_to_me + ")")(
  6130. ast, my_start_token, my_end_token, from_moz
  6131. );
  6132. me_to_moz = new Function("to_moz", "to_moz_block", "to_moz_scope", "return(" + me_to_moz + ")")(
  6133. to_moz, to_moz_block, to_moz_scope
  6134. );
  6135. MOZ_TO_ME[moztype] = moz_to_me;
  6136. def_to_moz(mytype, me_to_moz);
  6137. }
  6138. var FROM_MOZ_STACK = null;
  6139. function from_moz(node) {
  6140. FROM_MOZ_STACK.push(node);
  6141. var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
  6142. FROM_MOZ_STACK.pop();
  6143. return ret;
  6144. }
  6145. AST_Node.from_mozilla_ast = function(node) {
  6146. var save_stack = FROM_MOZ_STACK;
  6147. FROM_MOZ_STACK = [];
  6148. var ast = from_moz(node);
  6149. FROM_MOZ_STACK = save_stack;
  6150. return ast;
  6151. };
  6152. function set_moz_loc(mynode, moznode) {
  6153. var start = mynode.start;
  6154. var end = mynode.end;
  6155. if (!(start && end)) {
  6156. return moznode;
  6157. }
  6158. if (start.pos != null && end.endpos != null) {
  6159. moznode.range = [start.pos, end.endpos];
  6160. }
  6161. if (start.line) {
  6162. moznode.loc = {
  6163. start: {line: start.line, column: start.col},
  6164. end: end.endline ? {line: end.endline, column: end.endcol} : null
  6165. };
  6166. if (start.file) {
  6167. moznode.loc.source = start.file;
  6168. }
  6169. }
  6170. return moznode;
  6171. }
  6172. function def_to_moz(mytype, handler) {
  6173. mytype.DEFMETHOD("to_mozilla_ast", function(parent) {
  6174. return set_moz_loc(this, handler(this, parent));
  6175. });
  6176. }
  6177. var TO_MOZ_STACK = null;
  6178. function to_moz(node) {
  6179. if (TO_MOZ_STACK === null) { TO_MOZ_STACK = []; }
  6180. TO_MOZ_STACK.push(node);
  6181. var ast = node != null ? node.to_mozilla_ast(TO_MOZ_STACK[TO_MOZ_STACK.length - 2]) : null;
  6182. TO_MOZ_STACK.pop();
  6183. if (TO_MOZ_STACK.length === 0) { TO_MOZ_STACK = null; }
  6184. return ast;
  6185. }
  6186. function to_moz_in_destructuring() {
  6187. var i = TO_MOZ_STACK.length;
  6188. while (i--) {
  6189. if (TO_MOZ_STACK[i] instanceof AST_Destructuring) {
  6190. return true;
  6191. }
  6192. }
  6193. return false;
  6194. }
  6195. function to_moz_block(node) {
  6196. return {
  6197. type: "BlockStatement",
  6198. body: node.body.map(to_moz)
  6199. };
  6200. }
  6201. function to_moz_scope(type, node) {
  6202. var body = node.body.map(to_moz);
  6203. if (node.body[0] instanceof AST_SimpleStatement && node.body[0].body instanceof AST_String) {
  6204. body.unshift(to_moz(new AST_EmptyStatement(node.body[0])));
  6205. }
  6206. return {
  6207. type: type,
  6208. body: body
  6209. };
  6210. }
  6211. })();
  6212. // return true if the node at the top of the stack (that means the
  6213. // innermost node in the current output) is lexically the first in
  6214. // a statement.
  6215. function first_in_statement(stack) {
  6216. let node = stack.parent(-1);
  6217. for (let i = 0, p; p = stack.parent(i); i++) {
  6218. if (p instanceof AST_Statement && p.body === node)
  6219. return true;
  6220. if ((p instanceof AST_Sequence && p.expressions[0] === node) ||
  6221. (p.TYPE === "Call" && p.expression === node) ||
  6222. (p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
  6223. (p instanceof AST_Dot && p.expression === node) ||
  6224. (p instanceof AST_Sub && p.expression === node) ||
  6225. (p instanceof AST_Conditional && p.condition === node) ||
  6226. (p instanceof AST_Binary && p.left === node) ||
  6227. (p instanceof AST_UnaryPostfix && p.expression === node)
  6228. ) {
  6229. node = p;
  6230. } else {
  6231. return false;
  6232. }
  6233. }
  6234. }
  6235. // Returns whether the leftmost item in the expression is an object
  6236. function left_is_object(node) {
  6237. if (node instanceof AST_Object) return true;
  6238. if (node instanceof AST_Sequence) return left_is_object(node.expressions[0]);
  6239. if (node.TYPE === "Call") return left_is_object(node.expression);
  6240. if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
  6241. if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
  6242. if (node instanceof AST_Conditional) return left_is_object(node.condition);
  6243. if (node instanceof AST_Binary) return left_is_object(node.left);
  6244. if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
  6245. return false;
  6246. }
  6247. /***********************************************************************
  6248. A JavaScript tokenizer / parser / beautifier / compressor.
  6249. https://github.com/mishoo/UglifyJS2
  6250. -------------------------------- (C) ---------------------------------
  6251. Author: Mihai Bazon
  6252. <mihai.bazon@gmail.com>
  6253. http://mihai.bazon.net/blog
  6254. Distributed under the BSD license:
  6255. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  6256. Redistribution and use in source and binary forms, with or without
  6257. modification, are permitted provided that the following conditions
  6258. are met:
  6259. * Redistributions of source code must retain the above
  6260. copyright notice, this list of conditions and the following
  6261. disclaimer.
  6262. * Redistributions in binary form must reproduce the above
  6263. copyright notice, this list of conditions and the following
  6264. disclaimer in the documentation and/or other materials
  6265. provided with the distribution.
  6266. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  6267. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6268. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  6269. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  6270. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  6271. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  6272. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  6273. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  6274. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  6275. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  6276. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6277. SUCH DAMAGE.
  6278. ***********************************************************************/
  6279. const EXPECT_DIRECTIVE = /^$|[;{][\s\n]*$/;
  6280. const CODE_LINE_BREAK = 10;
  6281. const CODE_SPACE = 32;
  6282. const r_annotation = /[@#]__(PURE|INLINE|NOINLINE)__/g;
  6283. function is_some_comments(comment) {
  6284. // multiline comment
  6285. return (
  6286. (comment.type === "comment2" || comment.type === "comment1")
  6287. && /@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
  6288. );
  6289. }
  6290. class Rope {
  6291. constructor() {
  6292. this.committed = "";
  6293. this.current = "";
  6294. }
  6295. append(str) {
  6296. this.current += str;
  6297. }
  6298. insertAt(char, index) {
  6299. const { committed, current } = this;
  6300. if (index < committed.length) {
  6301. this.committed = committed.slice(0, index) + char + committed.slice(index);
  6302. } else if (index === committed.length) {
  6303. this.committed += char;
  6304. } else {
  6305. index -= committed.length;
  6306. this.committed += current.slice(0, index) + char;
  6307. this.current = current.slice(index);
  6308. }
  6309. }
  6310. charAt(index) {
  6311. const { committed } = this;
  6312. if (index < committed.length) return committed[index];
  6313. return this.current[index - committed.length];
  6314. }
  6315. curLength() {
  6316. return this.current.length;
  6317. }
  6318. length() {
  6319. return this.committed.length + this.current.length;
  6320. }
  6321. toString() {
  6322. return this.committed + this.current;
  6323. }
  6324. }
  6325. function OutputStream(options) {
  6326. var readonly = !options;
  6327. options = defaults(options, {
  6328. ascii_only : false,
  6329. beautify : false,
  6330. braces : false,
  6331. comments : "some",
  6332. ecma : 5,
  6333. ie8 : false,
  6334. indent_level : 4,
  6335. indent_start : 0,
  6336. inline_script : true,
  6337. keep_numbers : false,
  6338. keep_quoted_props : false,
  6339. max_line_len : false,
  6340. preamble : null,
  6341. preserve_annotations : false,
  6342. quote_keys : false,
  6343. quote_style : 0,
  6344. safari10 : false,
  6345. semicolons : true,
  6346. shebang : true,
  6347. shorthand : undefined,
  6348. source_map : null,
  6349. webkit : false,
  6350. width : 80,
  6351. wrap_iife : false,
  6352. wrap_func_args : true,
  6353. }, true);
  6354. if (options.shorthand === undefined)
  6355. options.shorthand = options.ecma > 5;
  6356. // Convert comment option to RegExp if neccessary and set up comments filter
  6357. var comment_filter = return_false; // Default case, throw all comments away
  6358. if (options.comments) {
  6359. let comments = options.comments;
  6360. if (typeof options.comments === "string" && /^\/.*\/[a-zA-Z]*$/.test(options.comments)) {
  6361. var regex_pos = options.comments.lastIndexOf("/");
  6362. comments = new RegExp(
  6363. options.comments.substr(1, regex_pos - 1),
  6364. options.comments.substr(regex_pos + 1)
  6365. );
  6366. }
  6367. if (comments instanceof RegExp) {
  6368. comment_filter = function(comment) {
  6369. return comment.type != "comment5" && comments.test(comment.value);
  6370. };
  6371. } else if (typeof comments === "function") {
  6372. comment_filter = function(comment) {
  6373. return comment.type != "comment5" && comments(this, comment);
  6374. };
  6375. } else if (comments === "some") {
  6376. comment_filter = is_some_comments;
  6377. } else { // NOTE includes "all" option
  6378. comment_filter = return_true;
  6379. }
  6380. }
  6381. var indentation = 0;
  6382. var current_col = 0;
  6383. var current_line = 1;
  6384. var current_pos = 0;
  6385. var OUTPUT = new Rope();
  6386. let printed_comments = new Set();
  6387. var to_utf8 = options.ascii_only ? function(str, identifier = false, regexp = false) {
  6388. if (options.ecma >= 2015 && !options.safari10 && !regexp) {
  6389. str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
  6390. var code = get_full_char_code(ch, 0).toString(16);
  6391. return "\\u{" + code + "}";
  6392. });
  6393. }
  6394. return str.replace(/[\u0000-\u001f\u007f-\uffff]/g, function(ch) {
  6395. var code = ch.charCodeAt(0).toString(16);
  6396. if (code.length <= 2 && !identifier) {
  6397. while (code.length < 2) code = "0" + code;
  6398. return "\\x" + code;
  6399. } else {
  6400. while (code.length < 4) code = "0" + code;
  6401. return "\\u" + code;
  6402. }
  6403. });
  6404. } : function(str) {
  6405. return str.replace(/[\ud800-\udbff][\udc00-\udfff]|([\ud800-\udbff]|[\udc00-\udfff])/g, function(match, lone) {
  6406. if (lone) {
  6407. return "\\u" + lone.charCodeAt(0).toString(16);
  6408. }
  6409. return match;
  6410. });
  6411. };
  6412. function make_string(str, quote) {
  6413. var dq = 0, sq = 0;
  6414. str = str.replace(/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g,
  6415. function(s, i) {
  6416. switch (s) {
  6417. case '"': ++dq; return '"';
  6418. case "'": ++sq; return "'";
  6419. case "\\": return "\\\\";
  6420. case "\n": return "\\n";
  6421. case "\r": return "\\r";
  6422. case "\t": return "\\t";
  6423. case "\b": return "\\b";
  6424. case "\f": return "\\f";
  6425. case "\x0B": return options.ie8 ? "\\x0B" : "\\v";
  6426. case "\u2028": return "\\u2028";
  6427. case "\u2029": return "\\u2029";
  6428. case "\ufeff": return "\\ufeff";
  6429. case "\0":
  6430. return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0";
  6431. }
  6432. return s;
  6433. });
  6434. function quote_single() {
  6435. return "'" + str.replace(/\x27/g, "\\'") + "'";
  6436. }
  6437. function quote_double() {
  6438. return '"' + str.replace(/\x22/g, '\\"') + '"';
  6439. }
  6440. function quote_template() {
  6441. return "`" + str.replace(/`/g, "\\`") + "`";
  6442. }
  6443. str = to_utf8(str);
  6444. if (quote === "`") return quote_template();
  6445. switch (options.quote_style) {
  6446. case 1:
  6447. return quote_single();
  6448. case 2:
  6449. return quote_double();
  6450. case 3:
  6451. return quote == "'" ? quote_single() : quote_double();
  6452. default:
  6453. return dq > sq ? quote_single() : quote_double();
  6454. }
  6455. }
  6456. function encode_string(str, quote) {
  6457. var ret = make_string(str, quote);
  6458. if (options.inline_script) {
  6459. ret = ret.replace(/<\x2f(script)([>\/\t\n\f\r ])/gi, "<\\/$1$2");
  6460. ret = ret.replace(/\x3c!--/g, "\\x3c!--");
  6461. ret = ret.replace(/--\x3e/g, "--\\x3e");
  6462. }
  6463. return ret;
  6464. }
  6465. function make_name(name) {
  6466. name = name.toString();
  6467. name = to_utf8(name, true);
  6468. return name;
  6469. }
  6470. function make_indent(back) {
  6471. return " ".repeat(options.indent_start + indentation - back * options.indent_level);
  6472. }
  6473. /* -----[ beautification/minification ]----- */
  6474. var has_parens = false;
  6475. var might_need_space = false;
  6476. var might_need_semicolon = false;
  6477. var might_add_newline = 0;
  6478. var need_newline_indented = false;
  6479. var need_space = false;
  6480. var newline_insert = -1;
  6481. var last = "";
  6482. var mapping_token, mapping_name, mappings = options.source_map && [];
  6483. var do_add_mapping = mappings ? function() {
  6484. mappings.forEach(function(mapping) {
  6485. try {
  6486. let { name, token } = mapping;
  6487. if (token.type == "name" || token.type === "privatename") {
  6488. name = token.value;
  6489. } else if (name instanceof AST_Symbol) {
  6490. name = token.type === "string" ? token.value : name.name;
  6491. }
  6492. options.source_map.add(
  6493. mapping.token.file,
  6494. mapping.line, mapping.col,
  6495. mapping.token.line, mapping.token.col,
  6496. is_basic_identifier_string(name) ? name : undefined
  6497. );
  6498. } catch(ex) {
  6499. // Ignore bad mapping
  6500. }
  6501. });
  6502. mappings = [];
  6503. } : noop;
  6504. var ensure_line_len = options.max_line_len ? function() {
  6505. if (current_col > options.max_line_len) {
  6506. if (might_add_newline) {
  6507. OUTPUT.insertAt("\n", might_add_newline);
  6508. const curLength = OUTPUT.curLength();
  6509. if (mappings) {
  6510. var delta = curLength - current_col;
  6511. mappings.forEach(function(mapping) {
  6512. mapping.line++;
  6513. mapping.col += delta;
  6514. });
  6515. }
  6516. current_line++;
  6517. current_pos++;
  6518. current_col = curLength;
  6519. }
  6520. }
  6521. if (might_add_newline) {
  6522. might_add_newline = 0;
  6523. do_add_mapping();
  6524. }
  6525. } : noop;
  6526. var requireSemicolonChars = makePredicate("( [ + * / - , . `");
  6527. function print(str) {
  6528. str = String(str);
  6529. var ch = get_full_char(str, 0);
  6530. if (need_newline_indented && ch) {
  6531. need_newline_indented = false;
  6532. if (ch !== "\n") {
  6533. print("\n");
  6534. indent();
  6535. }
  6536. }
  6537. if (need_space && ch) {
  6538. need_space = false;
  6539. if (!/[\s;})]/.test(ch)) {
  6540. space();
  6541. }
  6542. }
  6543. newline_insert = -1;
  6544. var prev = last.charAt(last.length - 1);
  6545. if (might_need_semicolon) {
  6546. might_need_semicolon = false;
  6547. if (prev === ":" && ch === "}" || (!ch || !";}".includes(ch)) && prev !== ";") {
  6548. if (options.semicolons || requireSemicolonChars.has(ch)) {
  6549. OUTPUT.append(";");
  6550. current_col++;
  6551. current_pos++;
  6552. } else {
  6553. ensure_line_len();
  6554. if (current_col > 0) {
  6555. OUTPUT.append("\n");
  6556. current_pos++;
  6557. current_line++;
  6558. current_col = 0;
  6559. }
  6560. if (/^\s+$/.test(str)) {
  6561. // reset the semicolon flag, since we didn't print one
  6562. // now and might still have to later
  6563. might_need_semicolon = true;
  6564. }
  6565. }
  6566. if (!options.beautify)
  6567. might_need_space = false;
  6568. }
  6569. }
  6570. if (might_need_space) {
  6571. if ((is_identifier_char(prev)
  6572. && (is_identifier_char(ch) || ch == "\\"))
  6573. || (ch == "/" && ch == prev)
  6574. || ((ch == "+" || ch == "-") && ch == last)
  6575. ) {
  6576. OUTPUT.append(" ");
  6577. current_col++;
  6578. current_pos++;
  6579. }
  6580. might_need_space = false;
  6581. }
  6582. if (mapping_token) {
  6583. mappings.push({
  6584. token: mapping_token,
  6585. name: mapping_name,
  6586. line: current_line,
  6587. col: current_col
  6588. });
  6589. mapping_token = false;
  6590. if (!might_add_newline) do_add_mapping();
  6591. }
  6592. OUTPUT.append(str);
  6593. has_parens = str[str.length - 1] == "(";
  6594. current_pos += str.length;
  6595. var a = str.split(/\r?\n/), n = a.length - 1;
  6596. current_line += n;
  6597. current_col += a[0].length;
  6598. if (n > 0) {
  6599. ensure_line_len();
  6600. current_col = a[n].length;
  6601. }
  6602. last = str;
  6603. }
  6604. var star = function() {
  6605. print("*");
  6606. };
  6607. var space = options.beautify ? function() {
  6608. print(" ");
  6609. } : function() {
  6610. might_need_space = true;
  6611. };
  6612. var indent = options.beautify ? function(half) {
  6613. if (options.beautify) {
  6614. print(make_indent(half ? 0.5 : 0));
  6615. }
  6616. } : noop;
  6617. var with_indent = options.beautify ? function(col, cont) {
  6618. if (col === true) col = next_indent();
  6619. var save_indentation = indentation;
  6620. indentation = col;
  6621. var ret = cont();
  6622. indentation = save_indentation;
  6623. return ret;
  6624. } : function(col, cont) { return cont(); };
  6625. var newline = options.beautify ? function() {
  6626. if (newline_insert < 0) return print("\n");
  6627. if (OUTPUT.charAt(newline_insert) != "\n") {
  6628. OUTPUT.insertAt("\n", newline_insert);
  6629. current_pos++;
  6630. current_line++;
  6631. }
  6632. newline_insert++;
  6633. } : options.max_line_len ? function() {
  6634. ensure_line_len();
  6635. might_add_newline = OUTPUT.length();
  6636. } : noop;
  6637. var semicolon = options.beautify ? function() {
  6638. print(";");
  6639. } : function() {
  6640. might_need_semicolon = true;
  6641. };
  6642. function force_semicolon() {
  6643. might_need_semicolon = false;
  6644. print(";");
  6645. }
  6646. function next_indent() {
  6647. return indentation + options.indent_level;
  6648. }
  6649. function with_block(cont) {
  6650. var ret;
  6651. print("{");
  6652. newline();
  6653. with_indent(next_indent(), function() {
  6654. ret = cont();
  6655. });
  6656. indent();
  6657. print("}");
  6658. return ret;
  6659. }
  6660. function with_parens(cont) {
  6661. print("(");
  6662. //XXX: still nice to have that for argument lists
  6663. //var ret = with_indent(current_col, cont);
  6664. var ret = cont();
  6665. print(")");
  6666. return ret;
  6667. }
  6668. function with_square(cont) {
  6669. print("[");
  6670. //var ret = with_indent(current_col, cont);
  6671. var ret = cont();
  6672. print("]");
  6673. return ret;
  6674. }
  6675. function comma() {
  6676. print(",");
  6677. space();
  6678. }
  6679. function colon() {
  6680. print(":");
  6681. space();
  6682. }
  6683. var add_mapping = mappings ? function(token, name) {
  6684. mapping_token = token;
  6685. mapping_name = name;
  6686. } : noop;
  6687. function get() {
  6688. if (might_add_newline) {
  6689. ensure_line_len();
  6690. }
  6691. return OUTPUT.toString();
  6692. }
  6693. function has_nlb() {
  6694. const output = OUTPUT.toString();
  6695. let n = output.length - 1;
  6696. while (n >= 0) {
  6697. const code = output.charCodeAt(n);
  6698. if (code === CODE_LINE_BREAK) {
  6699. return true;
  6700. }
  6701. if (code !== CODE_SPACE) {
  6702. return false;
  6703. }
  6704. n--;
  6705. }
  6706. return true;
  6707. }
  6708. function filter_comment(comment) {
  6709. if (!options.preserve_annotations) {
  6710. comment = comment.replace(r_annotation, " ");
  6711. }
  6712. if (/^\s*$/.test(comment)) {
  6713. return "";
  6714. }
  6715. return comment.replace(/(<\s*\/\s*)(script)/i, "<\\/$2");
  6716. }
  6717. function prepend_comments(node) {
  6718. var self = this;
  6719. var start = node.start;
  6720. if (!start) return;
  6721. var printed_comments = self.printed_comments;
  6722. // There cannot be a newline between return and its value.
  6723. const return_with_value = node instanceof AST_Exit && node.value;
  6724. if (
  6725. start.comments_before
  6726. && printed_comments.has(start.comments_before)
  6727. ) {
  6728. if (return_with_value) {
  6729. start.comments_before = [];
  6730. } else {
  6731. return;
  6732. }
  6733. }
  6734. var comments = start.comments_before;
  6735. if (!comments) {
  6736. comments = start.comments_before = [];
  6737. }
  6738. printed_comments.add(comments);
  6739. if (return_with_value) {
  6740. var tw = new TreeWalker(function(node) {
  6741. var parent = tw.parent();
  6742. if (parent instanceof AST_Exit
  6743. || parent instanceof AST_Binary && parent.left === node
  6744. || parent.TYPE == "Call" && parent.expression === node
  6745. || parent instanceof AST_Conditional && parent.condition === node
  6746. || parent instanceof AST_Dot && parent.expression === node
  6747. || parent instanceof AST_Sequence && parent.expressions[0] === node
  6748. || parent instanceof AST_Sub && parent.expression === node
  6749. || parent instanceof AST_UnaryPostfix) {
  6750. if (!node.start) return;
  6751. var text = node.start.comments_before;
  6752. if (text && !printed_comments.has(text)) {
  6753. printed_comments.add(text);
  6754. comments = comments.concat(text);
  6755. }
  6756. } else {
  6757. return true;
  6758. }
  6759. });
  6760. tw.push(node);
  6761. node.value.walk(tw);
  6762. }
  6763. if (current_pos == 0) {
  6764. if (comments.length > 0 && options.shebang && comments[0].type === "comment5"
  6765. && !printed_comments.has(comments[0])) {
  6766. print("#!" + comments.shift().value + "\n");
  6767. indent();
  6768. }
  6769. var preamble = options.preamble;
  6770. if (preamble) {
  6771. print(preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
  6772. }
  6773. }
  6774. comments = comments.filter(comment_filter, node).filter(c => !printed_comments.has(c));
  6775. if (comments.length == 0) return;
  6776. var last_nlb = has_nlb();
  6777. comments.forEach(function(c, i) {
  6778. printed_comments.add(c);
  6779. if (!last_nlb) {
  6780. if (c.nlb) {
  6781. print("\n");
  6782. indent();
  6783. last_nlb = true;
  6784. } else if (i > 0) {
  6785. space();
  6786. }
  6787. }
  6788. if (/comment[134]/.test(c.type)) {
  6789. var value = filter_comment(c.value);
  6790. if (value) {
  6791. print("//" + value + "\n");
  6792. indent();
  6793. }
  6794. last_nlb = true;
  6795. } else if (c.type == "comment2") {
  6796. var value = filter_comment(c.value);
  6797. if (value) {
  6798. print("/*" + value + "*/");
  6799. }
  6800. last_nlb = false;
  6801. }
  6802. });
  6803. if (!last_nlb) {
  6804. if (start.nlb) {
  6805. print("\n");
  6806. indent();
  6807. } else {
  6808. space();
  6809. }
  6810. }
  6811. }
  6812. function append_comments(node, tail) {
  6813. var self = this;
  6814. var token = node.end;
  6815. if (!token) return;
  6816. var printed_comments = self.printed_comments;
  6817. var comments = token[tail ? "comments_before" : "comments_after"];
  6818. if (!comments || printed_comments.has(comments)) return;
  6819. if (!(node instanceof AST_Statement || comments.every((c) =>
  6820. !/comment[134]/.test(c.type)
  6821. ))) return;
  6822. printed_comments.add(comments);
  6823. var insert = OUTPUT.length();
  6824. comments.filter(comment_filter, node).forEach(function(c, i) {
  6825. if (printed_comments.has(c)) return;
  6826. printed_comments.add(c);
  6827. need_space = false;
  6828. if (need_newline_indented) {
  6829. print("\n");
  6830. indent();
  6831. need_newline_indented = false;
  6832. } else if (c.nlb && (i > 0 || !has_nlb())) {
  6833. print("\n");
  6834. indent();
  6835. } else if (i > 0 || !tail) {
  6836. space();
  6837. }
  6838. if (/comment[134]/.test(c.type)) {
  6839. const value = filter_comment(c.value);
  6840. if (value) {
  6841. print("//" + value);
  6842. }
  6843. need_newline_indented = true;
  6844. } else if (c.type == "comment2") {
  6845. const value = filter_comment(c.value);
  6846. if (value) {
  6847. print("/*" + value + "*/");
  6848. }
  6849. need_space = true;
  6850. }
  6851. });
  6852. if (OUTPUT.length() > insert) newline_insert = insert;
  6853. }
  6854. var stack = [];
  6855. return {
  6856. get : get,
  6857. toString : get,
  6858. indent : indent,
  6859. in_directive : false,
  6860. use_asm : null,
  6861. active_scope : null,
  6862. indentation : function() { return indentation; },
  6863. current_width : function() { return current_col - indentation; },
  6864. should_break : function() { return options.width && this.current_width() >= options.width; },
  6865. has_parens : function() { return has_parens; },
  6866. newline : newline,
  6867. print : print,
  6868. star : star,
  6869. space : space,
  6870. comma : comma,
  6871. colon : colon,
  6872. last : function() { return last; },
  6873. semicolon : semicolon,
  6874. force_semicolon : force_semicolon,
  6875. to_utf8 : to_utf8,
  6876. print_name : function(name) { print(make_name(name)); },
  6877. print_string : function(str, quote, escape_directive) {
  6878. var encoded = encode_string(str, quote);
  6879. if (escape_directive === true && !encoded.includes("\\")) {
  6880. // Insert semicolons to break directive prologue
  6881. if (!EXPECT_DIRECTIVE.test(OUTPUT.toString())) {
  6882. force_semicolon();
  6883. }
  6884. force_semicolon();
  6885. }
  6886. print(encoded);
  6887. },
  6888. print_template_string_chars: function(str) {
  6889. var encoded = encode_string(str, "`").replace(/\${/g, "\\${");
  6890. return print(encoded.substr(1, encoded.length - 2));
  6891. },
  6892. encode_string : encode_string,
  6893. next_indent : next_indent,
  6894. with_indent : with_indent,
  6895. with_block : with_block,
  6896. with_parens : with_parens,
  6897. with_square : with_square,
  6898. add_mapping : add_mapping,
  6899. option : function(opt) { return options[opt]; },
  6900. printed_comments: printed_comments,
  6901. prepend_comments: readonly ? noop : prepend_comments,
  6902. append_comments : readonly || comment_filter === return_false ? noop : append_comments,
  6903. line : function() { return current_line; },
  6904. col : function() { return current_col; },
  6905. pos : function() { return current_pos; },
  6906. push_node : function(node) { stack.push(node); },
  6907. pop_node : function() { return stack.pop(); },
  6908. parent : function(n) {
  6909. return stack[stack.length - 2 - (n || 0)];
  6910. }
  6911. };
  6912. }
  6913. /* -----[ code generators ]----- */
  6914. (function() {
  6915. /* -----[ utils ]----- */
  6916. function DEFPRINT(nodetype, generator) {
  6917. nodetype.DEFMETHOD("_codegen", generator);
  6918. }
  6919. AST_Node.DEFMETHOD("print", function(output, force_parens) {
  6920. var self = this, generator = self._codegen;
  6921. if (self instanceof AST_Scope) {
  6922. output.active_scope = self;
  6923. } else if (!output.use_asm && self instanceof AST_Directive && self.value == "use asm") {
  6924. output.use_asm = output.active_scope;
  6925. }
  6926. function doit() {
  6927. output.prepend_comments(self);
  6928. self.add_source_map(output);
  6929. generator(self, output);
  6930. output.append_comments(self);
  6931. }
  6932. output.push_node(self);
  6933. if (force_parens || self.needs_parens(output)) {
  6934. output.with_parens(doit);
  6935. } else {
  6936. doit();
  6937. }
  6938. output.pop_node();
  6939. if (self === output.use_asm) {
  6940. output.use_asm = null;
  6941. }
  6942. });
  6943. AST_Node.DEFMETHOD("_print", AST_Node.prototype.print);
  6944. AST_Node.DEFMETHOD("print_to_string", function(options) {
  6945. var output = OutputStream(options);
  6946. this.print(output);
  6947. return output.get();
  6948. });
  6949. /* -----[ PARENTHESES ]----- */
  6950. function PARENS(nodetype, func) {
  6951. if (Array.isArray(nodetype)) {
  6952. nodetype.forEach(function(nodetype) {
  6953. PARENS(nodetype, func);
  6954. });
  6955. } else {
  6956. nodetype.DEFMETHOD("needs_parens", func);
  6957. }
  6958. }
  6959. PARENS(AST_Node, return_false);
  6960. // a function expression needs parens around it when it's provably
  6961. // the first token to appear in a statement.
  6962. PARENS(AST_Function, function(output) {
  6963. if (!output.has_parens() && first_in_statement(output)) {
  6964. return true;
  6965. }
  6966. if (output.option("webkit")) {
  6967. var p = output.parent();
  6968. if (p instanceof AST_PropAccess && p.expression === this) {
  6969. return true;
  6970. }
  6971. }
  6972. if (output.option("wrap_iife")) {
  6973. var p = output.parent();
  6974. if (p instanceof AST_Call && p.expression === this) {
  6975. return true;
  6976. }
  6977. }
  6978. if (output.option("wrap_func_args")) {
  6979. var p = output.parent();
  6980. if (p instanceof AST_Call && p.args.includes(this)) {
  6981. return true;
  6982. }
  6983. }
  6984. return false;
  6985. });
  6986. PARENS(AST_Arrow, function(output) {
  6987. var p = output.parent();
  6988. if (
  6989. output.option("wrap_func_args")
  6990. && p instanceof AST_Call
  6991. && p.args.includes(this)
  6992. ) {
  6993. return true;
  6994. }
  6995. return p instanceof AST_PropAccess && p.expression === this;
  6996. });
  6997. // same goes for an object literal (as in AST_Function), because
  6998. // otherwise {...} would be interpreted as a block of code.
  6999. PARENS(AST_Object, function(output) {
  7000. return !output.has_parens() && first_in_statement(output);
  7001. });
  7002. PARENS(AST_ClassExpression, first_in_statement);
  7003. PARENS(AST_Unary, function(output) {
  7004. var p = output.parent();
  7005. return p instanceof AST_PropAccess && p.expression === this
  7006. || p instanceof AST_Call && p.expression === this
  7007. || p instanceof AST_Binary
  7008. && p.operator === "**"
  7009. && this instanceof AST_UnaryPrefix
  7010. && p.left === this
  7011. && this.operator !== "++"
  7012. && this.operator !== "--";
  7013. });
  7014. PARENS(AST_Await, function(output) {
  7015. var p = output.parent();
  7016. return p instanceof AST_PropAccess && p.expression === this
  7017. || p instanceof AST_Call && p.expression === this
  7018. || p instanceof AST_Binary && p.operator === "**" && p.left === this
  7019. || output.option("safari10") && p instanceof AST_UnaryPrefix;
  7020. });
  7021. PARENS(AST_Sequence, function(output) {
  7022. var p = output.parent();
  7023. return p instanceof AST_Call // (foo, bar)() or foo(1, (2, 3), 4)
  7024. || p instanceof AST_Unary // !(foo, bar, baz)
  7025. || p instanceof AST_Binary // 1 + (2, 3) + 4 ==> 8
  7026. || p instanceof AST_VarDef // var a = (1, 2), b = a + a; ==> b == 4
  7027. || p instanceof AST_PropAccess // (1, {foo:2}).foo or (1, {foo:2})["foo"] ==> 2
  7028. || p instanceof AST_Array // [ 1, (2, 3), 4 ] ==> [ 1, 3, 4 ]
  7029. || p instanceof AST_ObjectProperty // { foo: (1, 2) }.foo ==> 2
  7030. || p instanceof AST_Conditional /* (false, true) ? (a = 10, b = 20) : (c = 30)
  7031. * ==> 20 (side effect, set a := 10 and b := 20) */
  7032. || p instanceof AST_Arrow // x => (x, x)
  7033. || p instanceof AST_DefaultAssign // x => (x = (0, function(){}))
  7034. || p instanceof AST_Expansion // [...(a, b)]
  7035. || p instanceof AST_ForOf && this === p.object // for (e of (foo, bar)) {}
  7036. || p instanceof AST_Yield // yield (foo, bar)
  7037. || p instanceof AST_Export // export default (foo, bar)
  7038. ;
  7039. });
  7040. PARENS(AST_Binary, function(output) {
  7041. var p = output.parent();
  7042. // (foo && bar)()
  7043. if (p instanceof AST_Call && p.expression === this)
  7044. return true;
  7045. // typeof (foo && bar)
  7046. if (p instanceof AST_Unary)
  7047. return true;
  7048. // (foo && bar)["prop"], (foo && bar).prop
  7049. if (p instanceof AST_PropAccess && p.expression === this)
  7050. return true;
  7051. // this deals with precedence: 3 * (2 + 1)
  7052. if (p instanceof AST_Binary) {
  7053. const po = p.operator;
  7054. const so = this.operator;
  7055. if (so === "??" && (po === "||" || po === "&&")) {
  7056. return true;
  7057. }
  7058. if (po === "??" && (so === "||" || so === "&&")) {
  7059. return true;
  7060. }
  7061. const pp = PRECEDENCE[po];
  7062. const sp = PRECEDENCE[so];
  7063. if (pp > sp
  7064. || (pp == sp
  7065. && (this === p.right || po == "**"))) {
  7066. return true;
  7067. }
  7068. }
  7069. });
  7070. PARENS(AST_Yield, function(output) {
  7071. var p = output.parent();
  7072. // (yield 1) + (yield 2)
  7073. // a = yield 3
  7074. if (p instanceof AST_Binary && p.operator !== "=")
  7075. return true;
  7076. // (yield 1)()
  7077. // new (yield 1)()
  7078. if (p instanceof AST_Call && p.expression === this)
  7079. return true;
  7080. // (yield 1) ? yield 2 : yield 3
  7081. if (p instanceof AST_Conditional && p.condition === this)
  7082. return true;
  7083. // -(yield 4)
  7084. if (p instanceof AST_Unary)
  7085. return true;
  7086. // (yield x).foo
  7087. // (yield x)['foo']
  7088. if (p instanceof AST_PropAccess && p.expression === this)
  7089. return true;
  7090. });
  7091. PARENS(AST_PropAccess, function(output) {
  7092. var p = output.parent();
  7093. if (p instanceof AST_New && p.expression === this) {
  7094. // i.e. new (foo.bar().baz)
  7095. //
  7096. // if there's one call into this subtree, then we need
  7097. // parens around it too, otherwise the call will be
  7098. // interpreted as passing the arguments to the upper New
  7099. // expression.
  7100. return walk(this, node => {
  7101. if (node instanceof AST_Scope) return true;
  7102. if (node instanceof AST_Call) {
  7103. return walk_abort; // makes walk() return true.
  7104. }
  7105. });
  7106. }
  7107. });
  7108. PARENS(AST_Call, function(output) {
  7109. var p = output.parent(), p1;
  7110. if (p instanceof AST_New && p.expression === this
  7111. || p instanceof AST_Export && p.is_default && this.expression instanceof AST_Function)
  7112. return true;
  7113. // workaround for Safari bug.
  7114. // https://bugs.webkit.org/show_bug.cgi?id=123506
  7115. return this.expression instanceof AST_Function
  7116. && p instanceof AST_PropAccess
  7117. && p.expression === this
  7118. && (p1 = output.parent(1)) instanceof AST_Assign
  7119. && p1.left === p;
  7120. });
  7121. PARENS(AST_New, function(output) {
  7122. var p = output.parent();
  7123. if (this.args.length === 0
  7124. && (p instanceof AST_PropAccess // (new Date).getTime(), (new Date)["getTime"]()
  7125. || p instanceof AST_Call && p.expression === this)) // (new foo)(bar)
  7126. return true;
  7127. });
  7128. PARENS(AST_Number, function(output) {
  7129. var p = output.parent();
  7130. if (p instanceof AST_PropAccess && p.expression === this) {
  7131. var value = this.getValue();
  7132. if (value < 0 || /^0/.test(make_num(value))) {
  7133. return true;
  7134. }
  7135. }
  7136. });
  7137. PARENS(AST_BigInt, function(output) {
  7138. var p = output.parent();
  7139. if (p instanceof AST_PropAccess && p.expression === this) {
  7140. var value = this.getValue();
  7141. if (value.startsWith("-")) {
  7142. return true;
  7143. }
  7144. }
  7145. });
  7146. PARENS([ AST_Assign, AST_Conditional ], function(output) {
  7147. var p = output.parent();
  7148. // !(a = false) → true
  7149. if (p instanceof AST_Unary)
  7150. return true;
  7151. // 1 + (a = 2) + 3 → 6, side effect setting a = 2
  7152. if (p instanceof AST_Binary && !(p instanceof AST_Assign))
  7153. return true;
  7154. // (a = func)() —or— new (a = Object)()
  7155. if (p instanceof AST_Call && p.expression === this)
  7156. return true;
  7157. // (a = foo) ? bar : baz
  7158. if (p instanceof AST_Conditional && p.condition === this)
  7159. return true;
  7160. // (a = foo)["prop"] —or— (a = foo).prop
  7161. if (p instanceof AST_PropAccess && p.expression === this)
  7162. return true;
  7163. // ({a, b} = {a: 1, b: 2}), a destructuring assignment
  7164. if (this instanceof AST_Assign && this.left instanceof AST_Destructuring && this.left.is_array === false)
  7165. return true;
  7166. });
  7167. /* -----[ PRINTERS ]----- */
  7168. DEFPRINT(AST_Directive, function(self, output) {
  7169. output.print_string(self.value, self.quote);
  7170. output.semicolon();
  7171. });
  7172. DEFPRINT(AST_Expansion, function (self, output) {
  7173. output.print("...");
  7174. self.expression.print(output);
  7175. });
  7176. DEFPRINT(AST_Destructuring, function (self, output) {
  7177. output.print(self.is_array ? "[" : "{");
  7178. var len = self.names.length;
  7179. self.names.forEach(function (name, i) {
  7180. if (i > 0) output.comma();
  7181. name.print(output);
  7182. // If the final element is a hole, we need to make sure it
  7183. // doesn't look like a trailing comma, by inserting an actual
  7184. // trailing comma.
  7185. if (i == len - 1 && name instanceof AST_Hole) output.comma();
  7186. });
  7187. output.print(self.is_array ? "]" : "}");
  7188. });
  7189. DEFPRINT(AST_Debugger, function(self, output) {
  7190. output.print("debugger");
  7191. output.semicolon();
  7192. });
  7193. /* -----[ statements ]----- */
  7194. function display_body(body, is_toplevel, output, allow_directives) {
  7195. var last = body.length - 1;
  7196. output.in_directive = allow_directives;
  7197. body.forEach(function(stmt, i) {
  7198. if (output.in_directive === true && !(stmt instanceof AST_Directive ||
  7199. stmt instanceof AST_EmptyStatement ||
  7200. (stmt instanceof AST_SimpleStatement && stmt.body instanceof AST_String)
  7201. )) {
  7202. output.in_directive = false;
  7203. }
  7204. if (!(stmt instanceof AST_EmptyStatement)) {
  7205. output.indent();
  7206. stmt.print(output);
  7207. if (!(i == last && is_toplevel)) {
  7208. output.newline();
  7209. if (is_toplevel) output.newline();
  7210. }
  7211. }
  7212. if (output.in_directive === true &&
  7213. stmt instanceof AST_SimpleStatement &&
  7214. stmt.body instanceof AST_String
  7215. ) {
  7216. output.in_directive = false;
  7217. }
  7218. });
  7219. output.in_directive = false;
  7220. }
  7221. AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
  7222. force_statement(this.body, output);
  7223. });
  7224. DEFPRINT(AST_Statement, function(self, output) {
  7225. self.body.print(output);
  7226. output.semicolon();
  7227. });
  7228. DEFPRINT(AST_Toplevel, function(self, output) {
  7229. display_body(self.body, true, output, true);
  7230. output.print("");
  7231. });
  7232. DEFPRINT(AST_LabeledStatement, function(self, output) {
  7233. self.label.print(output);
  7234. output.colon();
  7235. self.body.print(output);
  7236. });
  7237. DEFPRINT(AST_SimpleStatement, function(self, output) {
  7238. self.body.print(output);
  7239. output.semicolon();
  7240. });
  7241. function print_braced_empty(self, output) {
  7242. output.print("{");
  7243. output.with_indent(output.next_indent(), function() {
  7244. output.append_comments(self, true);
  7245. });
  7246. output.print("}");
  7247. }
  7248. function print_braced(self, output, allow_directives) {
  7249. if (self.body.length > 0) {
  7250. output.with_block(function() {
  7251. display_body(self.body, false, output, allow_directives);
  7252. });
  7253. } else print_braced_empty(self, output);
  7254. }
  7255. DEFPRINT(AST_BlockStatement, function(self, output) {
  7256. print_braced(self, output);
  7257. });
  7258. DEFPRINT(AST_EmptyStatement, function(self, output) {
  7259. output.semicolon();
  7260. });
  7261. DEFPRINT(AST_Do, function(self, output) {
  7262. output.print("do");
  7263. output.space();
  7264. make_block(self.body, output);
  7265. output.space();
  7266. output.print("while");
  7267. output.space();
  7268. output.with_parens(function() {
  7269. self.condition.print(output);
  7270. });
  7271. output.semicolon();
  7272. });
  7273. DEFPRINT(AST_While, function(self, output) {
  7274. output.print("while");
  7275. output.space();
  7276. output.with_parens(function() {
  7277. self.condition.print(output);
  7278. });
  7279. output.space();
  7280. self._do_print_body(output);
  7281. });
  7282. DEFPRINT(AST_For, function(self, output) {
  7283. output.print("for");
  7284. output.space();
  7285. output.with_parens(function() {
  7286. if (self.init) {
  7287. if (self.init instanceof AST_Definitions) {
  7288. self.init.print(output);
  7289. } else {
  7290. parenthesize_for_noin(self.init, output, true);
  7291. }
  7292. output.print(";");
  7293. output.space();
  7294. } else {
  7295. output.print(";");
  7296. }
  7297. if (self.condition) {
  7298. self.condition.print(output);
  7299. output.print(";");
  7300. output.space();
  7301. } else {
  7302. output.print(";");
  7303. }
  7304. if (self.step) {
  7305. self.step.print(output);
  7306. }
  7307. });
  7308. output.space();
  7309. self._do_print_body(output);
  7310. });
  7311. DEFPRINT(AST_ForIn, function(self, output) {
  7312. output.print("for");
  7313. if (self.await) {
  7314. output.space();
  7315. output.print("await");
  7316. }
  7317. output.space();
  7318. output.with_parens(function() {
  7319. self.init.print(output);
  7320. output.space();
  7321. output.print(self instanceof AST_ForOf ? "of" : "in");
  7322. output.space();
  7323. self.object.print(output);
  7324. });
  7325. output.space();
  7326. self._do_print_body(output);
  7327. });
  7328. DEFPRINT(AST_With, function(self, output) {
  7329. output.print("with");
  7330. output.space();
  7331. output.with_parens(function() {
  7332. self.expression.print(output);
  7333. });
  7334. output.space();
  7335. self._do_print_body(output);
  7336. });
  7337. /* -----[ functions ]----- */
  7338. AST_Lambda.DEFMETHOD("_do_print", function(output, nokeyword) {
  7339. var self = this;
  7340. if (!nokeyword) {
  7341. if (self.async) {
  7342. output.print("async");
  7343. output.space();
  7344. }
  7345. output.print("function");
  7346. if (self.is_generator) {
  7347. output.star();
  7348. }
  7349. if (self.name) {
  7350. output.space();
  7351. }
  7352. }
  7353. if (self.name instanceof AST_Symbol) {
  7354. self.name.print(output);
  7355. } else if (nokeyword && self.name instanceof AST_Node) {
  7356. output.with_square(function() {
  7357. self.name.print(output); // Computed method name
  7358. });
  7359. }
  7360. output.with_parens(function() {
  7361. self.argnames.forEach(function(arg, i) {
  7362. if (i) output.comma();
  7363. arg.print(output);
  7364. });
  7365. });
  7366. output.space();
  7367. print_braced(self, output, true);
  7368. });
  7369. DEFPRINT(AST_Lambda, function(self, output) {
  7370. self._do_print(output);
  7371. });
  7372. DEFPRINT(AST_PrefixedTemplateString, function(self, output) {
  7373. var tag = self.prefix;
  7374. var parenthesize_tag = tag instanceof AST_Lambda
  7375. || tag instanceof AST_Binary
  7376. || tag instanceof AST_Conditional
  7377. || tag instanceof AST_Sequence
  7378. || tag instanceof AST_Unary
  7379. || tag instanceof AST_Dot && tag.expression instanceof AST_Object;
  7380. if (parenthesize_tag) output.print("(");
  7381. self.prefix.print(output);
  7382. if (parenthesize_tag) output.print(")");
  7383. self.template_string.print(output);
  7384. });
  7385. DEFPRINT(AST_TemplateString, function(self, output) {
  7386. var is_tagged = output.parent() instanceof AST_PrefixedTemplateString;
  7387. output.print("`");
  7388. for (var i = 0; i < self.segments.length; i++) {
  7389. if (!(self.segments[i] instanceof AST_TemplateSegment)) {
  7390. output.print("${");
  7391. self.segments[i].print(output);
  7392. output.print("}");
  7393. } else if (is_tagged) {
  7394. output.print(self.segments[i].raw);
  7395. } else {
  7396. output.print_template_string_chars(self.segments[i].value);
  7397. }
  7398. }
  7399. output.print("`");
  7400. });
  7401. DEFPRINT(AST_TemplateSegment, function(self, output) {
  7402. output.print_template_string_chars(self.value);
  7403. });
  7404. AST_Arrow.DEFMETHOD("_do_print", function(output) {
  7405. var self = this;
  7406. var parent = output.parent();
  7407. var needs_parens = (parent instanceof AST_Binary && !(parent instanceof AST_Assign)) ||
  7408. parent instanceof AST_Unary ||
  7409. (parent instanceof AST_Call && self === parent.expression);
  7410. if (needs_parens) { output.print("("); }
  7411. if (self.async) {
  7412. output.print("async");
  7413. output.space();
  7414. }
  7415. if (self.argnames.length === 1 && self.argnames[0] instanceof AST_Symbol) {
  7416. self.argnames[0].print(output);
  7417. } else {
  7418. output.with_parens(function() {
  7419. self.argnames.forEach(function(arg, i) {
  7420. if (i) output.comma();
  7421. arg.print(output);
  7422. });
  7423. });
  7424. }
  7425. output.space();
  7426. output.print("=>");
  7427. output.space();
  7428. const first_statement = self.body[0];
  7429. if (
  7430. self.body.length === 1
  7431. && first_statement instanceof AST_Return
  7432. ) {
  7433. const returned = first_statement.value;
  7434. if (!returned) {
  7435. output.print("{}");
  7436. } else if (left_is_object(returned)) {
  7437. output.print("(");
  7438. returned.print(output);
  7439. output.print(")");
  7440. } else {
  7441. returned.print(output);
  7442. }
  7443. } else {
  7444. print_braced(self, output);
  7445. }
  7446. if (needs_parens) { output.print(")"); }
  7447. });
  7448. /* -----[ exits ]----- */
  7449. AST_Exit.DEFMETHOD("_do_print", function(output, kind) {
  7450. output.print(kind);
  7451. if (this.value) {
  7452. output.space();
  7453. const comments = this.value.start.comments_before;
  7454. if (comments && comments.length && !output.printed_comments.has(comments)) {
  7455. output.print("(");
  7456. this.value.print(output);
  7457. output.print(")");
  7458. } else {
  7459. this.value.print(output);
  7460. }
  7461. }
  7462. output.semicolon();
  7463. });
  7464. DEFPRINT(AST_Return, function(self, output) {
  7465. self._do_print(output, "return");
  7466. });
  7467. DEFPRINT(AST_Throw, function(self, output) {
  7468. self._do_print(output, "throw");
  7469. });
  7470. /* -----[ yield ]----- */
  7471. DEFPRINT(AST_Yield, function(self, output) {
  7472. var star = self.is_star ? "*" : "";
  7473. output.print("yield" + star);
  7474. if (self.expression) {
  7475. output.space();
  7476. self.expression.print(output);
  7477. }
  7478. });
  7479. DEFPRINT(AST_Await, function(self, output) {
  7480. output.print("await");
  7481. output.space();
  7482. var e = self.expression;
  7483. var parens = !(
  7484. e instanceof AST_Call
  7485. || e instanceof AST_SymbolRef
  7486. || e instanceof AST_PropAccess
  7487. || e instanceof AST_Unary
  7488. || e instanceof AST_Constant
  7489. || e instanceof AST_Await
  7490. || e instanceof AST_Object
  7491. );
  7492. if (parens) output.print("(");
  7493. self.expression.print(output);
  7494. if (parens) output.print(")");
  7495. });
  7496. /* -----[ loop control ]----- */
  7497. AST_LoopControl.DEFMETHOD("_do_print", function(output, kind) {
  7498. output.print(kind);
  7499. if (this.label) {
  7500. output.space();
  7501. this.label.print(output);
  7502. }
  7503. output.semicolon();
  7504. });
  7505. DEFPRINT(AST_Break, function(self, output) {
  7506. self._do_print(output, "break");
  7507. });
  7508. DEFPRINT(AST_Continue, function(self, output) {
  7509. self._do_print(output, "continue");
  7510. });
  7511. /* -----[ if ]----- */
  7512. function make_then(self, output) {
  7513. var b = self.body;
  7514. if (output.option("braces")
  7515. || output.option("ie8") && b instanceof AST_Do)
  7516. return make_block(b, output);
  7517. // The squeezer replaces "block"-s that contain only a single
  7518. // statement with the statement itself; technically, the AST
  7519. // is correct, but this can create problems when we output an
  7520. // IF having an ELSE clause where the THEN clause ends in an
  7521. // IF *without* an ELSE block (then the outer ELSE would refer
  7522. // to the inner IF). This function checks for this case and
  7523. // adds the block braces if needed.
  7524. if (!b) return output.force_semicolon();
  7525. while (true) {
  7526. if (b instanceof AST_If) {
  7527. if (!b.alternative) {
  7528. make_block(self.body, output);
  7529. return;
  7530. }
  7531. b = b.alternative;
  7532. } else if (b instanceof AST_StatementWithBody) {
  7533. b = b.body;
  7534. } else break;
  7535. }
  7536. force_statement(self.body, output);
  7537. }
  7538. DEFPRINT(AST_If, function(self, output) {
  7539. output.print("if");
  7540. output.space();
  7541. output.with_parens(function() {
  7542. self.condition.print(output);
  7543. });
  7544. output.space();
  7545. if (self.alternative) {
  7546. make_then(self, output);
  7547. output.space();
  7548. output.print("else");
  7549. output.space();
  7550. if (self.alternative instanceof AST_If)
  7551. self.alternative.print(output);
  7552. else
  7553. force_statement(self.alternative, output);
  7554. } else {
  7555. self._do_print_body(output);
  7556. }
  7557. });
  7558. /* -----[ switch ]----- */
  7559. DEFPRINT(AST_Switch, function(self, output) {
  7560. output.print("switch");
  7561. output.space();
  7562. output.with_parens(function() {
  7563. self.expression.print(output);
  7564. });
  7565. output.space();
  7566. var last = self.body.length - 1;
  7567. if (last < 0) print_braced_empty(self, output);
  7568. else output.with_block(function() {
  7569. self.body.forEach(function(branch, i) {
  7570. output.indent(true);
  7571. branch.print(output);
  7572. if (i < last && branch.body.length > 0)
  7573. output.newline();
  7574. });
  7575. });
  7576. });
  7577. AST_SwitchBranch.DEFMETHOD("_do_print_body", function(output) {
  7578. output.newline();
  7579. this.body.forEach(function(stmt) {
  7580. output.indent();
  7581. stmt.print(output);
  7582. output.newline();
  7583. });
  7584. });
  7585. DEFPRINT(AST_Default, function(self, output) {
  7586. output.print("default:");
  7587. self._do_print_body(output);
  7588. });
  7589. DEFPRINT(AST_Case, function(self, output) {
  7590. output.print("case");
  7591. output.space();
  7592. self.expression.print(output);
  7593. output.print(":");
  7594. self._do_print_body(output);
  7595. });
  7596. /* -----[ exceptions ]----- */
  7597. DEFPRINT(AST_Try, function(self, output) {
  7598. output.print("try");
  7599. output.space();
  7600. print_braced(self, output);
  7601. if (self.bcatch) {
  7602. output.space();
  7603. self.bcatch.print(output);
  7604. }
  7605. if (self.bfinally) {
  7606. output.space();
  7607. self.bfinally.print(output);
  7608. }
  7609. });
  7610. DEFPRINT(AST_Catch, function(self, output) {
  7611. output.print("catch");
  7612. if (self.argname) {
  7613. output.space();
  7614. output.with_parens(function() {
  7615. self.argname.print(output);
  7616. });
  7617. }
  7618. output.space();
  7619. print_braced(self, output);
  7620. });
  7621. DEFPRINT(AST_Finally, function(self, output) {
  7622. output.print("finally");
  7623. output.space();
  7624. print_braced(self, output);
  7625. });
  7626. /* -----[ var/const ]----- */
  7627. AST_Definitions.DEFMETHOD("_do_print", function(output, kind) {
  7628. output.print(kind);
  7629. output.space();
  7630. this.definitions.forEach(function(def, i) {
  7631. if (i) output.comma();
  7632. def.print(output);
  7633. });
  7634. var p = output.parent();
  7635. var in_for = p instanceof AST_For || p instanceof AST_ForIn;
  7636. var output_semicolon = !in_for || p && p.init !== this;
  7637. if (output_semicolon)
  7638. output.semicolon();
  7639. });
  7640. DEFPRINT(AST_Let, function(self, output) {
  7641. self._do_print(output, "let");
  7642. });
  7643. DEFPRINT(AST_Var, function(self, output) {
  7644. self._do_print(output, "var");
  7645. });
  7646. DEFPRINT(AST_Const, function(self, output) {
  7647. self._do_print(output, "const");
  7648. });
  7649. DEFPRINT(AST_Import, function(self, output) {
  7650. output.print("import");
  7651. output.space();
  7652. if (self.imported_name) {
  7653. self.imported_name.print(output);
  7654. }
  7655. if (self.imported_name && self.imported_names) {
  7656. output.print(",");
  7657. output.space();
  7658. }
  7659. if (self.imported_names) {
  7660. if (self.imported_names.length === 1 && self.imported_names[0].foreign_name.name === "*") {
  7661. self.imported_names[0].print(output);
  7662. } else {
  7663. output.print("{");
  7664. self.imported_names.forEach(function (name_import, i) {
  7665. output.space();
  7666. name_import.print(output);
  7667. if (i < self.imported_names.length - 1) {
  7668. output.print(",");
  7669. }
  7670. });
  7671. output.space();
  7672. output.print("}");
  7673. }
  7674. }
  7675. if (self.imported_name || self.imported_names) {
  7676. output.space();
  7677. output.print("from");
  7678. output.space();
  7679. }
  7680. self.module_name.print(output);
  7681. if (self.assert_clause) {
  7682. output.print("assert");
  7683. self.assert_clause.print(output);
  7684. }
  7685. output.semicolon();
  7686. });
  7687. DEFPRINT(AST_ImportMeta, function(self, output) {
  7688. output.print("import.meta");
  7689. });
  7690. DEFPRINT(AST_NameMapping, function(self, output) {
  7691. var is_import = output.parent() instanceof AST_Import;
  7692. var definition = self.name.definition();
  7693. var names_are_different =
  7694. (definition && definition.mangled_name || self.name.name) !==
  7695. self.foreign_name.name;
  7696. if (names_are_different) {
  7697. if (is_import) {
  7698. output.print(self.foreign_name.name);
  7699. } else {
  7700. self.name.print(output);
  7701. }
  7702. output.space();
  7703. output.print("as");
  7704. output.space();
  7705. if (is_import) {
  7706. self.name.print(output);
  7707. } else {
  7708. output.print(self.foreign_name.name);
  7709. }
  7710. } else {
  7711. self.name.print(output);
  7712. }
  7713. });
  7714. DEFPRINT(AST_Export, function(self, output) {
  7715. output.print("export");
  7716. output.space();
  7717. if (self.is_default) {
  7718. output.print("default");
  7719. output.space();
  7720. }
  7721. if (self.exported_names) {
  7722. if (self.exported_names.length === 1 && self.exported_names[0].name.name === "*") {
  7723. self.exported_names[0].print(output);
  7724. } else {
  7725. output.print("{");
  7726. self.exported_names.forEach(function(name_export, i) {
  7727. output.space();
  7728. name_export.print(output);
  7729. if (i < self.exported_names.length - 1) {
  7730. output.print(",");
  7731. }
  7732. });
  7733. output.space();
  7734. output.print("}");
  7735. }
  7736. } else if (self.exported_value) {
  7737. self.exported_value.print(output);
  7738. } else if (self.exported_definition) {
  7739. self.exported_definition.print(output);
  7740. if (self.exported_definition instanceof AST_Definitions) return;
  7741. }
  7742. if (self.module_name) {
  7743. output.space();
  7744. output.print("from");
  7745. output.space();
  7746. self.module_name.print(output);
  7747. }
  7748. if (self.assert_clause) {
  7749. output.print("assert");
  7750. self.assert_clause.print(output);
  7751. }
  7752. if (self.exported_value
  7753. && !(self.exported_value instanceof AST_Defun ||
  7754. self.exported_value instanceof AST_Function ||
  7755. self.exported_value instanceof AST_Class)
  7756. || self.module_name
  7757. || self.exported_names
  7758. ) {
  7759. output.semicolon();
  7760. }
  7761. });
  7762. function parenthesize_for_noin(node, output, noin) {
  7763. var parens = false;
  7764. // need to take some precautions here:
  7765. // https://github.com/mishoo/UglifyJS2/issues/60
  7766. if (noin) {
  7767. parens = walk(node, node => {
  7768. // Don't go into scopes -- except arrow functions:
  7769. // https://github.com/terser/terser/issues/1019#issuecomment-877642607
  7770. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  7771. return true;
  7772. }
  7773. if (node instanceof AST_Binary && node.operator == "in") {
  7774. return walk_abort; // makes walk() return true
  7775. }
  7776. });
  7777. }
  7778. node.print(output, parens);
  7779. }
  7780. DEFPRINT(AST_VarDef, function(self, output) {
  7781. self.name.print(output);
  7782. if (self.value) {
  7783. output.space();
  7784. output.print("=");
  7785. output.space();
  7786. var p = output.parent(1);
  7787. var noin = p instanceof AST_For || p instanceof AST_ForIn;
  7788. parenthesize_for_noin(self.value, output, noin);
  7789. }
  7790. });
  7791. /* -----[ other expressions ]----- */
  7792. DEFPRINT(AST_Call, function(self, output) {
  7793. self.expression.print(output);
  7794. if (self instanceof AST_New && self.args.length === 0)
  7795. return;
  7796. if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) {
  7797. output.add_mapping(self.start);
  7798. }
  7799. if (self.optional) output.print("?.");
  7800. output.with_parens(function() {
  7801. self.args.forEach(function(expr, i) {
  7802. if (i) output.comma();
  7803. expr.print(output);
  7804. });
  7805. });
  7806. });
  7807. DEFPRINT(AST_New, function(self, output) {
  7808. output.print("new");
  7809. output.space();
  7810. AST_Call.prototype._codegen(self, output);
  7811. });
  7812. AST_Sequence.DEFMETHOD("_do_print", function(output) {
  7813. this.expressions.forEach(function(node, index) {
  7814. if (index > 0) {
  7815. output.comma();
  7816. if (output.should_break()) {
  7817. output.newline();
  7818. output.indent();
  7819. }
  7820. }
  7821. node.print(output);
  7822. });
  7823. });
  7824. DEFPRINT(AST_Sequence, function(self, output) {
  7825. self._do_print(output);
  7826. // var p = output.parent();
  7827. // if (p instanceof AST_Statement) {
  7828. // output.with_indent(output.next_indent(), function(){
  7829. // self._do_print(output);
  7830. // });
  7831. // } else {
  7832. // self._do_print(output);
  7833. // }
  7834. });
  7835. DEFPRINT(AST_Dot, function(self, output) {
  7836. var expr = self.expression;
  7837. expr.print(output);
  7838. var prop = self.property;
  7839. var print_computed = ALL_RESERVED_WORDS.has(prop)
  7840. ? output.option("ie8")
  7841. : !is_identifier_string(
  7842. prop,
  7843. output.option("ecma") >= 2015 || output.option("safari10")
  7844. );
  7845. if (self.optional) output.print("?.");
  7846. if (print_computed) {
  7847. output.print("[");
  7848. output.add_mapping(self.end);
  7849. output.print_string(prop);
  7850. output.print("]");
  7851. } else {
  7852. if (expr instanceof AST_Number && expr.getValue() >= 0) {
  7853. if (!/[xa-f.)]/i.test(output.last())) {
  7854. output.print(".");
  7855. }
  7856. }
  7857. if (!self.optional) output.print(".");
  7858. // the name after dot would be mapped about here.
  7859. output.add_mapping(self.end);
  7860. output.print_name(prop);
  7861. }
  7862. });
  7863. DEFPRINT(AST_DotHash, function(self, output) {
  7864. var expr = self.expression;
  7865. expr.print(output);
  7866. var prop = self.property;
  7867. if (self.optional) output.print("?");
  7868. output.print(".#");
  7869. output.add_mapping(self.end);
  7870. output.print_name(prop);
  7871. });
  7872. DEFPRINT(AST_Sub, function(self, output) {
  7873. self.expression.print(output);
  7874. if (self.optional) output.print("?.");
  7875. output.print("[");
  7876. self.property.print(output);
  7877. output.print("]");
  7878. });
  7879. DEFPRINT(AST_Chain, function(self, output) {
  7880. self.expression.print(output);
  7881. });
  7882. DEFPRINT(AST_UnaryPrefix, function(self, output) {
  7883. var op = self.operator;
  7884. output.print(op);
  7885. if (/^[a-z]/i.test(op)
  7886. || (/[+-]$/.test(op)
  7887. && self.expression instanceof AST_UnaryPrefix
  7888. && /^[+-]/.test(self.expression.operator))) {
  7889. output.space();
  7890. }
  7891. self.expression.print(output);
  7892. });
  7893. DEFPRINT(AST_UnaryPostfix, function(self, output) {
  7894. self.expression.print(output);
  7895. output.print(self.operator);
  7896. });
  7897. DEFPRINT(AST_Binary, function(self, output) {
  7898. var op = self.operator;
  7899. self.left.print(output);
  7900. if (op[0] == ">" /* ">>" ">>>" ">" ">=" */
  7901. && self.left instanceof AST_UnaryPostfix
  7902. && self.left.operator == "--") {
  7903. // space is mandatory to avoid outputting -->
  7904. output.print(" ");
  7905. } else {
  7906. // the space is optional depending on "beautify"
  7907. output.space();
  7908. }
  7909. output.print(op);
  7910. if ((op == "<" || op == "<<")
  7911. && self.right instanceof AST_UnaryPrefix
  7912. && self.right.operator == "!"
  7913. && self.right.expression instanceof AST_UnaryPrefix
  7914. && self.right.expression.operator == "--") {
  7915. // space is mandatory to avoid outputting <!--
  7916. output.print(" ");
  7917. } else {
  7918. // the space is optional depending on "beautify"
  7919. output.space();
  7920. }
  7921. self.right.print(output);
  7922. });
  7923. DEFPRINT(AST_Conditional, function(self, output) {
  7924. self.condition.print(output);
  7925. output.space();
  7926. output.print("?");
  7927. output.space();
  7928. self.consequent.print(output);
  7929. output.space();
  7930. output.colon();
  7931. self.alternative.print(output);
  7932. });
  7933. /* -----[ literals ]----- */
  7934. DEFPRINT(AST_Array, function(self, output) {
  7935. output.with_square(function() {
  7936. var a = self.elements, len = a.length;
  7937. if (len > 0) output.space();
  7938. a.forEach(function(exp, i) {
  7939. if (i) output.comma();
  7940. exp.print(output);
  7941. // If the final element is a hole, we need to make sure it
  7942. // doesn't look like a trailing comma, by inserting an actual
  7943. // trailing comma.
  7944. if (i === len - 1 && exp instanceof AST_Hole)
  7945. output.comma();
  7946. });
  7947. if (len > 0) output.space();
  7948. });
  7949. });
  7950. DEFPRINT(AST_Object, function(self, output) {
  7951. if (self.properties.length > 0) output.with_block(function() {
  7952. self.properties.forEach(function(prop, i) {
  7953. if (i) {
  7954. output.print(",");
  7955. output.newline();
  7956. }
  7957. output.indent();
  7958. prop.print(output);
  7959. });
  7960. output.newline();
  7961. });
  7962. else print_braced_empty(self, output);
  7963. });
  7964. DEFPRINT(AST_Class, function(self, output) {
  7965. output.print("class");
  7966. output.space();
  7967. if (self.name) {
  7968. self.name.print(output);
  7969. output.space();
  7970. }
  7971. if (self.extends) {
  7972. var parens = (
  7973. !(self.extends instanceof AST_SymbolRef)
  7974. && !(self.extends instanceof AST_PropAccess)
  7975. && !(self.extends instanceof AST_ClassExpression)
  7976. && !(self.extends instanceof AST_Function)
  7977. );
  7978. output.print("extends");
  7979. if (parens) {
  7980. output.print("(");
  7981. } else {
  7982. output.space();
  7983. }
  7984. self.extends.print(output);
  7985. if (parens) {
  7986. output.print(")");
  7987. } else {
  7988. output.space();
  7989. }
  7990. }
  7991. if (self.properties.length > 0) output.with_block(function() {
  7992. self.properties.forEach(function(prop, i) {
  7993. if (i) {
  7994. output.newline();
  7995. }
  7996. output.indent();
  7997. prop.print(output);
  7998. });
  7999. output.newline();
  8000. });
  8001. else output.print("{}");
  8002. });
  8003. DEFPRINT(AST_NewTarget, function(self, output) {
  8004. output.print("new.target");
  8005. });
  8006. function print_property_name(key, quote, output) {
  8007. if (output.option("quote_keys")) {
  8008. return output.print_string(key);
  8009. }
  8010. if ("" + +key == key && key >= 0) {
  8011. if (output.option("keep_numbers")) {
  8012. return output.print(key);
  8013. }
  8014. return output.print(make_num(key));
  8015. }
  8016. var print_string = ALL_RESERVED_WORDS.has(key)
  8017. ? output.option("ie8")
  8018. : (
  8019. output.option("ecma") < 2015 || output.option("safari10")
  8020. ? !is_basic_identifier_string(key)
  8021. : !is_identifier_string(key, true)
  8022. );
  8023. if (print_string || (quote && output.option("keep_quoted_props"))) {
  8024. return output.print_string(key, quote);
  8025. }
  8026. return output.print_name(key);
  8027. }
  8028. DEFPRINT(AST_ObjectKeyVal, function(self, output) {
  8029. function get_name(self) {
  8030. var def = self.definition();
  8031. return def ? def.mangled_name || def.name : self.name;
  8032. }
  8033. var allowShortHand = output.option("shorthand");
  8034. if (allowShortHand &&
  8035. self.value instanceof AST_Symbol &&
  8036. is_identifier_string(
  8037. self.key,
  8038. output.option("ecma") >= 2015 || output.option("safari10")
  8039. ) &&
  8040. get_name(self.value) === self.key &&
  8041. !ALL_RESERVED_WORDS.has(self.key)
  8042. ) {
  8043. print_property_name(self.key, self.quote, output);
  8044. } else if (allowShortHand &&
  8045. self.value instanceof AST_DefaultAssign &&
  8046. self.value.left instanceof AST_Symbol &&
  8047. is_identifier_string(
  8048. self.key,
  8049. output.option("ecma") >= 2015 || output.option("safari10")
  8050. ) &&
  8051. get_name(self.value.left) === self.key
  8052. ) {
  8053. print_property_name(self.key, self.quote, output);
  8054. output.space();
  8055. output.print("=");
  8056. output.space();
  8057. self.value.right.print(output);
  8058. } else {
  8059. if (!(self.key instanceof AST_Node)) {
  8060. print_property_name(self.key, self.quote, output);
  8061. } else {
  8062. output.with_square(function() {
  8063. self.key.print(output);
  8064. });
  8065. }
  8066. output.colon();
  8067. self.value.print(output);
  8068. }
  8069. });
  8070. DEFPRINT(AST_ClassPrivateProperty, (self, output) => {
  8071. if (self.static) {
  8072. output.print("static");
  8073. output.space();
  8074. }
  8075. output.print("#");
  8076. print_property_name(self.key.name, self.quote, output);
  8077. if (self.value) {
  8078. output.print("=");
  8079. self.value.print(output);
  8080. }
  8081. output.semicolon();
  8082. });
  8083. DEFPRINT(AST_ClassProperty, (self, output) => {
  8084. if (self.static) {
  8085. output.print("static");
  8086. output.space();
  8087. }
  8088. if (self.key instanceof AST_SymbolClassProperty) {
  8089. print_property_name(self.key.name, self.quote, output);
  8090. } else {
  8091. output.print("[");
  8092. self.key.print(output);
  8093. output.print("]");
  8094. }
  8095. if (self.value) {
  8096. output.print("=");
  8097. self.value.print(output);
  8098. }
  8099. output.semicolon();
  8100. });
  8101. AST_ObjectProperty.DEFMETHOD("_print_getter_setter", function(type, is_private, output) {
  8102. var self = this;
  8103. if (self.static) {
  8104. output.print("static");
  8105. output.space();
  8106. }
  8107. if (type) {
  8108. output.print(type);
  8109. output.space();
  8110. }
  8111. if (self.key instanceof AST_SymbolMethod) {
  8112. if (is_private) output.print("#");
  8113. print_property_name(self.key.name, self.quote, output);
  8114. } else {
  8115. output.with_square(function() {
  8116. self.key.print(output);
  8117. });
  8118. }
  8119. self.value._do_print(output, true);
  8120. });
  8121. DEFPRINT(AST_ObjectSetter, function(self, output) {
  8122. self._print_getter_setter("set", false, output);
  8123. });
  8124. DEFPRINT(AST_ObjectGetter, function(self, output) {
  8125. self._print_getter_setter("get", false, output);
  8126. });
  8127. DEFPRINT(AST_PrivateSetter, function(self, output) {
  8128. self._print_getter_setter("set", true, output);
  8129. });
  8130. DEFPRINT(AST_PrivateGetter, function(self, output) {
  8131. self._print_getter_setter("get", true, output);
  8132. });
  8133. DEFPRINT(AST_PrivateMethod, function(self, output) {
  8134. var type;
  8135. if (self.is_generator && self.async) {
  8136. type = "async*";
  8137. } else if (self.is_generator) {
  8138. type = "*";
  8139. } else if (self.async) {
  8140. type = "async";
  8141. }
  8142. self._print_getter_setter(type, true, output);
  8143. });
  8144. DEFPRINT(AST_ConciseMethod, function(self, output) {
  8145. var type;
  8146. if (self.is_generator && self.async) {
  8147. type = "async*";
  8148. } else if (self.is_generator) {
  8149. type = "*";
  8150. } else if (self.async) {
  8151. type = "async";
  8152. }
  8153. self._print_getter_setter(type, false, output);
  8154. });
  8155. AST_Symbol.DEFMETHOD("_do_print", function(output) {
  8156. var def = this.definition();
  8157. output.print_name(def ? def.mangled_name || def.name : this.name);
  8158. });
  8159. DEFPRINT(AST_Symbol, function (self, output) {
  8160. self._do_print(output);
  8161. });
  8162. DEFPRINT(AST_Hole, noop);
  8163. DEFPRINT(AST_This, function(self, output) {
  8164. output.print("this");
  8165. });
  8166. DEFPRINT(AST_Super, function(self, output) {
  8167. output.print("super");
  8168. });
  8169. DEFPRINT(AST_Constant, function(self, output) {
  8170. output.print(self.getValue());
  8171. });
  8172. DEFPRINT(AST_String, function(self, output) {
  8173. output.print_string(self.getValue(), self.quote, output.in_directive);
  8174. });
  8175. DEFPRINT(AST_Number, function(self, output) {
  8176. if ((output.option("keep_numbers") || output.use_asm) && self.raw) {
  8177. output.print(self.raw);
  8178. } else {
  8179. output.print(make_num(self.getValue()));
  8180. }
  8181. });
  8182. DEFPRINT(AST_BigInt, function(self, output) {
  8183. output.print(self.getValue() + "n");
  8184. });
  8185. const r_slash_script = /(<\s*\/\s*script)/i;
  8186. const slash_script_replace = (_, $1) => $1.replace("/", "\\/");
  8187. DEFPRINT(AST_RegExp, function(self, output) {
  8188. let { source, flags } = self.getValue();
  8189. source = regexp_source_fix(source);
  8190. flags = flags ? sort_regexp_flags(flags) : "";
  8191. source = source.replace(r_slash_script, slash_script_replace);
  8192. output.print(output.to_utf8(`/${source}/${flags}`, false, true));
  8193. const parent = output.parent();
  8194. if (
  8195. parent instanceof AST_Binary
  8196. && /^\w/.test(parent.operator)
  8197. && parent.left === self
  8198. ) {
  8199. output.print(" ");
  8200. }
  8201. });
  8202. function force_statement(stat, output) {
  8203. if (output.option("braces")) {
  8204. make_block(stat, output);
  8205. } else {
  8206. if (!stat || stat instanceof AST_EmptyStatement)
  8207. output.force_semicolon();
  8208. else
  8209. stat.print(output);
  8210. }
  8211. }
  8212. function best_of(a) {
  8213. var best = a[0], len = best.length;
  8214. for (var i = 1; i < a.length; ++i) {
  8215. if (a[i].length < len) {
  8216. best = a[i];
  8217. len = best.length;
  8218. }
  8219. }
  8220. return best;
  8221. }
  8222. function make_num(num) {
  8223. var str = num.toString(10).replace(/^0\./, ".").replace("e+", "e");
  8224. var candidates = [ str ];
  8225. if (Math.floor(num) === num) {
  8226. if (num < 0) {
  8227. candidates.push("-0x" + (-num).toString(16).toLowerCase());
  8228. } else {
  8229. candidates.push("0x" + num.toString(16).toLowerCase());
  8230. }
  8231. }
  8232. var match, len, digits;
  8233. if (match = /^\.0+/.exec(str)) {
  8234. len = match[0].length;
  8235. digits = str.slice(len);
  8236. candidates.push(digits + "e-" + (digits.length + len - 1));
  8237. } else if (match = /0+$/.exec(str)) {
  8238. len = match[0].length;
  8239. candidates.push(str.slice(0, -len) + "e" + len);
  8240. } else if (match = /^(\d)\.(\d+)e(-?\d+)$/.exec(str)) {
  8241. candidates.push(match[1] + match[2] + "e" + (match[3] - match[2].length));
  8242. }
  8243. return best_of(candidates);
  8244. }
  8245. function make_block(stmt, output) {
  8246. if (!stmt || stmt instanceof AST_EmptyStatement)
  8247. output.print("{}");
  8248. else if (stmt instanceof AST_BlockStatement)
  8249. stmt.print(output);
  8250. else output.with_block(function() {
  8251. output.indent();
  8252. stmt.print(output);
  8253. output.newline();
  8254. });
  8255. }
  8256. /* -----[ source map generators ]----- */
  8257. function DEFMAP(nodetype, generator) {
  8258. nodetype.forEach(function(nodetype) {
  8259. nodetype.DEFMETHOD("add_source_map", generator);
  8260. });
  8261. }
  8262. DEFMAP([
  8263. // We could easily add info for ALL nodes, but it seems to me that
  8264. // would be quite wasteful, hence this noop in the base class.
  8265. AST_Node,
  8266. // since the label symbol will mark it
  8267. AST_LabeledStatement,
  8268. AST_Toplevel,
  8269. ], noop);
  8270. // XXX: I'm not exactly sure if we need it for all of these nodes,
  8271. // or if we should add even more.
  8272. DEFMAP([
  8273. AST_Array,
  8274. AST_BlockStatement,
  8275. AST_Catch,
  8276. AST_Class,
  8277. AST_Constant,
  8278. AST_Debugger,
  8279. AST_Definitions,
  8280. AST_Directive,
  8281. AST_Finally,
  8282. AST_Jump,
  8283. AST_Lambda,
  8284. AST_New,
  8285. AST_Object,
  8286. AST_StatementWithBody,
  8287. AST_Symbol,
  8288. AST_Switch,
  8289. AST_SwitchBranch,
  8290. AST_TemplateString,
  8291. AST_TemplateSegment,
  8292. AST_Try,
  8293. ], function(output) {
  8294. output.add_mapping(this.start);
  8295. });
  8296. DEFMAP([
  8297. AST_ObjectGetter,
  8298. AST_ObjectSetter,
  8299. AST_PrivateGetter,
  8300. AST_PrivateSetter,
  8301. ], function(output) {
  8302. output.add_mapping(this.key.end, this.key.name);
  8303. });
  8304. DEFMAP([ AST_ObjectProperty ], function(output) {
  8305. output.add_mapping(this.start, this.key);
  8306. });
  8307. })();
  8308. const shallow_cmp = (node1, node2) => {
  8309. return (
  8310. node1 === null && node2 === null
  8311. || node1.TYPE === node2.TYPE && node1.shallow_cmp(node2)
  8312. );
  8313. };
  8314. const equivalent_to = (tree1, tree2) => {
  8315. if (!shallow_cmp(tree1, tree2)) return false;
  8316. const walk_1_state = [tree1];
  8317. const walk_2_state = [tree2];
  8318. const walk_1_push = walk_1_state.push.bind(walk_1_state);
  8319. const walk_2_push = walk_2_state.push.bind(walk_2_state);
  8320. while (walk_1_state.length && walk_2_state.length) {
  8321. const node_1 = walk_1_state.pop();
  8322. const node_2 = walk_2_state.pop();
  8323. if (!shallow_cmp(node_1, node_2)) return false;
  8324. node_1._children_backwards(walk_1_push);
  8325. node_2._children_backwards(walk_2_push);
  8326. if (walk_1_state.length !== walk_2_state.length) {
  8327. // Different number of children
  8328. return false;
  8329. }
  8330. }
  8331. return walk_1_state.length == 0 && walk_2_state.length == 0;
  8332. };
  8333. // Creates a shallow compare function
  8334. const mkshallow = (props) => {
  8335. const comparisons = Object
  8336. .keys(props)
  8337. .map(key => {
  8338. if (props[key] === "eq") {
  8339. return `this.${key} === other.${key}`;
  8340. } else if (props[key] === "exist") {
  8341. return `(this.${key} == null ? other.${key} == null : this.${key} === other.${key})`;
  8342. } else {
  8343. throw new Error(`mkshallow: Unexpected instruction: ${props[key]}`);
  8344. }
  8345. })
  8346. .join(" && ");
  8347. return new Function("other", "return " + comparisons);
  8348. };
  8349. const pass_through = () => true;
  8350. AST_Node.prototype.shallow_cmp = function () {
  8351. throw new Error("did not find a shallow_cmp function for " + this.constructor.name);
  8352. };
  8353. AST_Debugger.prototype.shallow_cmp = pass_through;
  8354. AST_Directive.prototype.shallow_cmp = mkshallow({ value: "eq" });
  8355. AST_SimpleStatement.prototype.shallow_cmp = pass_through;
  8356. AST_Block.prototype.shallow_cmp = pass_through;
  8357. AST_EmptyStatement.prototype.shallow_cmp = pass_through;
  8358. AST_LabeledStatement.prototype.shallow_cmp = mkshallow({ "label.name": "eq" });
  8359. AST_Do.prototype.shallow_cmp = pass_through;
  8360. AST_While.prototype.shallow_cmp = pass_through;
  8361. AST_For.prototype.shallow_cmp = mkshallow({
  8362. init: "exist",
  8363. condition: "exist",
  8364. step: "exist"
  8365. });
  8366. AST_ForIn.prototype.shallow_cmp = pass_through;
  8367. AST_ForOf.prototype.shallow_cmp = pass_through;
  8368. AST_With.prototype.shallow_cmp = pass_through;
  8369. AST_Toplevel.prototype.shallow_cmp = pass_through;
  8370. AST_Expansion.prototype.shallow_cmp = pass_through;
  8371. AST_Lambda.prototype.shallow_cmp = mkshallow({
  8372. is_generator: "eq",
  8373. async: "eq"
  8374. });
  8375. AST_Destructuring.prototype.shallow_cmp = mkshallow({
  8376. is_array: "eq"
  8377. });
  8378. AST_PrefixedTemplateString.prototype.shallow_cmp = pass_through;
  8379. AST_TemplateString.prototype.shallow_cmp = pass_through;
  8380. AST_TemplateSegment.prototype.shallow_cmp = mkshallow({
  8381. "value": "eq"
  8382. });
  8383. AST_Jump.prototype.shallow_cmp = pass_through;
  8384. AST_LoopControl.prototype.shallow_cmp = pass_through;
  8385. AST_Await.prototype.shallow_cmp = pass_through;
  8386. AST_Yield.prototype.shallow_cmp = mkshallow({
  8387. is_star: "eq"
  8388. });
  8389. AST_If.prototype.shallow_cmp = mkshallow({
  8390. alternative: "exist"
  8391. });
  8392. AST_Switch.prototype.shallow_cmp = pass_through;
  8393. AST_SwitchBranch.prototype.shallow_cmp = pass_through;
  8394. AST_Try.prototype.shallow_cmp = mkshallow({
  8395. bcatch: "exist",
  8396. bfinally: "exist"
  8397. });
  8398. AST_Catch.prototype.shallow_cmp = mkshallow({
  8399. argname: "exist"
  8400. });
  8401. AST_Finally.prototype.shallow_cmp = pass_through;
  8402. AST_Definitions.prototype.shallow_cmp = pass_through;
  8403. AST_VarDef.prototype.shallow_cmp = mkshallow({
  8404. value: "exist"
  8405. });
  8406. AST_NameMapping.prototype.shallow_cmp = pass_through;
  8407. AST_Import.prototype.shallow_cmp = mkshallow({
  8408. imported_name: "exist",
  8409. imported_names: "exist"
  8410. });
  8411. AST_ImportMeta.prototype.shallow_cmp = pass_through;
  8412. AST_Export.prototype.shallow_cmp = mkshallow({
  8413. exported_definition: "exist",
  8414. exported_value: "exist",
  8415. exported_names: "exist",
  8416. module_name: "eq",
  8417. is_default: "eq",
  8418. });
  8419. AST_Call.prototype.shallow_cmp = pass_through;
  8420. AST_Sequence.prototype.shallow_cmp = pass_through;
  8421. AST_PropAccess.prototype.shallow_cmp = pass_through;
  8422. AST_Chain.prototype.shallow_cmp = pass_through;
  8423. AST_Dot.prototype.shallow_cmp = mkshallow({
  8424. property: "eq"
  8425. });
  8426. AST_DotHash.prototype.shallow_cmp = mkshallow({
  8427. property: "eq"
  8428. });
  8429. AST_Unary.prototype.shallow_cmp = mkshallow({
  8430. operator: "eq"
  8431. });
  8432. AST_Binary.prototype.shallow_cmp = mkshallow({
  8433. operator: "eq"
  8434. });
  8435. AST_Conditional.prototype.shallow_cmp = pass_through;
  8436. AST_Array.prototype.shallow_cmp = pass_through;
  8437. AST_Object.prototype.shallow_cmp = pass_through;
  8438. AST_ObjectProperty.prototype.shallow_cmp = pass_through;
  8439. AST_ObjectKeyVal.prototype.shallow_cmp = mkshallow({
  8440. key: "eq"
  8441. });
  8442. AST_ObjectSetter.prototype.shallow_cmp = mkshallow({
  8443. static: "eq"
  8444. });
  8445. AST_ObjectGetter.prototype.shallow_cmp = mkshallow({
  8446. static: "eq"
  8447. });
  8448. AST_ConciseMethod.prototype.shallow_cmp = mkshallow({
  8449. static: "eq",
  8450. is_generator: "eq",
  8451. async: "eq",
  8452. });
  8453. AST_Class.prototype.shallow_cmp = mkshallow({
  8454. name: "exist",
  8455. extends: "exist",
  8456. });
  8457. AST_ClassProperty.prototype.shallow_cmp = mkshallow({
  8458. static: "eq"
  8459. });
  8460. AST_Symbol.prototype.shallow_cmp = mkshallow({
  8461. name: "eq"
  8462. });
  8463. AST_NewTarget.prototype.shallow_cmp = pass_through;
  8464. AST_This.prototype.shallow_cmp = pass_through;
  8465. AST_Super.prototype.shallow_cmp = pass_through;
  8466. AST_String.prototype.shallow_cmp = mkshallow({
  8467. value: "eq"
  8468. });
  8469. AST_Number.prototype.shallow_cmp = mkshallow({
  8470. value: "eq"
  8471. });
  8472. AST_BigInt.prototype.shallow_cmp = mkshallow({
  8473. value: "eq"
  8474. });
  8475. AST_RegExp.prototype.shallow_cmp = function (other) {
  8476. return (
  8477. this.value.flags === other.value.flags
  8478. && this.value.source === other.value.source
  8479. );
  8480. };
  8481. AST_Atom.prototype.shallow_cmp = pass_through;
  8482. /***********************************************************************
  8483. A JavaScript tokenizer / parser / beautifier / compressor.
  8484. https://github.com/mishoo/UglifyJS2
  8485. -------------------------------- (C) ---------------------------------
  8486. Author: Mihai Bazon
  8487. <mihai.bazon@gmail.com>
  8488. http://mihai.bazon.net/blog
  8489. Distributed under the BSD license:
  8490. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  8491. Redistribution and use in source and binary forms, with or without
  8492. modification, are permitted provided that the following conditions
  8493. are met:
  8494. * Redistributions of source code must retain the above
  8495. copyright notice, this list of conditions and the following
  8496. disclaimer.
  8497. * Redistributions in binary form must reproduce the above
  8498. copyright notice, this list of conditions and the following
  8499. disclaimer in the documentation and/or other materials
  8500. provided with the distribution.
  8501. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  8502. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8503. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8504. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  8505. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  8506. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  8507. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  8508. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  8509. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  8510. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  8511. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8512. SUCH DAMAGE.
  8513. ***********************************************************************/
  8514. const MASK_EXPORT_DONT_MANGLE = 1 << 0;
  8515. const MASK_EXPORT_WANT_MANGLE = 1 << 1;
  8516. let function_defs = null;
  8517. let unmangleable_names = null;
  8518. class SymbolDef {
  8519. constructor(scope, orig, init) {
  8520. this.name = orig.name;
  8521. this.orig = [ orig ];
  8522. this.init = init;
  8523. this.eliminated = 0;
  8524. this.assignments = 0;
  8525. this.scope = scope;
  8526. this.replaced = 0;
  8527. this.global = false;
  8528. this.export = 0;
  8529. this.mangled_name = null;
  8530. this.undeclared = false;
  8531. this.id = SymbolDef.next_id++;
  8532. this.chained = false;
  8533. this.direct_access = false;
  8534. this.escaped = 0;
  8535. this.recursive_refs = 0;
  8536. this.references = [];
  8537. this.should_replace = undefined;
  8538. this.single_use = false;
  8539. this.fixed = false;
  8540. Object.seal(this);
  8541. }
  8542. fixed_value() {
  8543. if (!this.fixed || this.fixed instanceof AST_Node) return this.fixed;
  8544. return this.fixed();
  8545. }
  8546. unmangleable(options) {
  8547. if (!options) options = {};
  8548. if (
  8549. function_defs &&
  8550. function_defs.has(this.id) &&
  8551. keep_name(options.keep_fnames, this.orig[0].name)
  8552. ) return true;
  8553. return this.global && !options.toplevel
  8554. || (this.export & MASK_EXPORT_DONT_MANGLE)
  8555. || this.undeclared
  8556. || !options.eval && this.scope.pinned()
  8557. || (this.orig[0] instanceof AST_SymbolLambda
  8558. || this.orig[0] instanceof AST_SymbolDefun) && keep_name(options.keep_fnames, this.orig[0].name)
  8559. || this.orig[0] instanceof AST_SymbolMethod
  8560. || (this.orig[0] instanceof AST_SymbolClass
  8561. || this.orig[0] instanceof AST_SymbolDefClass) && keep_name(options.keep_classnames, this.orig[0].name);
  8562. }
  8563. mangle(options) {
  8564. const cache = options.cache && options.cache.props;
  8565. if (this.global && cache && cache.has(this.name)) {
  8566. this.mangled_name = cache.get(this.name);
  8567. } else if (!this.mangled_name && !this.unmangleable(options)) {
  8568. var s = this.scope;
  8569. var sym = this.orig[0];
  8570. if (options.ie8 && sym instanceof AST_SymbolLambda)
  8571. s = s.parent_scope;
  8572. const redefinition = redefined_catch_def(this);
  8573. this.mangled_name = redefinition
  8574. ? redefinition.mangled_name || redefinition.name
  8575. : s.next_mangled(options, this);
  8576. if (this.global && cache) {
  8577. cache.set(this.name, this.mangled_name);
  8578. }
  8579. }
  8580. }
  8581. }
  8582. SymbolDef.next_id = 1;
  8583. function redefined_catch_def(def) {
  8584. if (def.orig[0] instanceof AST_SymbolCatch
  8585. && def.scope.is_block_scope()
  8586. ) {
  8587. return def.scope.get_defun_scope().variables.get(def.name);
  8588. }
  8589. }
  8590. AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
  8591. options = defaults(options, {
  8592. cache: null,
  8593. ie8: false,
  8594. safari10: false,
  8595. });
  8596. if (!(toplevel instanceof AST_Toplevel)) {
  8597. throw new Error("Invalid toplevel scope");
  8598. }
  8599. // pass 1: setup scope chaining and handle definitions
  8600. var scope = this.parent_scope = parent_scope;
  8601. var labels = new Map();
  8602. var defun = null;
  8603. var in_destructuring = null;
  8604. var for_scopes = [];
  8605. var tw = new TreeWalker((node, descend) => {
  8606. if (node.is_block_scope()) {
  8607. const save_scope = scope;
  8608. node.block_scope = scope = new AST_Scope(node);
  8609. scope._block_scope = true;
  8610. // AST_Try in the AST sadly *is* (not has) a body itself,
  8611. // and its catch and finally branches are children of the AST_Try itself
  8612. const parent_scope = node instanceof AST_Catch
  8613. ? save_scope.parent_scope
  8614. : save_scope;
  8615. scope.init_scope_vars(parent_scope);
  8616. scope.uses_with = save_scope.uses_with;
  8617. scope.uses_eval = save_scope.uses_eval;
  8618. if (options.safari10) {
  8619. if (node instanceof AST_For || node instanceof AST_ForIn) {
  8620. for_scopes.push(scope);
  8621. }
  8622. }
  8623. if (node instanceof AST_Switch) {
  8624. // XXX: HACK! Ensure the switch expression gets the correct scope (the parent scope) and the body gets the contained scope
  8625. // AST_Switch has a scope within the body, but it itself "is a block scope"
  8626. // This means the switched expression has to belong to the outer scope
  8627. // while the body inside belongs to the switch itself.
  8628. // This is pretty nasty and warrants an AST change similar to AST_Try (read above)
  8629. const the_block_scope = scope;
  8630. scope = save_scope;
  8631. node.expression.walk(tw);
  8632. scope = the_block_scope;
  8633. for (let i = 0; i < node.body.length; i++) {
  8634. node.body[i].walk(tw);
  8635. }
  8636. } else {
  8637. descend();
  8638. }
  8639. scope = save_scope;
  8640. return true;
  8641. }
  8642. if (node instanceof AST_Destructuring) {
  8643. const save_destructuring = in_destructuring;
  8644. in_destructuring = node;
  8645. descend();
  8646. in_destructuring = save_destructuring;
  8647. return true;
  8648. }
  8649. if (node instanceof AST_Scope) {
  8650. node.init_scope_vars(scope);
  8651. var save_scope = scope;
  8652. var save_defun = defun;
  8653. var save_labels = labels;
  8654. defun = scope = node;
  8655. labels = new Map();
  8656. descend();
  8657. scope = save_scope;
  8658. defun = save_defun;
  8659. labels = save_labels;
  8660. return true; // don't descend again in TreeWalker
  8661. }
  8662. if (node instanceof AST_LabeledStatement) {
  8663. var l = node.label;
  8664. if (labels.has(l.name)) {
  8665. throw new Error(string_template("Label {name} defined twice", l));
  8666. }
  8667. labels.set(l.name, l);
  8668. descend();
  8669. labels.delete(l.name);
  8670. return true; // no descend again
  8671. }
  8672. if (node instanceof AST_With) {
  8673. for (var s = scope; s; s = s.parent_scope)
  8674. s.uses_with = true;
  8675. return;
  8676. }
  8677. if (node instanceof AST_Symbol) {
  8678. node.scope = scope;
  8679. }
  8680. if (node instanceof AST_Label) {
  8681. node.thedef = node;
  8682. node.references = [];
  8683. }
  8684. if (node instanceof AST_SymbolLambda) {
  8685. defun.def_function(node, node.name == "arguments" ? undefined : defun);
  8686. } else if (node instanceof AST_SymbolDefun) {
  8687. // Careful here, the scope where this should be defined is
  8688. // the parent scope. The reason is that we enter a new
  8689. // scope when we encounter the AST_Defun node (which is
  8690. // instanceof AST_Scope) but we get to the symbol a bit
  8691. // later.
  8692. const closest_scope = defun.parent_scope;
  8693. // In strict mode, function definitions are block-scoped
  8694. node.scope = tw.directives["use strict"]
  8695. ? closest_scope
  8696. : closest_scope.get_defun_scope();
  8697. mark_export(node.scope.def_function(node, defun), 1);
  8698. } else if (node instanceof AST_SymbolClass) {
  8699. mark_export(defun.def_variable(node, defun), 1);
  8700. } else if (node instanceof AST_SymbolImport) {
  8701. scope.def_variable(node);
  8702. } else if (node instanceof AST_SymbolDefClass) {
  8703. // This deals with the name of the class being available
  8704. // inside the class.
  8705. mark_export((node.scope = defun.parent_scope).def_function(node, defun), 1);
  8706. } else if (
  8707. node instanceof AST_SymbolVar
  8708. || node instanceof AST_SymbolLet
  8709. || node instanceof AST_SymbolConst
  8710. || node instanceof AST_SymbolCatch
  8711. ) {
  8712. var def;
  8713. if (node instanceof AST_SymbolBlockDeclaration) {
  8714. def = scope.def_variable(node, null);
  8715. } else {
  8716. def = defun.def_variable(node, node.TYPE == "SymbolVar" ? null : undefined);
  8717. }
  8718. if (!def.orig.every((sym) => {
  8719. if (sym === node) return true;
  8720. if (node instanceof AST_SymbolBlockDeclaration) {
  8721. return sym instanceof AST_SymbolLambda;
  8722. }
  8723. return !(sym instanceof AST_SymbolLet || sym instanceof AST_SymbolConst);
  8724. })) {
  8725. js_error(
  8726. `"${node.name}" is redeclared`,
  8727. node.start.file,
  8728. node.start.line,
  8729. node.start.col,
  8730. node.start.pos
  8731. );
  8732. }
  8733. if (!(node instanceof AST_SymbolFunarg)) mark_export(def, 2);
  8734. if (defun !== scope) {
  8735. node.mark_enclosed();
  8736. var def = scope.find_variable(node);
  8737. if (node.thedef !== def) {
  8738. node.thedef = def;
  8739. node.reference();
  8740. }
  8741. }
  8742. } else if (node instanceof AST_LabelRef) {
  8743. var sym = labels.get(node.name);
  8744. if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", {
  8745. name: node.name,
  8746. line: node.start.line,
  8747. col: node.start.col
  8748. }));
  8749. node.thedef = sym;
  8750. }
  8751. if (!(scope instanceof AST_Toplevel) && (node instanceof AST_Export || node instanceof AST_Import)) {
  8752. js_error(
  8753. `"${node.TYPE}" statement may only appear at the top level`,
  8754. node.start.file,
  8755. node.start.line,
  8756. node.start.col,
  8757. node.start.pos
  8758. );
  8759. }
  8760. });
  8761. this.walk(tw);
  8762. function mark_export(def, level) {
  8763. if (in_destructuring) {
  8764. var i = 0;
  8765. do {
  8766. level++;
  8767. } while (tw.parent(i++) !== in_destructuring);
  8768. }
  8769. var node = tw.parent(level);
  8770. if (def.export = node instanceof AST_Export ? MASK_EXPORT_DONT_MANGLE : 0) {
  8771. var exported = node.exported_definition;
  8772. if ((exported instanceof AST_Defun || exported instanceof AST_DefClass) && node.is_default) {
  8773. def.export = MASK_EXPORT_WANT_MANGLE;
  8774. }
  8775. }
  8776. }
  8777. // pass 2: find back references and eval
  8778. const is_toplevel = this instanceof AST_Toplevel;
  8779. if (is_toplevel) {
  8780. this.globals = new Map();
  8781. }
  8782. var tw = new TreeWalker(node => {
  8783. if (node instanceof AST_LoopControl && node.label) {
  8784. node.label.thedef.references.push(node);
  8785. return true;
  8786. }
  8787. if (node instanceof AST_SymbolRef) {
  8788. var name = node.name;
  8789. if (name == "eval" && tw.parent() instanceof AST_Call) {
  8790. for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
  8791. s.uses_eval = true;
  8792. }
  8793. }
  8794. var sym;
  8795. if (tw.parent() instanceof AST_NameMapping && tw.parent(1).module_name
  8796. || !(sym = node.scope.find_variable(name))) {
  8797. sym = toplevel.def_global(node);
  8798. if (node instanceof AST_SymbolExport) sym.export = MASK_EXPORT_DONT_MANGLE;
  8799. } else if (sym.scope instanceof AST_Lambda && name == "arguments") {
  8800. sym.scope.uses_arguments = true;
  8801. }
  8802. node.thedef = sym;
  8803. node.reference();
  8804. if (node.scope.is_block_scope()
  8805. && !(sym.orig[0] instanceof AST_SymbolBlockDeclaration)) {
  8806. node.scope = node.scope.get_defun_scope();
  8807. }
  8808. return true;
  8809. }
  8810. // ensure mangling works if catch reuses a scope variable
  8811. var def;
  8812. if (node instanceof AST_SymbolCatch && (def = redefined_catch_def(node.definition()))) {
  8813. var s = node.scope;
  8814. while (s) {
  8815. push_uniq(s.enclosed, def);
  8816. if (s === def.scope) break;
  8817. s = s.parent_scope;
  8818. }
  8819. }
  8820. });
  8821. this.walk(tw);
  8822. // pass 3: work around IE8 and Safari catch scope bugs
  8823. if (options.ie8 || options.safari10) {
  8824. walk(this, node => {
  8825. if (node instanceof AST_SymbolCatch) {
  8826. var name = node.name;
  8827. var refs = node.thedef.references;
  8828. var scope = node.scope.get_defun_scope();
  8829. var def = scope.find_variable(name)
  8830. || toplevel.globals.get(name)
  8831. || scope.def_variable(node);
  8832. refs.forEach(function(ref) {
  8833. ref.thedef = def;
  8834. ref.reference();
  8835. });
  8836. node.thedef = def;
  8837. node.reference();
  8838. return true;
  8839. }
  8840. });
  8841. }
  8842. // pass 4: add symbol definitions to loop scopes
  8843. // Safari/Webkit bug workaround - loop init let variable shadowing argument.
  8844. // https://github.com/mishoo/UglifyJS2/issues/1753
  8845. // https://bugs.webkit.org/show_bug.cgi?id=171041
  8846. if (options.safari10) {
  8847. for (const scope of for_scopes) {
  8848. scope.parent_scope.variables.forEach(function(def) {
  8849. push_uniq(scope.enclosed, def);
  8850. });
  8851. }
  8852. }
  8853. });
  8854. AST_Toplevel.DEFMETHOD("def_global", function(node) {
  8855. var globals = this.globals, name = node.name;
  8856. if (globals.has(name)) {
  8857. return globals.get(name);
  8858. } else {
  8859. var g = new SymbolDef(this, node);
  8860. g.undeclared = true;
  8861. g.global = true;
  8862. globals.set(name, g);
  8863. return g;
  8864. }
  8865. });
  8866. AST_Scope.DEFMETHOD("init_scope_vars", function(parent_scope) {
  8867. this.variables = new Map(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
  8868. this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
  8869. this.uses_eval = false; // will be set to true if this or nested scope uses the global `eval`
  8870. this.parent_scope = parent_scope; // the parent scope
  8871. this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes
  8872. this.cname = -1; // the current index for mangling functions/variables
  8873. });
  8874. AST_Scope.DEFMETHOD("conflicting_def", function (name) {
  8875. return (
  8876. this.enclosed.find(def => def.name === name)
  8877. || this.variables.has(name)
  8878. || (this.parent_scope && this.parent_scope.conflicting_def(name))
  8879. );
  8880. });
  8881. AST_Scope.DEFMETHOD("conflicting_def_shallow", function (name) {
  8882. return (
  8883. this.enclosed.find(def => def.name === name)
  8884. || this.variables.has(name)
  8885. );
  8886. });
  8887. AST_Scope.DEFMETHOD("add_child_scope", function (scope) {
  8888. // `scope` is going to be moved into `this` right now.
  8889. // Update the required scopes' information
  8890. if (scope.parent_scope === this) return;
  8891. scope.parent_scope = this;
  8892. // TODO uses_with, uses_eval, etc
  8893. const scope_ancestry = (() => {
  8894. const ancestry = [];
  8895. let cur = this;
  8896. do {
  8897. ancestry.push(cur);
  8898. } while ((cur = cur.parent_scope));
  8899. ancestry.reverse();
  8900. return ancestry;
  8901. })();
  8902. const new_scope_enclosed_set = new Set(scope.enclosed);
  8903. const to_enclose = [];
  8904. for (const scope_topdown of scope_ancestry) {
  8905. to_enclose.forEach(e => push_uniq(scope_topdown.enclosed, e));
  8906. for (const def of scope_topdown.variables.values()) {
  8907. if (new_scope_enclosed_set.has(def)) {
  8908. push_uniq(to_enclose, def);
  8909. push_uniq(scope_topdown.enclosed, def);
  8910. }
  8911. }
  8912. }
  8913. });
  8914. function find_scopes_visible_from(scopes) {
  8915. const found_scopes = new Set();
  8916. for (const scope of new Set(scopes)) {
  8917. (function bubble_up(scope) {
  8918. if (scope == null || found_scopes.has(scope)) return;
  8919. found_scopes.add(scope);
  8920. bubble_up(scope.parent_scope);
  8921. })(scope);
  8922. }
  8923. return [...found_scopes];
  8924. }
  8925. // Creates a symbol during compression
  8926. AST_Scope.DEFMETHOD("create_symbol", function(SymClass, {
  8927. source,
  8928. tentative_name,
  8929. scope,
  8930. conflict_scopes = [scope],
  8931. init = null
  8932. } = {}) {
  8933. let symbol_name;
  8934. conflict_scopes = find_scopes_visible_from(conflict_scopes);
  8935. if (tentative_name) {
  8936. // Implement hygiene (no new names are conflicting with existing names)
  8937. tentative_name =
  8938. symbol_name =
  8939. tentative_name.replace(/(?:^[^a-z_$]|[^a-z0-9_$])/ig, "_");
  8940. let i = 0;
  8941. while (conflict_scopes.find(s => s.conflicting_def_shallow(symbol_name))) {
  8942. symbol_name = tentative_name + "$" + i++;
  8943. }
  8944. }
  8945. if (!symbol_name) {
  8946. throw new Error("No symbol name could be generated in create_symbol()");
  8947. }
  8948. const symbol = make_node(SymClass, source, {
  8949. name: symbol_name,
  8950. scope
  8951. });
  8952. this.def_variable(symbol, init || null);
  8953. symbol.mark_enclosed();
  8954. return symbol;
  8955. });
  8956. AST_Node.DEFMETHOD("is_block_scope", return_false);
  8957. AST_Class.DEFMETHOD("is_block_scope", return_false);
  8958. AST_Lambda.DEFMETHOD("is_block_scope", return_false);
  8959. AST_Toplevel.DEFMETHOD("is_block_scope", return_false);
  8960. AST_SwitchBranch.DEFMETHOD("is_block_scope", return_false);
  8961. AST_Block.DEFMETHOD("is_block_scope", return_true);
  8962. AST_Scope.DEFMETHOD("is_block_scope", function () {
  8963. return this._block_scope || false;
  8964. });
  8965. AST_IterationStatement.DEFMETHOD("is_block_scope", return_true);
  8966. AST_Lambda.DEFMETHOD("init_scope_vars", function() {
  8967. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  8968. this.uses_arguments = false;
  8969. this.def_variable(new AST_SymbolFunarg({
  8970. name: "arguments",
  8971. start: this.start,
  8972. end: this.end
  8973. }));
  8974. });
  8975. AST_Arrow.DEFMETHOD("init_scope_vars", function() {
  8976. AST_Scope.prototype.init_scope_vars.apply(this, arguments);
  8977. this.uses_arguments = false;
  8978. });
  8979. AST_Symbol.DEFMETHOD("mark_enclosed", function() {
  8980. var def = this.definition();
  8981. var s = this.scope;
  8982. while (s) {
  8983. push_uniq(s.enclosed, def);
  8984. if (s === def.scope) break;
  8985. s = s.parent_scope;
  8986. }
  8987. });
  8988. AST_Symbol.DEFMETHOD("reference", function() {
  8989. this.definition().references.push(this);
  8990. this.mark_enclosed();
  8991. });
  8992. AST_Scope.DEFMETHOD("find_variable", function(name) {
  8993. if (name instanceof AST_Symbol) name = name.name;
  8994. return this.variables.get(name)
  8995. || (this.parent_scope && this.parent_scope.find_variable(name));
  8996. });
  8997. AST_Scope.DEFMETHOD("def_function", function(symbol, init) {
  8998. var def = this.def_variable(symbol, init);
  8999. if (!def.init || def.init instanceof AST_Defun) def.init = init;
  9000. return def;
  9001. });
  9002. AST_Scope.DEFMETHOD("def_variable", function(symbol, init) {
  9003. var def = this.variables.get(symbol.name);
  9004. if (def) {
  9005. def.orig.push(symbol);
  9006. if (def.init && (def.scope !== symbol.scope || def.init instanceof AST_Function)) {
  9007. def.init = init;
  9008. }
  9009. } else {
  9010. def = new SymbolDef(this, symbol, init);
  9011. this.variables.set(symbol.name, def);
  9012. def.global = !this.parent_scope;
  9013. }
  9014. return symbol.thedef = def;
  9015. });
  9016. function next_mangled(scope, options) {
  9017. var ext = scope.enclosed;
  9018. var nth_identifier = options.nth_identifier;
  9019. out: while (true) {
  9020. var m = nth_identifier.get(++scope.cname);
  9021. if (ALL_RESERVED_WORDS.has(m)) continue; // skip over "do"
  9022. // https://github.com/mishoo/UglifyJS2/issues/242 -- do not
  9023. // shadow a name reserved from mangling.
  9024. if (options.reserved.has(m)) continue;
  9025. // Functions with short names might collide with base54 output
  9026. // and therefore cause collisions when keep_fnames is true.
  9027. if (unmangleable_names && unmangleable_names.has(m)) continue out;
  9028. // we must ensure that the mangled name does not shadow a name
  9029. // from some parent scope that is referenced in this or in
  9030. // inner scopes.
  9031. for (let i = ext.length; --i >= 0;) {
  9032. const def = ext[i];
  9033. const name = def.mangled_name || (def.unmangleable(options) && def.name);
  9034. if (m == name) continue out;
  9035. }
  9036. return m;
  9037. }
  9038. }
  9039. AST_Scope.DEFMETHOD("next_mangled", function(options) {
  9040. return next_mangled(this, options);
  9041. });
  9042. AST_Toplevel.DEFMETHOD("next_mangled", function(options) {
  9043. let name;
  9044. const mangled_names = this.mangled_names;
  9045. do {
  9046. name = next_mangled(this, options);
  9047. } while (mangled_names.has(name));
  9048. return name;
  9049. });
  9050. AST_Function.DEFMETHOD("next_mangled", function(options, def) {
  9051. // #179, #326
  9052. // in Safari strict mode, something like (function x(x){...}) is a syntax error;
  9053. // a function expression's argument cannot shadow the function expression's name
  9054. var tricky_def = def.orig[0] instanceof AST_SymbolFunarg && this.name && this.name.definition();
  9055. // the function's mangled_name is null when keep_fnames is true
  9056. var tricky_name = tricky_def ? tricky_def.mangled_name || tricky_def.name : null;
  9057. while (true) {
  9058. var name = next_mangled(this, options);
  9059. if (!tricky_name || tricky_name != name)
  9060. return name;
  9061. }
  9062. });
  9063. AST_Symbol.DEFMETHOD("unmangleable", function(options) {
  9064. var def = this.definition();
  9065. return !def || def.unmangleable(options);
  9066. });
  9067. // labels are always mangleable
  9068. AST_Label.DEFMETHOD("unmangleable", return_false);
  9069. AST_Symbol.DEFMETHOD("unreferenced", function() {
  9070. return !this.definition().references.length && !this.scope.pinned();
  9071. });
  9072. AST_Symbol.DEFMETHOD("definition", function() {
  9073. return this.thedef;
  9074. });
  9075. AST_Symbol.DEFMETHOD("global", function() {
  9076. return this.thedef.global;
  9077. });
  9078. AST_Toplevel.DEFMETHOD("_default_mangler_options", function(options) {
  9079. options = defaults(options, {
  9080. eval : false,
  9081. nth_identifier : base54,
  9082. ie8 : false,
  9083. keep_classnames: false,
  9084. keep_fnames : false,
  9085. module : false,
  9086. reserved : [],
  9087. toplevel : false,
  9088. });
  9089. if (options.module) options.toplevel = true;
  9090. if (!Array.isArray(options.reserved)
  9091. && !(options.reserved instanceof Set)
  9092. ) {
  9093. options.reserved = [];
  9094. }
  9095. options.reserved = new Set(options.reserved);
  9096. // Never mangle arguments
  9097. options.reserved.add("arguments");
  9098. return options;
  9099. });
  9100. AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
  9101. options = this._default_mangler_options(options);
  9102. var nth_identifier = options.nth_identifier;
  9103. // We only need to mangle declaration nodes. Special logic wired
  9104. // into the code generator will display the mangled name if it's
  9105. // present (and for AST_SymbolRef-s it'll use the mangled name of
  9106. // the AST_SymbolDeclaration that it points to).
  9107. var lname = -1;
  9108. var to_mangle = [];
  9109. if (options.keep_fnames) {
  9110. function_defs = new Set();
  9111. }
  9112. const mangled_names = this.mangled_names = new Set();
  9113. unmangleable_names = new Set();
  9114. if (options.cache) {
  9115. this.globals.forEach(collect);
  9116. if (options.cache.props) {
  9117. options.cache.props.forEach(function(mangled_name) {
  9118. mangled_names.add(mangled_name);
  9119. });
  9120. }
  9121. }
  9122. var tw = new TreeWalker(function(node, descend) {
  9123. if (node instanceof AST_LabeledStatement) {
  9124. // lname is incremented when we get to the AST_Label
  9125. var save_nesting = lname;
  9126. descend();
  9127. lname = save_nesting;
  9128. return true; // don't descend again in TreeWalker
  9129. }
  9130. if (node instanceof AST_Scope) {
  9131. node.variables.forEach(collect);
  9132. return;
  9133. }
  9134. if (node.is_block_scope()) {
  9135. node.block_scope.variables.forEach(collect);
  9136. return;
  9137. }
  9138. if (
  9139. function_defs
  9140. && node instanceof AST_VarDef
  9141. && node.value instanceof AST_Lambda
  9142. && !node.value.name
  9143. && keep_name(options.keep_fnames, node.name.name)
  9144. ) {
  9145. function_defs.add(node.name.definition().id);
  9146. return;
  9147. }
  9148. if (node instanceof AST_Label) {
  9149. let name;
  9150. do {
  9151. name = nth_identifier.get(++lname);
  9152. } while (ALL_RESERVED_WORDS.has(name));
  9153. node.mangled_name = name;
  9154. return true;
  9155. }
  9156. if (!(options.ie8 || options.safari10) && node instanceof AST_SymbolCatch) {
  9157. to_mangle.push(node.definition());
  9158. return;
  9159. }
  9160. });
  9161. this.walk(tw);
  9162. if (options.keep_fnames || options.keep_classnames) {
  9163. // Collect a set of short names which are unmangleable,
  9164. // for use in avoiding collisions in next_mangled.
  9165. to_mangle.forEach(def => {
  9166. if (def.name.length < 6 && def.unmangleable(options)) {
  9167. unmangleable_names.add(def.name);
  9168. }
  9169. });
  9170. }
  9171. to_mangle.forEach(def => { def.mangle(options); });
  9172. function_defs = null;
  9173. unmangleable_names = null;
  9174. function collect(symbol) {
  9175. if (symbol.export & MASK_EXPORT_DONT_MANGLE) {
  9176. unmangleable_names.add(symbol.name);
  9177. } else if (!options.reserved.has(symbol.name)) {
  9178. to_mangle.push(symbol);
  9179. }
  9180. }
  9181. });
  9182. AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
  9183. const cache = options.cache && options.cache.props;
  9184. const avoid = new Set();
  9185. options.reserved.forEach(to_avoid);
  9186. this.globals.forEach(add_def);
  9187. this.walk(new TreeWalker(function(node) {
  9188. if (node instanceof AST_Scope) node.variables.forEach(add_def);
  9189. if (node instanceof AST_SymbolCatch) add_def(node.definition());
  9190. }));
  9191. return avoid;
  9192. function to_avoid(name) {
  9193. avoid.add(name);
  9194. }
  9195. function add_def(def) {
  9196. var name = def.name;
  9197. if (def.global && cache && cache.has(name)) name = cache.get(name);
  9198. else if (!def.unmangleable(options)) return;
  9199. to_avoid(name);
  9200. }
  9201. });
  9202. AST_Toplevel.DEFMETHOD("expand_names", function(options) {
  9203. options = this._default_mangler_options(options);
  9204. var nth_identifier = options.nth_identifier;
  9205. if (nth_identifier.reset && nth_identifier.sort) {
  9206. nth_identifier.reset();
  9207. nth_identifier.sort();
  9208. }
  9209. var avoid = this.find_colliding_names(options);
  9210. var cname = 0;
  9211. this.globals.forEach(rename);
  9212. this.walk(new TreeWalker(function(node) {
  9213. if (node instanceof AST_Scope) node.variables.forEach(rename);
  9214. if (node instanceof AST_SymbolCatch) rename(node.definition());
  9215. }));
  9216. function next_name() {
  9217. var name;
  9218. do {
  9219. name = nth_identifier.get(cname++);
  9220. } while (avoid.has(name) || ALL_RESERVED_WORDS.has(name));
  9221. return name;
  9222. }
  9223. function rename(def) {
  9224. if (def.global && options.cache) return;
  9225. if (def.unmangleable(options)) return;
  9226. if (options.reserved.has(def.name)) return;
  9227. const redefinition = redefined_catch_def(def);
  9228. const name = def.name = redefinition ? redefinition.name : next_name();
  9229. def.orig.forEach(function(sym) {
  9230. sym.name = name;
  9231. });
  9232. def.references.forEach(function(sym) {
  9233. sym.name = name;
  9234. });
  9235. }
  9236. });
  9237. AST_Node.DEFMETHOD("tail_node", return_this);
  9238. AST_Sequence.DEFMETHOD("tail_node", function() {
  9239. return this.expressions[this.expressions.length - 1];
  9240. });
  9241. AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) {
  9242. options = this._default_mangler_options(options);
  9243. var nth_identifier = options.nth_identifier;
  9244. if (!nth_identifier.reset || !nth_identifier.consider || !nth_identifier.sort) {
  9245. // If the identifier mangler is invariant, skip computing character frequency.
  9246. return;
  9247. }
  9248. nth_identifier.reset();
  9249. try {
  9250. AST_Node.prototype.print = function(stream, force_parens) {
  9251. this._print(stream, force_parens);
  9252. if (this instanceof AST_Symbol && !this.unmangleable(options)) {
  9253. nth_identifier.consider(this.name, -1);
  9254. } else if (options.properties) {
  9255. if (this instanceof AST_DotHash) {
  9256. nth_identifier.consider("#" + this.property, -1);
  9257. } else if (this instanceof AST_Dot) {
  9258. nth_identifier.consider(this.property, -1);
  9259. } else if (this instanceof AST_Sub) {
  9260. skip_string(this.property);
  9261. }
  9262. }
  9263. };
  9264. nth_identifier.consider(this.print_to_string(), 1);
  9265. } finally {
  9266. AST_Node.prototype.print = AST_Node.prototype._print;
  9267. }
  9268. nth_identifier.sort();
  9269. function skip_string(node) {
  9270. if (node instanceof AST_String) {
  9271. nth_identifier.consider(node.value, -1);
  9272. } else if (node instanceof AST_Conditional) {
  9273. skip_string(node.consequent);
  9274. skip_string(node.alternative);
  9275. } else if (node instanceof AST_Sequence) {
  9276. skip_string(node.tail_node());
  9277. }
  9278. }
  9279. });
  9280. const base54 = (() => {
  9281. const leading = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_".split("");
  9282. const digits = "0123456789".split("");
  9283. let chars;
  9284. let frequency;
  9285. function reset() {
  9286. frequency = new Map();
  9287. leading.forEach(function(ch) {
  9288. frequency.set(ch, 0);
  9289. });
  9290. digits.forEach(function(ch) {
  9291. frequency.set(ch, 0);
  9292. });
  9293. }
  9294. function consider(str, delta) {
  9295. for (var i = str.length; --i >= 0;) {
  9296. frequency.set(str[i], frequency.get(str[i]) + delta);
  9297. }
  9298. }
  9299. function compare(a, b) {
  9300. return frequency.get(b) - frequency.get(a);
  9301. }
  9302. function sort() {
  9303. chars = mergeSort(leading, compare).concat(mergeSort(digits, compare));
  9304. }
  9305. // Ensure this is in a usable initial state.
  9306. reset();
  9307. sort();
  9308. function base54(num) {
  9309. var ret = "", base = 54;
  9310. num++;
  9311. do {
  9312. num--;
  9313. ret += chars[num % base];
  9314. num = Math.floor(num / base);
  9315. base = 64;
  9316. } while (num > 0);
  9317. return ret;
  9318. }
  9319. return {
  9320. get: base54,
  9321. consider,
  9322. reset,
  9323. sort
  9324. };
  9325. })();
  9326. let mangle_options = undefined;
  9327. AST_Node.prototype.size = function (compressor, stack) {
  9328. mangle_options = compressor && compressor.mangle_options;
  9329. let size = 0;
  9330. walk_parent(this, (node, info) => {
  9331. size += node._size(info);
  9332. // Braceless arrow functions have fake "return" statements
  9333. if (node instanceof AST_Arrow && node.is_braceless()) {
  9334. size += node.body[0].value._size(info);
  9335. return true;
  9336. }
  9337. }, stack || (compressor && compressor.stack));
  9338. // just to save a bit of memory
  9339. mangle_options = undefined;
  9340. return size;
  9341. };
  9342. AST_Node.prototype._size = () => 0;
  9343. AST_Debugger.prototype._size = () => 8;
  9344. AST_Directive.prototype._size = function () {
  9345. // TODO string encoding stuff
  9346. return 2 + this.value.length;
  9347. };
  9348. const list_overhead = (array) => array.length && array.length - 1;
  9349. AST_Block.prototype._size = function () {
  9350. return 2 + list_overhead(this.body);
  9351. };
  9352. AST_Toplevel.prototype._size = function() {
  9353. return list_overhead(this.body);
  9354. };
  9355. AST_EmptyStatement.prototype._size = () => 1;
  9356. AST_LabeledStatement.prototype._size = () => 2; // x:
  9357. AST_Do.prototype._size = () => 9;
  9358. AST_While.prototype._size = () => 7;
  9359. AST_For.prototype._size = () => 8;
  9360. AST_ForIn.prototype._size = () => 8;
  9361. // AST_ForOf inherits ^
  9362. AST_With.prototype._size = () => 6;
  9363. AST_Expansion.prototype._size = () => 3;
  9364. const lambda_modifiers = func =>
  9365. (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);
  9366. AST_Accessor.prototype._size = function () {
  9367. return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);
  9368. };
  9369. AST_Function.prototype._size = function (info) {
  9370. const first = !!first_in_statement(info);
  9371. return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);
  9372. };
  9373. AST_Defun.prototype._size = function () {
  9374. return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);
  9375. };
  9376. AST_Arrow.prototype._size = function () {
  9377. let args_and_arrow = 2 + list_overhead(this.argnames);
  9378. if (
  9379. !(
  9380. this.argnames.length === 1
  9381. && this.argnames[0] instanceof AST_Symbol
  9382. )
  9383. ) {
  9384. args_and_arrow += 2;
  9385. }
  9386. const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;
  9387. return lambda_modifiers(this) + args_and_arrow + body_overhead;
  9388. };
  9389. AST_Destructuring.prototype._size = () => 2;
  9390. AST_TemplateString.prototype._size = function () {
  9391. return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */
  9392. };
  9393. AST_TemplateSegment.prototype._size = function () {
  9394. return this.value.length;
  9395. };
  9396. AST_Return.prototype._size = function () {
  9397. return this.value ? 7 : 6;
  9398. };
  9399. AST_Throw.prototype._size = () => 6;
  9400. AST_Break.prototype._size = function () {
  9401. return this.label ? 6 : 5;
  9402. };
  9403. AST_Continue.prototype._size = function () {
  9404. return this.label ? 9 : 8;
  9405. };
  9406. AST_If.prototype._size = () => 4;
  9407. AST_Switch.prototype._size = function () {
  9408. return 8 + list_overhead(this.body);
  9409. };
  9410. AST_Case.prototype._size = function () {
  9411. return 5 + list_overhead(this.body);
  9412. };
  9413. AST_Default.prototype._size = function () {
  9414. return 8 + list_overhead(this.body);
  9415. };
  9416. AST_Try.prototype._size = function () {
  9417. return 3 + list_overhead(this.body);
  9418. };
  9419. AST_Catch.prototype._size = function () {
  9420. let size = 7 + list_overhead(this.body);
  9421. if (this.argname) {
  9422. size += 2;
  9423. }
  9424. return size;
  9425. };
  9426. AST_Finally.prototype._size = function () {
  9427. return 7 + list_overhead(this.body);
  9428. };
  9429. /*#__INLINE__*/
  9430. const def_size = (size, def) => size + list_overhead(def.definitions);
  9431. AST_Var.prototype._size = function () {
  9432. return def_size(4, this);
  9433. };
  9434. AST_Let.prototype._size = function () {
  9435. return def_size(4, this);
  9436. };
  9437. AST_Const.prototype._size = function () {
  9438. return def_size(6, this);
  9439. };
  9440. AST_VarDef.prototype._size = function () {
  9441. return this.value ? 1 : 0;
  9442. };
  9443. AST_NameMapping.prototype._size = function () {
  9444. // foreign name isn't mangled
  9445. return this.name ? 4 : 0;
  9446. };
  9447. AST_Import.prototype._size = function () {
  9448. // import
  9449. let size = 6;
  9450. if (this.imported_name) size += 1;
  9451. // from
  9452. if (this.imported_name || this.imported_names) size += 5;
  9453. // braces, and the commas
  9454. if (this.imported_names) {
  9455. size += 2 + list_overhead(this.imported_names);
  9456. }
  9457. return size;
  9458. };
  9459. AST_ImportMeta.prototype._size = () => 11;
  9460. AST_Export.prototype._size = function () {
  9461. let size = 7 + (this.is_default ? 8 : 0);
  9462. if (this.exported_value) {
  9463. size += this.exported_value._size();
  9464. }
  9465. if (this.exported_names) {
  9466. // Braces and commas
  9467. size += 2 + list_overhead(this.exported_names);
  9468. }
  9469. if (this.module_name) {
  9470. // "from "
  9471. size += 5;
  9472. }
  9473. return size;
  9474. };
  9475. AST_Call.prototype._size = function () {
  9476. if (this.optional) {
  9477. return 4 + list_overhead(this.args);
  9478. }
  9479. return 2 + list_overhead(this.args);
  9480. };
  9481. AST_New.prototype._size = function () {
  9482. return 6 + list_overhead(this.args);
  9483. };
  9484. AST_Sequence.prototype._size = function () {
  9485. return list_overhead(this.expressions);
  9486. };
  9487. AST_Dot.prototype._size = function () {
  9488. if (this.optional) {
  9489. return this.property.length + 2;
  9490. }
  9491. return this.property.length + 1;
  9492. };
  9493. AST_DotHash.prototype._size = function () {
  9494. if (this.optional) {
  9495. return this.property.length + 3;
  9496. }
  9497. return this.property.length + 2;
  9498. };
  9499. AST_Sub.prototype._size = function () {
  9500. return this.optional ? 4 : 2;
  9501. };
  9502. AST_Unary.prototype._size = function () {
  9503. if (this.operator === "typeof") return 7;
  9504. if (this.operator === "void") return 5;
  9505. return this.operator.length;
  9506. };
  9507. AST_Binary.prototype._size = function (info) {
  9508. if (this.operator === "in") return 4;
  9509. let size = this.operator.length;
  9510. if (
  9511. (this.operator === "+" || this.operator === "-")
  9512. && this.right instanceof AST_Unary && this.right.operator === this.operator
  9513. ) {
  9514. // 1+ +a > needs space between the +
  9515. size += 1;
  9516. }
  9517. if (this.needs_parens(info)) {
  9518. size += 2;
  9519. }
  9520. return size;
  9521. };
  9522. AST_Conditional.prototype._size = () => 3;
  9523. AST_Array.prototype._size = function () {
  9524. return 2 + list_overhead(this.elements);
  9525. };
  9526. AST_Object.prototype._size = function (info) {
  9527. let base = 2;
  9528. if (first_in_statement(info)) {
  9529. base += 2; // parens
  9530. }
  9531. return base + list_overhead(this.properties);
  9532. };
  9533. /*#__INLINE__*/
  9534. const key_size = key =>
  9535. typeof key === "string" ? key.length : 0;
  9536. AST_ObjectKeyVal.prototype._size = function () {
  9537. return key_size(this.key) + 1;
  9538. };
  9539. /*#__INLINE__*/
  9540. const static_size = is_static => is_static ? 7 : 0;
  9541. AST_ObjectGetter.prototype._size = function () {
  9542. return 5 + static_size(this.static) + key_size(this.key);
  9543. };
  9544. AST_ObjectSetter.prototype._size = function () {
  9545. return 5 + static_size(this.static) + key_size(this.key);
  9546. };
  9547. AST_ConciseMethod.prototype._size = function () {
  9548. return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);
  9549. };
  9550. AST_PrivateMethod.prototype._size = function () {
  9551. return AST_ConciseMethod.prototype._size.call(this) + 1;
  9552. };
  9553. AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {
  9554. return AST_ConciseMethod.prototype._size.call(this) + 4;
  9555. };
  9556. AST_Class.prototype._size = function () {
  9557. return (
  9558. (this.name ? 8 : 7)
  9559. + (this.extends ? 8 : 0)
  9560. );
  9561. };
  9562. AST_ClassProperty.prototype._size = function () {
  9563. return (
  9564. static_size(this.static)
  9565. + (typeof this.key === "string" ? this.key.length + 2 : 0)
  9566. + (this.value ? 1 : 0)
  9567. );
  9568. };
  9569. AST_ClassPrivateProperty.prototype._size = function () {
  9570. return AST_ClassProperty.prototype._size.call(this) + 1;
  9571. };
  9572. AST_Symbol.prototype._size = function () {
  9573. return !mangle_options || this.definition().unmangleable(mangle_options)
  9574. ? this.name.length
  9575. : 1;
  9576. };
  9577. // TODO take propmangle into account
  9578. AST_SymbolClassProperty.prototype._size = function () {
  9579. return this.name.length;
  9580. };
  9581. AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {
  9582. const { name, thedef } = this;
  9583. if (thedef && thedef.global) return name.length;
  9584. if (name === "arguments") return 9;
  9585. return AST_Symbol.prototype._size.call(this);
  9586. };
  9587. AST_NewTarget.prototype._size = () => 10;
  9588. AST_SymbolImportForeign.prototype._size = function () {
  9589. return this.name.length;
  9590. };
  9591. AST_SymbolExportForeign.prototype._size = function () {
  9592. return this.name.length;
  9593. };
  9594. AST_This.prototype._size = () => 4;
  9595. AST_Super.prototype._size = () => 5;
  9596. AST_String.prototype._size = function () {
  9597. return this.value.length + 2;
  9598. };
  9599. AST_Number.prototype._size = function () {
  9600. const { value } = this;
  9601. if (value === 0) return 1;
  9602. if (value > 0 && Math.floor(value) === value) {
  9603. return Math.floor(Math.log10(value) + 1);
  9604. }
  9605. return value.toString().length;
  9606. };
  9607. AST_BigInt.prototype._size = function () {
  9608. return this.value.length;
  9609. };
  9610. AST_RegExp.prototype._size = function () {
  9611. return this.value.toString().length;
  9612. };
  9613. AST_Null.prototype._size = () => 4;
  9614. AST_NaN.prototype._size = () => 3;
  9615. AST_Undefined.prototype._size = () => 6; // "void 0"
  9616. AST_Hole.prototype._size = () => 0; // comma is taken into account
  9617. AST_Infinity.prototype._size = () => 8;
  9618. AST_True.prototype._size = () => 4;
  9619. AST_False.prototype._size = () => 5;
  9620. AST_Await.prototype._size = () => 6;
  9621. AST_Yield.prototype._size = () => 6;
  9622. /***********************************************************************
  9623. A JavaScript tokenizer / parser / beautifier / compressor.
  9624. https://github.com/mishoo/UglifyJS2
  9625. -------------------------------- (C) ---------------------------------
  9626. Author: Mihai Bazon
  9627. <mihai.bazon@gmail.com>
  9628. http://mihai.bazon.net/blog
  9629. Distributed under the BSD license:
  9630. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  9631. Redistribution and use in source and binary forms, with or without
  9632. modification, are permitted provided that the following conditions
  9633. are met:
  9634. * Redistributions of source code must retain the above
  9635. copyright notice, this list of conditions and the following
  9636. disclaimer.
  9637. * Redistributions in binary form must reproduce the above
  9638. copyright notice, this list of conditions and the following
  9639. disclaimer in the documentation and/or other materials
  9640. provided with the distribution.
  9641. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  9642. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9643. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9644. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  9645. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  9646. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9647. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9648. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9649. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  9650. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  9651. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9652. SUCH DAMAGE.
  9653. ***********************************************************************/
  9654. function merge_sequence(array, node) {
  9655. if (node instanceof AST_Sequence) {
  9656. array.push(...node.expressions);
  9657. } else {
  9658. array.push(node);
  9659. }
  9660. return array;
  9661. }
  9662. function make_sequence(orig, expressions) {
  9663. if (expressions.length == 1) return expressions[0];
  9664. if (expressions.length == 0) throw new Error("trying to create a sequence with length zero!");
  9665. return make_node(AST_Sequence, orig, {
  9666. expressions: expressions.reduce(merge_sequence, [])
  9667. });
  9668. }
  9669. function make_node_from_constant(val, orig) {
  9670. switch (typeof val) {
  9671. case "string":
  9672. return make_node(AST_String, orig, {
  9673. value: val
  9674. });
  9675. case "number":
  9676. if (isNaN(val)) return make_node(AST_NaN, orig);
  9677. if (isFinite(val)) {
  9678. return 1 / val < 0 ? make_node(AST_UnaryPrefix, orig, {
  9679. operator: "-",
  9680. expression: make_node(AST_Number, orig, { value: -val })
  9681. }) : make_node(AST_Number, orig, { value: val });
  9682. }
  9683. return val < 0 ? make_node(AST_UnaryPrefix, orig, {
  9684. operator: "-",
  9685. expression: make_node(AST_Infinity, orig)
  9686. }) : make_node(AST_Infinity, orig);
  9687. case "boolean":
  9688. return make_node(val ? AST_True : AST_False, orig);
  9689. case "undefined":
  9690. return make_node(AST_Undefined, orig);
  9691. default:
  9692. if (val === null) {
  9693. return make_node(AST_Null, orig, { value: null });
  9694. }
  9695. if (val instanceof RegExp) {
  9696. return make_node(AST_RegExp, orig, {
  9697. value: {
  9698. source: regexp_source_fix(val.source),
  9699. flags: val.flags
  9700. }
  9701. });
  9702. }
  9703. throw new Error(string_template("Can't handle constant of type: {type}", {
  9704. type: typeof val
  9705. }));
  9706. }
  9707. }
  9708. function best_of_expression(ast1, ast2) {
  9709. return ast1.size() > ast2.size() ? ast2 : ast1;
  9710. }
  9711. function best_of_statement(ast1, ast2) {
  9712. return best_of_expression(
  9713. make_node(AST_SimpleStatement, ast1, {
  9714. body: ast1
  9715. }),
  9716. make_node(AST_SimpleStatement, ast2, {
  9717. body: ast2
  9718. })
  9719. ).body;
  9720. }
  9721. /** Find which node is smaller, and return that */
  9722. function best_of(compressor, ast1, ast2) {
  9723. if (first_in_statement(compressor)) {
  9724. return best_of_statement(ast1, ast2);
  9725. } else {
  9726. return best_of_expression(ast1, ast2);
  9727. }
  9728. }
  9729. /** Simplify an object property's key, if possible */
  9730. function get_simple_key(key) {
  9731. if (key instanceof AST_Constant) {
  9732. return key.getValue();
  9733. }
  9734. if (key instanceof AST_UnaryPrefix
  9735. && key.operator == "void"
  9736. && key.expression instanceof AST_Constant) {
  9737. return;
  9738. }
  9739. return key;
  9740. }
  9741. function read_property(obj, key) {
  9742. key = get_simple_key(key);
  9743. if (key instanceof AST_Node) return;
  9744. var value;
  9745. if (obj instanceof AST_Array) {
  9746. var elements = obj.elements;
  9747. if (key == "length") return make_node_from_constant(elements.length, obj);
  9748. if (typeof key == "number" && key in elements) value = elements[key];
  9749. } else if (obj instanceof AST_Object) {
  9750. key = "" + key;
  9751. var props = obj.properties;
  9752. for (var i = props.length; --i >= 0;) {
  9753. var prop = props[i];
  9754. if (!(prop instanceof AST_ObjectKeyVal)) return;
  9755. if (!value && props[i].key === key) value = props[i].value;
  9756. }
  9757. }
  9758. return value instanceof AST_SymbolRef && value.fixed_value() || value;
  9759. }
  9760. function has_break_or_continue(loop, parent) {
  9761. var found = false;
  9762. var tw = new TreeWalker(function(node) {
  9763. if (found || node instanceof AST_Scope) return true;
  9764. if (node instanceof AST_LoopControl && tw.loopcontrol_target(node) === loop) {
  9765. return found = true;
  9766. }
  9767. });
  9768. if (parent instanceof AST_LabeledStatement) tw.push(parent);
  9769. tw.push(loop);
  9770. loop.body.walk(tw);
  9771. return found;
  9772. }
  9773. // we shouldn't compress (1,func)(something) to
  9774. // func(something) because that changes the meaning of
  9775. // the func (becomes lexical instead of global).
  9776. function maintain_this_binding(parent, orig, val) {
  9777. if (
  9778. parent instanceof AST_UnaryPrefix && parent.operator == "delete"
  9779. || parent instanceof AST_Call && parent.expression === orig
  9780. && (
  9781. val instanceof AST_PropAccess
  9782. || val instanceof AST_SymbolRef && val.name == "eval"
  9783. )
  9784. ) {
  9785. const zero = make_node(AST_Number, orig, { value: 0 });
  9786. return make_sequence(orig, [ zero, val ]);
  9787. } else {
  9788. return val;
  9789. }
  9790. }
  9791. function is_func_expr(node) {
  9792. return node instanceof AST_Arrow || node instanceof AST_Function;
  9793. }
  9794. function is_iife_call(node) {
  9795. // Used to determine whether the node can benefit from negation.
  9796. // Not the case with arrow functions (you need an extra set of parens).
  9797. if (node.TYPE != "Call") return false;
  9798. return node.expression instanceof AST_Function || is_iife_call(node.expression);
  9799. }
  9800. const identifier_atom = makePredicate("Infinity NaN undefined");
  9801. function is_identifier_atom(node) {
  9802. return node instanceof AST_Infinity
  9803. || node instanceof AST_NaN
  9804. || node instanceof AST_Undefined;
  9805. }
  9806. /** Check if this is a SymbolRef node which has one def of a certain AST type */
  9807. function is_ref_of(ref, type) {
  9808. if (!(ref instanceof AST_SymbolRef)) return false;
  9809. var orig = ref.definition().orig;
  9810. for (var i = orig.length; --i >= 0;) {
  9811. if (orig[i] instanceof type) return true;
  9812. }
  9813. }
  9814. // Can we turn { block contents... } into just the block contents ?
  9815. // Not if one of these is inside.
  9816. function can_be_evicted_from_block(node) {
  9817. return !(
  9818. node instanceof AST_DefClass ||
  9819. node instanceof AST_Defun ||
  9820. node instanceof AST_Let ||
  9821. node instanceof AST_Const ||
  9822. node instanceof AST_Export ||
  9823. node instanceof AST_Import
  9824. );
  9825. }
  9826. function as_statement_array(thing) {
  9827. if (thing === null) return [];
  9828. if (thing instanceof AST_BlockStatement) return thing.body;
  9829. if (thing instanceof AST_EmptyStatement) return [];
  9830. if (thing instanceof AST_Statement) return [ thing ];
  9831. throw new Error("Can't convert thing to statement array");
  9832. }
  9833. /** Check if a ref refers to the name of a function/class it's defined within */
  9834. function is_recursive_ref(compressor, def) {
  9835. var node;
  9836. for (var i = 0; node = compressor.parent(i); i++) {
  9837. if (node instanceof AST_Lambda || node instanceof AST_Class) {
  9838. var name = node.name;
  9839. if (name && name.definition() === def) {
  9840. return true;
  9841. }
  9842. }
  9843. }
  9844. return false;
  9845. }
  9846. /***********************************************************************
  9847. A JavaScript tokenizer / parser / beautifier / compressor.
  9848. https://github.com/mishoo/UglifyJS2
  9849. -------------------------------- (C) ---------------------------------
  9850. Author: Mihai Bazon
  9851. <mihai.bazon@gmail.com>
  9852. http://mihai.bazon.net/blog
  9853. Distributed under the BSD license:
  9854. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  9855. Redistribution and use in source and binary forms, with or without
  9856. modification, are permitted provided that the following conditions
  9857. are met:
  9858. * Redistributions of source code must retain the above
  9859. copyright notice, this list of conditions and the following
  9860. disclaimer.
  9861. * Redistributions in binary form must reproduce the above
  9862. copyright notice, this list of conditions and the following
  9863. disclaimer in the documentation and/or other materials
  9864. provided with the distribution.
  9865. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  9866. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9867. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9868. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  9869. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  9870. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9871. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9872. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9873. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  9874. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  9875. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9876. SUCH DAMAGE.
  9877. ***********************************************************************/
  9878. // bitfield flags to be stored in node.flags.
  9879. // These are set and unset during compression, and store information in the node without requiring multiple fields.
  9880. const UNUSED = 0b00000001;
  9881. const TRUTHY = 0b00000010;
  9882. const FALSY = 0b00000100;
  9883. const UNDEFINED = 0b00001000;
  9884. const INLINED = 0b00010000;
  9885. // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
  9886. const WRITE_ONLY = 0b00100000;
  9887. // information specific to a single compression pass
  9888. const SQUEEZED = 0b0000000100000000;
  9889. const OPTIMIZED = 0b0000001000000000;
  9890. const TOP = 0b0000010000000000;
  9891. const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
  9892. const has_flag = (node, flag) => node.flags & flag;
  9893. const set_flag = (node, flag) => { node.flags |= flag; };
  9894. const clear_flag = (node, flag) => { node.flags &= ~flag; };
  9895. /***********************************************************************
  9896. A JavaScript tokenizer / parser / beautifier / compressor.
  9897. https://github.com/mishoo/UglifyJS2
  9898. -------------------------------- (C) ---------------------------------
  9899. Author: Mihai Bazon
  9900. <mihai.bazon@gmail.com>
  9901. http://mihai.bazon.net/blog
  9902. Distributed under the BSD license:
  9903. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  9904. Redistribution and use in source and binary forms, with or without
  9905. modification, are permitted provided that the following conditions
  9906. are met:
  9907. * Redistributions of source code must retain the above
  9908. copyright notice, this list of conditions and the following
  9909. disclaimer.
  9910. * Redistributions in binary form must reproduce the above
  9911. copyright notice, this list of conditions and the following
  9912. disclaimer in the documentation and/or other materials
  9913. provided with the distribution.
  9914. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  9915. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9916. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9917. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  9918. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  9919. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9920. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9921. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  9922. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  9923. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  9924. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9925. SUCH DAMAGE.
  9926. ***********************************************************************/
  9927. // Lists of native methods, useful for `unsafe` option which assumes they exist.
  9928. // Note: Lots of methods and functions are missing here, in case they aren't pure
  9929. // or not available in all JS environments.
  9930. function make_nested_lookup(obj) {
  9931. const out = new Map();
  9932. for (var key of Object.keys(obj)) {
  9933. out.set(key, makePredicate(obj[key]));
  9934. }
  9935. const does_have = (global_name, fname) => {
  9936. const inner_map = out.get(global_name);
  9937. return inner_map != null && inner_map.has(fname);
  9938. };
  9939. return does_have;
  9940. }
  9941. // Objects which are safe to access without throwing or causing a side effect.
  9942. // Usually we'd check the `unsafe` option first but these are way too common for that
  9943. const pure_prop_access_globals = new Set([
  9944. "Number",
  9945. "String",
  9946. "Array",
  9947. "Object",
  9948. "Function",
  9949. "Promise",
  9950. ]);
  9951. const object_methods = [
  9952. "constructor",
  9953. "toString",
  9954. "valueOf",
  9955. ];
  9956. const is_pure_native_method = make_nested_lookup({
  9957. Array: [
  9958. "indexOf",
  9959. "join",
  9960. "lastIndexOf",
  9961. "slice",
  9962. ...object_methods,
  9963. ],
  9964. Boolean: object_methods,
  9965. Function: object_methods,
  9966. Number: [
  9967. "toExponential",
  9968. "toFixed",
  9969. "toPrecision",
  9970. ...object_methods,
  9971. ],
  9972. Object: object_methods,
  9973. RegExp: [
  9974. "test",
  9975. ...object_methods,
  9976. ],
  9977. String: [
  9978. "charAt",
  9979. "charCodeAt",
  9980. "concat",
  9981. "indexOf",
  9982. "italics",
  9983. "lastIndexOf",
  9984. "match",
  9985. "replace",
  9986. "search",
  9987. "slice",
  9988. "split",
  9989. "substr",
  9990. "substring",
  9991. "toLowerCase",
  9992. "toUpperCase",
  9993. "trim",
  9994. ...object_methods,
  9995. ],
  9996. });
  9997. const is_pure_native_fn = make_nested_lookup({
  9998. Array: [
  9999. "isArray",
  10000. ],
  10001. Math: [
  10002. "abs",
  10003. "acos",
  10004. "asin",
  10005. "atan",
  10006. "ceil",
  10007. "cos",
  10008. "exp",
  10009. "floor",
  10010. "log",
  10011. "round",
  10012. "sin",
  10013. "sqrt",
  10014. "tan",
  10015. "atan2",
  10016. "pow",
  10017. "max",
  10018. "min",
  10019. ],
  10020. Number: [
  10021. "isFinite",
  10022. "isNaN",
  10023. ],
  10024. Object: [
  10025. "create",
  10026. "getOwnPropertyDescriptor",
  10027. "getOwnPropertyNames",
  10028. "getPrototypeOf",
  10029. "isExtensible",
  10030. "isFrozen",
  10031. "isSealed",
  10032. "hasOwn",
  10033. "keys",
  10034. ],
  10035. String: [
  10036. "fromCharCode",
  10037. ],
  10038. });
  10039. // Known numeric values which come with JS environments
  10040. const is_pure_native_value = make_nested_lookup({
  10041. Math: [
  10042. "E",
  10043. "LN10",
  10044. "LN2",
  10045. "LOG2E",
  10046. "LOG10E",
  10047. "PI",
  10048. "SQRT1_2",
  10049. "SQRT2",
  10050. ],
  10051. Number: [
  10052. "MAX_VALUE",
  10053. "MIN_VALUE",
  10054. "NaN",
  10055. "NEGATIVE_INFINITY",
  10056. "POSITIVE_INFINITY",
  10057. ],
  10058. });
  10059. /***********************************************************************
  10060. A JavaScript tokenizer / parser / beautifier / compressor.
  10061. https://github.com/mishoo/UglifyJS2
  10062. -------------------------------- (C) ---------------------------------
  10063. Author: Mihai Bazon
  10064. <mihai.bazon@gmail.com>
  10065. http://mihai.bazon.net/blog
  10066. Distributed under the BSD license:
  10067. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10068. Redistribution and use in source and binary forms, with or without
  10069. modification, are permitted provided that the following conditions
  10070. are met:
  10071. * Redistributions of source code must retain the above
  10072. copyright notice, this list of conditions and the following
  10073. disclaimer.
  10074. * Redistributions in binary form must reproduce the above
  10075. copyright notice, this list of conditions and the following
  10076. disclaimer in the documentation and/or other materials
  10077. provided with the distribution.
  10078. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10079. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10080. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10081. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10082. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10083. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10084. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10085. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10086. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10087. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10088. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10089. SUCH DAMAGE.
  10090. ***********************************************************************/
  10091. // Functions and methods to infer certain facts about expressions
  10092. // It's not always possible to be 100% sure about something just by static analysis,
  10093. // so `true` means yes, and `false` means maybe
  10094. const is_undeclared_ref = (node) =>
  10095. node instanceof AST_SymbolRef && node.definition().undeclared;
  10096. const lazy_op = makePredicate("&& || ??");
  10097. const unary_side_effects = makePredicate("delete ++ --");
  10098. // methods to determine whether an expression has a boolean result type
  10099. (function(def_is_boolean) {
  10100. const unary_bool = makePredicate("! delete");
  10101. const binary_bool = makePredicate("in instanceof == != === !== < <= >= >");
  10102. def_is_boolean(AST_Node, return_false);
  10103. def_is_boolean(AST_UnaryPrefix, function() {
  10104. return unary_bool.has(this.operator);
  10105. });
  10106. def_is_boolean(AST_Binary, function() {
  10107. return binary_bool.has(this.operator)
  10108. || lazy_op.has(this.operator)
  10109. && this.left.is_boolean()
  10110. && this.right.is_boolean();
  10111. });
  10112. def_is_boolean(AST_Conditional, function() {
  10113. return this.consequent.is_boolean() && this.alternative.is_boolean();
  10114. });
  10115. def_is_boolean(AST_Assign, function() {
  10116. return this.operator == "=" && this.right.is_boolean();
  10117. });
  10118. def_is_boolean(AST_Sequence, function() {
  10119. return this.tail_node().is_boolean();
  10120. });
  10121. def_is_boolean(AST_True, return_true);
  10122. def_is_boolean(AST_False, return_true);
  10123. })(function(node, func) {
  10124. node.DEFMETHOD("is_boolean", func);
  10125. });
  10126. // methods to determine if an expression has a numeric result type
  10127. (function(def_is_number) {
  10128. def_is_number(AST_Node, return_false);
  10129. def_is_number(AST_Number, return_true);
  10130. const unary = makePredicate("+ - ~ ++ --");
  10131. def_is_number(AST_Unary, function() {
  10132. return unary.has(this.operator);
  10133. });
  10134. const numeric_ops = makePredicate("- * / % & | ^ << >> >>>");
  10135. def_is_number(AST_Binary, function(compressor) {
  10136. return numeric_ops.has(this.operator) || this.operator == "+"
  10137. && this.left.is_number(compressor)
  10138. && this.right.is_number(compressor);
  10139. });
  10140. def_is_number(AST_Assign, function(compressor) {
  10141. return numeric_ops.has(this.operator.slice(0, -1))
  10142. || this.operator == "=" && this.right.is_number(compressor);
  10143. });
  10144. def_is_number(AST_Sequence, function(compressor) {
  10145. return this.tail_node().is_number(compressor);
  10146. });
  10147. def_is_number(AST_Conditional, function(compressor) {
  10148. return this.consequent.is_number(compressor) && this.alternative.is_number(compressor);
  10149. });
  10150. })(function(node, func) {
  10151. node.DEFMETHOD("is_number", func);
  10152. });
  10153. // methods to determine if an expression has a string result type
  10154. (function(def_is_string) {
  10155. def_is_string(AST_Node, return_false);
  10156. def_is_string(AST_String, return_true);
  10157. def_is_string(AST_TemplateString, return_true);
  10158. def_is_string(AST_UnaryPrefix, function() {
  10159. return this.operator == "typeof";
  10160. });
  10161. def_is_string(AST_Binary, function(compressor) {
  10162. return this.operator == "+" &&
  10163. (this.left.is_string(compressor) || this.right.is_string(compressor));
  10164. });
  10165. def_is_string(AST_Assign, function(compressor) {
  10166. return (this.operator == "=" || this.operator == "+=") && this.right.is_string(compressor);
  10167. });
  10168. def_is_string(AST_Sequence, function(compressor) {
  10169. return this.tail_node().is_string(compressor);
  10170. });
  10171. def_is_string(AST_Conditional, function(compressor) {
  10172. return this.consequent.is_string(compressor) && this.alternative.is_string(compressor);
  10173. });
  10174. })(function(node, func) {
  10175. node.DEFMETHOD("is_string", func);
  10176. });
  10177. function is_undefined(node, compressor) {
  10178. return (
  10179. has_flag(node, UNDEFINED)
  10180. || node instanceof AST_Undefined
  10181. || node instanceof AST_UnaryPrefix
  10182. && node.operator == "void"
  10183. && !node.expression.has_side_effects(compressor)
  10184. );
  10185. }
  10186. // Is the node explicitly null or undefined.
  10187. function is_null_or_undefined(node, compressor) {
  10188. let fixed;
  10189. return (
  10190. node instanceof AST_Null
  10191. || is_undefined(node, compressor)
  10192. || (
  10193. node instanceof AST_SymbolRef
  10194. && (fixed = node.definition().fixed) instanceof AST_Node
  10195. && is_nullish(fixed, compressor)
  10196. )
  10197. );
  10198. }
  10199. // Find out if this expression is optionally chained from a base-point that we
  10200. // can statically analyze as null or undefined.
  10201. function is_nullish_shortcircuited(node, compressor) {
  10202. if (node instanceof AST_PropAccess || node instanceof AST_Call) {
  10203. return (
  10204. (node.optional && is_null_or_undefined(node.expression, compressor))
  10205. || is_nullish_shortcircuited(node.expression, compressor)
  10206. );
  10207. }
  10208. if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
  10209. return false;
  10210. }
  10211. // Find out if something is == null, or can short circuit into nullish.
  10212. // Used to optimize ?. and ??
  10213. function is_nullish(node, compressor) {
  10214. if (is_null_or_undefined(node, compressor)) return true;
  10215. return is_nullish_shortcircuited(node, compressor);
  10216. }
  10217. // Determine if expression might cause side effects
  10218. // If there's a possibility that a node may change something when it's executed, this returns true
  10219. (function(def_has_side_effects) {
  10220. def_has_side_effects(AST_Node, return_true);
  10221. def_has_side_effects(AST_EmptyStatement, return_false);
  10222. def_has_side_effects(AST_Constant, return_false);
  10223. def_has_side_effects(AST_This, return_false);
  10224. function any(list, compressor) {
  10225. for (var i = list.length; --i >= 0;)
  10226. if (list[i].has_side_effects(compressor))
  10227. return true;
  10228. return false;
  10229. }
  10230. def_has_side_effects(AST_Block, function(compressor) {
  10231. return any(this.body, compressor);
  10232. });
  10233. def_has_side_effects(AST_Call, function(compressor) {
  10234. if (
  10235. !this.is_callee_pure(compressor)
  10236. && (!this.expression.is_call_pure(compressor)
  10237. || this.expression.has_side_effects(compressor))
  10238. ) {
  10239. return true;
  10240. }
  10241. return any(this.args, compressor);
  10242. });
  10243. def_has_side_effects(AST_Switch, function(compressor) {
  10244. return this.expression.has_side_effects(compressor)
  10245. || any(this.body, compressor);
  10246. });
  10247. def_has_side_effects(AST_Case, function(compressor) {
  10248. return this.expression.has_side_effects(compressor)
  10249. || any(this.body, compressor);
  10250. });
  10251. def_has_side_effects(AST_Try, function(compressor) {
  10252. return any(this.body, compressor)
  10253. || this.bcatch && this.bcatch.has_side_effects(compressor)
  10254. || this.bfinally && this.bfinally.has_side_effects(compressor);
  10255. });
  10256. def_has_side_effects(AST_If, function(compressor) {
  10257. return this.condition.has_side_effects(compressor)
  10258. || this.body && this.body.has_side_effects(compressor)
  10259. || this.alternative && this.alternative.has_side_effects(compressor);
  10260. });
  10261. def_has_side_effects(AST_LabeledStatement, function(compressor) {
  10262. return this.body.has_side_effects(compressor);
  10263. });
  10264. def_has_side_effects(AST_SimpleStatement, function(compressor) {
  10265. return this.body.has_side_effects(compressor);
  10266. });
  10267. def_has_side_effects(AST_Lambda, return_false);
  10268. def_has_side_effects(AST_Class, function (compressor) {
  10269. if (this.extends && this.extends.has_side_effects(compressor)) {
  10270. return true;
  10271. }
  10272. return any(this.properties, compressor);
  10273. });
  10274. def_has_side_effects(AST_Binary, function(compressor) {
  10275. return this.left.has_side_effects(compressor)
  10276. || this.right.has_side_effects(compressor);
  10277. });
  10278. def_has_side_effects(AST_Assign, return_true);
  10279. def_has_side_effects(AST_Conditional, function(compressor) {
  10280. return this.condition.has_side_effects(compressor)
  10281. || this.consequent.has_side_effects(compressor)
  10282. || this.alternative.has_side_effects(compressor);
  10283. });
  10284. def_has_side_effects(AST_Unary, function(compressor) {
  10285. return unary_side_effects.has(this.operator)
  10286. || this.expression.has_side_effects(compressor);
  10287. });
  10288. def_has_side_effects(AST_SymbolRef, function(compressor) {
  10289. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  10290. });
  10291. def_has_side_effects(AST_SymbolClassProperty, return_false);
  10292. def_has_side_effects(AST_SymbolDeclaration, return_false);
  10293. def_has_side_effects(AST_Object, function(compressor) {
  10294. return any(this.properties, compressor);
  10295. });
  10296. def_has_side_effects(AST_ObjectProperty, function(compressor) {
  10297. return (
  10298. this.computed_key() && this.key.has_side_effects(compressor)
  10299. || this.value && this.value.has_side_effects(compressor)
  10300. );
  10301. });
  10302. def_has_side_effects(AST_ClassProperty, function(compressor) {
  10303. return (
  10304. this.computed_key() && this.key.has_side_effects(compressor)
  10305. || this.static && this.value && this.value.has_side_effects(compressor)
  10306. );
  10307. });
  10308. def_has_side_effects(AST_ConciseMethod, function(compressor) {
  10309. return this.computed_key() && this.key.has_side_effects(compressor);
  10310. });
  10311. def_has_side_effects(AST_ObjectGetter, function(compressor) {
  10312. return this.computed_key() && this.key.has_side_effects(compressor);
  10313. });
  10314. def_has_side_effects(AST_ObjectSetter, function(compressor) {
  10315. return this.computed_key() && this.key.has_side_effects(compressor);
  10316. });
  10317. def_has_side_effects(AST_Array, function(compressor) {
  10318. return any(this.elements, compressor);
  10319. });
  10320. def_has_side_effects(AST_Dot, function(compressor) {
  10321. if (is_nullish(this, compressor)) return false;
  10322. return !this.optional && this.expression.may_throw_on_access(compressor)
  10323. || this.expression.has_side_effects(compressor);
  10324. });
  10325. def_has_side_effects(AST_Sub, function(compressor) {
  10326. if (is_nullish(this, compressor)) return false;
  10327. return !this.optional && this.expression.may_throw_on_access(compressor)
  10328. || this.expression.has_side_effects(compressor)
  10329. || this.property.has_side_effects(compressor);
  10330. });
  10331. def_has_side_effects(AST_Chain, function (compressor) {
  10332. return this.expression.has_side_effects(compressor);
  10333. });
  10334. def_has_side_effects(AST_Sequence, function(compressor) {
  10335. return any(this.expressions, compressor);
  10336. });
  10337. def_has_side_effects(AST_Definitions, function(compressor) {
  10338. return any(this.definitions, compressor);
  10339. });
  10340. def_has_side_effects(AST_VarDef, function() {
  10341. return this.value;
  10342. });
  10343. def_has_side_effects(AST_TemplateSegment, return_false);
  10344. def_has_side_effects(AST_TemplateString, function(compressor) {
  10345. return any(this.segments, compressor);
  10346. });
  10347. })(function(node, func) {
  10348. node.DEFMETHOD("has_side_effects", func);
  10349. });
  10350. // determine if expression may throw
  10351. (function(def_may_throw) {
  10352. def_may_throw(AST_Node, return_true);
  10353. def_may_throw(AST_Constant, return_false);
  10354. def_may_throw(AST_EmptyStatement, return_false);
  10355. def_may_throw(AST_Lambda, return_false);
  10356. def_may_throw(AST_SymbolDeclaration, return_false);
  10357. def_may_throw(AST_This, return_false);
  10358. function any(list, compressor) {
  10359. for (var i = list.length; --i >= 0;)
  10360. if (list[i].may_throw(compressor))
  10361. return true;
  10362. return false;
  10363. }
  10364. def_may_throw(AST_Class, function(compressor) {
  10365. if (this.extends && this.extends.may_throw(compressor)) return true;
  10366. return any(this.properties, compressor);
  10367. });
  10368. def_may_throw(AST_Array, function(compressor) {
  10369. return any(this.elements, compressor);
  10370. });
  10371. def_may_throw(AST_Assign, function(compressor) {
  10372. if (this.right.may_throw(compressor)) return true;
  10373. if (!compressor.has_directive("use strict")
  10374. && this.operator == "="
  10375. && this.left instanceof AST_SymbolRef) {
  10376. return false;
  10377. }
  10378. return this.left.may_throw(compressor);
  10379. });
  10380. def_may_throw(AST_Binary, function(compressor) {
  10381. return this.left.may_throw(compressor)
  10382. || this.right.may_throw(compressor);
  10383. });
  10384. def_may_throw(AST_Block, function(compressor) {
  10385. return any(this.body, compressor);
  10386. });
  10387. def_may_throw(AST_Call, function(compressor) {
  10388. if (is_nullish(this, compressor)) return false;
  10389. if (any(this.args, compressor)) return true;
  10390. if (this.is_callee_pure(compressor)) return false;
  10391. if (this.expression.may_throw(compressor)) return true;
  10392. return !(this.expression instanceof AST_Lambda)
  10393. || any(this.expression.body, compressor);
  10394. });
  10395. def_may_throw(AST_Case, function(compressor) {
  10396. return this.expression.may_throw(compressor)
  10397. || any(this.body, compressor);
  10398. });
  10399. def_may_throw(AST_Conditional, function(compressor) {
  10400. return this.condition.may_throw(compressor)
  10401. || this.consequent.may_throw(compressor)
  10402. || this.alternative.may_throw(compressor);
  10403. });
  10404. def_may_throw(AST_Definitions, function(compressor) {
  10405. return any(this.definitions, compressor);
  10406. });
  10407. def_may_throw(AST_If, function(compressor) {
  10408. return this.condition.may_throw(compressor)
  10409. || this.body && this.body.may_throw(compressor)
  10410. || this.alternative && this.alternative.may_throw(compressor);
  10411. });
  10412. def_may_throw(AST_LabeledStatement, function(compressor) {
  10413. return this.body.may_throw(compressor);
  10414. });
  10415. def_may_throw(AST_Object, function(compressor) {
  10416. return any(this.properties, compressor);
  10417. });
  10418. def_may_throw(AST_ObjectProperty, function(compressor) {
  10419. // TODO key may throw too
  10420. return this.value ? this.value.may_throw(compressor) : false;
  10421. });
  10422. def_may_throw(AST_ClassProperty, function(compressor) {
  10423. return (
  10424. this.computed_key() && this.key.may_throw(compressor)
  10425. || this.static && this.value && this.value.may_throw(compressor)
  10426. );
  10427. });
  10428. def_may_throw(AST_ConciseMethod, function(compressor) {
  10429. return this.computed_key() && this.key.may_throw(compressor);
  10430. });
  10431. def_may_throw(AST_ObjectGetter, function(compressor) {
  10432. return this.computed_key() && this.key.may_throw(compressor);
  10433. });
  10434. def_may_throw(AST_ObjectSetter, function(compressor) {
  10435. return this.computed_key() && this.key.may_throw(compressor);
  10436. });
  10437. def_may_throw(AST_Return, function(compressor) {
  10438. return this.value && this.value.may_throw(compressor);
  10439. });
  10440. def_may_throw(AST_Sequence, function(compressor) {
  10441. return any(this.expressions, compressor);
  10442. });
  10443. def_may_throw(AST_SimpleStatement, function(compressor) {
  10444. return this.body.may_throw(compressor);
  10445. });
  10446. def_may_throw(AST_Dot, function(compressor) {
  10447. if (is_nullish(this, compressor)) return false;
  10448. return !this.optional && this.expression.may_throw_on_access(compressor)
  10449. || this.expression.may_throw(compressor);
  10450. });
  10451. def_may_throw(AST_Sub, function(compressor) {
  10452. if (is_nullish(this, compressor)) return false;
  10453. return !this.optional && this.expression.may_throw_on_access(compressor)
  10454. || this.expression.may_throw(compressor)
  10455. || this.property.may_throw(compressor);
  10456. });
  10457. def_may_throw(AST_Chain, function(compressor) {
  10458. return this.expression.may_throw(compressor);
  10459. });
  10460. def_may_throw(AST_Switch, function(compressor) {
  10461. return this.expression.may_throw(compressor)
  10462. || any(this.body, compressor);
  10463. });
  10464. def_may_throw(AST_SymbolRef, function(compressor) {
  10465. return !this.is_declared(compressor) && !pure_prop_access_globals.has(this.name);
  10466. });
  10467. def_may_throw(AST_SymbolClassProperty, return_false);
  10468. def_may_throw(AST_Try, function(compressor) {
  10469. return this.bcatch ? this.bcatch.may_throw(compressor) : any(this.body, compressor)
  10470. || this.bfinally && this.bfinally.may_throw(compressor);
  10471. });
  10472. def_may_throw(AST_Unary, function(compressor) {
  10473. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  10474. return false;
  10475. return this.expression.may_throw(compressor);
  10476. });
  10477. def_may_throw(AST_VarDef, function(compressor) {
  10478. if (!this.value) return false;
  10479. return this.value.may_throw(compressor);
  10480. });
  10481. })(function(node, func) {
  10482. node.DEFMETHOD("may_throw", func);
  10483. });
  10484. // determine if expression is constant
  10485. (function(def_is_constant_expression) {
  10486. function all_refs_local(scope) {
  10487. let result = true;
  10488. walk(this, node => {
  10489. if (node instanceof AST_SymbolRef) {
  10490. if (has_flag(this, INLINED)) {
  10491. result = false;
  10492. return walk_abort;
  10493. }
  10494. var def = node.definition();
  10495. if (
  10496. member(def, this.enclosed)
  10497. && !this.variables.has(def.name)
  10498. ) {
  10499. if (scope) {
  10500. var scope_def = scope.find_variable(node);
  10501. if (def.undeclared ? !scope_def : scope_def === def) {
  10502. result = "f";
  10503. return true;
  10504. }
  10505. }
  10506. result = false;
  10507. return walk_abort;
  10508. }
  10509. return true;
  10510. }
  10511. if (node instanceof AST_This && this instanceof AST_Arrow) {
  10512. // TODO check arguments too!
  10513. result = false;
  10514. return walk_abort;
  10515. }
  10516. });
  10517. return result;
  10518. }
  10519. def_is_constant_expression(AST_Node, return_false);
  10520. def_is_constant_expression(AST_Constant, return_true);
  10521. def_is_constant_expression(AST_Class, function(scope) {
  10522. if (this.extends && !this.extends.is_constant_expression(scope)) {
  10523. return false;
  10524. }
  10525. for (const prop of this.properties) {
  10526. if (prop.computed_key() && !prop.key.is_constant_expression(scope)) {
  10527. return false;
  10528. }
  10529. if (prop.static && prop.value && !prop.value.is_constant_expression(scope)) {
  10530. return false;
  10531. }
  10532. }
  10533. return all_refs_local.call(this, scope);
  10534. });
  10535. def_is_constant_expression(AST_Lambda, all_refs_local);
  10536. def_is_constant_expression(AST_Unary, function() {
  10537. return this.expression.is_constant_expression();
  10538. });
  10539. def_is_constant_expression(AST_Binary, function() {
  10540. return this.left.is_constant_expression()
  10541. && this.right.is_constant_expression();
  10542. });
  10543. def_is_constant_expression(AST_Array, function() {
  10544. return this.elements.every((l) => l.is_constant_expression());
  10545. });
  10546. def_is_constant_expression(AST_Object, function() {
  10547. return this.properties.every((l) => l.is_constant_expression());
  10548. });
  10549. def_is_constant_expression(AST_ObjectProperty, function() {
  10550. return !!(!(this.key instanceof AST_Node) && this.value && this.value.is_constant_expression());
  10551. });
  10552. })(function(node, func) {
  10553. node.DEFMETHOD("is_constant_expression", func);
  10554. });
  10555. // may_throw_on_access()
  10556. // returns true if this node may be null, undefined or contain `AST_Accessor`
  10557. (function(def_may_throw_on_access) {
  10558. AST_Node.DEFMETHOD("may_throw_on_access", function(compressor) {
  10559. return !compressor.option("pure_getters")
  10560. || this._dot_throw(compressor);
  10561. });
  10562. function is_strict(compressor) {
  10563. return /strict/.test(compressor.option("pure_getters"));
  10564. }
  10565. def_may_throw_on_access(AST_Node, is_strict);
  10566. def_may_throw_on_access(AST_Null, return_true);
  10567. def_may_throw_on_access(AST_Undefined, return_true);
  10568. def_may_throw_on_access(AST_Constant, return_false);
  10569. def_may_throw_on_access(AST_Array, return_false);
  10570. def_may_throw_on_access(AST_Object, function(compressor) {
  10571. if (!is_strict(compressor)) return false;
  10572. for (var i = this.properties.length; --i >=0;)
  10573. if (this.properties[i]._dot_throw(compressor)) return true;
  10574. return false;
  10575. });
  10576. // Do not be as strict with classes as we are with objects.
  10577. // Hopefully the community is not going to abuse static getters and setters.
  10578. // https://github.com/terser/terser/issues/724#issuecomment-643655656
  10579. def_may_throw_on_access(AST_Class, return_false);
  10580. def_may_throw_on_access(AST_ObjectProperty, return_false);
  10581. def_may_throw_on_access(AST_ObjectGetter, return_true);
  10582. def_may_throw_on_access(AST_Expansion, function(compressor) {
  10583. return this.expression._dot_throw(compressor);
  10584. });
  10585. def_may_throw_on_access(AST_Function, return_false);
  10586. def_may_throw_on_access(AST_Arrow, return_false);
  10587. def_may_throw_on_access(AST_UnaryPostfix, return_false);
  10588. def_may_throw_on_access(AST_UnaryPrefix, function() {
  10589. return this.operator == "void";
  10590. });
  10591. def_may_throw_on_access(AST_Binary, function(compressor) {
  10592. return (this.operator == "&&" || this.operator == "||" || this.operator == "??")
  10593. && (this.left._dot_throw(compressor) || this.right._dot_throw(compressor));
  10594. });
  10595. def_may_throw_on_access(AST_Assign, function(compressor) {
  10596. if (this.logical) return true;
  10597. return this.operator == "="
  10598. && this.right._dot_throw(compressor);
  10599. });
  10600. def_may_throw_on_access(AST_Conditional, function(compressor) {
  10601. return this.consequent._dot_throw(compressor)
  10602. || this.alternative._dot_throw(compressor);
  10603. });
  10604. def_may_throw_on_access(AST_Dot, function(compressor) {
  10605. if (!is_strict(compressor)) return false;
  10606. if (this.property == "prototype") {
  10607. return !(
  10608. this.expression instanceof AST_Function
  10609. || this.expression instanceof AST_Class
  10610. );
  10611. }
  10612. return true;
  10613. });
  10614. def_may_throw_on_access(AST_Chain, function(compressor) {
  10615. return this.expression._dot_throw(compressor);
  10616. });
  10617. def_may_throw_on_access(AST_Sequence, function(compressor) {
  10618. return this.tail_node()._dot_throw(compressor);
  10619. });
  10620. def_may_throw_on_access(AST_SymbolRef, function(compressor) {
  10621. if (this.name === "arguments") return false;
  10622. if (has_flag(this, UNDEFINED)) return true;
  10623. if (!is_strict(compressor)) return false;
  10624. if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
  10625. if (this.is_immutable()) return false;
  10626. var fixed = this.fixed_value();
  10627. return !fixed || fixed._dot_throw(compressor);
  10628. });
  10629. })(function(node, func) {
  10630. node.DEFMETHOD("_dot_throw", func);
  10631. });
  10632. function is_lhs(node, parent) {
  10633. if (parent instanceof AST_Unary && unary_side_effects.has(parent.operator)) return parent.expression;
  10634. if (parent instanceof AST_Assign && parent.left === node) return node;
  10635. }
  10636. (function(def_find_defs) {
  10637. function to_node(value, orig) {
  10638. if (value instanceof AST_Node) {
  10639. if (!(value instanceof AST_Constant)) {
  10640. // Value may be a function, an array including functions and even a complex assign / block expression,
  10641. // so it should never be shared in different places.
  10642. // Otherwise wrong information may be used in the compression phase
  10643. value = value.clone(true);
  10644. }
  10645. return make_node(value.CTOR, orig, value);
  10646. }
  10647. if (Array.isArray(value)) return make_node(AST_Array, orig, {
  10648. elements: value.map(function(value) {
  10649. return to_node(value, orig);
  10650. })
  10651. });
  10652. if (value && typeof value == "object") {
  10653. var props = [];
  10654. for (var key in value) if (HOP(value, key)) {
  10655. props.push(make_node(AST_ObjectKeyVal, orig, {
  10656. key: key,
  10657. value: to_node(value[key], orig)
  10658. }));
  10659. }
  10660. return make_node(AST_Object, orig, {
  10661. properties: props
  10662. });
  10663. }
  10664. return make_node_from_constant(value, orig);
  10665. }
  10666. AST_Toplevel.DEFMETHOD("resolve_defines", function(compressor) {
  10667. if (!compressor.option("global_defs")) return this;
  10668. this.figure_out_scope({ ie8: compressor.option("ie8") });
  10669. return this.transform(new TreeTransformer(function(node) {
  10670. var def = node._find_defs(compressor, "");
  10671. if (!def) return;
  10672. var level = 0, child = node, parent;
  10673. while (parent = this.parent(level++)) {
  10674. if (!(parent instanceof AST_PropAccess)) break;
  10675. if (parent.expression !== child) break;
  10676. child = parent;
  10677. }
  10678. if (is_lhs(child, parent)) {
  10679. return;
  10680. }
  10681. return def;
  10682. }));
  10683. });
  10684. def_find_defs(AST_Node, noop);
  10685. def_find_defs(AST_Chain, function(compressor, suffix) {
  10686. return this.expression._find_defs(compressor, suffix);
  10687. });
  10688. def_find_defs(AST_Dot, function(compressor, suffix) {
  10689. return this.expression._find_defs(compressor, "." + this.property + suffix);
  10690. });
  10691. def_find_defs(AST_SymbolDeclaration, function() {
  10692. if (!this.global()) return;
  10693. });
  10694. def_find_defs(AST_SymbolRef, function(compressor, suffix) {
  10695. if (!this.global()) return;
  10696. var defines = compressor.option("global_defs");
  10697. var name = this.name + suffix;
  10698. if (HOP(defines, name)) return to_node(defines[name], this);
  10699. });
  10700. })(function(node, func) {
  10701. node.DEFMETHOD("_find_defs", func);
  10702. });
  10703. // method to negate an expression
  10704. (function(def_negate) {
  10705. function basic_negation(exp) {
  10706. return make_node(AST_UnaryPrefix, exp, {
  10707. operator: "!",
  10708. expression: exp
  10709. });
  10710. }
  10711. function best(orig, alt, first_in_statement) {
  10712. var negated = basic_negation(orig);
  10713. if (first_in_statement) {
  10714. var stat = make_node(AST_SimpleStatement, alt, {
  10715. body: alt
  10716. });
  10717. return best_of_expression(negated, stat) === stat ? alt : negated;
  10718. }
  10719. return best_of_expression(negated, alt);
  10720. }
  10721. def_negate(AST_Node, function() {
  10722. return basic_negation(this);
  10723. });
  10724. def_negate(AST_Statement, function() {
  10725. throw new Error("Cannot negate a statement");
  10726. });
  10727. def_negate(AST_Function, function() {
  10728. return basic_negation(this);
  10729. });
  10730. def_negate(AST_Arrow, function() {
  10731. return basic_negation(this);
  10732. });
  10733. def_negate(AST_UnaryPrefix, function() {
  10734. if (this.operator == "!")
  10735. return this.expression;
  10736. return basic_negation(this);
  10737. });
  10738. def_negate(AST_Sequence, function(compressor) {
  10739. var expressions = this.expressions.slice();
  10740. expressions.push(expressions.pop().negate(compressor));
  10741. return make_sequence(this, expressions);
  10742. });
  10743. def_negate(AST_Conditional, function(compressor, first_in_statement) {
  10744. var self = this.clone();
  10745. self.consequent = self.consequent.negate(compressor);
  10746. self.alternative = self.alternative.negate(compressor);
  10747. return best(this, self, first_in_statement);
  10748. });
  10749. def_negate(AST_Binary, function(compressor, first_in_statement) {
  10750. var self = this.clone(), op = this.operator;
  10751. if (compressor.option("unsafe_comps")) {
  10752. switch (op) {
  10753. case "<=" : self.operator = ">" ; return self;
  10754. case "<" : self.operator = ">=" ; return self;
  10755. case ">=" : self.operator = "<" ; return self;
  10756. case ">" : self.operator = "<=" ; return self;
  10757. }
  10758. }
  10759. switch (op) {
  10760. case "==" : self.operator = "!="; return self;
  10761. case "!=" : self.operator = "=="; return self;
  10762. case "===": self.operator = "!=="; return self;
  10763. case "!==": self.operator = "==="; return self;
  10764. case "&&":
  10765. self.operator = "||";
  10766. self.left = self.left.negate(compressor, first_in_statement);
  10767. self.right = self.right.negate(compressor);
  10768. return best(this, self, first_in_statement);
  10769. case "||":
  10770. self.operator = "&&";
  10771. self.left = self.left.negate(compressor, first_in_statement);
  10772. self.right = self.right.negate(compressor);
  10773. return best(this, self, first_in_statement);
  10774. }
  10775. return basic_negation(this);
  10776. });
  10777. })(function(node, func) {
  10778. node.DEFMETHOD("negate", function(compressor, first_in_statement) {
  10779. return func.call(this, compressor, first_in_statement);
  10780. });
  10781. });
  10782. // Is the callee of this function pure?
  10783. 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");
  10784. AST_Call.DEFMETHOD("is_callee_pure", function(compressor) {
  10785. if (compressor.option("unsafe")) {
  10786. var expr = this.expression;
  10787. var first_arg = (this.args && this.args[0] && this.args[0].evaluate(compressor));
  10788. if (
  10789. expr.expression && expr.expression.name === "hasOwnProperty" &&
  10790. (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)
  10791. ) {
  10792. return false;
  10793. }
  10794. if (is_undeclared_ref(expr) && global_pure_fns.has(expr.name)) return true;
  10795. if (
  10796. expr instanceof AST_Dot
  10797. && is_undeclared_ref(expr.expression)
  10798. && is_pure_native_fn(expr.expression.name, expr.property)
  10799. ) {
  10800. return true;
  10801. }
  10802. }
  10803. return !!has_annotation(this, _PURE) || !compressor.pure_funcs(this);
  10804. });
  10805. // If I call this, is it a pure function?
  10806. AST_Node.DEFMETHOD("is_call_pure", return_false);
  10807. AST_Dot.DEFMETHOD("is_call_pure", function(compressor) {
  10808. if (!compressor.option("unsafe")) return;
  10809. const expr = this.expression;
  10810. let native_obj;
  10811. if (expr instanceof AST_Array) {
  10812. native_obj = "Array";
  10813. } else if (expr.is_boolean()) {
  10814. native_obj = "Boolean";
  10815. } else if (expr.is_number(compressor)) {
  10816. native_obj = "Number";
  10817. } else if (expr instanceof AST_RegExp) {
  10818. native_obj = "RegExp";
  10819. } else if (expr.is_string(compressor)) {
  10820. native_obj = "String";
  10821. } else if (!this.may_throw_on_access(compressor)) {
  10822. native_obj = "Object";
  10823. }
  10824. return native_obj != null && is_pure_native_method(native_obj, this.property);
  10825. });
  10826. // tell me if a statement aborts
  10827. const aborts = (thing) => thing && thing.aborts();
  10828. (function(def_aborts) {
  10829. def_aborts(AST_Statement, return_null);
  10830. def_aborts(AST_Jump, return_this);
  10831. function block_aborts() {
  10832. for (var i = 0; i < this.body.length; i++) {
  10833. if (aborts(this.body[i])) {
  10834. return this.body[i];
  10835. }
  10836. }
  10837. return null;
  10838. }
  10839. def_aborts(AST_Import, function() { return null; });
  10840. def_aborts(AST_BlockStatement, block_aborts);
  10841. def_aborts(AST_SwitchBranch, block_aborts);
  10842. def_aborts(AST_If, function() {
  10843. return this.alternative && aborts(this.body) && aborts(this.alternative) && this;
  10844. });
  10845. })(function(node, func) {
  10846. node.DEFMETHOD("aborts", func);
  10847. });
  10848. function is_modified(compressor, tw, node, value, level, immutable) {
  10849. var parent = tw.parent(level);
  10850. var lhs = is_lhs(node, parent);
  10851. if (lhs) return lhs;
  10852. if (!immutable
  10853. && parent instanceof AST_Call
  10854. && parent.expression === node
  10855. && !(value instanceof AST_Arrow)
  10856. && !(value instanceof AST_Class)
  10857. && !parent.is_callee_pure(compressor)
  10858. && (!(value instanceof AST_Function)
  10859. || !(parent instanceof AST_New) && value.contains_this())) {
  10860. return true;
  10861. }
  10862. if (parent instanceof AST_Array) {
  10863. return is_modified(compressor, tw, parent, parent, level + 1);
  10864. }
  10865. if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  10866. var obj = tw.parent(level + 1);
  10867. return is_modified(compressor, tw, obj, obj, level + 2);
  10868. }
  10869. if (parent instanceof AST_PropAccess && parent.expression === node) {
  10870. var prop = read_property(value, parent.property);
  10871. return !immutable && is_modified(compressor, tw, parent, prop, level + 1);
  10872. }
  10873. }
  10874. /***********************************************************************
  10875. A JavaScript tokenizer / parser / beautifier / compressor.
  10876. https://github.com/mishoo/UglifyJS2
  10877. -------------------------------- (C) ---------------------------------
  10878. Author: Mihai Bazon
  10879. <mihai.bazon@gmail.com>
  10880. http://mihai.bazon.net/blog
  10881. Distributed under the BSD license:
  10882. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  10883. Redistribution and use in source and binary forms, with or without
  10884. modification, are permitted provided that the following conditions
  10885. are met:
  10886. * Redistributions of source code must retain the above
  10887. copyright notice, this list of conditions and the following
  10888. disclaimer.
  10889. * Redistributions in binary form must reproduce the above
  10890. copyright notice, this list of conditions and the following
  10891. disclaimer in the documentation and/or other materials
  10892. provided with the distribution.
  10893. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  10894. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10895. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10896. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  10897. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  10898. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10899. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10900. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  10901. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  10902. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  10903. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  10904. SUCH DAMAGE.
  10905. ***********************************************************************/
  10906. // methods to evaluate a constant expression
  10907. function def_eval(node, func) {
  10908. node.DEFMETHOD("_eval", func);
  10909. }
  10910. // Used to propagate a nullish short-circuit signal upwards through the chain.
  10911. const nullish = Symbol("This AST_Chain is nullish");
  10912. // If the node has been successfully reduced to a constant,
  10913. // then its value is returned; otherwise the element itself
  10914. // is returned.
  10915. // They can be distinguished as constant value is never a
  10916. // descendant of AST_Node.
  10917. AST_Node.DEFMETHOD("evaluate", function (compressor) {
  10918. if (!compressor.option("evaluate"))
  10919. return this;
  10920. var val = this._eval(compressor, 1);
  10921. if (!val || val instanceof RegExp)
  10922. return val;
  10923. if (typeof val == "function" || typeof val == "object" || val == nullish)
  10924. return this;
  10925. return val;
  10926. });
  10927. var unaryPrefix = makePredicate("! ~ - + void");
  10928. AST_Node.DEFMETHOD("is_constant", function () {
  10929. // Accomodate when compress option evaluate=false
  10930. // as well as the common constant expressions !0 and -1
  10931. if (this instanceof AST_Constant) {
  10932. return !(this instanceof AST_RegExp);
  10933. } else {
  10934. return this instanceof AST_UnaryPrefix
  10935. && this.expression instanceof AST_Constant
  10936. && unaryPrefix.has(this.operator);
  10937. }
  10938. });
  10939. def_eval(AST_Statement, function () {
  10940. throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start));
  10941. });
  10942. def_eval(AST_Lambda, return_this);
  10943. def_eval(AST_Class, return_this);
  10944. def_eval(AST_Node, return_this);
  10945. def_eval(AST_Constant, function () {
  10946. return this.getValue();
  10947. });
  10948. def_eval(AST_BigInt, return_this);
  10949. def_eval(AST_RegExp, function (compressor) {
  10950. let evaluated = compressor.evaluated_regexps.get(this);
  10951. if (evaluated === undefined) {
  10952. try {
  10953. evaluated = (0, eval)(this.print_to_string());
  10954. } catch (e) {
  10955. evaluated = null;
  10956. }
  10957. compressor.evaluated_regexps.set(this, evaluated);
  10958. }
  10959. return evaluated || this;
  10960. });
  10961. def_eval(AST_TemplateString, function () {
  10962. if (this.segments.length !== 1) return this;
  10963. return this.segments[0].value;
  10964. });
  10965. def_eval(AST_Function, function (compressor) {
  10966. if (compressor.option("unsafe")) {
  10967. var fn = function () { };
  10968. fn.node = this;
  10969. fn.toString = () => this.print_to_string();
  10970. return fn;
  10971. }
  10972. return this;
  10973. });
  10974. def_eval(AST_Array, function (compressor, depth) {
  10975. if (compressor.option("unsafe")) {
  10976. var elements = [];
  10977. for (var i = 0, len = this.elements.length; i < len; i++) {
  10978. var element = this.elements[i];
  10979. var value = element._eval(compressor, depth);
  10980. if (element === value)
  10981. return this;
  10982. elements.push(value);
  10983. }
  10984. return elements;
  10985. }
  10986. return this;
  10987. });
  10988. def_eval(AST_Object, function (compressor, depth) {
  10989. if (compressor.option("unsafe")) {
  10990. var val = {};
  10991. for (var i = 0, len = this.properties.length; i < len; i++) {
  10992. var prop = this.properties[i];
  10993. if (prop instanceof AST_Expansion)
  10994. return this;
  10995. var key = prop.key;
  10996. if (key instanceof AST_Symbol) {
  10997. key = key.name;
  10998. } else if (key instanceof AST_Node) {
  10999. key = key._eval(compressor, depth);
  11000. if (key === prop.key)
  11001. return this;
  11002. }
  11003. if (typeof Object.prototype[key] === "function") {
  11004. return this;
  11005. }
  11006. if (prop.value instanceof AST_Function)
  11007. continue;
  11008. val[key] = prop.value._eval(compressor, depth);
  11009. if (val[key] === prop.value)
  11010. return this;
  11011. }
  11012. return val;
  11013. }
  11014. return this;
  11015. });
  11016. var non_converting_unary = makePredicate("! typeof void");
  11017. def_eval(AST_UnaryPrefix, function (compressor, depth) {
  11018. var e = this.expression;
  11019. // Function would be evaluated to an array and so typeof would
  11020. // incorrectly return 'object'. Hence making is a special case.
  11021. if (compressor.option("typeofs")
  11022. && this.operator == "typeof"
  11023. && (e instanceof AST_Lambda
  11024. || e instanceof AST_SymbolRef
  11025. && e.fixed_value() instanceof AST_Lambda)) {
  11026. return typeof function () { };
  11027. }
  11028. if (!non_converting_unary.has(this.operator))
  11029. depth++;
  11030. e = e._eval(compressor, depth);
  11031. if (e === this.expression)
  11032. return this;
  11033. switch (this.operator) {
  11034. case "!": return !e;
  11035. case "typeof":
  11036. // typeof <RegExp> returns "object" or "function" on different platforms
  11037. // so cannot evaluate reliably
  11038. if (e instanceof RegExp)
  11039. return this;
  11040. return typeof e;
  11041. case "void": return void e;
  11042. case "~": return ~e;
  11043. case "-": return -e;
  11044. case "+": return +e;
  11045. }
  11046. return this;
  11047. });
  11048. var non_converting_binary = makePredicate("&& || ?? === !==");
  11049. const identity_comparison = makePredicate("== != === !==");
  11050. const has_identity = value => typeof value === "object"
  11051. || typeof value === "function"
  11052. || typeof value === "symbol";
  11053. def_eval(AST_Binary, function (compressor, depth) {
  11054. if (!non_converting_binary.has(this.operator))
  11055. depth++;
  11056. var left = this.left._eval(compressor, depth);
  11057. if (left === this.left)
  11058. return this;
  11059. var right = this.right._eval(compressor, depth);
  11060. if (right === this.right)
  11061. return this;
  11062. var result;
  11063. if (left != null
  11064. && right != null
  11065. && identity_comparison.has(this.operator)
  11066. && has_identity(left)
  11067. && has_identity(right)
  11068. && typeof left === typeof right) {
  11069. // Do not compare by reference
  11070. return this;
  11071. }
  11072. switch (this.operator) {
  11073. case "&&": result = left && right; break;
  11074. case "||": result = left || right; break;
  11075. case "??": result = left != null ? left : right; break;
  11076. case "|": result = left | right; break;
  11077. case "&": result = left & right; break;
  11078. case "^": result = left ^ right; break;
  11079. case "+": result = left + right; break;
  11080. case "*": result = left * right; break;
  11081. case "**": result = Math.pow(left, right); break;
  11082. case "/": result = left / right; break;
  11083. case "%": result = left % right; break;
  11084. case "-": result = left - right; break;
  11085. case "<<": result = left << right; break;
  11086. case ">>": result = left >> right; break;
  11087. case ">>>": result = left >>> right; break;
  11088. case "==": result = left == right; break;
  11089. case "===": result = left === right; break;
  11090. case "!=": result = left != right; break;
  11091. case "!==": result = left !== right; break;
  11092. case "<": result = left < right; break;
  11093. case "<=": result = left <= right; break;
  11094. case ">": result = left > right; break;
  11095. case ">=": result = left >= right; break;
  11096. default:
  11097. return this;
  11098. }
  11099. if (isNaN(result) && compressor.find_parent(AST_With)) {
  11100. // leave original expression as is
  11101. return this;
  11102. }
  11103. return result;
  11104. });
  11105. def_eval(AST_Conditional, function (compressor, depth) {
  11106. var condition = this.condition._eval(compressor, depth);
  11107. if (condition === this.condition)
  11108. return this;
  11109. var node = condition ? this.consequent : this.alternative;
  11110. var value = node._eval(compressor, depth);
  11111. return value === node ? this : value;
  11112. });
  11113. // Set of AST_SymbolRef which are currently being evaluated.
  11114. // Avoids infinite recursion of ._eval()
  11115. const reentrant_ref_eval = new Set();
  11116. def_eval(AST_SymbolRef, function (compressor, depth) {
  11117. if (reentrant_ref_eval.has(this))
  11118. return this;
  11119. var fixed = this.fixed_value();
  11120. if (!fixed)
  11121. return this;
  11122. reentrant_ref_eval.add(this);
  11123. const value = fixed._eval(compressor, depth);
  11124. reentrant_ref_eval.delete(this);
  11125. if (value === fixed)
  11126. return this;
  11127. if (value && typeof value == "object") {
  11128. var escaped = this.definition().escaped;
  11129. if (escaped && depth > escaped)
  11130. return this;
  11131. }
  11132. return value;
  11133. });
  11134. const global_objs = { Array, Math, Number, Object, String };
  11135. const regexp_flags = new Set([
  11136. "dotAll",
  11137. "global",
  11138. "ignoreCase",
  11139. "multiline",
  11140. "sticky",
  11141. "unicode",
  11142. ]);
  11143. def_eval(AST_PropAccess, function (compressor, depth) {
  11144. const obj = this.expression._eval(compressor, depth);
  11145. if (obj === nullish || (this.optional && obj == null)) return nullish;
  11146. if (compressor.option("unsafe")) {
  11147. var key = this.property;
  11148. if (key instanceof AST_Node) {
  11149. key = key._eval(compressor, depth);
  11150. if (key === this.property)
  11151. return this;
  11152. }
  11153. var exp = this.expression;
  11154. var val;
  11155. if (is_undeclared_ref(exp)) {
  11156. var aa;
  11157. var first_arg = exp.name === "hasOwnProperty"
  11158. && key === "call"
  11159. && (aa = compressor.parent() && compressor.parent().args)
  11160. && (aa && aa[0]
  11161. && aa[0].evaluate(compressor));
  11162. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  11163. if (first_arg == null || first_arg.thedef && first_arg.thedef.undeclared) {
  11164. return this.clone();
  11165. }
  11166. if (!is_pure_native_value(exp.name, key))
  11167. return this;
  11168. val = global_objs[exp.name];
  11169. } else {
  11170. val = exp._eval(compressor, depth + 1);
  11171. if (val instanceof RegExp) {
  11172. if (key == "source") {
  11173. return regexp_source_fix(val.source);
  11174. } else if (key == "flags" || regexp_flags.has(key)) {
  11175. return val[key];
  11176. }
  11177. }
  11178. if (!val || val === exp || !HOP(val, key))
  11179. return this;
  11180. if (typeof val == "function")
  11181. switch (key) {
  11182. case "name":
  11183. return val.node.name ? val.node.name.name : "";
  11184. case "length":
  11185. return val.node.length_property();
  11186. default:
  11187. return this;
  11188. }
  11189. }
  11190. return val[key];
  11191. }
  11192. return this;
  11193. });
  11194. def_eval(AST_Chain, function (compressor, depth) {
  11195. const evaluated = this.expression._eval(compressor, depth);
  11196. return evaluated === nullish
  11197. ? undefined
  11198. : evaluated === this.expression
  11199. ? this
  11200. : evaluated;
  11201. });
  11202. def_eval(AST_Call, function (compressor, depth) {
  11203. var exp = this.expression;
  11204. const callee = exp._eval(compressor, depth);
  11205. if (callee === nullish || (this.optional && callee == null)) return nullish;
  11206. if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
  11207. var key = exp.property;
  11208. if (key instanceof AST_Node) {
  11209. key = key._eval(compressor, depth);
  11210. if (key === exp.property)
  11211. return this;
  11212. }
  11213. var val;
  11214. var e = exp.expression;
  11215. if (is_undeclared_ref(e)) {
  11216. var first_arg = e.name === "hasOwnProperty" &&
  11217. key === "call" &&
  11218. (this.args[0] && this.args[0].evaluate(compressor));
  11219. first_arg = first_arg instanceof AST_Dot ? first_arg.expression : first_arg;
  11220. if ((first_arg == null || first_arg.thedef && first_arg.thedef.undeclared)) {
  11221. return this.clone();
  11222. }
  11223. if (!is_pure_native_fn(e.name, key)) return this;
  11224. val = global_objs[e.name];
  11225. } else {
  11226. val = e._eval(compressor, depth + 1);
  11227. if (val === e || !val)
  11228. return this;
  11229. if (!is_pure_native_method(val.constructor.name, key))
  11230. return this;
  11231. }
  11232. var args = [];
  11233. for (var i = 0, len = this.args.length; i < len; i++) {
  11234. var arg = this.args[i];
  11235. var value = arg._eval(compressor, depth);
  11236. if (arg === value)
  11237. return this;
  11238. if (arg instanceof AST_Lambda)
  11239. return this;
  11240. args.push(value);
  11241. }
  11242. try {
  11243. return val[key].apply(val, args);
  11244. } catch (ex) {
  11245. // We don't really care
  11246. }
  11247. }
  11248. return this;
  11249. });
  11250. // Also a subclass of AST_Call
  11251. def_eval(AST_New, return_this);
  11252. /***********************************************************************
  11253. A JavaScript tokenizer / parser / beautifier / compressor.
  11254. https://github.com/mishoo/UglifyJS2
  11255. -------------------------------- (C) ---------------------------------
  11256. Author: Mihai Bazon
  11257. <mihai.bazon@gmail.com>
  11258. http://mihai.bazon.net/blog
  11259. Distributed under the BSD license:
  11260. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11261. Redistribution and use in source and binary forms, with or without
  11262. modification, are permitted provided that the following conditions
  11263. are met:
  11264. * Redistributions of source code must retain the above
  11265. copyright notice, this list of conditions and the following
  11266. disclaimer.
  11267. * Redistributions in binary form must reproduce the above
  11268. copyright notice, this list of conditions and the following
  11269. disclaimer in the documentation and/or other materials
  11270. provided with the distribution.
  11271. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11272. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11273. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11274. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11275. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11276. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11277. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11278. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11279. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11280. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11281. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11282. SUCH DAMAGE.
  11283. ***********************************************************************/
  11284. // AST_Node#drop_side_effect_free() gets called when we don't care about the value,
  11285. // only about side effects. We'll be defining this method for each node type in this module
  11286. //
  11287. // Examples:
  11288. // foo++ -> foo++
  11289. // 1 + func() -> func()
  11290. // 10 -> (nothing)
  11291. // knownPureFunc(foo++) -> foo++
  11292. function def_drop_side_effect_free(node, func) {
  11293. node.DEFMETHOD("drop_side_effect_free", func);
  11294. }
  11295. // Drop side-effect-free elements from an array of expressions.
  11296. // Returns an array of expressions with side-effects or null
  11297. // if all elements were dropped. Note: original array may be
  11298. // returned if nothing changed.
  11299. function trim(nodes, compressor, first_in_statement) {
  11300. var len = nodes.length;
  11301. if (!len) return null;
  11302. var ret = [], changed = false;
  11303. for (var i = 0; i < len; i++) {
  11304. var node = nodes[i].drop_side_effect_free(compressor, first_in_statement);
  11305. changed |= node !== nodes[i];
  11306. if (node) {
  11307. ret.push(node);
  11308. first_in_statement = false;
  11309. }
  11310. }
  11311. return changed ? ret.length ? ret : null : nodes;
  11312. }
  11313. def_drop_side_effect_free(AST_Node, return_this);
  11314. def_drop_side_effect_free(AST_Constant, return_null);
  11315. def_drop_side_effect_free(AST_This, return_null);
  11316. def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
  11317. if (is_nullish_shortcircuited(this, compressor)) {
  11318. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  11319. }
  11320. if (!this.is_callee_pure(compressor)) {
  11321. if (this.expression.is_call_pure(compressor)) {
  11322. var exprs = this.args.slice();
  11323. exprs.unshift(this.expression.expression);
  11324. exprs = trim(exprs, compressor, first_in_statement);
  11325. return exprs && make_sequence(this, exprs);
  11326. }
  11327. if (is_func_expr(this.expression)
  11328. && (!this.expression.name || !this.expression.name.definition().references.length)) {
  11329. var node = this.clone();
  11330. node.expression.process_expression(false, compressor);
  11331. return node;
  11332. }
  11333. return this;
  11334. }
  11335. var args = trim(this.args, compressor, first_in_statement);
  11336. return args && make_sequence(this, args);
  11337. });
  11338. def_drop_side_effect_free(AST_Accessor, return_null);
  11339. def_drop_side_effect_free(AST_Function, return_null);
  11340. def_drop_side_effect_free(AST_Arrow, return_null);
  11341. def_drop_side_effect_free(AST_Class, function (compressor) {
  11342. const with_effects = [];
  11343. const trimmed_extends = this.extends && this.extends.drop_side_effect_free(compressor);
  11344. if (trimmed_extends)
  11345. with_effects.push(trimmed_extends);
  11346. for (const prop of this.properties) {
  11347. const trimmed_prop = prop.drop_side_effect_free(compressor);
  11348. if (trimmed_prop)
  11349. with_effects.push(trimmed_prop);
  11350. }
  11351. if (!with_effects.length)
  11352. return null;
  11353. return make_sequence(this, with_effects);
  11354. });
  11355. def_drop_side_effect_free(AST_Binary, function (compressor, first_in_statement) {
  11356. var right = this.right.drop_side_effect_free(compressor);
  11357. if (!right)
  11358. return this.left.drop_side_effect_free(compressor, first_in_statement);
  11359. if (lazy_op.has(this.operator)) {
  11360. if (right === this.right)
  11361. return this;
  11362. var node = this.clone();
  11363. node.right = right;
  11364. return node;
  11365. } else {
  11366. var left = this.left.drop_side_effect_free(compressor, first_in_statement);
  11367. if (!left)
  11368. return this.right.drop_side_effect_free(compressor, first_in_statement);
  11369. return make_sequence(this, [left, right]);
  11370. }
  11371. });
  11372. def_drop_side_effect_free(AST_Assign, function (compressor) {
  11373. if (this.logical)
  11374. return this;
  11375. var left = this.left;
  11376. if (left.has_side_effects(compressor)
  11377. || compressor.has_directive("use strict")
  11378. && left instanceof AST_PropAccess
  11379. && left.expression.is_constant()) {
  11380. return this;
  11381. }
  11382. set_flag(this, WRITE_ONLY);
  11383. while (left instanceof AST_PropAccess) {
  11384. left = left.expression;
  11385. }
  11386. if (left.is_constant_expression(compressor.find_parent(AST_Scope))) {
  11387. return this.right.drop_side_effect_free(compressor);
  11388. }
  11389. return this;
  11390. });
  11391. def_drop_side_effect_free(AST_Conditional, function (compressor) {
  11392. var consequent = this.consequent.drop_side_effect_free(compressor);
  11393. var alternative = this.alternative.drop_side_effect_free(compressor);
  11394. if (consequent === this.consequent && alternative === this.alternative)
  11395. return this;
  11396. if (!consequent)
  11397. return alternative ? make_node(AST_Binary, this, {
  11398. operator: "||",
  11399. left: this.condition,
  11400. right: alternative
  11401. }) : this.condition.drop_side_effect_free(compressor);
  11402. if (!alternative)
  11403. return make_node(AST_Binary, this, {
  11404. operator: "&&",
  11405. left: this.condition,
  11406. right: consequent
  11407. });
  11408. var node = this.clone();
  11409. node.consequent = consequent;
  11410. node.alternative = alternative;
  11411. return node;
  11412. });
  11413. def_drop_side_effect_free(AST_Unary, function (compressor, first_in_statement) {
  11414. if (unary_side_effects.has(this.operator)) {
  11415. if (!this.expression.has_side_effects(compressor)) {
  11416. set_flag(this, WRITE_ONLY);
  11417. } else {
  11418. clear_flag(this, WRITE_ONLY);
  11419. }
  11420. return this;
  11421. }
  11422. if (this.operator == "typeof" && this.expression instanceof AST_SymbolRef)
  11423. return null;
  11424. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  11425. if (first_in_statement && expression && is_iife_call(expression)) {
  11426. if (expression === this.expression && this.operator == "!")
  11427. return this;
  11428. return expression.negate(compressor, first_in_statement);
  11429. }
  11430. return expression;
  11431. });
  11432. def_drop_side_effect_free(AST_SymbolRef, function (compressor) {
  11433. const safe_access = this.is_declared(compressor)
  11434. || pure_prop_access_globals.has(this.name);
  11435. return safe_access ? null : this;
  11436. });
  11437. def_drop_side_effect_free(AST_Object, function (compressor, first_in_statement) {
  11438. var values = trim(this.properties, compressor, first_in_statement);
  11439. return values && make_sequence(this, values);
  11440. });
  11441. def_drop_side_effect_free(AST_ObjectProperty, function (compressor, first_in_statement) {
  11442. const computed_key = this instanceof AST_ObjectKeyVal && this.key instanceof AST_Node;
  11443. const key = computed_key && this.key.drop_side_effect_free(compressor, first_in_statement);
  11444. const value = this.value && this.value.drop_side_effect_free(compressor, first_in_statement);
  11445. if (key && value) {
  11446. return make_sequence(this, [key, value]);
  11447. }
  11448. return key || value;
  11449. });
  11450. def_drop_side_effect_free(AST_ClassProperty, function (compressor) {
  11451. const key = this.computed_key() && this.key.drop_side_effect_free(compressor);
  11452. const value = this.static && this.value
  11453. && this.value.drop_side_effect_free(compressor);
  11454. if (key && value)
  11455. return make_sequence(this, [key, value]);
  11456. return key || value || null;
  11457. });
  11458. def_drop_side_effect_free(AST_ConciseMethod, function () {
  11459. return this.computed_key() ? this.key : null;
  11460. });
  11461. def_drop_side_effect_free(AST_ObjectGetter, function () {
  11462. return this.computed_key() ? this.key : null;
  11463. });
  11464. def_drop_side_effect_free(AST_ObjectSetter, function () {
  11465. return this.computed_key() ? this.key : null;
  11466. });
  11467. def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
  11468. var values = trim(this.elements, compressor, first_in_statement);
  11469. return values && make_sequence(this, values);
  11470. });
  11471. def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
  11472. if (is_nullish_shortcircuited(this, compressor)) {
  11473. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  11474. }
  11475. if (this.expression.may_throw_on_access(compressor)) return this;
  11476. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  11477. });
  11478. def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
  11479. if (is_nullish_shortcircuited(this, compressor)) {
  11480. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  11481. }
  11482. if (this.expression.may_throw_on_access(compressor)) return this;
  11483. var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
  11484. if (!expression)
  11485. return this.property.drop_side_effect_free(compressor, first_in_statement);
  11486. var property = this.property.drop_side_effect_free(compressor);
  11487. if (!property)
  11488. return expression;
  11489. return make_sequence(this, [expression, property]);
  11490. });
  11491. def_drop_side_effect_free(AST_Chain, function (compressor, first_in_statement) {
  11492. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  11493. });
  11494. def_drop_side_effect_free(AST_Sequence, function (compressor) {
  11495. var last = this.tail_node();
  11496. var expr = last.drop_side_effect_free(compressor);
  11497. if (expr === last)
  11498. return this;
  11499. var expressions = this.expressions.slice(0, -1);
  11500. if (expr)
  11501. expressions.push(expr);
  11502. if (!expressions.length) {
  11503. return make_node(AST_Number, this, { value: 0 });
  11504. }
  11505. return make_sequence(this, expressions);
  11506. });
  11507. def_drop_side_effect_free(AST_Expansion, function (compressor, first_in_statement) {
  11508. return this.expression.drop_side_effect_free(compressor, first_in_statement);
  11509. });
  11510. def_drop_side_effect_free(AST_TemplateSegment, return_null);
  11511. def_drop_side_effect_free(AST_TemplateString, function (compressor) {
  11512. var values = trim(this.segments, compressor, first_in_statement);
  11513. return values && make_sequence(this, values);
  11514. });
  11515. /***********************************************************************
  11516. A JavaScript tokenizer / parser / beautifier / compressor.
  11517. https://github.com/mishoo/UglifyJS2
  11518. -------------------------------- (C) ---------------------------------
  11519. Author: Mihai Bazon
  11520. <mihai.bazon@gmail.com>
  11521. http://mihai.bazon.net/blog
  11522. Distributed under the BSD license:
  11523. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  11524. Redistribution and use in source and binary forms, with or without
  11525. modification, are permitted provided that the following conditions
  11526. are met:
  11527. * Redistributions of source code must retain the above
  11528. copyright notice, this list of conditions and the following
  11529. disclaimer.
  11530. * Redistributions in binary form must reproduce the above
  11531. copyright notice, this list of conditions and the following
  11532. disclaimer in the documentation and/or other materials
  11533. provided with the distribution.
  11534. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  11535. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  11536. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11537. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  11538. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  11539. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11540. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  11541. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11542. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  11543. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  11544. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  11545. SUCH DAMAGE.
  11546. ***********************************************************************/
  11547. // Define the method AST_Node#reduce_vars, which goes through the AST in
  11548. // execution order to perform basic flow analysis
  11549. function def_reduce_vars(node, func) {
  11550. node.DEFMETHOD("reduce_vars", func);
  11551. }
  11552. def_reduce_vars(AST_Node, noop);
  11553. function reset_def(compressor, def) {
  11554. def.assignments = 0;
  11555. def.chained = false;
  11556. def.direct_access = false;
  11557. def.escaped = 0;
  11558. def.recursive_refs = 0;
  11559. def.references = [];
  11560. def.single_use = undefined;
  11561. if (def.scope.pinned()) {
  11562. def.fixed = false;
  11563. } else if (def.orig[0] instanceof AST_SymbolConst || !compressor.exposed(def)) {
  11564. def.fixed = def.init;
  11565. } else {
  11566. def.fixed = false;
  11567. }
  11568. }
  11569. function reset_variables(tw, compressor, node) {
  11570. node.variables.forEach(function(def) {
  11571. reset_def(compressor, def);
  11572. if (def.fixed === null) {
  11573. tw.defs_to_safe_ids.set(def.id, tw.safe_ids);
  11574. mark(tw, def, true);
  11575. } else if (def.fixed) {
  11576. tw.loop_ids.set(def.id, tw.in_loop);
  11577. mark(tw, def, true);
  11578. }
  11579. });
  11580. }
  11581. function reset_block_variables(compressor, node) {
  11582. if (node.block_scope) node.block_scope.variables.forEach((def) => {
  11583. reset_def(compressor, def);
  11584. });
  11585. }
  11586. function push(tw) {
  11587. tw.safe_ids = Object.create(tw.safe_ids);
  11588. }
  11589. function pop(tw) {
  11590. tw.safe_ids = Object.getPrototypeOf(tw.safe_ids);
  11591. }
  11592. function mark(tw, def, safe) {
  11593. tw.safe_ids[def.id] = safe;
  11594. }
  11595. function safe_to_read(tw, def) {
  11596. if (def.single_use == "m") return false;
  11597. if (tw.safe_ids[def.id]) {
  11598. if (def.fixed == null) {
  11599. var orig = def.orig[0];
  11600. if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
  11601. def.fixed = make_node(AST_Undefined, orig);
  11602. }
  11603. return true;
  11604. }
  11605. return def.fixed instanceof AST_Defun;
  11606. }
  11607. function safe_to_assign(tw, def, scope, value) {
  11608. if (def.fixed === undefined) return true;
  11609. let def_safe_ids;
  11610. if (def.fixed === null
  11611. && (def_safe_ids = tw.defs_to_safe_ids.get(def.id))
  11612. ) {
  11613. def_safe_ids[def.id] = false;
  11614. tw.defs_to_safe_ids.delete(def.id);
  11615. return true;
  11616. }
  11617. if (!HOP(tw.safe_ids, def.id)) return false;
  11618. if (!safe_to_read(tw, def)) return false;
  11619. if (def.fixed === false) return false;
  11620. if (def.fixed != null && (!value || def.references.length > def.assignments)) return false;
  11621. if (def.fixed instanceof AST_Defun) {
  11622. return value instanceof AST_Node && def.fixed.parent_scope === scope;
  11623. }
  11624. return def.orig.every((sym) => {
  11625. return !(sym instanceof AST_SymbolConst
  11626. || sym instanceof AST_SymbolDefun
  11627. || sym instanceof AST_SymbolLambda);
  11628. });
  11629. }
  11630. function ref_once(tw, compressor, def) {
  11631. return compressor.option("unused")
  11632. && !def.scope.pinned()
  11633. && def.references.length - def.recursive_refs == 1
  11634. && tw.loop_ids.get(def.id) === tw.in_loop;
  11635. }
  11636. function is_immutable(value) {
  11637. if (!value) return false;
  11638. return value.is_constant()
  11639. || value instanceof AST_Lambda
  11640. || value instanceof AST_This;
  11641. }
  11642. // A definition "escapes" when its value can leave the point of use.
  11643. // Example: `a = b || c`
  11644. // In this example, "b" and "c" are escaping, because they're going into "a"
  11645. //
  11646. // def.escaped is != 0 when it escapes.
  11647. //
  11648. // When greater than 1, it means that N chained properties will be read off
  11649. // of that def before an escape occurs. This is useful for evaluating
  11650. // property accesses, where you need to know when to stop.
  11651. function mark_escaped(tw, d, scope, node, value, level = 0, depth = 1) {
  11652. var parent = tw.parent(level);
  11653. if (value) {
  11654. if (value.is_constant()) return;
  11655. if (value instanceof AST_ClassExpression) return;
  11656. }
  11657. if (
  11658. parent instanceof AST_Assign && (parent.operator === "=" || parent.logical) && node === parent.right
  11659. || parent instanceof AST_Call && (node !== parent.expression || parent instanceof AST_New)
  11660. || parent instanceof AST_Exit && node === parent.value && node.scope !== d.scope
  11661. || parent instanceof AST_VarDef && node === parent.value
  11662. || parent instanceof AST_Yield && node === parent.value && node.scope !== d.scope
  11663. ) {
  11664. if (depth > 1 && !(value && value.is_constant_expression(scope))) depth = 1;
  11665. if (!d.escaped || d.escaped > depth) d.escaped = depth;
  11666. return;
  11667. } else if (
  11668. parent instanceof AST_Array
  11669. || parent instanceof AST_Await
  11670. || parent instanceof AST_Binary && lazy_op.has(parent.operator)
  11671. || parent instanceof AST_Conditional && node !== parent.condition
  11672. || parent instanceof AST_Expansion
  11673. || parent instanceof AST_Sequence && node === parent.tail_node()
  11674. ) {
  11675. mark_escaped(tw, d, scope, parent, parent, level + 1, depth);
  11676. } else if (parent instanceof AST_ObjectKeyVal && node === parent.value) {
  11677. var obj = tw.parent(level + 1);
  11678. mark_escaped(tw, d, scope, obj, obj, level + 2, depth);
  11679. } else if (parent instanceof AST_PropAccess && node === parent.expression) {
  11680. value = read_property(value, parent.property);
  11681. mark_escaped(tw, d, scope, parent, value, level + 1, depth + 1);
  11682. if (value) return;
  11683. }
  11684. if (level > 0) return;
  11685. if (parent instanceof AST_Sequence && node !== parent.tail_node()) return;
  11686. if (parent instanceof AST_SimpleStatement) return;
  11687. d.direct_access = true;
  11688. }
  11689. const suppress = node => walk(node, node => {
  11690. if (!(node instanceof AST_Symbol)) return;
  11691. var d = node.definition();
  11692. if (!d) return;
  11693. if (node instanceof AST_SymbolRef) d.references.push(node);
  11694. d.fixed = false;
  11695. });
  11696. def_reduce_vars(AST_Accessor, function(tw, descend, compressor) {
  11697. push(tw);
  11698. reset_variables(tw, compressor, this);
  11699. descend();
  11700. pop(tw);
  11701. return true;
  11702. });
  11703. def_reduce_vars(AST_Assign, function(tw, descend, compressor) {
  11704. var node = this;
  11705. if (node.left instanceof AST_Destructuring) {
  11706. suppress(node.left);
  11707. return;
  11708. }
  11709. const finish_walk = () => {
  11710. if (node.logical) {
  11711. node.left.walk(tw);
  11712. push(tw);
  11713. node.right.walk(tw);
  11714. pop(tw);
  11715. return true;
  11716. }
  11717. };
  11718. var sym = node.left;
  11719. if (!(sym instanceof AST_SymbolRef)) return finish_walk();
  11720. var def = sym.definition();
  11721. var safe = safe_to_assign(tw, def, sym.scope, node.right);
  11722. def.assignments++;
  11723. if (!safe) return finish_walk();
  11724. var fixed = def.fixed;
  11725. if (!fixed && node.operator != "=" && !node.logical) return finish_walk();
  11726. var eq = node.operator == "=";
  11727. var value = eq ? node.right : node;
  11728. if (is_modified(compressor, tw, node, value, 0)) return finish_walk();
  11729. def.references.push(sym);
  11730. if (!node.logical) {
  11731. if (!eq) def.chained = true;
  11732. def.fixed = eq ? function() {
  11733. return node.right;
  11734. } : function() {
  11735. return make_node(AST_Binary, node, {
  11736. operator: node.operator.slice(0, -1),
  11737. left: fixed instanceof AST_Node ? fixed : fixed(),
  11738. right: node.right
  11739. });
  11740. };
  11741. }
  11742. if (node.logical) {
  11743. mark(tw, def, false);
  11744. push(tw);
  11745. node.right.walk(tw);
  11746. pop(tw);
  11747. return true;
  11748. }
  11749. mark(tw, def, false);
  11750. node.right.walk(tw);
  11751. mark(tw, def, true);
  11752. mark_escaped(tw, def, sym.scope, node, value, 0, 1);
  11753. return true;
  11754. });
  11755. def_reduce_vars(AST_Binary, function(tw) {
  11756. if (!lazy_op.has(this.operator)) return;
  11757. this.left.walk(tw);
  11758. push(tw);
  11759. this.right.walk(tw);
  11760. pop(tw);
  11761. return true;
  11762. });
  11763. def_reduce_vars(AST_Block, function(tw, descend, compressor) {
  11764. reset_block_variables(compressor, this);
  11765. });
  11766. def_reduce_vars(AST_Case, function(tw) {
  11767. push(tw);
  11768. this.expression.walk(tw);
  11769. pop(tw);
  11770. push(tw);
  11771. walk_body(this, tw);
  11772. pop(tw);
  11773. return true;
  11774. });
  11775. def_reduce_vars(AST_Class, function(tw, descend) {
  11776. clear_flag(this, INLINED);
  11777. push(tw);
  11778. descend();
  11779. pop(tw);
  11780. return true;
  11781. });
  11782. def_reduce_vars(AST_Conditional, function(tw) {
  11783. this.condition.walk(tw);
  11784. push(tw);
  11785. this.consequent.walk(tw);
  11786. pop(tw);
  11787. push(tw);
  11788. this.alternative.walk(tw);
  11789. pop(tw);
  11790. return true;
  11791. });
  11792. def_reduce_vars(AST_Chain, function(tw, descend) {
  11793. // Chains' conditions apply left-to-right, cumulatively.
  11794. // If we walk normally we don't go in that order because we would pop before pushing again
  11795. // Solution: AST_PropAccess and AST_Call push when they are optional, and never pop.
  11796. // Then we pop everything when they are done being walked.
  11797. const safe_ids = tw.safe_ids;
  11798. descend();
  11799. // Unroll back to start
  11800. tw.safe_ids = safe_ids;
  11801. return true;
  11802. });
  11803. def_reduce_vars(AST_Call, function (tw) {
  11804. this.expression.walk(tw);
  11805. if (this.optional) {
  11806. // Never pop -- it's popped at AST_Chain above
  11807. push(tw);
  11808. }
  11809. for (const arg of this.args) arg.walk(tw);
  11810. return true;
  11811. });
  11812. def_reduce_vars(AST_PropAccess, function (tw) {
  11813. if (!this.optional) return;
  11814. this.expression.walk(tw);
  11815. // Never pop -- it's popped at AST_Chain above
  11816. push(tw);
  11817. if (this.property instanceof AST_Node) this.property.walk(tw);
  11818. return true;
  11819. });
  11820. def_reduce_vars(AST_Default, function(tw, descend) {
  11821. push(tw);
  11822. descend();
  11823. pop(tw);
  11824. return true;
  11825. });
  11826. function mark_lambda(tw, descend, compressor) {
  11827. clear_flag(this, INLINED);
  11828. push(tw);
  11829. reset_variables(tw, compressor, this);
  11830. if (this.uses_arguments) {
  11831. descend();
  11832. pop(tw);
  11833. return;
  11834. }
  11835. var iife;
  11836. if (!this.name
  11837. && (iife = tw.parent()) instanceof AST_Call
  11838. && iife.expression === this
  11839. && !iife.args.some(arg => arg instanceof AST_Expansion)
  11840. && this.argnames.every(arg_name => arg_name instanceof AST_Symbol)
  11841. ) {
  11842. // Virtually turn IIFE parameters into variable definitions:
  11843. // (function(a,b) {...})(c,d) => (function() {var a=c,b=d; ...})()
  11844. // So existing transformation rules can work on them.
  11845. this.argnames.forEach((arg, i) => {
  11846. if (!arg.definition) return;
  11847. var d = arg.definition();
  11848. // Avoid setting fixed when there's more than one origin for a variable value
  11849. if (d.orig.length > 1) return;
  11850. if (d.fixed === undefined && (!this.uses_arguments || tw.has_directive("use strict"))) {
  11851. d.fixed = function() {
  11852. return iife.args[i] || make_node(AST_Undefined, iife);
  11853. };
  11854. tw.loop_ids.set(d.id, tw.in_loop);
  11855. mark(tw, d, true);
  11856. } else {
  11857. d.fixed = false;
  11858. }
  11859. });
  11860. }
  11861. descend();
  11862. pop(tw);
  11863. return true;
  11864. }
  11865. def_reduce_vars(AST_Lambda, mark_lambda);
  11866. def_reduce_vars(AST_Do, function(tw, descend, compressor) {
  11867. reset_block_variables(compressor, this);
  11868. const saved_loop = tw.in_loop;
  11869. tw.in_loop = this;
  11870. push(tw);
  11871. this.body.walk(tw);
  11872. if (has_break_or_continue(this)) {
  11873. pop(tw);
  11874. push(tw);
  11875. }
  11876. this.condition.walk(tw);
  11877. pop(tw);
  11878. tw.in_loop = saved_loop;
  11879. return true;
  11880. });
  11881. def_reduce_vars(AST_For, function(tw, descend, compressor) {
  11882. reset_block_variables(compressor, this);
  11883. if (this.init) this.init.walk(tw);
  11884. const saved_loop = tw.in_loop;
  11885. tw.in_loop = this;
  11886. push(tw);
  11887. if (this.condition) this.condition.walk(tw);
  11888. this.body.walk(tw);
  11889. if (this.step) {
  11890. if (has_break_or_continue(this)) {
  11891. pop(tw);
  11892. push(tw);
  11893. }
  11894. this.step.walk(tw);
  11895. }
  11896. pop(tw);
  11897. tw.in_loop = saved_loop;
  11898. return true;
  11899. });
  11900. def_reduce_vars(AST_ForIn, function(tw, descend, compressor) {
  11901. reset_block_variables(compressor, this);
  11902. suppress(this.init);
  11903. this.object.walk(tw);
  11904. const saved_loop = tw.in_loop;
  11905. tw.in_loop = this;
  11906. push(tw);
  11907. this.body.walk(tw);
  11908. pop(tw);
  11909. tw.in_loop = saved_loop;
  11910. return true;
  11911. });
  11912. def_reduce_vars(AST_If, function(tw) {
  11913. this.condition.walk(tw);
  11914. push(tw);
  11915. this.body.walk(tw);
  11916. pop(tw);
  11917. if (this.alternative) {
  11918. push(tw);
  11919. this.alternative.walk(tw);
  11920. pop(tw);
  11921. }
  11922. return true;
  11923. });
  11924. def_reduce_vars(AST_LabeledStatement, function(tw) {
  11925. push(tw);
  11926. this.body.walk(tw);
  11927. pop(tw);
  11928. return true;
  11929. });
  11930. def_reduce_vars(AST_SymbolCatch, function() {
  11931. this.definition().fixed = false;
  11932. });
  11933. def_reduce_vars(AST_SymbolRef, function(tw, descend, compressor) {
  11934. var d = this.definition();
  11935. d.references.push(this);
  11936. if (d.references.length == 1
  11937. && !d.fixed
  11938. && d.orig[0] instanceof AST_SymbolDefun) {
  11939. tw.loop_ids.set(d.id, tw.in_loop);
  11940. }
  11941. var fixed_value;
  11942. if (d.fixed === undefined || !safe_to_read(tw, d)) {
  11943. d.fixed = false;
  11944. } else if (d.fixed) {
  11945. fixed_value = this.fixed_value();
  11946. if (
  11947. fixed_value instanceof AST_Lambda
  11948. && is_recursive_ref(tw, d)
  11949. ) {
  11950. d.recursive_refs++;
  11951. } else if (fixed_value
  11952. && !compressor.exposed(d)
  11953. && ref_once(tw, compressor, d)
  11954. ) {
  11955. d.single_use =
  11956. fixed_value instanceof AST_Lambda && !fixed_value.pinned()
  11957. || fixed_value instanceof AST_Class
  11958. || d.scope === this.scope && fixed_value.is_constant_expression();
  11959. } else {
  11960. d.single_use = false;
  11961. }
  11962. if (is_modified(compressor, tw, this, fixed_value, 0, is_immutable(fixed_value))) {
  11963. if (d.single_use) {
  11964. d.single_use = "m";
  11965. } else {
  11966. d.fixed = false;
  11967. }
  11968. }
  11969. }
  11970. mark_escaped(tw, d, this.scope, this, fixed_value, 0, 1);
  11971. });
  11972. def_reduce_vars(AST_Toplevel, function(tw, descend, compressor) {
  11973. this.globals.forEach(function(def) {
  11974. reset_def(compressor, def);
  11975. });
  11976. reset_variables(tw, compressor, this);
  11977. });
  11978. def_reduce_vars(AST_Try, function(tw, descend, compressor) {
  11979. reset_block_variables(compressor, this);
  11980. push(tw);
  11981. walk_body(this, tw);
  11982. pop(tw);
  11983. if (this.bcatch) {
  11984. push(tw);
  11985. this.bcatch.walk(tw);
  11986. pop(tw);
  11987. }
  11988. if (this.bfinally) this.bfinally.walk(tw);
  11989. return true;
  11990. });
  11991. def_reduce_vars(AST_Unary, function(tw) {
  11992. var node = this;
  11993. if (node.operator !== "++" && node.operator !== "--") return;
  11994. var exp = node.expression;
  11995. if (!(exp instanceof AST_SymbolRef)) return;
  11996. var def = exp.definition();
  11997. var safe = safe_to_assign(tw, def, exp.scope, true);
  11998. def.assignments++;
  11999. if (!safe) return;
  12000. var fixed = def.fixed;
  12001. if (!fixed) return;
  12002. def.references.push(exp);
  12003. def.chained = true;
  12004. def.fixed = function() {
  12005. return make_node(AST_Binary, node, {
  12006. operator: node.operator.slice(0, -1),
  12007. left: make_node(AST_UnaryPrefix, node, {
  12008. operator: "+",
  12009. expression: fixed instanceof AST_Node ? fixed : fixed()
  12010. }),
  12011. right: make_node(AST_Number, node, {
  12012. value: 1
  12013. })
  12014. });
  12015. };
  12016. mark(tw, def, true);
  12017. return true;
  12018. });
  12019. def_reduce_vars(AST_VarDef, function(tw, descend) {
  12020. var node = this;
  12021. if (node.name instanceof AST_Destructuring) {
  12022. suppress(node.name);
  12023. return;
  12024. }
  12025. var d = node.name.definition();
  12026. if (node.value) {
  12027. if (safe_to_assign(tw, d, node.name.scope, node.value)) {
  12028. d.fixed = function() {
  12029. return node.value;
  12030. };
  12031. tw.loop_ids.set(d.id, tw.in_loop);
  12032. mark(tw, d, false);
  12033. descend();
  12034. mark(tw, d, true);
  12035. return true;
  12036. } else {
  12037. d.fixed = false;
  12038. }
  12039. }
  12040. });
  12041. def_reduce_vars(AST_While, function(tw, descend, compressor) {
  12042. reset_block_variables(compressor, this);
  12043. const saved_loop = tw.in_loop;
  12044. tw.in_loop = this;
  12045. push(tw);
  12046. descend();
  12047. pop(tw);
  12048. tw.in_loop = saved_loop;
  12049. return true;
  12050. });
  12051. /***********************************************************************
  12052. A JavaScript tokenizer / parser / beautifier / compressor.
  12053. https://github.com/mishoo/UglifyJS2
  12054. -------------------------------- (C) ---------------------------------
  12055. Author: Mihai Bazon
  12056. <mihai.bazon@gmail.com>
  12057. http://mihai.bazon.net/blog
  12058. Distributed under the BSD license:
  12059. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  12060. Redistribution and use in source and binary forms, with or without
  12061. modification, are permitted provided that the following conditions
  12062. are met:
  12063. * Redistributions of source code must retain the above
  12064. copyright notice, this list of conditions and the following
  12065. disclaimer.
  12066. * Redistributions in binary form must reproduce the above
  12067. copyright notice, this list of conditions and the following
  12068. disclaimer in the documentation and/or other materials
  12069. provided with the distribution.
  12070. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  12071. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12072. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  12073. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  12074. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  12075. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12076. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  12077. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12078. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  12079. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  12080. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12081. SUCH DAMAGE.
  12082. ***********************************************************************/
  12083. function loop_body(x) {
  12084. if (x instanceof AST_IterationStatement) {
  12085. return x.body instanceof AST_BlockStatement ? x.body : x;
  12086. }
  12087. return x;
  12088. }
  12089. function is_lhs_read_only(lhs) {
  12090. if (lhs instanceof AST_This) return true;
  12091. if (lhs instanceof AST_SymbolRef) return lhs.definition().orig[0] instanceof AST_SymbolLambda;
  12092. if (lhs instanceof AST_PropAccess) {
  12093. lhs = lhs.expression;
  12094. if (lhs instanceof AST_SymbolRef) {
  12095. if (lhs.is_immutable()) return false;
  12096. lhs = lhs.fixed_value();
  12097. }
  12098. if (!lhs) return true;
  12099. if (lhs instanceof AST_RegExp) return false;
  12100. if (lhs instanceof AST_Constant) return true;
  12101. return is_lhs_read_only(lhs);
  12102. }
  12103. return false;
  12104. }
  12105. // Remove code which we know is unreachable.
  12106. function trim_unreachable_code(compressor, stat, target) {
  12107. walk(stat, node => {
  12108. if (node instanceof AST_Var) {
  12109. node.remove_initializers();
  12110. target.push(node);
  12111. return true;
  12112. }
  12113. if (
  12114. node instanceof AST_Defun
  12115. && (node === stat || !compressor.has_directive("use strict"))
  12116. ) {
  12117. target.push(node === stat ? node : make_node(AST_Var, node, {
  12118. definitions: [
  12119. make_node(AST_VarDef, node, {
  12120. name: make_node(AST_SymbolVar, node.name, node.name),
  12121. value: null
  12122. })
  12123. ]
  12124. }));
  12125. return true;
  12126. }
  12127. if (node instanceof AST_Export || node instanceof AST_Import) {
  12128. target.push(node);
  12129. return true;
  12130. }
  12131. if (node instanceof AST_Scope) {
  12132. return true;
  12133. }
  12134. });
  12135. }
  12136. // Tighten a bunch of statements together, and perform statement-level optimization.
  12137. function tighten_body(statements, compressor) {
  12138. var in_loop, in_try;
  12139. var scope = compressor.find_parent(AST_Scope).get_defun_scope();
  12140. find_loop_scope_try();
  12141. var CHANGED, max_iter = 10;
  12142. do {
  12143. CHANGED = false;
  12144. eliminate_spurious_blocks(statements);
  12145. if (compressor.option("dead_code")) {
  12146. eliminate_dead_code(statements, compressor);
  12147. }
  12148. if (compressor.option("if_return")) {
  12149. handle_if_return(statements, compressor);
  12150. }
  12151. if (compressor.sequences_limit > 0) {
  12152. sequencesize(statements, compressor);
  12153. sequencesize_2(statements, compressor);
  12154. }
  12155. if (compressor.option("join_vars")) {
  12156. join_consecutive_vars(statements);
  12157. }
  12158. if (compressor.option("collapse_vars")) {
  12159. collapse(statements, compressor);
  12160. }
  12161. } while (CHANGED && max_iter-- > 0);
  12162. function find_loop_scope_try() {
  12163. var node = compressor.self(), level = 0;
  12164. do {
  12165. if (node instanceof AST_Catch || node instanceof AST_Finally) {
  12166. level++;
  12167. } else if (node instanceof AST_IterationStatement) {
  12168. in_loop = true;
  12169. } else if (node instanceof AST_Scope) {
  12170. scope = node;
  12171. break;
  12172. } else if (node instanceof AST_Try) {
  12173. in_try = true;
  12174. }
  12175. } while (node = compressor.parent(level++));
  12176. }
  12177. // Search from right to left for assignment-like expressions:
  12178. // - `var a = x;`
  12179. // - `a = x;`
  12180. // - `++a`
  12181. // For each candidate, scan from left to right for first usage, then try
  12182. // to fold assignment into the site for compression.
  12183. // Will not attempt to collapse assignments into or past code blocks
  12184. // which are not sequentially executed, e.g. loops and conditionals.
  12185. function collapse(statements, compressor) {
  12186. if (scope.pinned())
  12187. return statements;
  12188. var args;
  12189. var candidates = [];
  12190. var stat_index = statements.length;
  12191. var scanner = new TreeTransformer(function (node) {
  12192. if (abort)
  12193. return node;
  12194. // Skip nodes before `candidate` as quickly as possible
  12195. if (!hit) {
  12196. if (node !== hit_stack[hit_index])
  12197. return node;
  12198. hit_index++;
  12199. if (hit_index < hit_stack.length)
  12200. return handle_custom_scan_order(node);
  12201. hit = true;
  12202. stop_after = find_stop(node, 0);
  12203. if (stop_after === node)
  12204. abort = true;
  12205. return node;
  12206. }
  12207. // Stop immediately if these node types are encountered
  12208. var parent = scanner.parent();
  12209. if (node instanceof AST_Assign
  12210. && (node.logical || node.operator != "=" && lhs.equivalent_to(node.left))
  12211. || node instanceof AST_Await
  12212. || node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
  12213. || node instanceof AST_Debugger
  12214. || node instanceof AST_Destructuring
  12215. || node instanceof AST_Expansion
  12216. && node.expression instanceof AST_Symbol
  12217. && (
  12218. node.expression instanceof AST_This
  12219. || node.expression.definition().references.length > 1
  12220. )
  12221. || node instanceof AST_IterationStatement && !(node instanceof AST_For)
  12222. || node instanceof AST_LoopControl
  12223. || node instanceof AST_Try
  12224. || node instanceof AST_With
  12225. || node instanceof AST_Yield
  12226. || node instanceof AST_Export
  12227. || node instanceof AST_Class
  12228. || parent instanceof AST_For && node !== parent.init
  12229. || !replace_all
  12230. && (
  12231. node instanceof AST_SymbolRef
  12232. && !node.is_declared(compressor)
  12233. && !pure_prop_access_globals.has(node)
  12234. )
  12235. || node instanceof AST_SymbolRef
  12236. && parent instanceof AST_Call
  12237. && has_annotation(parent, _NOINLINE)
  12238. ) {
  12239. abort = true;
  12240. return node;
  12241. }
  12242. // Stop only if candidate is found within conditional branches
  12243. if (!stop_if_hit && (!lhs_local || !replace_all)
  12244. && (parent instanceof AST_Binary && lazy_op.has(parent.operator) && parent.left !== node
  12245. || parent instanceof AST_Conditional && parent.condition !== node
  12246. || parent instanceof AST_If && parent.condition !== node)) {
  12247. stop_if_hit = parent;
  12248. }
  12249. // Replace variable with assignment when found
  12250. if (can_replace
  12251. && !(node instanceof AST_SymbolDeclaration)
  12252. && lhs.equivalent_to(node)
  12253. && !shadows(node.scope, lvalues)
  12254. ) {
  12255. if (stop_if_hit) {
  12256. abort = true;
  12257. return node;
  12258. }
  12259. if (is_lhs(node, parent)) {
  12260. if (value_def)
  12261. replaced++;
  12262. return node;
  12263. } else {
  12264. replaced++;
  12265. if (value_def && candidate instanceof AST_VarDef)
  12266. return node;
  12267. }
  12268. CHANGED = abort = true;
  12269. if (candidate instanceof AST_UnaryPostfix) {
  12270. return make_node(AST_UnaryPrefix, candidate, candidate);
  12271. }
  12272. if (candidate instanceof AST_VarDef) {
  12273. var def = candidate.name.definition();
  12274. var value = candidate.value;
  12275. if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
  12276. def.replaced++;
  12277. if (funarg && is_identifier_atom(value)) {
  12278. return value.transform(compressor);
  12279. } else {
  12280. return maintain_this_binding(parent, node, value);
  12281. }
  12282. }
  12283. return make_node(AST_Assign, candidate, {
  12284. operator: "=",
  12285. logical: false,
  12286. left: make_node(AST_SymbolRef, candidate.name, candidate.name),
  12287. right: value
  12288. });
  12289. }
  12290. clear_flag(candidate, WRITE_ONLY);
  12291. return candidate;
  12292. }
  12293. // These node types have child nodes that execute sequentially,
  12294. // but are otherwise not safe to scan into or beyond them.
  12295. var sym;
  12296. if (node instanceof AST_Call
  12297. || node instanceof AST_Exit
  12298. && (side_effects || lhs instanceof AST_PropAccess || may_modify(lhs))
  12299. || node instanceof AST_PropAccess
  12300. && (side_effects || node.expression.may_throw_on_access(compressor))
  12301. || node instanceof AST_SymbolRef
  12302. && ((lvalues.has(node.name) && lvalues.get(node.name).modified) || side_effects && may_modify(node))
  12303. || node instanceof AST_VarDef && node.value
  12304. && (lvalues.has(node.name.name) || side_effects && may_modify(node.name))
  12305. || (sym = is_lhs(node.left, node))
  12306. && (sym instanceof AST_PropAccess || lvalues.has(sym.name))
  12307. || may_throw
  12308. && (in_try ? node.has_side_effects(compressor) : side_effects_external(node))) {
  12309. stop_after = node;
  12310. if (node instanceof AST_Scope)
  12311. abort = true;
  12312. }
  12313. return handle_custom_scan_order(node);
  12314. }, function (node) {
  12315. if (abort)
  12316. return;
  12317. if (stop_after === node)
  12318. abort = true;
  12319. if (stop_if_hit === node)
  12320. stop_if_hit = null;
  12321. });
  12322. var multi_replacer = new TreeTransformer(function (node) {
  12323. if (abort)
  12324. return node;
  12325. // Skip nodes before `candidate` as quickly as possible
  12326. if (!hit) {
  12327. if (node !== hit_stack[hit_index])
  12328. return node;
  12329. hit_index++;
  12330. if (hit_index < hit_stack.length)
  12331. return;
  12332. hit = true;
  12333. return node;
  12334. }
  12335. // Replace variable when found
  12336. if (node instanceof AST_SymbolRef
  12337. && node.name == def.name) {
  12338. if (!--replaced)
  12339. abort = true;
  12340. if (is_lhs(node, multi_replacer.parent()))
  12341. return node;
  12342. def.replaced++;
  12343. value_def.replaced--;
  12344. return candidate.value;
  12345. }
  12346. // Skip (non-executed) functions and (leading) default case in switch statements
  12347. if (node instanceof AST_Default || node instanceof AST_Scope)
  12348. return node;
  12349. });
  12350. while (--stat_index >= 0) {
  12351. // Treat parameters as collapsible in IIFE, i.e.
  12352. // function(a, b){ ... }(x());
  12353. // would be translated into equivalent assignments:
  12354. // var a = x(), b = undefined;
  12355. if (stat_index == 0 && compressor.option("unused"))
  12356. extract_args();
  12357. // Find collapsible assignments
  12358. var hit_stack = [];
  12359. extract_candidates(statements[stat_index]);
  12360. while (candidates.length > 0) {
  12361. hit_stack = candidates.pop();
  12362. var hit_index = 0;
  12363. var candidate = hit_stack[hit_stack.length - 1];
  12364. var value_def = null;
  12365. var stop_after = null;
  12366. var stop_if_hit = null;
  12367. var lhs = get_lhs(candidate);
  12368. if (!lhs || is_lhs_read_only(lhs) || lhs.has_side_effects(compressor))
  12369. continue;
  12370. // Locate symbols which may execute code outside of scanning range
  12371. var lvalues = get_lvalues(candidate);
  12372. var lhs_local = is_lhs_local(lhs);
  12373. if (lhs instanceof AST_SymbolRef) {
  12374. lvalues.set(lhs.name, { def: lhs.definition(), modified: false });
  12375. }
  12376. var side_effects = value_has_side_effects(candidate);
  12377. var replace_all = replace_all_symbols();
  12378. var may_throw = candidate.may_throw(compressor);
  12379. var funarg = candidate.name instanceof AST_SymbolFunarg;
  12380. var hit = funarg;
  12381. var abort = false, replaced = 0, can_replace = !args || !hit;
  12382. if (!can_replace) {
  12383. for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
  12384. args[j].transform(scanner);
  12385. }
  12386. can_replace = true;
  12387. }
  12388. for (var i = stat_index; !abort && i < statements.length; i++) {
  12389. statements[i].transform(scanner);
  12390. }
  12391. if (value_def) {
  12392. var def = candidate.name.definition();
  12393. if (abort && def.references.length - def.replaced > replaced)
  12394. replaced = false;
  12395. else {
  12396. abort = false;
  12397. hit_index = 0;
  12398. hit = funarg;
  12399. for (var i = stat_index; !abort && i < statements.length; i++) {
  12400. statements[i].transform(multi_replacer);
  12401. }
  12402. value_def.single_use = false;
  12403. }
  12404. }
  12405. if (replaced && !remove_candidate(candidate))
  12406. statements.splice(stat_index, 1);
  12407. }
  12408. }
  12409. function handle_custom_scan_order(node) {
  12410. // Skip (non-executed) functions
  12411. if (node instanceof AST_Scope)
  12412. return node;
  12413. // Scan case expressions first in a switch statement
  12414. if (node instanceof AST_Switch) {
  12415. node.expression = node.expression.transform(scanner);
  12416. for (var i = 0, len = node.body.length; !abort && i < len; i++) {
  12417. var branch = node.body[i];
  12418. if (branch instanceof AST_Case) {
  12419. if (!hit) {
  12420. if (branch !== hit_stack[hit_index])
  12421. continue;
  12422. hit_index++;
  12423. }
  12424. branch.expression = branch.expression.transform(scanner);
  12425. if (!replace_all)
  12426. break;
  12427. }
  12428. }
  12429. abort = true;
  12430. return node;
  12431. }
  12432. }
  12433. function redefined_within_scope(def, scope) {
  12434. if (def.global)
  12435. return false;
  12436. let cur_scope = def.scope;
  12437. while (cur_scope && cur_scope !== scope) {
  12438. if (cur_scope.variables.has(def.name)) {
  12439. return true;
  12440. }
  12441. cur_scope = cur_scope.parent_scope;
  12442. }
  12443. return false;
  12444. }
  12445. function has_overlapping_symbol(fn, arg, fn_strict) {
  12446. var found = false, scan_this = !(fn instanceof AST_Arrow);
  12447. arg.walk(new TreeWalker(function (node, descend) {
  12448. if (found)
  12449. return true;
  12450. if (node instanceof AST_SymbolRef && (fn.variables.has(node.name) || redefined_within_scope(node.definition(), fn))) {
  12451. var s = node.definition().scope;
  12452. if (s !== scope)
  12453. while (s = s.parent_scope) {
  12454. if (s === scope)
  12455. return true;
  12456. }
  12457. return found = true;
  12458. }
  12459. if ((fn_strict || scan_this) && node instanceof AST_This) {
  12460. return found = true;
  12461. }
  12462. if (node instanceof AST_Scope && !(node instanceof AST_Arrow)) {
  12463. var prev = scan_this;
  12464. scan_this = false;
  12465. descend();
  12466. scan_this = prev;
  12467. return true;
  12468. }
  12469. }));
  12470. return found;
  12471. }
  12472. function extract_args() {
  12473. var iife, fn = compressor.self();
  12474. if (is_func_expr(fn)
  12475. && !fn.name
  12476. && !fn.uses_arguments
  12477. && !fn.pinned()
  12478. && (iife = compressor.parent()) instanceof AST_Call
  12479. && iife.expression === fn
  12480. && iife.args.every((arg) => !(arg instanceof AST_Expansion))) {
  12481. var fn_strict = compressor.has_directive("use strict");
  12482. if (fn_strict && !member(fn_strict, fn.body))
  12483. fn_strict = false;
  12484. var len = fn.argnames.length;
  12485. args = iife.args.slice(len);
  12486. var names = new Set();
  12487. for (var i = len; --i >= 0;) {
  12488. var sym = fn.argnames[i];
  12489. var arg = iife.args[i];
  12490. // The following two line fix is a duplicate of the fix at
  12491. // https://github.com/terser/terser/commit/011d3eb08cefe6922c7d1bdfa113fc4aeaca1b75
  12492. // This might mean that these two pieces of code (one here in collapse_vars and another in reduce_vars
  12493. // Might be doing the exact same thing.
  12494. const def = sym.definition && sym.definition();
  12495. const is_reassigned = def && def.orig.length > 1;
  12496. if (is_reassigned)
  12497. continue;
  12498. args.unshift(make_node(AST_VarDef, sym, {
  12499. name: sym,
  12500. value: arg
  12501. }));
  12502. if (names.has(sym.name))
  12503. continue;
  12504. names.add(sym.name);
  12505. if (sym instanceof AST_Expansion) {
  12506. var elements = iife.args.slice(i);
  12507. if (elements.every((arg) => !has_overlapping_symbol(fn, arg, fn_strict)
  12508. )) {
  12509. candidates.unshift([make_node(AST_VarDef, sym, {
  12510. name: sym.expression,
  12511. value: make_node(AST_Array, iife, {
  12512. elements: elements
  12513. })
  12514. })]);
  12515. }
  12516. } else {
  12517. if (!arg) {
  12518. arg = make_node(AST_Undefined, sym).transform(compressor);
  12519. } else if (arg instanceof AST_Lambda && arg.pinned()
  12520. || has_overlapping_symbol(fn, arg, fn_strict)) {
  12521. arg = null;
  12522. }
  12523. if (arg)
  12524. candidates.unshift([make_node(AST_VarDef, sym, {
  12525. name: sym,
  12526. value: arg
  12527. })]);
  12528. }
  12529. }
  12530. }
  12531. }
  12532. function extract_candidates(expr) {
  12533. hit_stack.push(expr);
  12534. if (expr instanceof AST_Assign) {
  12535. if (!expr.left.has_side_effects(compressor)
  12536. && !(expr.right instanceof AST_Chain)) {
  12537. candidates.push(hit_stack.slice());
  12538. }
  12539. extract_candidates(expr.right);
  12540. } else if (expr instanceof AST_Binary) {
  12541. extract_candidates(expr.left);
  12542. extract_candidates(expr.right);
  12543. } else if (expr instanceof AST_Call && !has_annotation(expr, _NOINLINE)) {
  12544. extract_candidates(expr.expression);
  12545. expr.args.forEach(extract_candidates);
  12546. } else if (expr instanceof AST_Case) {
  12547. extract_candidates(expr.expression);
  12548. } else if (expr instanceof AST_Conditional) {
  12549. extract_candidates(expr.condition);
  12550. extract_candidates(expr.consequent);
  12551. extract_candidates(expr.alternative);
  12552. } else if (expr instanceof AST_Definitions) {
  12553. var len = expr.definitions.length;
  12554. // limit number of trailing variable definitions for consideration
  12555. var i = len - 200;
  12556. if (i < 0)
  12557. i = 0;
  12558. for (; i < len; i++) {
  12559. extract_candidates(expr.definitions[i]);
  12560. }
  12561. } else if (expr instanceof AST_DWLoop) {
  12562. extract_candidates(expr.condition);
  12563. if (!(expr.body instanceof AST_Block)) {
  12564. extract_candidates(expr.body);
  12565. }
  12566. } else if (expr instanceof AST_Exit) {
  12567. if (expr.value)
  12568. extract_candidates(expr.value);
  12569. } else if (expr instanceof AST_For) {
  12570. if (expr.init)
  12571. extract_candidates(expr.init);
  12572. if (expr.condition)
  12573. extract_candidates(expr.condition);
  12574. if (expr.step)
  12575. extract_candidates(expr.step);
  12576. if (!(expr.body instanceof AST_Block)) {
  12577. extract_candidates(expr.body);
  12578. }
  12579. } else if (expr instanceof AST_ForIn) {
  12580. extract_candidates(expr.object);
  12581. if (!(expr.body instanceof AST_Block)) {
  12582. extract_candidates(expr.body);
  12583. }
  12584. } else if (expr instanceof AST_If) {
  12585. extract_candidates(expr.condition);
  12586. if (!(expr.body instanceof AST_Block)) {
  12587. extract_candidates(expr.body);
  12588. }
  12589. if (expr.alternative && !(expr.alternative instanceof AST_Block)) {
  12590. extract_candidates(expr.alternative);
  12591. }
  12592. } else if (expr instanceof AST_Sequence) {
  12593. expr.expressions.forEach(extract_candidates);
  12594. } else if (expr instanceof AST_SimpleStatement) {
  12595. extract_candidates(expr.body);
  12596. } else if (expr instanceof AST_Switch) {
  12597. extract_candidates(expr.expression);
  12598. expr.body.forEach(extract_candidates);
  12599. } else if (expr instanceof AST_Unary) {
  12600. if (expr.operator == "++" || expr.operator == "--") {
  12601. candidates.push(hit_stack.slice());
  12602. }
  12603. } else if (expr instanceof AST_VarDef) {
  12604. if (expr.value && !(expr.value instanceof AST_Chain)) {
  12605. candidates.push(hit_stack.slice());
  12606. extract_candidates(expr.value);
  12607. }
  12608. }
  12609. hit_stack.pop();
  12610. }
  12611. function find_stop(node, level, write_only) {
  12612. var parent = scanner.parent(level);
  12613. if (parent instanceof AST_Assign) {
  12614. if (write_only
  12615. && !parent.logical
  12616. && !(parent.left instanceof AST_PropAccess
  12617. || lvalues.has(parent.left.name))) {
  12618. return find_stop(parent, level + 1, write_only);
  12619. }
  12620. return node;
  12621. }
  12622. if (parent instanceof AST_Binary) {
  12623. if (write_only && (!lazy_op.has(parent.operator) || parent.left === node)) {
  12624. return find_stop(parent, level + 1, write_only);
  12625. }
  12626. return node;
  12627. }
  12628. if (parent instanceof AST_Call)
  12629. return node;
  12630. if (parent instanceof AST_Case)
  12631. return node;
  12632. if (parent instanceof AST_Conditional) {
  12633. if (write_only && parent.condition === node) {
  12634. return find_stop(parent, level + 1, write_only);
  12635. }
  12636. return node;
  12637. }
  12638. if (parent instanceof AST_Definitions) {
  12639. return find_stop(parent, level + 1, true);
  12640. }
  12641. if (parent instanceof AST_Exit) {
  12642. return write_only ? find_stop(parent, level + 1, write_only) : node;
  12643. }
  12644. if (parent instanceof AST_If) {
  12645. if (write_only && parent.condition === node) {
  12646. return find_stop(parent, level + 1, write_only);
  12647. }
  12648. return node;
  12649. }
  12650. if (parent instanceof AST_IterationStatement)
  12651. return node;
  12652. if (parent instanceof AST_Sequence) {
  12653. return find_stop(parent, level + 1, parent.tail_node() !== node);
  12654. }
  12655. if (parent instanceof AST_SimpleStatement) {
  12656. return find_stop(parent, level + 1, true);
  12657. }
  12658. if (parent instanceof AST_Switch)
  12659. return node;
  12660. if (parent instanceof AST_VarDef)
  12661. return node;
  12662. return null;
  12663. }
  12664. function mangleable_var(var_def) {
  12665. var value = var_def.value;
  12666. if (!(value instanceof AST_SymbolRef))
  12667. return;
  12668. if (value.name == "arguments")
  12669. return;
  12670. var def = value.definition();
  12671. if (def.undeclared)
  12672. return;
  12673. return value_def = def;
  12674. }
  12675. function get_lhs(expr) {
  12676. if (expr instanceof AST_Assign && expr.logical) {
  12677. return false;
  12678. } else if (expr instanceof AST_VarDef && expr.name instanceof AST_SymbolDeclaration) {
  12679. var def = expr.name.definition();
  12680. if (!member(expr.name, def.orig))
  12681. return;
  12682. var referenced = def.references.length - def.replaced;
  12683. if (!referenced)
  12684. return;
  12685. var declared = def.orig.length - def.eliminated;
  12686. if (declared > 1 && !(expr.name instanceof AST_SymbolFunarg)
  12687. || (referenced > 1 ? mangleable_var(expr) : !compressor.exposed(def))) {
  12688. return make_node(AST_SymbolRef, expr.name, expr.name);
  12689. }
  12690. } else {
  12691. const lhs = expr instanceof AST_Assign
  12692. ? expr.left
  12693. : expr.expression;
  12694. return !is_ref_of(lhs, AST_SymbolConst)
  12695. && !is_ref_of(lhs, AST_SymbolLet) && lhs;
  12696. }
  12697. }
  12698. function get_rvalue(expr) {
  12699. if (expr instanceof AST_Assign) {
  12700. return expr.right;
  12701. } else {
  12702. return expr.value;
  12703. }
  12704. }
  12705. function get_lvalues(expr) {
  12706. var lvalues = new Map();
  12707. if (expr instanceof AST_Unary)
  12708. return lvalues;
  12709. var tw = new TreeWalker(function (node) {
  12710. var sym = node;
  12711. while (sym instanceof AST_PropAccess)
  12712. sym = sym.expression;
  12713. if (sym instanceof AST_SymbolRef) {
  12714. const prev = lvalues.get(sym.name);
  12715. if (!prev || !prev.modified) {
  12716. lvalues.set(sym.name, {
  12717. def: sym.definition(),
  12718. modified: is_modified(compressor, tw, node, node, 0)
  12719. });
  12720. }
  12721. }
  12722. });
  12723. get_rvalue(expr).walk(tw);
  12724. return lvalues;
  12725. }
  12726. function remove_candidate(expr) {
  12727. if (expr.name instanceof AST_SymbolFunarg) {
  12728. var iife = compressor.parent(), argnames = compressor.self().argnames;
  12729. var index = argnames.indexOf(expr.name);
  12730. if (index < 0) {
  12731. iife.args.length = Math.min(iife.args.length, argnames.length - 1);
  12732. } else {
  12733. var args = iife.args;
  12734. if (args[index])
  12735. args[index] = make_node(AST_Number, args[index], {
  12736. value: 0
  12737. });
  12738. }
  12739. return true;
  12740. }
  12741. var found = false;
  12742. return statements[stat_index].transform(new TreeTransformer(function (node, descend, in_list) {
  12743. if (found)
  12744. return node;
  12745. if (node === expr || node.body === expr) {
  12746. found = true;
  12747. if (node instanceof AST_VarDef) {
  12748. node.value = node.name instanceof AST_SymbolConst
  12749. ? make_node(AST_Undefined, node.value) // `const` always needs value.
  12750. : null;
  12751. return node;
  12752. }
  12753. return in_list ? MAP.skip : null;
  12754. }
  12755. }, function (node) {
  12756. if (node instanceof AST_Sequence)
  12757. switch (node.expressions.length) {
  12758. case 0: return null;
  12759. case 1: return node.expressions[0];
  12760. }
  12761. }));
  12762. }
  12763. function is_lhs_local(lhs) {
  12764. while (lhs instanceof AST_PropAccess)
  12765. lhs = lhs.expression;
  12766. return lhs instanceof AST_SymbolRef
  12767. && lhs.definition().scope === scope
  12768. && !(in_loop
  12769. && (lvalues.has(lhs.name)
  12770. || candidate instanceof AST_Unary
  12771. || (candidate instanceof AST_Assign
  12772. && !candidate.logical
  12773. && candidate.operator != "=")));
  12774. }
  12775. function value_has_side_effects(expr) {
  12776. if (expr instanceof AST_Unary)
  12777. return unary_side_effects.has(expr.operator);
  12778. return get_rvalue(expr).has_side_effects(compressor);
  12779. }
  12780. function replace_all_symbols() {
  12781. if (side_effects)
  12782. return false;
  12783. if (value_def)
  12784. return true;
  12785. if (lhs instanceof AST_SymbolRef) {
  12786. var def = lhs.definition();
  12787. if (def.references.length - def.replaced == (candidate instanceof AST_VarDef ? 1 : 2)) {
  12788. return true;
  12789. }
  12790. }
  12791. return false;
  12792. }
  12793. function may_modify(sym) {
  12794. if (!sym.definition)
  12795. return true; // AST_Destructuring
  12796. var def = sym.definition();
  12797. if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun)
  12798. return false;
  12799. if (def.scope.get_defun_scope() !== scope)
  12800. return true;
  12801. return !def.references.every((ref) => {
  12802. var s = ref.scope.get_defun_scope();
  12803. // "block" scope within AST_Catch
  12804. if (s.TYPE == "Scope")
  12805. s = s.parent_scope;
  12806. return s === scope;
  12807. });
  12808. }
  12809. function side_effects_external(node, lhs) {
  12810. if (node instanceof AST_Assign)
  12811. return side_effects_external(node.left, true);
  12812. if (node instanceof AST_Unary)
  12813. return side_effects_external(node.expression, true);
  12814. if (node instanceof AST_VarDef)
  12815. return node.value && side_effects_external(node.value);
  12816. if (lhs) {
  12817. if (node instanceof AST_Dot)
  12818. return side_effects_external(node.expression, true);
  12819. if (node instanceof AST_Sub)
  12820. return side_effects_external(node.expression, true);
  12821. if (node instanceof AST_SymbolRef)
  12822. return node.definition().scope !== scope;
  12823. }
  12824. return false;
  12825. }
  12826. function shadows(newScope, lvalues) {
  12827. for (const {def} of lvalues.values()) {
  12828. let current = newScope;
  12829. while (current && current !== def.scope) {
  12830. let nested_def = current.variables.get(def.name);
  12831. if (nested_def && nested_def !== def) return true;
  12832. current = current.parent_scope;
  12833. }
  12834. }
  12835. return false;
  12836. }
  12837. }
  12838. function eliminate_spurious_blocks(statements) {
  12839. var seen_dirs = [];
  12840. for (var i = 0; i < statements.length;) {
  12841. var stat = statements[i];
  12842. if (stat instanceof AST_BlockStatement && stat.body.every(can_be_evicted_from_block)) {
  12843. CHANGED = true;
  12844. eliminate_spurious_blocks(stat.body);
  12845. statements.splice(i, 1, ...stat.body);
  12846. i += stat.body.length;
  12847. } else if (stat instanceof AST_EmptyStatement) {
  12848. CHANGED = true;
  12849. statements.splice(i, 1);
  12850. } else if (stat instanceof AST_Directive) {
  12851. if (seen_dirs.indexOf(stat.value) < 0) {
  12852. i++;
  12853. seen_dirs.push(stat.value);
  12854. } else {
  12855. CHANGED = true;
  12856. statements.splice(i, 1);
  12857. }
  12858. } else
  12859. i++;
  12860. }
  12861. }
  12862. function handle_if_return(statements, compressor) {
  12863. var self = compressor.self();
  12864. var multiple_if_returns = has_multiple_if_returns(statements);
  12865. var in_lambda = self instanceof AST_Lambda;
  12866. for (var i = statements.length; --i >= 0;) {
  12867. var stat = statements[i];
  12868. var j = next_index(i);
  12869. var next = statements[j];
  12870. if (in_lambda && !next && stat instanceof AST_Return) {
  12871. if (!stat.value) {
  12872. CHANGED = true;
  12873. statements.splice(i, 1);
  12874. continue;
  12875. }
  12876. if (stat.value instanceof AST_UnaryPrefix && stat.value.operator == "void") {
  12877. CHANGED = true;
  12878. statements[i] = make_node(AST_SimpleStatement, stat, {
  12879. body: stat.value.expression
  12880. });
  12881. continue;
  12882. }
  12883. }
  12884. if (stat instanceof AST_If) {
  12885. var ab = aborts(stat.body);
  12886. if (can_merge_flow(ab)) {
  12887. if (ab.label) {
  12888. remove(ab.label.thedef.references, ab);
  12889. }
  12890. CHANGED = true;
  12891. stat = stat.clone();
  12892. stat.condition = stat.condition.negate(compressor);
  12893. var body = as_statement_array_with_return(stat.body, ab);
  12894. stat.body = make_node(AST_BlockStatement, stat, {
  12895. body: as_statement_array(stat.alternative).concat(extract_functions())
  12896. });
  12897. stat.alternative = make_node(AST_BlockStatement, stat, {
  12898. body: body
  12899. });
  12900. statements[i] = stat.transform(compressor);
  12901. continue;
  12902. }
  12903. var ab = aborts(stat.alternative);
  12904. if (can_merge_flow(ab)) {
  12905. if (ab.label) {
  12906. remove(ab.label.thedef.references, ab);
  12907. }
  12908. CHANGED = true;
  12909. stat = stat.clone();
  12910. stat.body = make_node(AST_BlockStatement, stat.body, {
  12911. body: as_statement_array(stat.body).concat(extract_functions())
  12912. });
  12913. var body = as_statement_array_with_return(stat.alternative, ab);
  12914. stat.alternative = make_node(AST_BlockStatement, stat.alternative, {
  12915. body: body
  12916. });
  12917. statements[i] = stat.transform(compressor);
  12918. continue;
  12919. }
  12920. }
  12921. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  12922. var value = stat.body.value;
  12923. //---
  12924. // pretty silly case, but:
  12925. // if (foo()) return; return; ==> foo(); return;
  12926. if (!value && !stat.alternative
  12927. && (in_lambda && !next || next instanceof AST_Return && !next.value)) {
  12928. CHANGED = true;
  12929. statements[i] = make_node(AST_SimpleStatement, stat.condition, {
  12930. body: stat.condition
  12931. });
  12932. continue;
  12933. }
  12934. //---
  12935. // if (foo()) return x; return y; ==> return foo() ? x : y;
  12936. if (value && !stat.alternative && next instanceof AST_Return && next.value) {
  12937. CHANGED = true;
  12938. stat = stat.clone();
  12939. stat.alternative = next;
  12940. statements[i] = stat.transform(compressor);
  12941. statements.splice(j, 1);
  12942. continue;
  12943. }
  12944. //---
  12945. // if (foo()) return x; [ return ; ] ==> return foo() ? x : undefined;
  12946. if (value && !stat.alternative
  12947. && (!next && in_lambda && multiple_if_returns
  12948. || next instanceof AST_Return)) {
  12949. CHANGED = true;
  12950. stat = stat.clone();
  12951. stat.alternative = next || make_node(AST_Return, stat, {
  12952. value: null
  12953. });
  12954. statements[i] = stat.transform(compressor);
  12955. if (next)
  12956. statements.splice(j, 1);
  12957. continue;
  12958. }
  12959. //---
  12960. // if (a) return b; if (c) return d; e; ==> return a ? b : c ? d : void e;
  12961. //
  12962. // if sequences is not enabled, this can lead to an endless loop (issue #866).
  12963. // however, with sequences on this helps producing slightly better output for
  12964. // the example code.
  12965. var prev = statements[prev_index(i)];
  12966. if (compressor.option("sequences") && in_lambda && !stat.alternative
  12967. && prev instanceof AST_If && prev.body instanceof AST_Return
  12968. && next_index(j) == statements.length && next instanceof AST_SimpleStatement) {
  12969. CHANGED = true;
  12970. stat = stat.clone();
  12971. stat.alternative = make_node(AST_BlockStatement, next, {
  12972. body: [
  12973. next,
  12974. make_node(AST_Return, next, {
  12975. value: null
  12976. })
  12977. ]
  12978. });
  12979. statements[i] = stat.transform(compressor);
  12980. statements.splice(j, 1);
  12981. continue;
  12982. }
  12983. }
  12984. }
  12985. function has_multiple_if_returns(statements) {
  12986. var n = 0;
  12987. for (var i = statements.length; --i >= 0;) {
  12988. var stat = statements[i];
  12989. if (stat instanceof AST_If && stat.body instanceof AST_Return) {
  12990. if (++n > 1)
  12991. return true;
  12992. }
  12993. }
  12994. return false;
  12995. }
  12996. function is_return_void(value) {
  12997. return !value || value instanceof AST_UnaryPrefix && value.operator == "void";
  12998. }
  12999. function can_merge_flow(ab) {
  13000. if (!ab)
  13001. return false;
  13002. for (var j = i + 1, len = statements.length; j < len; j++) {
  13003. var stat = statements[j];
  13004. if (stat instanceof AST_Const || stat instanceof AST_Let)
  13005. return false;
  13006. }
  13007. var lct = ab instanceof AST_LoopControl ? compressor.loopcontrol_target(ab) : null;
  13008. return ab instanceof AST_Return && in_lambda && is_return_void(ab.value)
  13009. || ab instanceof AST_Continue && self === loop_body(lct)
  13010. || ab instanceof AST_Break && lct instanceof AST_BlockStatement && self === lct;
  13011. }
  13012. function extract_functions() {
  13013. var tail = statements.slice(i + 1);
  13014. statements.length = i + 1;
  13015. return tail.filter(function (stat) {
  13016. if (stat instanceof AST_Defun) {
  13017. statements.push(stat);
  13018. return false;
  13019. }
  13020. return true;
  13021. });
  13022. }
  13023. function as_statement_array_with_return(node, ab) {
  13024. var body = as_statement_array(node).slice(0, -1);
  13025. if (ab.value) {
  13026. body.push(make_node(AST_SimpleStatement, ab.value, {
  13027. body: ab.value.expression
  13028. }));
  13029. }
  13030. return body;
  13031. }
  13032. function next_index(i) {
  13033. for (var j = i + 1, len = statements.length; j < len; j++) {
  13034. var stat = statements[j];
  13035. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  13036. break;
  13037. }
  13038. }
  13039. return j;
  13040. }
  13041. function prev_index(i) {
  13042. for (var j = i; --j >= 0;) {
  13043. var stat = statements[j];
  13044. if (!(stat instanceof AST_Var && declarations_only(stat))) {
  13045. break;
  13046. }
  13047. }
  13048. return j;
  13049. }
  13050. }
  13051. function eliminate_dead_code(statements, compressor) {
  13052. var has_quit;
  13053. var self = compressor.self();
  13054. for (var i = 0, n = 0, len = statements.length; i < len; i++) {
  13055. var stat = statements[i];
  13056. if (stat instanceof AST_LoopControl) {
  13057. var lct = compressor.loopcontrol_target(stat);
  13058. if (stat instanceof AST_Break
  13059. && !(lct instanceof AST_IterationStatement)
  13060. && loop_body(lct) === self
  13061. || stat instanceof AST_Continue
  13062. && loop_body(lct) === self) {
  13063. if (stat.label) {
  13064. remove(stat.label.thedef.references, stat);
  13065. }
  13066. } else {
  13067. statements[n++] = stat;
  13068. }
  13069. } else {
  13070. statements[n++] = stat;
  13071. }
  13072. if (aborts(stat)) {
  13073. has_quit = statements.slice(i + 1);
  13074. break;
  13075. }
  13076. }
  13077. statements.length = n;
  13078. CHANGED = n != len;
  13079. if (has_quit)
  13080. has_quit.forEach(function (stat) {
  13081. trim_unreachable_code(compressor, stat, statements);
  13082. });
  13083. }
  13084. function declarations_only(node) {
  13085. return node.definitions.every((var_def) => !var_def.value
  13086. );
  13087. }
  13088. function sequencesize(statements, compressor) {
  13089. if (statements.length < 2)
  13090. return;
  13091. var seq = [], n = 0;
  13092. function push_seq() {
  13093. if (!seq.length)
  13094. return;
  13095. var body = make_sequence(seq[0], seq);
  13096. statements[n++] = make_node(AST_SimpleStatement, body, { body: body });
  13097. seq = [];
  13098. }
  13099. for (var i = 0, len = statements.length; i < len; i++) {
  13100. var stat = statements[i];
  13101. if (stat instanceof AST_SimpleStatement) {
  13102. if (seq.length >= compressor.sequences_limit)
  13103. push_seq();
  13104. var body = stat.body;
  13105. if (seq.length > 0)
  13106. body = body.drop_side_effect_free(compressor);
  13107. if (body)
  13108. merge_sequence(seq, body);
  13109. } else if (stat instanceof AST_Definitions && declarations_only(stat)
  13110. || stat instanceof AST_Defun) {
  13111. statements[n++] = stat;
  13112. } else {
  13113. push_seq();
  13114. statements[n++] = stat;
  13115. }
  13116. }
  13117. push_seq();
  13118. statements.length = n;
  13119. if (n != len)
  13120. CHANGED = true;
  13121. }
  13122. function to_simple_statement(block, decls) {
  13123. if (!(block instanceof AST_BlockStatement))
  13124. return block;
  13125. var stat = null;
  13126. for (var i = 0, len = block.body.length; i < len; i++) {
  13127. var line = block.body[i];
  13128. if (line instanceof AST_Var && declarations_only(line)) {
  13129. decls.push(line);
  13130. } else if (stat) {
  13131. return false;
  13132. } else {
  13133. stat = line;
  13134. }
  13135. }
  13136. return stat;
  13137. }
  13138. function sequencesize_2(statements, compressor) {
  13139. function cons_seq(right) {
  13140. n--;
  13141. CHANGED = true;
  13142. var left = prev.body;
  13143. return make_sequence(left, [left, right]).transform(compressor);
  13144. }
  13145. var n = 0, prev;
  13146. for (var i = 0; i < statements.length; i++) {
  13147. var stat = statements[i];
  13148. if (prev) {
  13149. if (stat instanceof AST_Exit) {
  13150. stat.value = cons_seq(stat.value || make_node(AST_Undefined, stat).transform(compressor));
  13151. } else if (stat instanceof AST_For) {
  13152. if (!(stat.init instanceof AST_Definitions)) {
  13153. const abort = walk(prev.body, node => {
  13154. if (node instanceof AST_Scope)
  13155. return true;
  13156. if (node instanceof AST_Binary
  13157. && node.operator === "in") {
  13158. return walk_abort;
  13159. }
  13160. });
  13161. if (!abort) {
  13162. if (stat.init)
  13163. stat.init = cons_seq(stat.init);
  13164. else {
  13165. stat.init = prev.body;
  13166. n--;
  13167. CHANGED = true;
  13168. }
  13169. }
  13170. }
  13171. } else if (stat instanceof AST_ForIn) {
  13172. if (!(stat.init instanceof AST_Const) && !(stat.init instanceof AST_Let)) {
  13173. stat.object = cons_seq(stat.object);
  13174. }
  13175. } else if (stat instanceof AST_If) {
  13176. stat.condition = cons_seq(stat.condition);
  13177. } else if (stat instanceof AST_Switch) {
  13178. stat.expression = cons_seq(stat.expression);
  13179. } else if (stat instanceof AST_With) {
  13180. stat.expression = cons_seq(stat.expression);
  13181. }
  13182. }
  13183. if (compressor.option("conditionals") && stat instanceof AST_If) {
  13184. var decls = [];
  13185. var body = to_simple_statement(stat.body, decls);
  13186. var alt = to_simple_statement(stat.alternative, decls);
  13187. if (body !== false && alt !== false && decls.length > 0) {
  13188. var len = decls.length;
  13189. decls.push(make_node(AST_If, stat, {
  13190. condition: stat.condition,
  13191. body: body || make_node(AST_EmptyStatement, stat.body),
  13192. alternative: alt
  13193. }));
  13194. decls.unshift(n, 1);
  13195. [].splice.apply(statements, decls);
  13196. i += len;
  13197. n += len + 1;
  13198. prev = null;
  13199. CHANGED = true;
  13200. continue;
  13201. }
  13202. }
  13203. statements[n++] = stat;
  13204. prev = stat instanceof AST_SimpleStatement ? stat : null;
  13205. }
  13206. statements.length = n;
  13207. }
  13208. function join_object_assignments(defn, body) {
  13209. if (!(defn instanceof AST_Definitions))
  13210. return;
  13211. var def = defn.definitions[defn.definitions.length - 1];
  13212. if (!(def.value instanceof AST_Object))
  13213. return;
  13214. var exprs;
  13215. if (body instanceof AST_Assign && !body.logical) {
  13216. exprs = [body];
  13217. } else if (body instanceof AST_Sequence) {
  13218. exprs = body.expressions.slice();
  13219. }
  13220. if (!exprs)
  13221. return;
  13222. var trimmed = false;
  13223. do {
  13224. var node = exprs[0];
  13225. if (!(node instanceof AST_Assign))
  13226. break;
  13227. if (node.operator != "=")
  13228. break;
  13229. if (!(node.left instanceof AST_PropAccess))
  13230. break;
  13231. var sym = node.left.expression;
  13232. if (!(sym instanceof AST_SymbolRef))
  13233. break;
  13234. if (def.name.name != sym.name)
  13235. break;
  13236. if (!node.right.is_constant_expression(scope))
  13237. break;
  13238. var prop = node.left.property;
  13239. if (prop instanceof AST_Node) {
  13240. prop = prop.evaluate(compressor);
  13241. }
  13242. if (prop instanceof AST_Node)
  13243. break;
  13244. prop = "" + prop;
  13245. var diff = compressor.option("ecma") < 2015
  13246. && compressor.has_directive("use strict") ? function (node) {
  13247. return node.key != prop && (node.key && node.key.name != prop);
  13248. } : function (node) {
  13249. return node.key && node.key.name != prop;
  13250. };
  13251. if (!def.value.properties.every(diff))
  13252. break;
  13253. var p = def.value.properties.filter(function (p) { return p.key === prop; })[0];
  13254. if (!p) {
  13255. def.value.properties.push(make_node(AST_ObjectKeyVal, node, {
  13256. key: prop,
  13257. value: node.right
  13258. }));
  13259. } else {
  13260. p.value = new AST_Sequence({
  13261. start: p.start,
  13262. expressions: [p.value.clone(), node.right.clone()],
  13263. end: p.end
  13264. });
  13265. }
  13266. exprs.shift();
  13267. trimmed = true;
  13268. } while (exprs.length);
  13269. return trimmed && exprs;
  13270. }
  13271. function join_consecutive_vars(statements) {
  13272. var defs;
  13273. for (var i = 0, j = -1, len = statements.length; i < len; i++) {
  13274. var stat = statements[i];
  13275. var prev = statements[j];
  13276. if (stat instanceof AST_Definitions) {
  13277. if (prev && prev.TYPE == stat.TYPE) {
  13278. prev.definitions = prev.definitions.concat(stat.definitions);
  13279. CHANGED = true;
  13280. } else if (defs && defs.TYPE == stat.TYPE && declarations_only(stat)) {
  13281. defs.definitions = defs.definitions.concat(stat.definitions);
  13282. CHANGED = true;
  13283. } else {
  13284. statements[++j] = stat;
  13285. defs = stat;
  13286. }
  13287. } else if (stat instanceof AST_Exit) {
  13288. stat.value = extract_object_assignments(stat.value);
  13289. } else if (stat instanceof AST_For) {
  13290. var exprs = join_object_assignments(prev, stat.init);
  13291. if (exprs) {
  13292. CHANGED = true;
  13293. stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
  13294. statements[++j] = stat;
  13295. } else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
  13296. if (stat.init) {
  13297. prev.definitions = prev.definitions.concat(stat.init.definitions);
  13298. }
  13299. stat.init = prev;
  13300. statements[j] = stat;
  13301. CHANGED = true;
  13302. } else if (defs && stat.init && defs.TYPE == stat.init.TYPE && declarations_only(stat.init)) {
  13303. defs.definitions = defs.definitions.concat(stat.init.definitions);
  13304. stat.init = null;
  13305. statements[++j] = stat;
  13306. CHANGED = true;
  13307. } else {
  13308. statements[++j] = stat;
  13309. }
  13310. } else if (stat instanceof AST_ForIn) {
  13311. stat.object = extract_object_assignments(stat.object);
  13312. } else if (stat instanceof AST_If) {
  13313. stat.condition = extract_object_assignments(stat.condition);
  13314. } else if (stat instanceof AST_SimpleStatement) {
  13315. var exprs = join_object_assignments(prev, stat.body);
  13316. if (exprs) {
  13317. CHANGED = true;
  13318. if (!exprs.length)
  13319. continue;
  13320. stat.body = make_sequence(stat.body, exprs);
  13321. }
  13322. statements[++j] = stat;
  13323. } else if (stat instanceof AST_Switch) {
  13324. stat.expression = extract_object_assignments(stat.expression);
  13325. } else if (stat instanceof AST_With) {
  13326. stat.expression = extract_object_assignments(stat.expression);
  13327. } else {
  13328. statements[++j] = stat;
  13329. }
  13330. }
  13331. statements.length = j + 1;
  13332. function extract_object_assignments(value) {
  13333. statements[++j] = stat;
  13334. var exprs = join_object_assignments(prev, value);
  13335. if (exprs) {
  13336. CHANGED = true;
  13337. if (exprs.length) {
  13338. return make_sequence(value, exprs);
  13339. } else if (value instanceof AST_Sequence) {
  13340. return value.tail_node().left;
  13341. } else {
  13342. return value.left;
  13343. }
  13344. }
  13345. return value;
  13346. }
  13347. }
  13348. }
  13349. /***********************************************************************
  13350. A JavaScript tokenizer / parser / beautifier / compressor.
  13351. https://github.com/mishoo/UglifyJS2
  13352. -------------------------------- (C) ---------------------------------
  13353. Author: Mihai Bazon
  13354. <mihai.bazon@gmail.com>
  13355. http://mihai.bazon.net/blog
  13356. Distributed under the BSD license:
  13357. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  13358. Redistribution and use in source and binary forms, with or without
  13359. modification, are permitted provided that the following conditions
  13360. are met:
  13361. * Redistributions of source code must retain the above
  13362. copyright notice, this list of conditions and the following
  13363. disclaimer.
  13364. * Redistributions in binary form must reproduce the above
  13365. copyright notice, this list of conditions and the following
  13366. disclaimer in the documentation and/or other materials
  13367. provided with the distribution.
  13368. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  13369. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13370. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13371. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  13372. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  13373. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13374. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  13375. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13376. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  13377. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  13378. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  13379. SUCH DAMAGE.
  13380. ***********************************************************************/
  13381. class Compressor extends TreeWalker {
  13382. constructor(options, { false_by_default = false, mangle_options = false }) {
  13383. super();
  13384. if (options.defaults !== undefined && !options.defaults) false_by_default = true;
  13385. this.options = defaults(options, {
  13386. arguments : false,
  13387. arrows : !false_by_default,
  13388. booleans : !false_by_default,
  13389. booleans_as_integers : false,
  13390. collapse_vars : !false_by_default,
  13391. comparisons : !false_by_default,
  13392. computed_props: !false_by_default,
  13393. conditionals : !false_by_default,
  13394. dead_code : !false_by_default,
  13395. defaults : true,
  13396. directives : !false_by_default,
  13397. drop_console : false,
  13398. drop_debugger : !false_by_default,
  13399. ecma : 5,
  13400. evaluate : !false_by_default,
  13401. expression : false,
  13402. global_defs : false,
  13403. hoist_funs : false,
  13404. hoist_props : !false_by_default,
  13405. hoist_vars : false,
  13406. ie8 : false,
  13407. if_return : !false_by_default,
  13408. inline : !false_by_default,
  13409. join_vars : !false_by_default,
  13410. keep_classnames: false,
  13411. keep_fargs : true,
  13412. keep_fnames : false,
  13413. keep_infinity : false,
  13414. loops : !false_by_default,
  13415. module : false,
  13416. negate_iife : !false_by_default,
  13417. passes : 1,
  13418. properties : !false_by_default,
  13419. pure_getters : !false_by_default && "strict",
  13420. pure_funcs : null,
  13421. reduce_funcs : !false_by_default,
  13422. reduce_vars : !false_by_default,
  13423. sequences : !false_by_default,
  13424. side_effects : !false_by_default,
  13425. switches : !false_by_default,
  13426. top_retain : null,
  13427. toplevel : !!(options && options["top_retain"]),
  13428. typeofs : !false_by_default,
  13429. unsafe : false,
  13430. unsafe_arrows : false,
  13431. unsafe_comps : false,
  13432. unsafe_Function: false,
  13433. unsafe_math : false,
  13434. unsafe_symbols: false,
  13435. unsafe_methods: false,
  13436. unsafe_proto : false,
  13437. unsafe_regexp : false,
  13438. unsafe_undefined: false,
  13439. unused : !false_by_default,
  13440. warnings : false // legacy
  13441. }, true);
  13442. var global_defs = this.options["global_defs"];
  13443. if (typeof global_defs == "object") for (var key in global_defs) {
  13444. if (key[0] === "@" && HOP(global_defs, key)) {
  13445. global_defs[key.slice(1)] = parse(global_defs[key], {
  13446. expression: true
  13447. });
  13448. }
  13449. }
  13450. if (this.options["inline"] === true) this.options["inline"] = 3;
  13451. var pure_funcs = this.options["pure_funcs"];
  13452. if (typeof pure_funcs == "function") {
  13453. this.pure_funcs = pure_funcs;
  13454. } else {
  13455. this.pure_funcs = pure_funcs ? function(node) {
  13456. return !pure_funcs.includes(node.expression.print_to_string());
  13457. } : return_true;
  13458. }
  13459. var top_retain = this.options["top_retain"];
  13460. if (top_retain instanceof RegExp) {
  13461. this.top_retain = function(def) {
  13462. return top_retain.test(def.name);
  13463. };
  13464. } else if (typeof top_retain == "function") {
  13465. this.top_retain = top_retain;
  13466. } else if (top_retain) {
  13467. if (typeof top_retain == "string") {
  13468. top_retain = top_retain.split(/,/);
  13469. }
  13470. this.top_retain = function(def) {
  13471. return top_retain.includes(def.name);
  13472. };
  13473. }
  13474. if (this.options["module"]) {
  13475. this.directives["use strict"] = true;
  13476. this.options["toplevel"] = true;
  13477. }
  13478. var toplevel = this.options["toplevel"];
  13479. this.toplevel = typeof toplevel == "string" ? {
  13480. funcs: /funcs/.test(toplevel),
  13481. vars: /vars/.test(toplevel)
  13482. } : {
  13483. funcs: toplevel,
  13484. vars: toplevel
  13485. };
  13486. var sequences = this.options["sequences"];
  13487. this.sequences_limit = sequences == 1 ? 800 : sequences | 0;
  13488. this.evaluated_regexps = new Map();
  13489. this._toplevel = undefined;
  13490. this.mangle_options = mangle_options;
  13491. }
  13492. option(key) {
  13493. return this.options[key];
  13494. }
  13495. exposed(def) {
  13496. if (def.export) return true;
  13497. if (def.global) for (var i = 0, len = def.orig.length; i < len; i++)
  13498. if (!this.toplevel[def.orig[i] instanceof AST_SymbolDefun ? "funcs" : "vars"])
  13499. return true;
  13500. return false;
  13501. }
  13502. in_boolean_context() {
  13503. if (!this.option("booleans")) return false;
  13504. var self = this.self();
  13505. for (var i = 0, p; p = this.parent(i); i++) {
  13506. if (p instanceof AST_SimpleStatement
  13507. || p instanceof AST_Conditional && p.condition === self
  13508. || p instanceof AST_DWLoop && p.condition === self
  13509. || p instanceof AST_For && p.condition === self
  13510. || p instanceof AST_If && p.condition === self
  13511. || p instanceof AST_UnaryPrefix && p.operator == "!" && p.expression === self) {
  13512. return true;
  13513. }
  13514. if (
  13515. p instanceof AST_Binary
  13516. && (
  13517. p.operator == "&&"
  13518. || p.operator == "||"
  13519. || p.operator == "??"
  13520. )
  13521. || p instanceof AST_Conditional
  13522. || p.tail_node() === self
  13523. ) {
  13524. self = p;
  13525. } else {
  13526. return false;
  13527. }
  13528. }
  13529. }
  13530. get_toplevel() {
  13531. return this._toplevel;
  13532. }
  13533. compress(toplevel) {
  13534. toplevel = toplevel.resolve_defines(this);
  13535. this._toplevel = toplevel;
  13536. if (this.option("expression")) {
  13537. this._toplevel.process_expression(true);
  13538. }
  13539. var passes = +this.options.passes || 1;
  13540. var min_count = 1 / 0;
  13541. var stopping = false;
  13542. var nth_identifier = this.mangle_options && this.mangle_options.nth_identifier || base54;
  13543. var mangle = { ie8: this.option("ie8"), nth_identifier: nth_identifier };
  13544. for (var pass = 0; pass < passes; pass++) {
  13545. this._toplevel.figure_out_scope(mangle);
  13546. if (pass === 0 && this.option("drop_console")) {
  13547. // must be run before reduce_vars and compress pass
  13548. this._toplevel = this._toplevel.drop_console();
  13549. }
  13550. if (pass > 0 || this.option("reduce_vars")) {
  13551. this._toplevel.reset_opt_flags(this);
  13552. }
  13553. this._toplevel = this._toplevel.transform(this);
  13554. if (passes > 1) {
  13555. let count = 0;
  13556. walk(this._toplevel, () => { count++; });
  13557. if (count < min_count) {
  13558. min_count = count;
  13559. stopping = false;
  13560. } else if (stopping) {
  13561. break;
  13562. } else {
  13563. stopping = true;
  13564. }
  13565. }
  13566. }
  13567. if (this.option("expression")) {
  13568. this._toplevel.process_expression(false);
  13569. }
  13570. toplevel = this._toplevel;
  13571. this._toplevel = undefined;
  13572. return toplevel;
  13573. }
  13574. before(node, descend) {
  13575. if (has_flag(node, SQUEEZED)) return node;
  13576. var was_scope = false;
  13577. if (node instanceof AST_Scope) {
  13578. node = node.hoist_properties(this);
  13579. node = node.hoist_declarations(this);
  13580. was_scope = true;
  13581. }
  13582. // Before https://github.com/mishoo/UglifyJS2/pull/1602 AST_Node.optimize()
  13583. // would call AST_Node.transform() if a different instance of AST_Node is
  13584. // produced after def_optimize().
  13585. // This corrupts TreeWalker.stack, which cause AST look-ups to malfunction.
  13586. // Migrate and defer all children's AST_Node.transform() to below, which
  13587. // will now happen after this parent AST_Node has been properly substituted
  13588. // thus gives a consistent AST snapshot.
  13589. descend(node, this);
  13590. // Existing code relies on how AST_Node.optimize() worked, and omitting the
  13591. // following replacement call would result in degraded efficiency of both
  13592. // output and performance.
  13593. descend(node, this);
  13594. var opt = node.optimize(this);
  13595. if (was_scope && opt instanceof AST_Scope) {
  13596. opt.drop_unused(this);
  13597. descend(opt, this);
  13598. }
  13599. if (opt === node) set_flag(opt, SQUEEZED);
  13600. return opt;
  13601. }
  13602. }
  13603. function def_optimize(node, optimizer) {
  13604. node.DEFMETHOD("optimize", function(compressor) {
  13605. var self = this;
  13606. if (has_flag(self, OPTIMIZED)) return self;
  13607. if (compressor.has_directive("use asm")) return self;
  13608. var opt = optimizer(self, compressor);
  13609. set_flag(opt, OPTIMIZED);
  13610. return opt;
  13611. });
  13612. }
  13613. def_optimize(AST_Node, function(self) {
  13614. return self;
  13615. });
  13616. AST_Toplevel.DEFMETHOD("drop_console", function() {
  13617. return this.transform(new TreeTransformer(function(self) {
  13618. if (self.TYPE == "Call") {
  13619. var exp = self.expression;
  13620. if (exp instanceof AST_PropAccess) {
  13621. var name = exp.expression;
  13622. while (name.expression) {
  13623. name = name.expression;
  13624. }
  13625. if (is_undeclared_ref(name) && name.name == "console") {
  13626. return make_node(AST_Undefined, self);
  13627. }
  13628. }
  13629. }
  13630. }));
  13631. });
  13632. AST_Node.DEFMETHOD("equivalent_to", function(node) {
  13633. return equivalent_to(this, node);
  13634. });
  13635. AST_Scope.DEFMETHOD("process_expression", function(insert, compressor) {
  13636. var self = this;
  13637. var tt = new TreeTransformer(function(node) {
  13638. if (insert && node instanceof AST_SimpleStatement) {
  13639. return make_node(AST_Return, node, {
  13640. value: node.body
  13641. });
  13642. }
  13643. if (!insert && node instanceof AST_Return) {
  13644. if (compressor) {
  13645. var value = node.value && node.value.drop_side_effect_free(compressor, true);
  13646. return value
  13647. ? make_node(AST_SimpleStatement, node, { body: value })
  13648. : make_node(AST_EmptyStatement, node);
  13649. }
  13650. return make_node(AST_SimpleStatement, node, {
  13651. body: node.value || make_node(AST_UnaryPrefix, node, {
  13652. operator: "void",
  13653. expression: make_node(AST_Number, node, {
  13654. value: 0
  13655. })
  13656. })
  13657. });
  13658. }
  13659. if (node instanceof AST_Class || node instanceof AST_Lambda && node !== self) {
  13660. return node;
  13661. }
  13662. if (node instanceof AST_Block) {
  13663. var index = node.body.length - 1;
  13664. if (index >= 0) {
  13665. node.body[index] = node.body[index].transform(tt);
  13666. }
  13667. } else if (node instanceof AST_If) {
  13668. node.body = node.body.transform(tt);
  13669. if (node.alternative) {
  13670. node.alternative = node.alternative.transform(tt);
  13671. }
  13672. } else if (node instanceof AST_With) {
  13673. node.body = node.body.transform(tt);
  13674. }
  13675. return node;
  13676. });
  13677. self.transform(tt);
  13678. });
  13679. AST_Toplevel.DEFMETHOD("reset_opt_flags", function(compressor) {
  13680. const self = this;
  13681. const reduce_vars = compressor.option("reduce_vars");
  13682. const preparation = new TreeWalker(function(node, descend) {
  13683. clear_flag(node, CLEAR_BETWEEN_PASSES);
  13684. if (reduce_vars) {
  13685. if (compressor.top_retain
  13686. && node instanceof AST_Defun // Only functions are retained
  13687. && preparation.parent() === self
  13688. ) {
  13689. set_flag(node, TOP);
  13690. }
  13691. return node.reduce_vars(preparation, descend, compressor);
  13692. }
  13693. });
  13694. // Stack of look-up tables to keep track of whether a `SymbolDef` has been
  13695. // properly assigned before use:
  13696. // - `push()` & `pop()` when visiting conditional branches
  13697. preparation.safe_ids = Object.create(null);
  13698. preparation.in_loop = null;
  13699. preparation.loop_ids = new Map();
  13700. preparation.defs_to_safe_ids = new Map();
  13701. self.walk(preparation);
  13702. });
  13703. AST_Symbol.DEFMETHOD("fixed_value", function() {
  13704. var fixed = this.thedef.fixed;
  13705. if (!fixed || fixed instanceof AST_Node) return fixed;
  13706. return fixed();
  13707. });
  13708. AST_SymbolRef.DEFMETHOD("is_immutable", function() {
  13709. var orig = this.definition().orig;
  13710. return orig.length == 1 && orig[0] instanceof AST_SymbolLambda;
  13711. });
  13712. function find_scope(tw) {
  13713. for (let i = 0;;i++) {
  13714. const p = tw.parent(i);
  13715. if (p instanceof AST_Toplevel) return p;
  13716. if (p instanceof AST_Lambda) return p;
  13717. if (p.block_scope) return p.block_scope;
  13718. }
  13719. }
  13720. function find_variable(compressor, name) {
  13721. var scope, i = 0;
  13722. while (scope = compressor.parent(i++)) {
  13723. if (scope instanceof AST_Scope) break;
  13724. if (scope instanceof AST_Catch && scope.argname) {
  13725. scope = scope.argname.definition().scope;
  13726. break;
  13727. }
  13728. }
  13729. return scope.find_variable(name);
  13730. }
  13731. function is_empty(thing) {
  13732. if (thing === null) return true;
  13733. if (thing instanceof AST_EmptyStatement) return true;
  13734. if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
  13735. return false;
  13736. }
  13737. 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");
  13738. AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) {
  13739. return !this.definition().undeclared
  13740. || compressor.option("unsafe") && global_names.has(this.name);
  13741. });
  13742. /* -----[ optimizers ]----- */
  13743. var directives = new Set(["use asm", "use strict"]);
  13744. def_optimize(AST_Directive, function(self, compressor) {
  13745. if (compressor.option("directives")
  13746. && (!directives.has(self.value) || compressor.has_directive(self.value) !== self)) {
  13747. return make_node(AST_EmptyStatement, self);
  13748. }
  13749. return self;
  13750. });
  13751. def_optimize(AST_Debugger, function(self, compressor) {
  13752. if (compressor.option("drop_debugger"))
  13753. return make_node(AST_EmptyStatement, self);
  13754. return self;
  13755. });
  13756. def_optimize(AST_LabeledStatement, function(self, compressor) {
  13757. if (self.body instanceof AST_Break
  13758. && compressor.loopcontrol_target(self.body) === self.body) {
  13759. return make_node(AST_EmptyStatement, self);
  13760. }
  13761. return self.label.references.length == 0 ? self.body : self;
  13762. });
  13763. def_optimize(AST_Block, function(self, compressor) {
  13764. tighten_body(self.body, compressor);
  13765. return self;
  13766. });
  13767. function can_be_extracted_from_if_block(node) {
  13768. return !(
  13769. node instanceof AST_Const
  13770. || node instanceof AST_Let
  13771. || node instanceof AST_Class
  13772. );
  13773. }
  13774. def_optimize(AST_BlockStatement, function(self, compressor) {
  13775. tighten_body(self.body, compressor);
  13776. switch (self.body.length) {
  13777. case 1:
  13778. if (!compressor.has_directive("use strict")
  13779. && compressor.parent() instanceof AST_If
  13780. && can_be_extracted_from_if_block(self.body[0])
  13781. || can_be_evicted_from_block(self.body[0])) {
  13782. return self.body[0];
  13783. }
  13784. break;
  13785. case 0: return make_node(AST_EmptyStatement, self);
  13786. }
  13787. return self;
  13788. });
  13789. function opt_AST_Lambda(self, compressor) {
  13790. tighten_body(self.body, compressor);
  13791. if (compressor.option("side_effects")
  13792. && self.body.length == 1
  13793. && self.body[0] === compressor.has_directive("use strict")) {
  13794. self.body.length = 0;
  13795. }
  13796. return self;
  13797. }
  13798. def_optimize(AST_Lambda, opt_AST_Lambda);
  13799. const r_keep_assign = /keep_assign/;
  13800. AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
  13801. if (!compressor.option("unused")) return;
  13802. if (compressor.has_directive("use asm")) return;
  13803. var self = this;
  13804. if (self.pinned()) return;
  13805. var drop_funcs = !(self instanceof AST_Toplevel) || compressor.toplevel.funcs;
  13806. var drop_vars = !(self instanceof AST_Toplevel) || compressor.toplevel.vars;
  13807. const assign_as_unused = r_keep_assign.test(compressor.option("unused")) ? return_false : function(node) {
  13808. if (node instanceof AST_Assign
  13809. && !node.logical
  13810. && (has_flag(node, WRITE_ONLY) || node.operator == "=")
  13811. ) {
  13812. return node.left;
  13813. }
  13814. if (node instanceof AST_Unary && has_flag(node, WRITE_ONLY)) {
  13815. return node.expression;
  13816. }
  13817. };
  13818. var in_use_ids = new Map();
  13819. var fixed_ids = new Map();
  13820. if (self instanceof AST_Toplevel && compressor.top_retain) {
  13821. self.variables.forEach(function(def) {
  13822. if (compressor.top_retain(def) && !in_use_ids.has(def.id)) {
  13823. in_use_ids.set(def.id, def);
  13824. }
  13825. });
  13826. }
  13827. var var_defs_by_id = new Map();
  13828. var initializations = new Map();
  13829. // pass 1: find out which symbols are directly used in
  13830. // this scope (not in nested scopes).
  13831. var scope = this;
  13832. var tw = new TreeWalker(function(node, descend) {
  13833. if (node instanceof AST_Lambda && node.uses_arguments && !tw.has_directive("use strict")) {
  13834. node.argnames.forEach(function(argname) {
  13835. if (!(argname instanceof AST_SymbolDeclaration)) return;
  13836. var def = argname.definition();
  13837. if (!in_use_ids.has(def.id)) {
  13838. in_use_ids.set(def.id, def);
  13839. }
  13840. });
  13841. }
  13842. if (node === self) return;
  13843. if (node instanceof AST_Defun || node instanceof AST_DefClass) {
  13844. var node_def = node.name.definition();
  13845. const in_export = tw.parent() instanceof AST_Export;
  13846. if (in_export || !drop_funcs && scope === self) {
  13847. if (node_def.global && !in_use_ids.has(node_def.id)) {
  13848. in_use_ids.set(node_def.id, node_def);
  13849. }
  13850. }
  13851. if (node instanceof AST_DefClass) {
  13852. if (
  13853. node.extends
  13854. && (node.extends.has_side_effects(compressor)
  13855. || node.extends.may_throw(compressor))
  13856. ) {
  13857. node.extends.walk(tw);
  13858. }
  13859. for (const prop of node.properties) {
  13860. if (
  13861. prop.has_side_effects(compressor) ||
  13862. prop.may_throw(compressor)
  13863. ) {
  13864. prop.walk(tw);
  13865. }
  13866. }
  13867. }
  13868. map_add(initializations, node_def.id, node);
  13869. return true; // don't go in nested scopes
  13870. }
  13871. if (node instanceof AST_SymbolFunarg && scope === self) {
  13872. map_add(var_defs_by_id, node.definition().id, node);
  13873. }
  13874. if (node instanceof AST_Definitions && scope === self) {
  13875. const in_export = tw.parent() instanceof AST_Export;
  13876. node.definitions.forEach(function(def) {
  13877. if (def.name instanceof AST_SymbolVar) {
  13878. map_add(var_defs_by_id, def.name.definition().id, def);
  13879. }
  13880. if (in_export || !drop_vars) {
  13881. walk(def.name, node => {
  13882. if (node instanceof AST_SymbolDeclaration) {
  13883. const def = node.definition();
  13884. if (
  13885. (in_export || def.global)
  13886. && !in_use_ids.has(def.id)
  13887. ) {
  13888. in_use_ids.set(def.id, def);
  13889. }
  13890. }
  13891. });
  13892. }
  13893. if (def.value) {
  13894. if (def.name instanceof AST_Destructuring) {
  13895. def.walk(tw);
  13896. } else {
  13897. var node_def = def.name.definition();
  13898. map_add(initializations, node_def.id, def.value);
  13899. if (!node_def.chained && def.name.fixed_value() === def.value) {
  13900. fixed_ids.set(node_def.id, def);
  13901. }
  13902. }
  13903. if (def.value.has_side_effects(compressor)) {
  13904. def.value.walk(tw);
  13905. }
  13906. }
  13907. });
  13908. return true;
  13909. }
  13910. return scan_ref_scoped(node, descend);
  13911. });
  13912. self.walk(tw);
  13913. // pass 2: for every used symbol we need to walk its
  13914. // initialization code to figure out if it uses other
  13915. // symbols (that may not be in_use).
  13916. tw = new TreeWalker(scan_ref_scoped);
  13917. in_use_ids.forEach(function (def) {
  13918. var init = initializations.get(def.id);
  13919. if (init) init.forEach(function(init) {
  13920. init.walk(tw);
  13921. });
  13922. });
  13923. // pass 3: we should drop declarations not in_use
  13924. var tt = new TreeTransformer(
  13925. function before(node, descend, in_list) {
  13926. var parent = tt.parent();
  13927. if (drop_vars) {
  13928. const sym = assign_as_unused(node);
  13929. if (sym instanceof AST_SymbolRef) {
  13930. var def = sym.definition();
  13931. var in_use = in_use_ids.has(def.id);
  13932. if (node instanceof AST_Assign) {
  13933. if (!in_use || fixed_ids.has(def.id) && fixed_ids.get(def.id) !== node) {
  13934. return maintain_this_binding(parent, node, node.right.transform(tt));
  13935. }
  13936. } else if (!in_use) return in_list ? MAP.skip : make_node(AST_Number, node, {
  13937. value: 0
  13938. });
  13939. }
  13940. }
  13941. if (scope !== self) return;
  13942. var def;
  13943. if (node.name
  13944. && (node instanceof AST_ClassExpression
  13945. && !keep_name(compressor.option("keep_classnames"), (def = node.name.definition()).name)
  13946. || node instanceof AST_Function
  13947. && !keep_name(compressor.option("keep_fnames"), (def = node.name.definition()).name))) {
  13948. // any declarations with same name will overshadow
  13949. // name of this anonymous function and can therefore
  13950. // never be used anywhere
  13951. if (!in_use_ids.has(def.id) || def.orig.length > 1) node.name = null;
  13952. }
  13953. if (node instanceof AST_Lambda && !(node instanceof AST_Accessor)) {
  13954. var trim = !compressor.option("keep_fargs");
  13955. for (var a = node.argnames, i = a.length; --i >= 0;) {
  13956. var sym = a[i];
  13957. if (sym instanceof AST_Expansion) {
  13958. sym = sym.expression;
  13959. }
  13960. if (sym instanceof AST_DefaultAssign) {
  13961. sym = sym.left;
  13962. }
  13963. // Do not drop destructuring arguments.
  13964. // They constitute a type assertion, so dropping
  13965. // them would stop that TypeError which would happen
  13966. // if someone called it with an incorrectly formatted
  13967. // parameter.
  13968. if (!(sym instanceof AST_Destructuring) && !in_use_ids.has(sym.definition().id)) {
  13969. set_flag(sym, UNUSED);
  13970. if (trim) {
  13971. a.pop();
  13972. }
  13973. } else {
  13974. trim = false;
  13975. }
  13976. }
  13977. }
  13978. if ((node instanceof AST_Defun || node instanceof AST_DefClass) && node !== self) {
  13979. const def = node.name.definition();
  13980. let keep = def.global && !drop_funcs || in_use_ids.has(def.id);
  13981. if (!keep) {
  13982. def.eliminated++;
  13983. if (node instanceof AST_DefClass) {
  13984. // Classes might have extends with side effects
  13985. const side_effects = node.drop_side_effect_free(compressor);
  13986. if (side_effects) {
  13987. return make_node(AST_SimpleStatement, node, {
  13988. body: side_effects
  13989. });
  13990. }
  13991. }
  13992. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  13993. }
  13994. }
  13995. if (node instanceof AST_Definitions && !(parent instanceof AST_ForIn && parent.init === node)) {
  13996. var drop_block = !(parent instanceof AST_Toplevel) && !(node instanceof AST_Var);
  13997. // place uninitialized names at the start
  13998. var body = [], head = [], tail = [];
  13999. // for unused names whose initialization has
  14000. // side effects, we can cascade the init. code
  14001. // into the next one, or next statement.
  14002. var side_effects = [];
  14003. node.definitions.forEach(function(def) {
  14004. if (def.value) def.value = def.value.transform(tt);
  14005. var is_destructure = def.name instanceof AST_Destructuring;
  14006. var sym = is_destructure
  14007. ? new SymbolDef(null, { name: "<destructure>" }) /* fake SymbolDef */
  14008. : def.name.definition();
  14009. if (drop_block && sym.global) return tail.push(def);
  14010. if (!(drop_vars || drop_block)
  14011. || is_destructure
  14012. && (def.name.names.length
  14013. || def.name.is_array
  14014. || compressor.option("pure_getters") != true)
  14015. || in_use_ids.has(sym.id)
  14016. ) {
  14017. if (def.value && fixed_ids.has(sym.id) && fixed_ids.get(sym.id) !== def) {
  14018. def.value = def.value.drop_side_effect_free(compressor);
  14019. }
  14020. if (def.name instanceof AST_SymbolVar) {
  14021. var var_defs = var_defs_by_id.get(sym.id);
  14022. if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
  14023. if (def.value) {
  14024. var ref = make_node(AST_SymbolRef, def.name, def.name);
  14025. sym.references.push(ref);
  14026. var assign = make_node(AST_Assign, def, {
  14027. operator: "=",
  14028. logical: false,
  14029. left: ref,
  14030. right: def.value
  14031. });
  14032. if (fixed_ids.get(sym.id) === def) {
  14033. fixed_ids.set(sym.id, assign);
  14034. }
  14035. side_effects.push(assign.transform(tt));
  14036. }
  14037. remove(var_defs, def);
  14038. sym.eliminated++;
  14039. return;
  14040. }
  14041. }
  14042. if (def.value) {
  14043. if (side_effects.length > 0) {
  14044. if (tail.length > 0) {
  14045. side_effects.push(def.value);
  14046. def.value = make_sequence(def.value, side_effects);
  14047. } else {
  14048. body.push(make_node(AST_SimpleStatement, node, {
  14049. body: make_sequence(node, side_effects)
  14050. }));
  14051. }
  14052. side_effects = [];
  14053. }
  14054. tail.push(def);
  14055. } else {
  14056. head.push(def);
  14057. }
  14058. } else if (sym.orig[0] instanceof AST_SymbolCatch) {
  14059. var value = def.value && def.value.drop_side_effect_free(compressor);
  14060. if (value) side_effects.push(value);
  14061. def.value = null;
  14062. head.push(def);
  14063. } else {
  14064. var value = def.value && def.value.drop_side_effect_free(compressor);
  14065. if (value) {
  14066. side_effects.push(value);
  14067. }
  14068. sym.eliminated++;
  14069. }
  14070. });
  14071. if (head.length > 0 || tail.length > 0) {
  14072. node.definitions = head.concat(tail);
  14073. body.push(node);
  14074. }
  14075. if (side_effects.length > 0) {
  14076. body.push(make_node(AST_SimpleStatement, node, {
  14077. body: make_sequence(node, side_effects)
  14078. }));
  14079. }
  14080. switch (body.length) {
  14081. case 0:
  14082. return in_list ? MAP.skip : make_node(AST_EmptyStatement, node);
  14083. case 1:
  14084. return body[0];
  14085. default:
  14086. return in_list ? MAP.splice(body) : make_node(AST_BlockStatement, node, {
  14087. body: body
  14088. });
  14089. }
  14090. }
  14091. // certain combination of unused name + side effect leads to:
  14092. // https://github.com/mishoo/UglifyJS2/issues/44
  14093. // https://github.com/mishoo/UglifyJS2/issues/1830
  14094. // https://github.com/mishoo/UglifyJS2/issues/1838
  14095. // that's an invalid AST.
  14096. // We fix it at this stage by moving the `var` outside the `for`.
  14097. if (node instanceof AST_For) {
  14098. descend(node, this);
  14099. var block;
  14100. if (node.init instanceof AST_BlockStatement) {
  14101. block = node.init;
  14102. node.init = block.body.pop();
  14103. block.body.push(node);
  14104. }
  14105. if (node.init instanceof AST_SimpleStatement) {
  14106. node.init = node.init.body;
  14107. } else if (is_empty(node.init)) {
  14108. node.init = null;
  14109. }
  14110. return !block ? node : in_list ? MAP.splice(block.body) : block;
  14111. }
  14112. if (node instanceof AST_LabeledStatement
  14113. && node.body instanceof AST_For
  14114. ) {
  14115. descend(node, this);
  14116. if (node.body instanceof AST_BlockStatement) {
  14117. var block = node.body;
  14118. node.body = block.body.pop();
  14119. block.body.push(node);
  14120. return in_list ? MAP.splice(block.body) : block;
  14121. }
  14122. return node;
  14123. }
  14124. if (node instanceof AST_BlockStatement) {
  14125. descend(node, this);
  14126. if (in_list && node.body.every(can_be_evicted_from_block)) {
  14127. return MAP.splice(node.body);
  14128. }
  14129. return node;
  14130. }
  14131. if (node instanceof AST_Scope) {
  14132. const save_scope = scope;
  14133. scope = node;
  14134. descend(node, this);
  14135. scope = save_scope;
  14136. return node;
  14137. }
  14138. }
  14139. );
  14140. self.transform(tt);
  14141. function scan_ref_scoped(node, descend) {
  14142. var node_def;
  14143. const sym = assign_as_unused(node);
  14144. if (sym instanceof AST_SymbolRef
  14145. && !is_ref_of(node.left, AST_SymbolBlockDeclaration)
  14146. && self.variables.get(sym.name) === (node_def = sym.definition())
  14147. ) {
  14148. if (node instanceof AST_Assign) {
  14149. node.right.walk(tw);
  14150. if (!node_def.chained && node.left.fixed_value() === node.right) {
  14151. fixed_ids.set(node_def.id, node);
  14152. }
  14153. }
  14154. return true;
  14155. }
  14156. if (node instanceof AST_SymbolRef) {
  14157. node_def = node.definition();
  14158. if (!in_use_ids.has(node_def.id)) {
  14159. in_use_ids.set(node_def.id, node_def);
  14160. if (node_def.orig[0] instanceof AST_SymbolCatch) {
  14161. const redef = node_def.scope.is_block_scope()
  14162. && node_def.scope.get_defun_scope().variables.get(node_def.name);
  14163. if (redef) in_use_ids.set(redef.id, redef);
  14164. }
  14165. }
  14166. return true;
  14167. }
  14168. if (node instanceof AST_Scope) {
  14169. var save_scope = scope;
  14170. scope = node;
  14171. descend();
  14172. scope = save_scope;
  14173. return true;
  14174. }
  14175. }
  14176. });
  14177. AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
  14178. var self = this;
  14179. if (compressor.has_directive("use asm")) return self;
  14180. // Hoisting makes no sense in an arrow func
  14181. if (!Array.isArray(self.body)) return self;
  14182. var hoist_funs = compressor.option("hoist_funs");
  14183. var hoist_vars = compressor.option("hoist_vars");
  14184. if (hoist_funs || hoist_vars) {
  14185. var dirs = [];
  14186. var hoisted = [];
  14187. var vars = new Map(), vars_found = 0, var_decl = 0;
  14188. // let's count var_decl first, we seem to waste a lot of
  14189. // space if we hoist `var` when there's only one.
  14190. walk(self, node => {
  14191. if (node instanceof AST_Scope && node !== self)
  14192. return true;
  14193. if (node instanceof AST_Var) {
  14194. ++var_decl;
  14195. return true;
  14196. }
  14197. });
  14198. hoist_vars = hoist_vars && var_decl > 1;
  14199. var tt = new TreeTransformer(
  14200. function before(node) {
  14201. if (node !== self) {
  14202. if (node instanceof AST_Directive) {
  14203. dirs.push(node);
  14204. return make_node(AST_EmptyStatement, node);
  14205. }
  14206. if (hoist_funs && node instanceof AST_Defun
  14207. && !(tt.parent() instanceof AST_Export)
  14208. && tt.parent() === self) {
  14209. hoisted.push(node);
  14210. return make_node(AST_EmptyStatement, node);
  14211. }
  14212. if (
  14213. hoist_vars
  14214. && node instanceof AST_Var
  14215. && !node.definitions.some(def => def.name instanceof AST_Destructuring)
  14216. ) {
  14217. node.definitions.forEach(function(def) {
  14218. vars.set(def.name.name, def);
  14219. ++vars_found;
  14220. });
  14221. var seq = node.to_assignments(compressor);
  14222. var p = tt.parent();
  14223. if (p instanceof AST_ForIn && p.init === node) {
  14224. if (seq == null) {
  14225. var def = node.definitions[0].name;
  14226. return make_node(AST_SymbolRef, def, def);
  14227. }
  14228. return seq;
  14229. }
  14230. if (p instanceof AST_For && p.init === node) {
  14231. return seq;
  14232. }
  14233. if (!seq) return make_node(AST_EmptyStatement, node);
  14234. return make_node(AST_SimpleStatement, node, {
  14235. body: seq
  14236. });
  14237. }
  14238. if (node instanceof AST_Scope)
  14239. return node; // to avoid descending in nested scopes
  14240. }
  14241. }
  14242. );
  14243. self = self.transform(tt);
  14244. if (vars_found > 0) {
  14245. // collect only vars which don't show up in self's arguments list
  14246. var defs = [];
  14247. const is_lambda = self instanceof AST_Lambda;
  14248. const args_as_names = is_lambda ? self.args_as_names() : null;
  14249. vars.forEach((def, name) => {
  14250. if (is_lambda && args_as_names.some((x) => x.name === def.name.name)) {
  14251. vars.delete(name);
  14252. } else {
  14253. def = def.clone();
  14254. def.value = null;
  14255. defs.push(def);
  14256. vars.set(name, def);
  14257. }
  14258. });
  14259. if (defs.length > 0) {
  14260. // try to merge in assignments
  14261. for (var i = 0; i < self.body.length;) {
  14262. if (self.body[i] instanceof AST_SimpleStatement) {
  14263. var expr = self.body[i].body, sym, assign;
  14264. if (expr instanceof AST_Assign
  14265. && expr.operator == "="
  14266. && (sym = expr.left) instanceof AST_Symbol
  14267. && vars.has(sym.name)
  14268. ) {
  14269. var def = vars.get(sym.name);
  14270. if (def.value) break;
  14271. def.value = expr.right;
  14272. remove(defs, def);
  14273. defs.push(def);
  14274. self.body.splice(i, 1);
  14275. continue;
  14276. }
  14277. if (expr instanceof AST_Sequence
  14278. && (assign = expr.expressions[0]) instanceof AST_Assign
  14279. && assign.operator == "="
  14280. && (sym = assign.left) instanceof AST_Symbol
  14281. && vars.has(sym.name)
  14282. ) {
  14283. var def = vars.get(sym.name);
  14284. if (def.value) break;
  14285. def.value = assign.right;
  14286. remove(defs, def);
  14287. defs.push(def);
  14288. self.body[i].body = make_sequence(expr, expr.expressions.slice(1));
  14289. continue;
  14290. }
  14291. }
  14292. if (self.body[i] instanceof AST_EmptyStatement) {
  14293. self.body.splice(i, 1);
  14294. continue;
  14295. }
  14296. if (self.body[i] instanceof AST_BlockStatement) {
  14297. self.body.splice(i, 1, ...self.body[i].body);
  14298. continue;
  14299. }
  14300. break;
  14301. }
  14302. defs = make_node(AST_Var, self, {
  14303. definitions: defs
  14304. });
  14305. hoisted.push(defs);
  14306. }
  14307. }
  14308. self.body = dirs.concat(hoisted, self.body);
  14309. }
  14310. return self;
  14311. });
  14312. AST_Scope.DEFMETHOD("hoist_properties", function(compressor) {
  14313. var self = this;
  14314. if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self;
  14315. var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false;
  14316. var defs_by_id = new Map();
  14317. var hoister = new TreeTransformer(function(node, descend) {
  14318. if (node instanceof AST_Definitions
  14319. && hoister.parent() instanceof AST_Export) return node;
  14320. if (node instanceof AST_VarDef) {
  14321. const sym = node.name;
  14322. let def;
  14323. let value;
  14324. if (sym.scope === self
  14325. && (def = sym.definition()).escaped != 1
  14326. && !def.assignments
  14327. && !def.direct_access
  14328. && !def.single_use
  14329. && !compressor.exposed(def)
  14330. && !top_retain(def)
  14331. && (value = sym.fixed_value()) === node.value
  14332. && value instanceof AST_Object
  14333. && !value.properties.some(prop =>
  14334. prop instanceof AST_Expansion || prop.computed_key()
  14335. )
  14336. ) {
  14337. descend(node, this);
  14338. const defs = new Map();
  14339. const assignments = [];
  14340. value.properties.forEach(({ key, value }) => {
  14341. const scope = find_scope(hoister);
  14342. const symbol = self.create_symbol(sym.CTOR, {
  14343. source: sym,
  14344. scope,
  14345. conflict_scopes: new Set([
  14346. scope,
  14347. ...sym.definition().references.map(ref => ref.scope)
  14348. ]),
  14349. tentative_name: sym.name + "_" + key
  14350. });
  14351. defs.set(String(key), symbol.definition());
  14352. assignments.push(make_node(AST_VarDef, node, {
  14353. name: symbol,
  14354. value
  14355. }));
  14356. });
  14357. defs_by_id.set(def.id, defs);
  14358. return MAP.splice(assignments);
  14359. }
  14360. } else if (node instanceof AST_PropAccess
  14361. && node.expression instanceof AST_SymbolRef
  14362. ) {
  14363. const defs = defs_by_id.get(node.expression.definition().id);
  14364. if (defs) {
  14365. const def = defs.get(String(get_simple_key(node.property)));
  14366. const sym = make_node(AST_SymbolRef, node, {
  14367. name: def.name,
  14368. scope: node.expression.scope,
  14369. thedef: def
  14370. });
  14371. sym.reference({});
  14372. return sym;
  14373. }
  14374. }
  14375. });
  14376. return self.transform(hoister);
  14377. });
  14378. def_optimize(AST_SimpleStatement, function(self, compressor) {
  14379. if (compressor.option("side_effects")) {
  14380. var body = self.body;
  14381. var node = body.drop_side_effect_free(compressor, true);
  14382. if (!node) {
  14383. return make_node(AST_EmptyStatement, self);
  14384. }
  14385. if (node !== body) {
  14386. return make_node(AST_SimpleStatement, self, { body: node });
  14387. }
  14388. }
  14389. return self;
  14390. });
  14391. def_optimize(AST_While, function(self, compressor) {
  14392. return compressor.option("loops") ? make_node(AST_For, self, self).optimize(compressor) : self;
  14393. });
  14394. def_optimize(AST_Do, function(self, compressor) {
  14395. if (!compressor.option("loops")) return self;
  14396. var cond = self.condition.tail_node().evaluate(compressor);
  14397. if (!(cond instanceof AST_Node)) {
  14398. if (cond) return make_node(AST_For, self, {
  14399. body: make_node(AST_BlockStatement, self.body, {
  14400. body: [
  14401. self.body,
  14402. make_node(AST_SimpleStatement, self.condition, {
  14403. body: self.condition
  14404. })
  14405. ]
  14406. })
  14407. }).optimize(compressor);
  14408. if (!has_break_or_continue(self, compressor.parent())) {
  14409. return make_node(AST_BlockStatement, self.body, {
  14410. body: [
  14411. self.body,
  14412. make_node(AST_SimpleStatement, self.condition, {
  14413. body: self.condition
  14414. })
  14415. ]
  14416. }).optimize(compressor);
  14417. }
  14418. }
  14419. return self;
  14420. });
  14421. function if_break_in_loop(self, compressor) {
  14422. var first = self.body instanceof AST_BlockStatement ? self.body.body[0] : self.body;
  14423. if (compressor.option("dead_code") && is_break(first)) {
  14424. var body = [];
  14425. if (self.init instanceof AST_Statement) {
  14426. body.push(self.init);
  14427. } else if (self.init) {
  14428. body.push(make_node(AST_SimpleStatement, self.init, {
  14429. body: self.init
  14430. }));
  14431. }
  14432. if (self.condition) {
  14433. body.push(make_node(AST_SimpleStatement, self.condition, {
  14434. body: self.condition
  14435. }));
  14436. }
  14437. trim_unreachable_code(compressor, self.body, body);
  14438. return make_node(AST_BlockStatement, self, {
  14439. body: body
  14440. });
  14441. }
  14442. if (first instanceof AST_If) {
  14443. if (is_break(first.body)) {
  14444. if (self.condition) {
  14445. self.condition = make_node(AST_Binary, self.condition, {
  14446. left: self.condition,
  14447. operator: "&&",
  14448. right: first.condition.negate(compressor),
  14449. });
  14450. } else {
  14451. self.condition = first.condition.negate(compressor);
  14452. }
  14453. drop_it(first.alternative);
  14454. } else if (is_break(first.alternative)) {
  14455. if (self.condition) {
  14456. self.condition = make_node(AST_Binary, self.condition, {
  14457. left: self.condition,
  14458. operator: "&&",
  14459. right: first.condition,
  14460. });
  14461. } else {
  14462. self.condition = first.condition;
  14463. }
  14464. drop_it(first.body);
  14465. }
  14466. }
  14467. return self;
  14468. function is_break(node) {
  14469. return node instanceof AST_Break
  14470. && compressor.loopcontrol_target(node) === compressor.self();
  14471. }
  14472. function drop_it(rest) {
  14473. rest = as_statement_array(rest);
  14474. if (self.body instanceof AST_BlockStatement) {
  14475. self.body = self.body.clone();
  14476. self.body.body = rest.concat(self.body.body.slice(1));
  14477. self.body = self.body.transform(compressor);
  14478. } else {
  14479. self.body = make_node(AST_BlockStatement, self.body, {
  14480. body: rest
  14481. }).transform(compressor);
  14482. }
  14483. self = if_break_in_loop(self, compressor);
  14484. }
  14485. }
  14486. def_optimize(AST_For, function(self, compressor) {
  14487. if (!compressor.option("loops")) return self;
  14488. if (compressor.option("side_effects") && self.init) {
  14489. self.init = self.init.drop_side_effect_free(compressor);
  14490. }
  14491. if (self.condition) {
  14492. var cond = self.condition.evaluate(compressor);
  14493. if (!(cond instanceof AST_Node)) {
  14494. if (cond) self.condition = null;
  14495. else if (!compressor.option("dead_code")) {
  14496. var orig = self.condition;
  14497. self.condition = make_node_from_constant(cond, self.condition);
  14498. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  14499. }
  14500. }
  14501. if (compressor.option("dead_code")) {
  14502. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  14503. if (!cond) {
  14504. var body = [];
  14505. trim_unreachable_code(compressor, self.body, body);
  14506. if (self.init instanceof AST_Statement) {
  14507. body.push(self.init);
  14508. } else if (self.init) {
  14509. body.push(make_node(AST_SimpleStatement, self.init, {
  14510. body: self.init
  14511. }));
  14512. }
  14513. body.push(make_node(AST_SimpleStatement, self.condition, {
  14514. body: self.condition
  14515. }));
  14516. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  14517. }
  14518. }
  14519. }
  14520. return if_break_in_loop(self, compressor);
  14521. });
  14522. def_optimize(AST_If, function(self, compressor) {
  14523. if (is_empty(self.alternative)) self.alternative = null;
  14524. if (!compressor.option("conditionals")) return self;
  14525. // if condition can be statically determined, drop
  14526. // one of the blocks. note, statically determined implies
  14527. // “has no side effects”; also it doesn't work for cases like
  14528. // `x && true`, though it probably should.
  14529. var cond = self.condition.evaluate(compressor);
  14530. if (!compressor.option("dead_code") && !(cond instanceof AST_Node)) {
  14531. var orig = self.condition;
  14532. self.condition = make_node_from_constant(cond, orig);
  14533. self.condition = best_of_expression(self.condition.transform(compressor), orig);
  14534. }
  14535. if (compressor.option("dead_code")) {
  14536. if (cond instanceof AST_Node) cond = self.condition.tail_node().evaluate(compressor);
  14537. if (!cond) {
  14538. var body = [];
  14539. trim_unreachable_code(compressor, self.body, body);
  14540. body.push(make_node(AST_SimpleStatement, self.condition, {
  14541. body: self.condition
  14542. }));
  14543. if (self.alternative) body.push(self.alternative);
  14544. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  14545. } else if (!(cond instanceof AST_Node)) {
  14546. var body = [];
  14547. body.push(make_node(AST_SimpleStatement, self.condition, {
  14548. body: self.condition
  14549. }));
  14550. body.push(self.body);
  14551. if (self.alternative) {
  14552. trim_unreachable_code(compressor, self.alternative, body);
  14553. }
  14554. return make_node(AST_BlockStatement, self, { body: body }).optimize(compressor);
  14555. }
  14556. }
  14557. var negated = self.condition.negate(compressor);
  14558. var self_condition_length = self.condition.size();
  14559. var negated_length = negated.size();
  14560. var negated_is_best = negated_length < self_condition_length;
  14561. if (self.alternative && negated_is_best) {
  14562. negated_is_best = false; // because we already do the switch here.
  14563. // no need to swap values of self_condition_length and negated_length
  14564. // here because they are only used in an equality comparison later on.
  14565. self.condition = negated;
  14566. var tmp = self.body;
  14567. self.body = self.alternative || make_node(AST_EmptyStatement, self);
  14568. self.alternative = tmp;
  14569. }
  14570. if (is_empty(self.body) && is_empty(self.alternative)) {
  14571. return make_node(AST_SimpleStatement, self.condition, {
  14572. body: self.condition.clone()
  14573. }).optimize(compressor);
  14574. }
  14575. if (self.body instanceof AST_SimpleStatement
  14576. && self.alternative instanceof AST_SimpleStatement) {
  14577. return make_node(AST_SimpleStatement, self, {
  14578. body: make_node(AST_Conditional, self, {
  14579. condition : self.condition,
  14580. consequent : self.body.body,
  14581. alternative : self.alternative.body
  14582. })
  14583. }).optimize(compressor);
  14584. }
  14585. if (is_empty(self.alternative) && self.body instanceof AST_SimpleStatement) {
  14586. if (self_condition_length === negated_length && !negated_is_best
  14587. && self.condition instanceof AST_Binary && self.condition.operator == "||") {
  14588. // although the code length of self.condition and negated are the same,
  14589. // negated does not require additional surrounding parentheses.
  14590. // see https://github.com/mishoo/UglifyJS2/issues/979
  14591. negated_is_best = true;
  14592. }
  14593. if (negated_is_best) return make_node(AST_SimpleStatement, self, {
  14594. body: make_node(AST_Binary, self, {
  14595. operator : "||",
  14596. left : negated,
  14597. right : self.body.body
  14598. })
  14599. }).optimize(compressor);
  14600. return make_node(AST_SimpleStatement, self, {
  14601. body: make_node(AST_Binary, self, {
  14602. operator : "&&",
  14603. left : self.condition,
  14604. right : self.body.body
  14605. })
  14606. }).optimize(compressor);
  14607. }
  14608. if (self.body instanceof AST_EmptyStatement
  14609. && self.alternative instanceof AST_SimpleStatement) {
  14610. return make_node(AST_SimpleStatement, self, {
  14611. body: make_node(AST_Binary, self, {
  14612. operator : "||",
  14613. left : self.condition,
  14614. right : self.alternative.body
  14615. })
  14616. }).optimize(compressor);
  14617. }
  14618. if (self.body instanceof AST_Exit
  14619. && self.alternative instanceof AST_Exit
  14620. && self.body.TYPE == self.alternative.TYPE) {
  14621. return make_node(self.body.CTOR, self, {
  14622. value: make_node(AST_Conditional, self, {
  14623. condition : self.condition,
  14624. consequent : self.body.value || make_node(AST_Undefined, self.body),
  14625. alternative : self.alternative.value || make_node(AST_Undefined, self.alternative)
  14626. }).transform(compressor)
  14627. }).optimize(compressor);
  14628. }
  14629. if (self.body instanceof AST_If
  14630. && !self.body.alternative
  14631. && !self.alternative) {
  14632. self = make_node(AST_If, self, {
  14633. condition: make_node(AST_Binary, self.condition, {
  14634. operator: "&&",
  14635. left: self.condition,
  14636. right: self.body.condition
  14637. }),
  14638. body: self.body.body,
  14639. alternative: null
  14640. });
  14641. }
  14642. if (aborts(self.body)) {
  14643. if (self.alternative) {
  14644. var alt = self.alternative;
  14645. self.alternative = null;
  14646. return make_node(AST_BlockStatement, self, {
  14647. body: [ self, alt ]
  14648. }).optimize(compressor);
  14649. }
  14650. }
  14651. if (aborts(self.alternative)) {
  14652. var body = self.body;
  14653. self.body = self.alternative;
  14654. self.condition = negated_is_best ? negated : self.condition.negate(compressor);
  14655. self.alternative = null;
  14656. return make_node(AST_BlockStatement, self, {
  14657. body: [ self, body ]
  14658. }).optimize(compressor);
  14659. }
  14660. return self;
  14661. });
  14662. def_optimize(AST_Switch, function(self, compressor) {
  14663. if (!compressor.option("switches")) return self;
  14664. var branch;
  14665. var value = self.expression.evaluate(compressor);
  14666. if (!(value instanceof AST_Node)) {
  14667. var orig = self.expression;
  14668. self.expression = make_node_from_constant(value, orig);
  14669. self.expression = best_of_expression(self.expression.transform(compressor), orig);
  14670. }
  14671. if (!compressor.option("dead_code")) return self;
  14672. if (value instanceof AST_Node) {
  14673. value = self.expression.tail_node().evaluate(compressor);
  14674. }
  14675. var decl = [];
  14676. var body = [];
  14677. var default_branch;
  14678. var exact_match;
  14679. for (var i = 0, len = self.body.length; i < len && !exact_match; i++) {
  14680. branch = self.body[i];
  14681. if (branch instanceof AST_Default) {
  14682. if (!default_branch) {
  14683. default_branch = branch;
  14684. } else {
  14685. eliminate_branch(branch, body[body.length - 1]);
  14686. }
  14687. } else if (!(value instanceof AST_Node)) {
  14688. var exp = branch.expression.evaluate(compressor);
  14689. if (!(exp instanceof AST_Node) && exp !== value) {
  14690. eliminate_branch(branch, body[body.length - 1]);
  14691. continue;
  14692. }
  14693. if (exp instanceof AST_Node) exp = branch.expression.tail_node().evaluate(compressor);
  14694. if (exp === value) {
  14695. exact_match = branch;
  14696. if (default_branch) {
  14697. var default_index = body.indexOf(default_branch);
  14698. body.splice(default_index, 1);
  14699. eliminate_branch(default_branch, body[default_index - 1]);
  14700. default_branch = null;
  14701. }
  14702. }
  14703. }
  14704. body.push(branch);
  14705. }
  14706. while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
  14707. self.body = body;
  14708. let default_or_exact = default_branch || exact_match;
  14709. default_branch = null;
  14710. exact_match = null;
  14711. // group equivalent branches so they will be located next to each other,
  14712. // that way the next micro-optimization will merge them.
  14713. // ** bail micro-optimization if not a simple switch case with breaks
  14714. if (body.every((branch, i) =>
  14715. (branch === default_or_exact || branch.expression instanceof AST_Constant)
  14716. && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
  14717. ) {
  14718. for (let i = 0; i < body.length; i++) {
  14719. const branch = body[i];
  14720. for (let j = i + 1; j < body.length; j++) {
  14721. const next = body[j];
  14722. if (next.body.length === 0) continue;
  14723. const last_branch = j === (body.length - 1);
  14724. const equivalentBranch = branches_equivalent(next, branch, false);
  14725. if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
  14726. if (!equivalentBranch && last_branch) {
  14727. next.body.push(make_node(AST_Break));
  14728. }
  14729. // let's find previous siblings with inert fallthrough...
  14730. let x = j - 1;
  14731. let fallthroughDepth = 0;
  14732. while (x > i) {
  14733. if (is_inert_body(body[x--])) {
  14734. fallthroughDepth++;
  14735. } else {
  14736. break;
  14737. }
  14738. }
  14739. const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
  14740. body.splice(i + 1, 0, ...plucked);
  14741. i += plucked.length;
  14742. }
  14743. }
  14744. }
  14745. }
  14746. // merge equivalent branches in a row
  14747. for (let i = 0; i < body.length; i++) {
  14748. let branch = body[i];
  14749. if (branch.body.length === 0) continue;
  14750. if (!aborts(branch)) continue;
  14751. for (let j = i + 1; j < body.length; i++, j++) {
  14752. let next = body[j];
  14753. if (next.body.length === 0) continue;
  14754. if (
  14755. branches_equivalent(next, branch, false)
  14756. || (j === body.length - 1 && branches_equivalent(next, branch, true))
  14757. ) {
  14758. branch.body = [];
  14759. branch = next;
  14760. continue;
  14761. }
  14762. break;
  14763. }
  14764. }
  14765. // Prune any empty branches at the end of the switch statement.
  14766. {
  14767. let i = body.length - 1;
  14768. for (; i >= 0; i--) {
  14769. let bbody = body[i].body;
  14770. if (is_break(bbody[bbody.length - 1], compressor)) bbody.pop();
  14771. if (!is_inert_body(body[i])) break;
  14772. }
  14773. // i now points to the index of a branch that contains a body. By incrementing, it's
  14774. // pointing to the first branch that's empty.
  14775. i++;
  14776. if (!default_or_exact || body.indexOf(default_or_exact) >= i) {
  14777. // The default behavior is to do nothing. We can take advantage of that to
  14778. // remove all case expressions that are side-effect free that also do
  14779. // nothing, since they'll default to doing nothing. But we can't remove any
  14780. // case expressions before one that would side-effect, since they may cause
  14781. // the side-effect to be skipped.
  14782. for (let j = body.length - 1; j >= i; j--) {
  14783. let branch = body[j];
  14784. if (branch === default_or_exact) {
  14785. default_or_exact = null;
  14786. body.pop();
  14787. } else if (!branch.expression.has_side_effects(compressor)) {
  14788. body.pop();
  14789. } else {
  14790. break;
  14791. }
  14792. }
  14793. }
  14794. }
  14795. // Prune side-effect free branches that fall into default.
  14796. DEFAULT: if (default_or_exact) {
  14797. let default_index = body.indexOf(default_or_exact);
  14798. let default_body_index = default_index;
  14799. for (; default_body_index < body.length - 1; default_body_index++) {
  14800. if (!is_inert_body(body[default_body_index])) break;
  14801. }
  14802. if (default_body_index < body.length - 1) {
  14803. break DEFAULT;
  14804. }
  14805. let side_effect_index = body.length - 1;
  14806. for (; side_effect_index >= 0; side_effect_index--) {
  14807. let branch = body[side_effect_index];
  14808. if (branch === default_or_exact) continue;
  14809. if (branch.expression.has_side_effects(compressor)) break;
  14810. }
  14811. // If the default behavior comes after any side-effect case expressions,
  14812. // then we can fold all side-effect free cases into the default branch.
  14813. // If the side-effect case is after the default, then any side-effect
  14814. // free cases could prevent the side-effect from occurring.
  14815. if (default_body_index > side_effect_index) {
  14816. let prev_body_index = default_index - 1;
  14817. for (; prev_body_index >= 0; prev_body_index--) {
  14818. if (!is_inert_body(body[prev_body_index])) break;
  14819. }
  14820. let before = Math.max(side_effect_index, prev_body_index) + 1;
  14821. let after = default_index;
  14822. if (side_effect_index > default_index) {
  14823. // If the default falls into the same body as a side-effect
  14824. // case, then we need preserve that case and only prune the
  14825. // cases after it.
  14826. after = side_effect_index;
  14827. body[side_effect_index].body = body[default_body_index].body;
  14828. } else {
  14829. // The default will be the last branch.
  14830. default_or_exact.body = body[default_body_index].body;
  14831. }
  14832. // Prune everything after the default (or last side-effect case)
  14833. // until the next case with a body.
  14834. body.splice(after + 1, default_body_index - after);
  14835. // Prune everything before the default that falls into it.
  14836. body.splice(before, default_index - before);
  14837. }
  14838. }
  14839. // See if we can remove the switch entirely if all cases (the default) fall into the same case body.
  14840. DEFAULT: if (default_or_exact) {
  14841. let i = body.findIndex(branch => !is_inert_body(branch));
  14842. let caseBody;
  14843. // `i` is equal to one of the following:
  14844. // - `-1`, there is no body in the switch statement.
  14845. // - `body.length - 1`, all cases fall into the same body.
  14846. // - anything else, there are multiple bodies in the switch.
  14847. if (i === body.length - 1) {
  14848. // All cases fall into the case body.
  14849. let branch = body[i];
  14850. if (has_nested_break(self)) break DEFAULT;
  14851. // This is the last case body, and we've already pruned any breaks, so it's
  14852. // safe to hoist.
  14853. caseBody = make_node(AST_BlockStatement, branch, {
  14854. body: branch.body
  14855. });
  14856. branch.body = [];
  14857. } else if (i !== -1) {
  14858. // If there are multiple bodies, then we cannot optimize anything.
  14859. break DEFAULT;
  14860. }
  14861. let sideEffect = body.find(branch => {
  14862. return (
  14863. branch !== default_or_exact
  14864. && branch.expression.has_side_effects(compressor)
  14865. );
  14866. });
  14867. // If no cases cause a side-effect, we can eliminate the switch entirely.
  14868. if (!sideEffect) {
  14869. return make_node(AST_BlockStatement, self, {
  14870. body: decl.concat(
  14871. statement(self.expression),
  14872. default_or_exact.expression ? statement(default_or_exact.expression) : [],
  14873. caseBody || []
  14874. )
  14875. }).optimize(compressor);
  14876. }
  14877. // If we're this far, either there was no body or all cases fell into the same body.
  14878. // If there was no body, then we don't need a default branch (because the default is
  14879. // do nothing). If there was a body, we'll extract it to after the switch, so the
  14880. // switch's new default is to do nothing and we can still prune it.
  14881. const default_index = body.indexOf(default_or_exact);
  14882. body.splice(default_index, 1);
  14883. default_or_exact = null;
  14884. if (caseBody) {
  14885. // Recurse into switch statement one more time so that we can append the case body
  14886. // outside of the switch. This recursion will only happen once since we've pruned
  14887. // the default case.
  14888. return make_node(AST_BlockStatement, self, {
  14889. body: decl.concat(self, caseBody)
  14890. }).optimize(compressor);
  14891. }
  14892. // If we fall here, there is a default branch somewhere, there are no case bodies,
  14893. // and there's a side-effect somewhere. Just let the below paths take care of it.
  14894. }
  14895. if (body.length > 0) {
  14896. body[0].body = decl.concat(body[0].body);
  14897. }
  14898. if (body.length == 0) {
  14899. return make_node(AST_BlockStatement, self, {
  14900. body: decl.concat(statement(self.expression))
  14901. }).optimize(compressor);
  14902. }
  14903. if (body.length == 1 && !has_nested_break(self)) {
  14904. // This is the last case body, and we've already pruned any breaks, so it's
  14905. // safe to hoist.
  14906. let branch = body[0];
  14907. return make_node(AST_If, self, {
  14908. condition: make_node(AST_Binary, self, {
  14909. operator: "===",
  14910. left: self.expression,
  14911. right: branch.expression,
  14912. }),
  14913. body: make_node(AST_BlockStatement, branch, {
  14914. body: branch.body
  14915. }),
  14916. alternative: null
  14917. }).optimize(compressor);
  14918. }
  14919. if (body.length === 2 && default_or_exact && !has_nested_break(self)) {
  14920. let branch = body[0] === default_or_exact ? body[1] : body[0];
  14921. let exact_exp = default_or_exact.expression && statement(default_or_exact.expression);
  14922. if (aborts(body[0])) {
  14923. // Only the first branch body could have a break (at the last statement)
  14924. let first = body[0];
  14925. if (is_break(first.body[first.body.length - 1], compressor)) {
  14926. first.body.pop();
  14927. }
  14928. return make_node(AST_If, self, {
  14929. condition: make_node(AST_Binary, self, {
  14930. operator: "===",
  14931. left: self.expression,
  14932. right: branch.expression,
  14933. }),
  14934. body: make_node(AST_BlockStatement, branch, {
  14935. body: branch.body
  14936. }),
  14937. alternative: make_node(AST_BlockStatement, default_or_exact, {
  14938. body: [].concat(
  14939. exact_exp || [],
  14940. default_or_exact.body
  14941. )
  14942. })
  14943. }).optimize(compressor);
  14944. }
  14945. let operator = "===";
  14946. let consequent = make_node(AST_BlockStatement, branch, {
  14947. body: branch.body,
  14948. });
  14949. let always = make_node(AST_BlockStatement, default_or_exact, {
  14950. body: [].concat(
  14951. exact_exp || [],
  14952. default_or_exact.body
  14953. )
  14954. });
  14955. if (body[0] === default_or_exact) {
  14956. operator = "!==";
  14957. let tmp = always;
  14958. always = consequent;
  14959. consequent = tmp;
  14960. }
  14961. return make_node(AST_BlockStatement, self, {
  14962. body: [
  14963. make_node(AST_If, self, {
  14964. condition: make_node(AST_Binary, self, {
  14965. operator: operator,
  14966. left: self.expression,
  14967. right: branch.expression,
  14968. }),
  14969. body: consequent,
  14970. alternative: null
  14971. })
  14972. ].concat(always)
  14973. }).optimize(compressor);
  14974. }
  14975. return self;
  14976. function eliminate_branch(branch, prev) {
  14977. if (prev && !aborts(prev)) {
  14978. prev.body = prev.body.concat(branch.body);
  14979. } else {
  14980. trim_unreachable_code(compressor, branch, decl);
  14981. }
  14982. }
  14983. function branches_equivalent(branch, prev, insertBreak) {
  14984. let bbody = branch.body;
  14985. let pbody = prev.body;
  14986. if (insertBreak) {
  14987. bbody = bbody.concat(make_node(AST_Break));
  14988. }
  14989. if (bbody.length !== pbody.length) return false;
  14990. let bblock = make_node(AST_BlockStatement, branch, { body: bbody });
  14991. let pblock = make_node(AST_BlockStatement, prev, { body: pbody });
  14992. return bblock.equivalent_to(pblock);
  14993. }
  14994. function statement(expression) {
  14995. return make_node(AST_SimpleStatement, expression, {
  14996. body: expression
  14997. });
  14998. }
  14999. function has_nested_break(root) {
  15000. let has_break = false;
  15001. let tw = new TreeWalker(node => {
  15002. if (has_break) return true;
  15003. if (node instanceof AST_Lambda) return true;
  15004. if (node instanceof AST_SimpleStatement) return true;
  15005. if (!is_break(node, tw)) return;
  15006. let parent = tw.parent();
  15007. if (
  15008. parent instanceof AST_SwitchBranch
  15009. && parent.body[parent.body.length - 1] === node
  15010. ) {
  15011. return;
  15012. }
  15013. has_break = true;
  15014. });
  15015. root.walk(tw);
  15016. return has_break;
  15017. }
  15018. function is_break(node, stack) {
  15019. return node instanceof AST_Break
  15020. && stack.loopcontrol_target(node) === self;
  15021. }
  15022. function is_inert_body(branch) {
  15023. return !aborts(branch) && !make_node(AST_BlockStatement, branch, {
  15024. body: branch.body
  15025. }).has_side_effects(compressor);
  15026. }
  15027. });
  15028. def_optimize(AST_Try, function(self, compressor) {
  15029. tighten_body(self.body, compressor);
  15030. if (self.bcatch && self.bfinally && self.bfinally.body.every(is_empty)) self.bfinally = null;
  15031. if (compressor.option("dead_code") && self.body.every(is_empty)) {
  15032. var body = [];
  15033. if (self.bcatch) {
  15034. trim_unreachable_code(compressor, self.bcatch, body);
  15035. }
  15036. if (self.bfinally) body.push(...self.bfinally.body);
  15037. return make_node(AST_BlockStatement, self, {
  15038. body: body
  15039. }).optimize(compressor);
  15040. }
  15041. return self;
  15042. });
  15043. AST_Definitions.DEFMETHOD("remove_initializers", function() {
  15044. var decls = [];
  15045. this.definitions.forEach(function(def) {
  15046. if (def.name instanceof AST_SymbolDeclaration) {
  15047. def.value = null;
  15048. decls.push(def);
  15049. } else {
  15050. walk(def.name, node => {
  15051. if (node instanceof AST_SymbolDeclaration) {
  15052. decls.push(make_node(AST_VarDef, def, {
  15053. name: node,
  15054. value: null
  15055. }));
  15056. }
  15057. });
  15058. }
  15059. });
  15060. this.definitions = decls;
  15061. });
  15062. AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
  15063. var reduce_vars = compressor.option("reduce_vars");
  15064. var assignments = [];
  15065. for (const def of this.definitions) {
  15066. if (def.value) {
  15067. var name = make_node(AST_SymbolRef, def.name, def.name);
  15068. assignments.push(make_node(AST_Assign, def, {
  15069. operator : "=",
  15070. logical: false,
  15071. left : name,
  15072. right : def.value
  15073. }));
  15074. if (reduce_vars) name.definition().fixed = false;
  15075. } else if (def.value) {
  15076. // Because it's a destructuring, do not turn into an assignment.
  15077. var varDef = make_node(AST_VarDef, def, {
  15078. name: def.name,
  15079. value: def.value
  15080. });
  15081. var var_ = make_node(AST_Var, def, {
  15082. definitions: [ varDef ]
  15083. });
  15084. assignments.push(var_);
  15085. }
  15086. const thedef = def.name.definition();
  15087. thedef.eliminated++;
  15088. thedef.replaced--;
  15089. }
  15090. if (assignments.length == 0) return null;
  15091. return make_sequence(this, assignments);
  15092. });
  15093. def_optimize(AST_Definitions, function(self) {
  15094. if (self.definitions.length == 0)
  15095. return make_node(AST_EmptyStatement, self);
  15096. return self;
  15097. });
  15098. def_optimize(AST_VarDef, function(self, compressor) {
  15099. if (
  15100. self.name instanceof AST_SymbolLet
  15101. && self.value != null
  15102. && is_undefined(self.value, compressor)
  15103. ) {
  15104. self.value = null;
  15105. }
  15106. return self;
  15107. });
  15108. def_optimize(AST_Import, function(self) {
  15109. return self;
  15110. });
  15111. // TODO this only works with AST_Defun, shouldn't it work for other ways of defining functions?
  15112. function retain_top_func(fn, compressor) {
  15113. return compressor.top_retain
  15114. && fn instanceof AST_Defun
  15115. && has_flag(fn, TOP)
  15116. && fn.name
  15117. && compressor.top_retain(fn.name);
  15118. }
  15119. def_optimize(AST_Call, function(self, compressor) {
  15120. var exp = self.expression;
  15121. var fn = exp;
  15122. inline_array_like_spread(self.args);
  15123. var simple_args = self.args.every((arg) =>
  15124. !(arg instanceof AST_Expansion)
  15125. );
  15126. if (compressor.option("reduce_vars")
  15127. && fn instanceof AST_SymbolRef
  15128. && !has_annotation(self, _NOINLINE)
  15129. ) {
  15130. const fixed = fn.fixed_value();
  15131. if (!retain_top_func(fixed, compressor)) {
  15132. fn = fixed;
  15133. }
  15134. }
  15135. var is_func = fn instanceof AST_Lambda;
  15136. if (is_func && fn.pinned()) return self;
  15137. if (compressor.option("unused")
  15138. && simple_args
  15139. && is_func
  15140. && !fn.uses_arguments) {
  15141. var pos = 0, last = 0;
  15142. for (var i = 0, len = self.args.length; i < len; i++) {
  15143. if (fn.argnames[i] instanceof AST_Expansion) {
  15144. if (has_flag(fn.argnames[i].expression, UNUSED)) while (i < len) {
  15145. var node = self.args[i++].drop_side_effect_free(compressor);
  15146. if (node) {
  15147. self.args[pos++] = node;
  15148. }
  15149. } else while (i < len) {
  15150. self.args[pos++] = self.args[i++];
  15151. }
  15152. last = pos;
  15153. break;
  15154. }
  15155. var trim = i >= fn.argnames.length;
  15156. if (trim || has_flag(fn.argnames[i], UNUSED)) {
  15157. var node = self.args[i].drop_side_effect_free(compressor);
  15158. if (node) {
  15159. self.args[pos++] = node;
  15160. } else if (!trim) {
  15161. self.args[pos++] = make_node(AST_Number, self.args[i], {
  15162. value: 0
  15163. });
  15164. continue;
  15165. }
  15166. } else {
  15167. self.args[pos++] = self.args[i];
  15168. }
  15169. last = pos;
  15170. }
  15171. self.args.length = last;
  15172. }
  15173. if (compressor.option("unsafe")) {
  15174. if (exp instanceof AST_Dot && exp.start.value === "Array" && exp.property === "from" && self.args.length === 1) {
  15175. const [argument] = self.args;
  15176. if (argument instanceof AST_Array) {
  15177. return make_node(AST_Array, argument, {
  15178. elements: argument.elements
  15179. }).optimize(compressor);
  15180. }
  15181. }
  15182. if (is_undeclared_ref(exp)) switch (exp.name) {
  15183. case "Array":
  15184. if (self.args.length != 1) {
  15185. return make_node(AST_Array, self, {
  15186. elements: self.args
  15187. }).optimize(compressor);
  15188. } else if (self.args[0] instanceof AST_Number && self.args[0].value <= 11) {
  15189. const elements = [];
  15190. for (let i = 0; i < self.args[0].value; i++) elements.push(new AST_Hole);
  15191. return new AST_Array({ elements });
  15192. }
  15193. break;
  15194. case "Object":
  15195. if (self.args.length == 0) {
  15196. return make_node(AST_Object, self, {
  15197. properties: []
  15198. });
  15199. }
  15200. break;
  15201. case "String":
  15202. if (self.args.length == 0) return make_node(AST_String, self, {
  15203. value: ""
  15204. });
  15205. if (self.args.length <= 1) return make_node(AST_Binary, self, {
  15206. left: self.args[0],
  15207. operator: "+",
  15208. right: make_node(AST_String, self, { value: "" })
  15209. }).optimize(compressor);
  15210. break;
  15211. case "Number":
  15212. if (self.args.length == 0) return make_node(AST_Number, self, {
  15213. value: 0
  15214. });
  15215. if (self.args.length == 1 && compressor.option("unsafe_math")) {
  15216. return make_node(AST_UnaryPrefix, self, {
  15217. expression: self.args[0],
  15218. operator: "+"
  15219. }).optimize(compressor);
  15220. }
  15221. break;
  15222. case "Symbol":
  15223. if (self.args.length == 1 && self.args[0] instanceof AST_String && compressor.option("unsafe_symbols"))
  15224. self.args.length = 0;
  15225. break;
  15226. case "Boolean":
  15227. if (self.args.length == 0) return make_node(AST_False, self);
  15228. if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
  15229. expression: make_node(AST_UnaryPrefix, self, {
  15230. expression: self.args[0],
  15231. operator: "!"
  15232. }),
  15233. operator: "!"
  15234. }).optimize(compressor);
  15235. break;
  15236. case "RegExp":
  15237. var params = [];
  15238. if (self.args.length >= 1
  15239. && self.args.length <= 2
  15240. && self.args.every((arg) => {
  15241. var value = arg.evaluate(compressor);
  15242. params.push(value);
  15243. return arg !== value;
  15244. })
  15245. ) {
  15246. let [ source, flags ] = params;
  15247. source = regexp_source_fix(new RegExp(source).source);
  15248. const rx = make_node(AST_RegExp, self, {
  15249. value: { source, flags }
  15250. });
  15251. if (rx._eval(compressor) !== rx) {
  15252. return rx;
  15253. }
  15254. }
  15255. break;
  15256. } else if (exp instanceof AST_Dot) switch(exp.property) {
  15257. case "toString":
  15258. if (self.args.length == 0 && !exp.expression.may_throw_on_access(compressor)) {
  15259. return make_node(AST_Binary, self, {
  15260. left: make_node(AST_String, self, { value: "" }),
  15261. operator: "+",
  15262. right: exp.expression
  15263. }).optimize(compressor);
  15264. }
  15265. break;
  15266. case "join":
  15267. if (exp.expression instanceof AST_Array) EXIT: {
  15268. var separator;
  15269. if (self.args.length > 0) {
  15270. separator = self.args[0].evaluate(compressor);
  15271. if (separator === self.args[0]) break EXIT; // not a constant
  15272. }
  15273. var elements = [];
  15274. var consts = [];
  15275. for (var i = 0, len = exp.expression.elements.length; i < len; i++) {
  15276. var el = exp.expression.elements[i];
  15277. if (el instanceof AST_Expansion) break EXIT;
  15278. var value = el.evaluate(compressor);
  15279. if (value !== el) {
  15280. consts.push(value);
  15281. } else {
  15282. if (consts.length > 0) {
  15283. elements.push(make_node(AST_String, self, {
  15284. value: consts.join(separator)
  15285. }));
  15286. consts.length = 0;
  15287. }
  15288. elements.push(el);
  15289. }
  15290. }
  15291. if (consts.length > 0) {
  15292. elements.push(make_node(AST_String, self, {
  15293. value: consts.join(separator)
  15294. }));
  15295. }
  15296. if (elements.length == 0) return make_node(AST_String, self, { value: "" });
  15297. if (elements.length == 1) {
  15298. if (elements[0].is_string(compressor)) {
  15299. return elements[0];
  15300. }
  15301. return make_node(AST_Binary, elements[0], {
  15302. operator : "+",
  15303. left : make_node(AST_String, self, { value: "" }),
  15304. right : elements[0]
  15305. });
  15306. }
  15307. if (separator == "") {
  15308. var first;
  15309. if (elements[0].is_string(compressor)
  15310. || elements[1].is_string(compressor)) {
  15311. first = elements.shift();
  15312. } else {
  15313. first = make_node(AST_String, self, { value: "" });
  15314. }
  15315. return elements.reduce(function(prev, el) {
  15316. return make_node(AST_Binary, el, {
  15317. operator : "+",
  15318. left : prev,
  15319. right : el
  15320. });
  15321. }, first).optimize(compressor);
  15322. }
  15323. // need this awkward cloning to not affect original element
  15324. // best_of will decide which one to get through.
  15325. var node = self.clone();
  15326. node.expression = node.expression.clone();
  15327. node.expression.expression = node.expression.expression.clone();
  15328. node.expression.expression.elements = elements;
  15329. return best_of(compressor, self, node);
  15330. }
  15331. break;
  15332. case "charAt":
  15333. if (exp.expression.is_string(compressor)) {
  15334. var arg = self.args[0];
  15335. var index = arg ? arg.evaluate(compressor) : 0;
  15336. if (index !== arg) {
  15337. return make_node(AST_Sub, exp, {
  15338. expression: exp.expression,
  15339. property: make_node_from_constant(index | 0, arg || exp)
  15340. }).optimize(compressor);
  15341. }
  15342. }
  15343. break;
  15344. case "apply":
  15345. if (self.args.length == 2 && self.args[1] instanceof AST_Array) {
  15346. var args = self.args[1].elements.slice();
  15347. args.unshift(self.args[0]);
  15348. return make_node(AST_Call, self, {
  15349. expression: make_node(AST_Dot, exp, {
  15350. expression: exp.expression,
  15351. optional: false,
  15352. property: "call"
  15353. }),
  15354. args: args
  15355. }).optimize(compressor);
  15356. }
  15357. break;
  15358. case "call":
  15359. var func = exp.expression;
  15360. if (func instanceof AST_SymbolRef) {
  15361. func = func.fixed_value();
  15362. }
  15363. if (func instanceof AST_Lambda && !func.contains_this()) {
  15364. return (self.args.length ? make_sequence(this, [
  15365. self.args[0],
  15366. make_node(AST_Call, self, {
  15367. expression: exp.expression,
  15368. args: self.args.slice(1)
  15369. })
  15370. ]) : make_node(AST_Call, self, {
  15371. expression: exp.expression,
  15372. args: []
  15373. })).optimize(compressor);
  15374. }
  15375. break;
  15376. }
  15377. }
  15378. if (compressor.option("unsafe_Function")
  15379. && is_undeclared_ref(exp)
  15380. && exp.name == "Function") {
  15381. // new Function() => function(){}
  15382. if (self.args.length == 0) return make_node(AST_Function, self, {
  15383. argnames: [],
  15384. body: []
  15385. }).optimize(compressor);
  15386. var nth_identifier = compressor.mangle_options && compressor.mangle_options.nth_identifier || base54;
  15387. if (self.args.every((x) => x instanceof AST_String)) {
  15388. // quite a corner-case, but we can handle it:
  15389. // https://github.com/mishoo/UglifyJS2/issues/203
  15390. // if the code argument is a constant, then we can minify it.
  15391. try {
  15392. var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
  15393. return arg.value;
  15394. }).join(",") + "){" + self.args[self.args.length - 1].value + "})";
  15395. var ast = parse(code);
  15396. var mangle = { ie8: compressor.option("ie8"), nth_identifier: nth_identifier };
  15397. ast.figure_out_scope(mangle);
  15398. var comp = new Compressor(compressor.options, {
  15399. mangle_options: compressor.mangle_options
  15400. });
  15401. ast = ast.transform(comp);
  15402. ast.figure_out_scope(mangle);
  15403. ast.compute_char_frequency(mangle);
  15404. ast.mangle_names(mangle);
  15405. var fun;
  15406. walk(ast, node => {
  15407. if (is_func_expr(node)) {
  15408. fun = node;
  15409. return walk_abort;
  15410. }
  15411. });
  15412. var code = OutputStream();
  15413. AST_BlockStatement.prototype._codegen.call(fun, fun, code);
  15414. self.args = [
  15415. make_node(AST_String, self, {
  15416. value: fun.argnames.map(function(arg) {
  15417. return arg.print_to_string();
  15418. }).join(",")
  15419. }),
  15420. make_node(AST_String, self.args[self.args.length - 1], {
  15421. value: code.get().replace(/^{|}$/g, "")
  15422. })
  15423. ];
  15424. return self;
  15425. } catch (ex) {
  15426. if (!(ex instanceof JS_Parse_Error)) {
  15427. throw ex;
  15428. }
  15429. // Otherwise, it crashes at runtime. Or maybe it's nonstandard syntax.
  15430. }
  15431. }
  15432. }
  15433. var stat = is_func && fn.body[0];
  15434. var is_regular_func = is_func && !fn.is_generator && !fn.async;
  15435. var can_inline = is_regular_func && compressor.option("inline") && !self.is_callee_pure(compressor);
  15436. if (can_inline && stat instanceof AST_Return) {
  15437. let returned = stat.value;
  15438. if (!returned || returned.is_constant_expression()) {
  15439. if (returned) {
  15440. returned = returned.clone(true);
  15441. } else {
  15442. returned = make_node(AST_Undefined, self);
  15443. }
  15444. const args = self.args.concat(returned);
  15445. return make_sequence(self, args).optimize(compressor);
  15446. }
  15447. // optimize identity function
  15448. if (
  15449. fn.argnames.length === 1
  15450. && (fn.argnames[0] instanceof AST_SymbolFunarg)
  15451. && self.args.length < 2
  15452. && returned instanceof AST_SymbolRef
  15453. && returned.name === fn.argnames[0].name
  15454. ) {
  15455. const replacement =
  15456. (self.args[0] || make_node(AST_Undefined)).optimize(compressor);
  15457. let parent;
  15458. if (
  15459. replacement instanceof AST_PropAccess
  15460. && (parent = compressor.parent()) instanceof AST_Call
  15461. && parent.expression === self
  15462. ) {
  15463. // identity function was being used to remove `this`, like in
  15464. //
  15465. // id(bag.no_this)(...)
  15466. //
  15467. // Replace with a larger but more effish (0, bag.no_this) wrapper.
  15468. return make_sequence(self, [
  15469. make_node(AST_Number, self, { value: 0 }),
  15470. replacement
  15471. ]);
  15472. }
  15473. // replace call with first argument or undefined if none passed
  15474. return replacement;
  15475. }
  15476. }
  15477. if (can_inline) {
  15478. var scope, in_loop, level = -1;
  15479. let def;
  15480. let returned_value;
  15481. let nearest_scope;
  15482. if (simple_args
  15483. && !fn.uses_arguments
  15484. && !(compressor.parent() instanceof AST_Class)
  15485. && !(fn.name && fn instanceof AST_Function)
  15486. && (returned_value = can_flatten_body(stat))
  15487. && (exp === fn
  15488. || has_annotation(self, _INLINE)
  15489. || compressor.option("unused")
  15490. && (def = exp.definition()).references.length == 1
  15491. && !is_recursive_ref(compressor, def)
  15492. && fn.is_constant_expression(exp.scope))
  15493. && !has_annotation(self, _PURE | _NOINLINE)
  15494. && !fn.contains_this()
  15495. && can_inject_symbols()
  15496. && (nearest_scope = find_scope(compressor))
  15497. && !scope_encloses_variables_in_this_scope(nearest_scope, fn)
  15498. && !(function in_default_assign() {
  15499. // Due to the fact function parameters have their own scope
  15500. // which can't use `var something` in the function body within,
  15501. // we simply don't inline into DefaultAssign.
  15502. let i = 0;
  15503. let p;
  15504. while ((p = compressor.parent(i++))) {
  15505. if (p instanceof AST_DefaultAssign) return true;
  15506. if (p instanceof AST_Block) break;
  15507. }
  15508. return false;
  15509. })()
  15510. && !(scope instanceof AST_Class)
  15511. ) {
  15512. set_flag(fn, SQUEEZED);
  15513. nearest_scope.add_child_scope(fn);
  15514. return make_sequence(self, flatten_fn(returned_value)).optimize(compressor);
  15515. }
  15516. }
  15517. if (can_inline && has_annotation(self, _INLINE)) {
  15518. set_flag(fn, SQUEEZED);
  15519. fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
  15520. fn = fn.clone(true);
  15521. fn.figure_out_scope({}, {
  15522. parent_scope: find_scope(compressor),
  15523. toplevel: compressor.get_toplevel()
  15524. });
  15525. return make_node(AST_Call, self, {
  15526. expression: fn,
  15527. args: self.args,
  15528. }).optimize(compressor);
  15529. }
  15530. const can_drop_this_call = is_regular_func && compressor.option("side_effects") && fn.body.every(is_empty);
  15531. if (can_drop_this_call) {
  15532. var args = self.args.concat(make_node(AST_Undefined, self));
  15533. return make_sequence(self, args).optimize(compressor);
  15534. }
  15535. if (compressor.option("negate_iife")
  15536. && compressor.parent() instanceof AST_SimpleStatement
  15537. && is_iife_call(self)) {
  15538. return self.negate(compressor, true);
  15539. }
  15540. var ev = self.evaluate(compressor);
  15541. if (ev !== self) {
  15542. ev = make_node_from_constant(ev, self).optimize(compressor);
  15543. return best_of(compressor, ev, self);
  15544. }
  15545. return self;
  15546. function return_value(stat) {
  15547. if (!stat) return make_node(AST_Undefined, self);
  15548. if (stat instanceof AST_Return) {
  15549. if (!stat.value) return make_node(AST_Undefined, self);
  15550. return stat.value.clone(true);
  15551. }
  15552. if (stat instanceof AST_SimpleStatement) {
  15553. return make_node(AST_UnaryPrefix, stat, {
  15554. operator: "void",
  15555. expression: stat.body.clone(true)
  15556. });
  15557. }
  15558. }
  15559. function can_flatten_body(stat) {
  15560. var body = fn.body;
  15561. var len = body.length;
  15562. if (compressor.option("inline") < 3) {
  15563. return len == 1 && return_value(stat);
  15564. }
  15565. stat = null;
  15566. for (var i = 0; i < len; i++) {
  15567. var line = body[i];
  15568. if (line instanceof AST_Var) {
  15569. if (stat && !line.definitions.every((var_def) =>
  15570. !var_def.value
  15571. )) {
  15572. return false;
  15573. }
  15574. } else if (stat) {
  15575. return false;
  15576. } else if (!(line instanceof AST_EmptyStatement)) {
  15577. stat = line;
  15578. }
  15579. }
  15580. return return_value(stat);
  15581. }
  15582. function can_inject_args(block_scoped, safe_to_inject) {
  15583. for (var i = 0, len = fn.argnames.length; i < len; i++) {
  15584. var arg = fn.argnames[i];
  15585. if (arg instanceof AST_DefaultAssign) {
  15586. if (has_flag(arg.left, UNUSED)) continue;
  15587. return false;
  15588. }
  15589. if (arg instanceof AST_Destructuring) return false;
  15590. if (arg instanceof AST_Expansion) {
  15591. if (has_flag(arg.expression, UNUSED)) continue;
  15592. return false;
  15593. }
  15594. if (has_flag(arg, UNUSED)) continue;
  15595. if (!safe_to_inject
  15596. || block_scoped.has(arg.name)
  15597. || identifier_atom.has(arg.name)
  15598. || scope.conflicting_def(arg.name)) {
  15599. return false;
  15600. }
  15601. if (in_loop) in_loop.push(arg.definition());
  15602. }
  15603. return true;
  15604. }
  15605. function can_inject_vars(block_scoped, safe_to_inject) {
  15606. var len = fn.body.length;
  15607. for (var i = 0; i < len; i++) {
  15608. var stat = fn.body[i];
  15609. if (!(stat instanceof AST_Var)) continue;
  15610. if (!safe_to_inject) return false;
  15611. for (var j = stat.definitions.length; --j >= 0;) {
  15612. var name = stat.definitions[j].name;
  15613. if (name instanceof AST_Destructuring
  15614. || block_scoped.has(name.name)
  15615. || identifier_atom.has(name.name)
  15616. || scope.conflicting_def(name.name)) {
  15617. return false;
  15618. }
  15619. if (in_loop) in_loop.push(name.definition());
  15620. }
  15621. }
  15622. return true;
  15623. }
  15624. function can_inject_symbols() {
  15625. var block_scoped = new Set();
  15626. do {
  15627. scope = compressor.parent(++level);
  15628. if (scope.is_block_scope() && scope.block_scope) {
  15629. // TODO this is sometimes undefined during compression.
  15630. // But it should always have a value!
  15631. scope.block_scope.variables.forEach(function (variable) {
  15632. block_scoped.add(variable.name);
  15633. });
  15634. }
  15635. if (scope instanceof AST_Catch) {
  15636. // TODO can we delete? AST_Catch is a block scope.
  15637. if (scope.argname) {
  15638. block_scoped.add(scope.argname.name);
  15639. }
  15640. } else if (scope instanceof AST_IterationStatement) {
  15641. in_loop = [];
  15642. } else if (scope instanceof AST_SymbolRef) {
  15643. if (scope.fixed_value() instanceof AST_Scope) return false;
  15644. }
  15645. } while (!(scope instanceof AST_Scope));
  15646. var safe_to_inject = !(scope instanceof AST_Toplevel) || compressor.toplevel.vars;
  15647. var inline = compressor.option("inline");
  15648. if (!can_inject_vars(block_scoped, inline >= 3 && safe_to_inject)) return false;
  15649. if (!can_inject_args(block_scoped, inline >= 2 && safe_to_inject)) return false;
  15650. return !in_loop || in_loop.length == 0 || !is_reachable(fn, in_loop);
  15651. }
  15652. function append_var(decls, expressions, name, value) {
  15653. var def = name.definition();
  15654. // Name already exists, only when a function argument had the same name
  15655. const already_appended = scope.variables.has(name.name);
  15656. if (!already_appended) {
  15657. scope.variables.set(name.name, def);
  15658. scope.enclosed.push(def);
  15659. decls.push(make_node(AST_VarDef, name, {
  15660. name: name,
  15661. value: null
  15662. }));
  15663. }
  15664. var sym = make_node(AST_SymbolRef, name, name);
  15665. def.references.push(sym);
  15666. if (value) expressions.push(make_node(AST_Assign, self, {
  15667. operator: "=",
  15668. logical: false,
  15669. left: sym,
  15670. right: value.clone()
  15671. }));
  15672. }
  15673. function flatten_args(decls, expressions) {
  15674. var len = fn.argnames.length;
  15675. for (var i = self.args.length; --i >= len;) {
  15676. expressions.push(self.args[i]);
  15677. }
  15678. for (i = len; --i >= 0;) {
  15679. var name = fn.argnames[i];
  15680. var value = self.args[i];
  15681. if (has_flag(name, UNUSED) || !name.name || scope.conflicting_def(name.name)) {
  15682. if (value) expressions.push(value);
  15683. } else {
  15684. var symbol = make_node(AST_SymbolVar, name, name);
  15685. name.definition().orig.push(symbol);
  15686. if (!value && in_loop) value = make_node(AST_Undefined, self);
  15687. append_var(decls, expressions, symbol, value);
  15688. }
  15689. }
  15690. decls.reverse();
  15691. expressions.reverse();
  15692. }
  15693. function flatten_vars(decls, expressions) {
  15694. var pos = expressions.length;
  15695. for (var i = 0, lines = fn.body.length; i < lines; i++) {
  15696. var stat = fn.body[i];
  15697. if (!(stat instanceof AST_Var)) continue;
  15698. for (var j = 0, defs = stat.definitions.length; j < defs; j++) {
  15699. var var_def = stat.definitions[j];
  15700. var name = var_def.name;
  15701. append_var(decls, expressions, name, var_def.value);
  15702. if (in_loop && fn.argnames.every((argname) =>
  15703. argname.name != name.name
  15704. )) {
  15705. var def = fn.variables.get(name.name);
  15706. var sym = make_node(AST_SymbolRef, name, name);
  15707. def.references.push(sym);
  15708. expressions.splice(pos++, 0, make_node(AST_Assign, var_def, {
  15709. operator: "=",
  15710. logical: false,
  15711. left: sym,
  15712. right: make_node(AST_Undefined, name)
  15713. }));
  15714. }
  15715. }
  15716. }
  15717. }
  15718. function flatten_fn(returned_value) {
  15719. var decls = [];
  15720. var expressions = [];
  15721. flatten_args(decls, expressions);
  15722. flatten_vars(decls, expressions);
  15723. expressions.push(returned_value);
  15724. if (decls.length) {
  15725. const i = scope.body.indexOf(compressor.parent(level - 1)) + 1;
  15726. scope.body.splice(i, 0, make_node(AST_Var, fn, {
  15727. definitions: decls
  15728. }));
  15729. }
  15730. return expressions.map(exp => exp.clone(true));
  15731. }
  15732. });
  15733. def_optimize(AST_New, function(self, compressor) {
  15734. if (
  15735. compressor.option("unsafe") &&
  15736. is_undeclared_ref(self.expression) &&
  15737. ["Object", "RegExp", "Function", "Error", "Array"].includes(self.expression.name)
  15738. ) return make_node(AST_Call, self, self).transform(compressor);
  15739. return self;
  15740. });
  15741. def_optimize(AST_Sequence, function(self, compressor) {
  15742. if (!compressor.option("side_effects")) return self;
  15743. var expressions = [];
  15744. filter_for_side_effects();
  15745. var end = expressions.length - 1;
  15746. trim_right_for_undefined();
  15747. if (end == 0) {
  15748. self = maintain_this_binding(compressor.parent(), compressor.self(), expressions[0]);
  15749. if (!(self instanceof AST_Sequence)) self = self.optimize(compressor);
  15750. return self;
  15751. }
  15752. self.expressions = expressions;
  15753. return self;
  15754. function filter_for_side_effects() {
  15755. var first = first_in_statement(compressor);
  15756. var last = self.expressions.length - 1;
  15757. self.expressions.forEach(function(expr, index) {
  15758. if (index < last) expr = expr.drop_side_effect_free(compressor, first);
  15759. if (expr) {
  15760. merge_sequence(expressions, expr);
  15761. first = false;
  15762. }
  15763. });
  15764. }
  15765. function trim_right_for_undefined() {
  15766. while (end > 0 && is_undefined(expressions[end], compressor)) end--;
  15767. if (end < expressions.length - 1) {
  15768. expressions[end] = make_node(AST_UnaryPrefix, self, {
  15769. operator : "void",
  15770. expression : expressions[end]
  15771. });
  15772. expressions.length = end + 1;
  15773. }
  15774. }
  15775. });
  15776. AST_Unary.DEFMETHOD("lift_sequences", function(compressor) {
  15777. if (compressor.option("sequences")) {
  15778. if (this.expression instanceof AST_Sequence) {
  15779. var x = this.expression.expressions.slice();
  15780. var e = this.clone();
  15781. e.expression = x.pop();
  15782. x.push(e);
  15783. return make_sequence(this, x).optimize(compressor);
  15784. }
  15785. }
  15786. return this;
  15787. });
  15788. def_optimize(AST_UnaryPostfix, function(self, compressor) {
  15789. return self.lift_sequences(compressor);
  15790. });
  15791. def_optimize(AST_UnaryPrefix, function(self, compressor) {
  15792. var e = self.expression;
  15793. if (
  15794. self.operator == "delete" &&
  15795. !(
  15796. e instanceof AST_SymbolRef ||
  15797. e instanceof AST_PropAccess ||
  15798. e instanceof AST_Chain ||
  15799. is_identifier_atom(e)
  15800. )
  15801. ) {
  15802. return make_sequence(self, [e, make_node(AST_True, self)]).optimize(compressor);
  15803. }
  15804. var seq = self.lift_sequences(compressor);
  15805. if (seq !== self) {
  15806. return seq;
  15807. }
  15808. if (compressor.option("side_effects") && self.operator == "void") {
  15809. e = e.drop_side_effect_free(compressor);
  15810. if (e) {
  15811. self.expression = e;
  15812. return self;
  15813. } else {
  15814. return make_node(AST_Undefined, self).optimize(compressor);
  15815. }
  15816. }
  15817. if (compressor.in_boolean_context()) {
  15818. switch (self.operator) {
  15819. case "!":
  15820. if (e instanceof AST_UnaryPrefix && e.operator == "!") {
  15821. // !!foo ==> foo, if we're in boolean context
  15822. return e.expression;
  15823. }
  15824. if (e instanceof AST_Binary) {
  15825. self = best_of(compressor, self, e.negate(compressor, first_in_statement(compressor)));
  15826. }
  15827. break;
  15828. case "typeof":
  15829. // typeof always returns a non-empty string, thus it's
  15830. // always true in booleans
  15831. // And we don't need to check if it's undeclared, because in typeof, that's OK
  15832. return (e instanceof AST_SymbolRef ? make_node(AST_True, self) : make_sequence(self, [
  15833. e,
  15834. make_node(AST_True, self)
  15835. ])).optimize(compressor);
  15836. }
  15837. }
  15838. if (self.operator == "-" && e instanceof AST_Infinity) {
  15839. e = e.transform(compressor);
  15840. }
  15841. if (e instanceof AST_Binary
  15842. && (self.operator == "+" || self.operator == "-")
  15843. && (e.operator == "*" || e.operator == "/" || e.operator == "%")) {
  15844. return make_node(AST_Binary, self, {
  15845. operator: e.operator,
  15846. left: make_node(AST_UnaryPrefix, e.left, {
  15847. operator: self.operator,
  15848. expression: e.left
  15849. }),
  15850. right: e.right
  15851. });
  15852. }
  15853. // avoids infinite recursion of numerals
  15854. if (self.operator != "-"
  15855. || !(e instanceof AST_Number || e instanceof AST_Infinity || e instanceof AST_BigInt)) {
  15856. var ev = self.evaluate(compressor);
  15857. if (ev !== self) {
  15858. ev = make_node_from_constant(ev, self).optimize(compressor);
  15859. return best_of(compressor, ev, self);
  15860. }
  15861. }
  15862. return self;
  15863. });
  15864. AST_Binary.DEFMETHOD("lift_sequences", function(compressor) {
  15865. if (compressor.option("sequences")) {
  15866. if (this.left instanceof AST_Sequence) {
  15867. var x = this.left.expressions.slice();
  15868. var e = this.clone();
  15869. e.left = x.pop();
  15870. x.push(e);
  15871. return make_sequence(this, x).optimize(compressor);
  15872. }
  15873. if (this.right instanceof AST_Sequence && !this.left.has_side_effects(compressor)) {
  15874. var assign = this.operator == "=" && this.left instanceof AST_SymbolRef;
  15875. var x = this.right.expressions;
  15876. var last = x.length - 1;
  15877. for (var i = 0; i < last; i++) {
  15878. if (!assign && x[i].has_side_effects(compressor)) break;
  15879. }
  15880. if (i == last) {
  15881. x = x.slice();
  15882. var e = this.clone();
  15883. e.right = x.pop();
  15884. x.push(e);
  15885. return make_sequence(this, x).optimize(compressor);
  15886. } else if (i > 0) {
  15887. var e = this.clone();
  15888. e.right = make_sequence(this.right, x.slice(i));
  15889. x = x.slice(0, i);
  15890. x.push(e);
  15891. return make_sequence(this, x).optimize(compressor);
  15892. }
  15893. }
  15894. }
  15895. return this;
  15896. });
  15897. var commutativeOperators = makePredicate("== === != !== * & | ^");
  15898. function is_object(node) {
  15899. return node instanceof AST_Array
  15900. || node instanceof AST_Lambda
  15901. || node instanceof AST_Object
  15902. || node instanceof AST_Class;
  15903. }
  15904. def_optimize(AST_Binary, function(self, compressor) {
  15905. function reversible() {
  15906. return self.left.is_constant()
  15907. || self.right.is_constant()
  15908. || !self.left.has_side_effects(compressor)
  15909. && !self.right.has_side_effects(compressor);
  15910. }
  15911. function reverse(op) {
  15912. if (reversible()) {
  15913. if (op) self.operator = op;
  15914. var tmp = self.left;
  15915. self.left = self.right;
  15916. self.right = tmp;
  15917. }
  15918. }
  15919. if (commutativeOperators.has(self.operator)) {
  15920. if (self.right.is_constant()
  15921. && !self.left.is_constant()) {
  15922. // if right is a constant, whatever side effects the
  15923. // left side might have could not influence the
  15924. // result. hence, force switch.
  15925. if (!(self.left instanceof AST_Binary
  15926. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  15927. reverse();
  15928. }
  15929. }
  15930. }
  15931. self = self.lift_sequences(compressor);
  15932. if (compressor.option("comparisons")) switch (self.operator) {
  15933. case "===":
  15934. case "!==":
  15935. var is_strict_comparison = true;
  15936. if ((self.left.is_string(compressor) && self.right.is_string(compressor)) ||
  15937. (self.left.is_number(compressor) && self.right.is_number(compressor)) ||
  15938. (self.left.is_boolean() && self.right.is_boolean()) ||
  15939. self.left.equivalent_to(self.right)) {
  15940. self.operator = self.operator.substr(0, 2);
  15941. }
  15942. // XXX: intentionally falling down to the next case
  15943. case "==":
  15944. case "!=":
  15945. // void 0 == x => null == x
  15946. if (!is_strict_comparison && is_undefined(self.left, compressor)) {
  15947. self.left = make_node(AST_Null, self.left);
  15948. } else if (compressor.option("typeofs")
  15949. // "undefined" == typeof x => undefined === x
  15950. && self.left instanceof AST_String
  15951. && self.left.value == "undefined"
  15952. && self.right instanceof AST_UnaryPrefix
  15953. && self.right.operator == "typeof") {
  15954. var expr = self.right.expression;
  15955. if (expr instanceof AST_SymbolRef ? expr.is_declared(compressor)
  15956. : !(expr instanceof AST_PropAccess && compressor.option("ie8"))) {
  15957. self.right = expr;
  15958. self.left = make_node(AST_Undefined, self.left).optimize(compressor);
  15959. if (self.operator.length == 2) self.operator += "=";
  15960. }
  15961. } else if (self.left instanceof AST_SymbolRef
  15962. // obj !== obj => false
  15963. && self.right instanceof AST_SymbolRef
  15964. && self.left.definition() === self.right.definition()
  15965. && is_object(self.left.fixed_value())) {
  15966. return make_node(self.operator[0] == "=" ? AST_True : AST_False, self);
  15967. }
  15968. break;
  15969. case "&&":
  15970. case "||":
  15971. var lhs = self.left;
  15972. if (lhs.operator == self.operator) {
  15973. lhs = lhs.right;
  15974. }
  15975. if (lhs instanceof AST_Binary
  15976. && lhs.operator == (self.operator == "&&" ? "!==" : "===")
  15977. && self.right instanceof AST_Binary
  15978. && lhs.operator == self.right.operator
  15979. && (is_undefined(lhs.left, compressor) && self.right.left instanceof AST_Null
  15980. || lhs.left instanceof AST_Null && is_undefined(self.right.left, compressor))
  15981. && !lhs.right.has_side_effects(compressor)
  15982. && lhs.right.equivalent_to(self.right.right)) {
  15983. var combined = make_node(AST_Binary, self, {
  15984. operator: lhs.operator.slice(0, -1),
  15985. left: make_node(AST_Null, self),
  15986. right: lhs.right
  15987. });
  15988. if (lhs !== self.left) {
  15989. combined = make_node(AST_Binary, self, {
  15990. operator: self.operator,
  15991. left: self.left.left,
  15992. right: combined
  15993. });
  15994. }
  15995. return combined;
  15996. }
  15997. break;
  15998. }
  15999. if (self.operator == "+" && compressor.in_boolean_context()) {
  16000. var ll = self.left.evaluate(compressor);
  16001. var rr = self.right.evaluate(compressor);
  16002. if (ll && typeof ll == "string") {
  16003. return make_sequence(self, [
  16004. self.right,
  16005. make_node(AST_True, self)
  16006. ]).optimize(compressor);
  16007. }
  16008. if (rr && typeof rr == "string") {
  16009. return make_sequence(self, [
  16010. self.left,
  16011. make_node(AST_True, self)
  16012. ]).optimize(compressor);
  16013. }
  16014. }
  16015. if (compressor.option("comparisons") && self.is_boolean()) {
  16016. if (!(compressor.parent() instanceof AST_Binary)
  16017. || compressor.parent() instanceof AST_Assign) {
  16018. var negated = make_node(AST_UnaryPrefix, self, {
  16019. operator: "!",
  16020. expression: self.negate(compressor, first_in_statement(compressor))
  16021. });
  16022. self = best_of(compressor, self, negated);
  16023. }
  16024. if (compressor.option("unsafe_comps")) {
  16025. switch (self.operator) {
  16026. case "<": reverse(">"); break;
  16027. case "<=": reverse(">="); break;
  16028. }
  16029. }
  16030. }
  16031. if (self.operator == "+") {
  16032. if (self.right instanceof AST_String
  16033. && self.right.getValue() == ""
  16034. && self.left.is_string(compressor)) {
  16035. return self.left;
  16036. }
  16037. if (self.left instanceof AST_String
  16038. && self.left.getValue() == ""
  16039. && self.right.is_string(compressor)) {
  16040. return self.right;
  16041. }
  16042. if (self.left instanceof AST_Binary
  16043. && self.left.operator == "+"
  16044. && self.left.left instanceof AST_String
  16045. && self.left.left.getValue() == ""
  16046. && self.right.is_string(compressor)) {
  16047. self.left = self.left.right;
  16048. return self;
  16049. }
  16050. }
  16051. if (compressor.option("evaluate")) {
  16052. switch (self.operator) {
  16053. case "&&":
  16054. var ll = has_flag(self.left, TRUTHY)
  16055. ? true
  16056. : has_flag(self.left, FALSY)
  16057. ? false
  16058. : self.left.evaluate(compressor);
  16059. if (!ll) {
  16060. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  16061. } else if (!(ll instanceof AST_Node)) {
  16062. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  16063. }
  16064. var rr = self.right.evaluate(compressor);
  16065. if (!rr) {
  16066. if (compressor.in_boolean_context()) {
  16067. return make_sequence(self, [
  16068. self.left,
  16069. make_node(AST_False, self)
  16070. ]).optimize(compressor);
  16071. } else {
  16072. set_flag(self, FALSY);
  16073. }
  16074. } else if (!(rr instanceof AST_Node)) {
  16075. var parent = compressor.parent();
  16076. if (parent.operator == "&&" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  16077. return self.left.optimize(compressor);
  16078. }
  16079. }
  16080. // x || false && y ---> x ? y : false
  16081. if (self.left.operator == "||") {
  16082. var lr = self.left.right.evaluate(compressor);
  16083. if (!lr) return make_node(AST_Conditional, self, {
  16084. condition: self.left.left,
  16085. consequent: self.right,
  16086. alternative: self.left.right
  16087. }).optimize(compressor);
  16088. }
  16089. break;
  16090. case "||":
  16091. var ll = has_flag(self.left, TRUTHY)
  16092. ? true
  16093. : has_flag(self.left, FALSY)
  16094. ? false
  16095. : self.left.evaluate(compressor);
  16096. if (!ll) {
  16097. return make_sequence(self, [ self.left, self.right ]).optimize(compressor);
  16098. } else if (!(ll instanceof AST_Node)) {
  16099. return maintain_this_binding(compressor.parent(), compressor.self(), self.left).optimize(compressor);
  16100. }
  16101. var rr = self.right.evaluate(compressor);
  16102. if (!rr) {
  16103. var parent = compressor.parent();
  16104. if (parent.operator == "||" && parent.left === compressor.self() || compressor.in_boolean_context()) {
  16105. return self.left.optimize(compressor);
  16106. }
  16107. } else if (!(rr instanceof AST_Node)) {
  16108. if (compressor.in_boolean_context()) {
  16109. return make_sequence(self, [
  16110. self.left,
  16111. make_node(AST_True, self)
  16112. ]).optimize(compressor);
  16113. } else {
  16114. set_flag(self, TRUTHY);
  16115. }
  16116. }
  16117. if (self.left.operator == "&&") {
  16118. var lr = self.left.right.evaluate(compressor);
  16119. if (lr && !(lr instanceof AST_Node)) return make_node(AST_Conditional, self, {
  16120. condition: self.left.left,
  16121. consequent: self.left.right,
  16122. alternative: self.right
  16123. }).optimize(compressor);
  16124. }
  16125. break;
  16126. case "??":
  16127. if (is_nullish(self.left, compressor)) {
  16128. return self.right;
  16129. }
  16130. var ll = self.left.evaluate(compressor);
  16131. if (!(ll instanceof AST_Node)) {
  16132. // if we know the value for sure we can simply compute right away.
  16133. return ll == null ? self.right : self.left;
  16134. }
  16135. if (compressor.in_boolean_context()) {
  16136. const rr = self.right.evaluate(compressor);
  16137. if (!(rr instanceof AST_Node) && !rr) {
  16138. return self.left;
  16139. }
  16140. }
  16141. }
  16142. var associative = true;
  16143. switch (self.operator) {
  16144. case "+":
  16145. // (x + "foo") + "bar" => x + "foobar"
  16146. if (self.right instanceof AST_Constant
  16147. && self.left instanceof AST_Binary
  16148. && self.left.operator == "+"
  16149. && self.left.is_string(compressor)) {
  16150. var binary = make_node(AST_Binary, self, {
  16151. operator: "+",
  16152. left: self.left.right,
  16153. right: self.right,
  16154. });
  16155. var r = binary.optimize(compressor);
  16156. if (binary !== r) {
  16157. self = make_node(AST_Binary, self, {
  16158. operator: "+",
  16159. left: self.left.left,
  16160. right: r
  16161. });
  16162. }
  16163. }
  16164. // (x + "foo") + ("bar" + y) => (x + "foobar") + y
  16165. if (self.left instanceof AST_Binary
  16166. && self.left.operator == "+"
  16167. && self.left.is_string(compressor)
  16168. && self.right instanceof AST_Binary
  16169. && self.right.operator == "+"
  16170. && self.right.is_string(compressor)) {
  16171. var binary = make_node(AST_Binary, self, {
  16172. operator: "+",
  16173. left: self.left.right,
  16174. right: self.right.left,
  16175. });
  16176. var m = binary.optimize(compressor);
  16177. if (binary !== m) {
  16178. self = make_node(AST_Binary, self, {
  16179. operator: "+",
  16180. left: make_node(AST_Binary, self.left, {
  16181. operator: "+",
  16182. left: self.left.left,
  16183. right: m
  16184. }),
  16185. right: self.right.right
  16186. });
  16187. }
  16188. }
  16189. // a + -b => a - b
  16190. if (self.right instanceof AST_UnaryPrefix
  16191. && self.right.operator == "-"
  16192. && self.left.is_number(compressor)) {
  16193. self = make_node(AST_Binary, self, {
  16194. operator: "-",
  16195. left: self.left,
  16196. right: self.right.expression
  16197. });
  16198. break;
  16199. }
  16200. // -a + b => b - a
  16201. if (self.left instanceof AST_UnaryPrefix
  16202. && self.left.operator == "-"
  16203. && reversible()
  16204. && self.right.is_number(compressor)) {
  16205. self = make_node(AST_Binary, self, {
  16206. operator: "-",
  16207. left: self.right,
  16208. right: self.left.expression
  16209. });
  16210. break;
  16211. }
  16212. // `foo${bar}baz` + 1 => `foo${bar}baz1`
  16213. if (self.left instanceof AST_TemplateString) {
  16214. var l = self.left;
  16215. var r = self.right.evaluate(compressor);
  16216. if (r != self.right) {
  16217. l.segments[l.segments.length - 1].value += String(r);
  16218. return l;
  16219. }
  16220. }
  16221. // 1 + `foo${bar}baz` => `1foo${bar}baz`
  16222. if (self.right instanceof AST_TemplateString) {
  16223. var r = self.right;
  16224. var l = self.left.evaluate(compressor);
  16225. if (l != self.left) {
  16226. r.segments[0].value = String(l) + r.segments[0].value;
  16227. return r;
  16228. }
  16229. }
  16230. // `1${bar}2` + `foo${bar}baz` => `1${bar}2foo${bar}baz`
  16231. if (self.left instanceof AST_TemplateString
  16232. && self.right instanceof AST_TemplateString) {
  16233. var l = self.left;
  16234. var segments = l.segments;
  16235. var r = self.right;
  16236. segments[segments.length - 1].value += r.segments[0].value;
  16237. for (var i = 1; i < r.segments.length; i++) {
  16238. segments.push(r.segments[i]);
  16239. }
  16240. return l;
  16241. }
  16242. case "*":
  16243. associative = compressor.option("unsafe_math");
  16244. case "&":
  16245. case "|":
  16246. case "^":
  16247. // a + +b => +b + a
  16248. if (self.left.is_number(compressor)
  16249. && self.right.is_number(compressor)
  16250. && reversible()
  16251. && !(self.left instanceof AST_Binary
  16252. && self.left.operator != self.operator
  16253. && PRECEDENCE[self.left.operator] >= PRECEDENCE[self.operator])) {
  16254. var reversed = make_node(AST_Binary, self, {
  16255. operator: self.operator,
  16256. left: self.right,
  16257. right: self.left
  16258. });
  16259. if (self.right instanceof AST_Constant
  16260. && !(self.left instanceof AST_Constant)) {
  16261. self = best_of(compressor, reversed, self);
  16262. } else {
  16263. self = best_of(compressor, self, reversed);
  16264. }
  16265. }
  16266. if (associative && self.is_number(compressor)) {
  16267. // a + (b + c) => (a + b) + c
  16268. if (self.right instanceof AST_Binary
  16269. && self.right.operator == self.operator) {
  16270. self = make_node(AST_Binary, self, {
  16271. operator: self.operator,
  16272. left: make_node(AST_Binary, self.left, {
  16273. operator: self.operator,
  16274. left: self.left,
  16275. right: self.right.left,
  16276. start: self.left.start,
  16277. end: self.right.left.end
  16278. }),
  16279. right: self.right.right
  16280. });
  16281. }
  16282. // (n + 2) + 3 => 5 + n
  16283. // (2 * n) * 3 => 6 + n
  16284. if (self.right instanceof AST_Constant
  16285. && self.left instanceof AST_Binary
  16286. && self.left.operator == self.operator) {
  16287. if (self.left.left instanceof AST_Constant) {
  16288. self = make_node(AST_Binary, self, {
  16289. operator: self.operator,
  16290. left: make_node(AST_Binary, self.left, {
  16291. operator: self.operator,
  16292. left: self.left.left,
  16293. right: self.right,
  16294. start: self.left.left.start,
  16295. end: self.right.end
  16296. }),
  16297. right: self.left.right
  16298. });
  16299. } else if (self.left.right instanceof AST_Constant) {
  16300. self = make_node(AST_Binary, self, {
  16301. operator: self.operator,
  16302. left: make_node(AST_Binary, self.left, {
  16303. operator: self.operator,
  16304. left: self.left.right,
  16305. right: self.right,
  16306. start: self.left.right.start,
  16307. end: self.right.end
  16308. }),
  16309. right: self.left.left
  16310. });
  16311. }
  16312. }
  16313. // (a | 1) | (2 | d) => (3 | a) | b
  16314. if (self.left instanceof AST_Binary
  16315. && self.left.operator == self.operator
  16316. && self.left.right instanceof AST_Constant
  16317. && self.right instanceof AST_Binary
  16318. && self.right.operator == self.operator
  16319. && self.right.left instanceof AST_Constant) {
  16320. self = make_node(AST_Binary, self, {
  16321. operator: self.operator,
  16322. left: make_node(AST_Binary, self.left, {
  16323. operator: self.operator,
  16324. left: make_node(AST_Binary, self.left.left, {
  16325. operator: self.operator,
  16326. left: self.left.right,
  16327. right: self.right.left,
  16328. start: self.left.right.start,
  16329. end: self.right.left.end
  16330. }),
  16331. right: self.left.left
  16332. }),
  16333. right: self.right.right
  16334. });
  16335. }
  16336. }
  16337. }
  16338. }
  16339. // x && (y && z) ==> x && y && z
  16340. // x || (y || z) ==> x || y || z
  16341. // x + ("y" + z) ==> x + "y" + z
  16342. // "x" + (y + "z")==> "x" + y + "z"
  16343. if (self.right instanceof AST_Binary
  16344. && self.right.operator == self.operator
  16345. && (lazy_op.has(self.operator)
  16346. || (self.operator == "+"
  16347. && (self.right.left.is_string(compressor)
  16348. || (self.left.is_string(compressor)
  16349. && self.right.right.is_string(compressor)))))
  16350. ) {
  16351. self.left = make_node(AST_Binary, self.left, {
  16352. operator : self.operator,
  16353. left : self.left.transform(compressor),
  16354. right : self.right.left.transform(compressor)
  16355. });
  16356. self.right = self.right.right.transform(compressor);
  16357. return self.transform(compressor);
  16358. }
  16359. var ev = self.evaluate(compressor);
  16360. if (ev !== self) {
  16361. ev = make_node_from_constant(ev, self).optimize(compressor);
  16362. return best_of(compressor, ev, self);
  16363. }
  16364. return self;
  16365. });
  16366. def_optimize(AST_SymbolExport, function(self) {
  16367. return self;
  16368. });
  16369. function within_array_or_object_literal(compressor) {
  16370. var node, level = 0;
  16371. while (node = compressor.parent(level++)) {
  16372. if (node instanceof AST_Statement) return false;
  16373. if (node instanceof AST_Array
  16374. || node instanceof AST_ObjectKeyVal
  16375. || node instanceof AST_Object) {
  16376. return true;
  16377. }
  16378. }
  16379. return false;
  16380. }
  16381. def_optimize(AST_SymbolRef, function(self, compressor) {
  16382. if (
  16383. !compressor.option("ie8")
  16384. && is_undeclared_ref(self)
  16385. && !compressor.find_parent(AST_With)
  16386. ) {
  16387. switch (self.name) {
  16388. case "undefined":
  16389. return make_node(AST_Undefined, self).optimize(compressor);
  16390. case "NaN":
  16391. return make_node(AST_NaN, self).optimize(compressor);
  16392. case "Infinity":
  16393. return make_node(AST_Infinity, self).optimize(compressor);
  16394. }
  16395. }
  16396. const parent = compressor.parent();
  16397. if (compressor.option("reduce_vars") && is_lhs(self, parent) !== self) {
  16398. const def = self.definition();
  16399. const nearest_scope = find_scope(compressor);
  16400. if (compressor.top_retain && def.global && compressor.top_retain(def)) {
  16401. def.fixed = false;
  16402. def.single_use = false;
  16403. return self;
  16404. }
  16405. let fixed = self.fixed_value();
  16406. let single_use = def.single_use
  16407. && !(parent instanceof AST_Call
  16408. && (parent.is_callee_pure(compressor))
  16409. || has_annotation(parent, _NOINLINE))
  16410. && !(parent instanceof AST_Export
  16411. && fixed instanceof AST_Lambda
  16412. && fixed.name);
  16413. if (single_use && fixed instanceof AST_Node) {
  16414. single_use =
  16415. !fixed.has_side_effects(compressor)
  16416. && !fixed.may_throw(compressor);
  16417. }
  16418. if (single_use && (fixed instanceof AST_Lambda || fixed instanceof AST_Class)) {
  16419. if (retain_top_func(fixed, compressor)) {
  16420. single_use = false;
  16421. } else if (def.scope !== self.scope
  16422. && (def.escaped == 1
  16423. || has_flag(fixed, INLINED)
  16424. || within_array_or_object_literal(compressor)
  16425. || !compressor.option("reduce_funcs"))) {
  16426. single_use = false;
  16427. } else if (is_recursive_ref(compressor, def)) {
  16428. single_use = false;
  16429. } else if (def.scope !== self.scope || def.orig[0] instanceof AST_SymbolFunarg) {
  16430. single_use = fixed.is_constant_expression(self.scope);
  16431. if (single_use == "f") {
  16432. var scope = self.scope;
  16433. do {
  16434. if (scope instanceof AST_Defun || is_func_expr(scope)) {
  16435. set_flag(scope, INLINED);
  16436. }
  16437. } while (scope = scope.parent_scope);
  16438. }
  16439. }
  16440. }
  16441. if (single_use && fixed instanceof AST_Lambda) {
  16442. single_use =
  16443. def.scope === self.scope
  16444. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16445. || parent instanceof AST_Call
  16446. && parent.expression === self
  16447. && !scope_encloses_variables_in_this_scope(nearest_scope, fixed)
  16448. && !(fixed.name && fixed.name.definition().recursive_refs > 0);
  16449. }
  16450. if (single_use && fixed) {
  16451. if (fixed instanceof AST_DefClass) {
  16452. set_flag(fixed, SQUEEZED);
  16453. fixed = make_node(AST_ClassExpression, fixed, fixed);
  16454. }
  16455. if (fixed instanceof AST_Defun) {
  16456. set_flag(fixed, SQUEEZED);
  16457. fixed = make_node(AST_Function, fixed, fixed);
  16458. }
  16459. if (def.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
  16460. const defun_def = fixed.name.definition();
  16461. let lambda_def = fixed.variables.get(fixed.name.name);
  16462. let name = lambda_def && lambda_def.orig[0];
  16463. if (!(name instanceof AST_SymbolLambda)) {
  16464. name = make_node(AST_SymbolLambda, fixed.name, fixed.name);
  16465. name.scope = fixed;
  16466. fixed.name = name;
  16467. lambda_def = fixed.def_function(name);
  16468. }
  16469. walk(fixed, node => {
  16470. if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
  16471. node.thedef = lambda_def;
  16472. lambda_def.references.push(node);
  16473. }
  16474. });
  16475. }
  16476. if (
  16477. (fixed instanceof AST_Lambda || fixed instanceof AST_Class)
  16478. && fixed.parent_scope !== nearest_scope
  16479. ) {
  16480. fixed = fixed.clone(true, compressor.get_toplevel());
  16481. nearest_scope.add_child_scope(fixed);
  16482. }
  16483. return fixed.optimize(compressor);
  16484. }
  16485. // multiple uses
  16486. if (fixed) {
  16487. let replace;
  16488. if (fixed instanceof AST_This) {
  16489. if (!(def.orig[0] instanceof AST_SymbolFunarg)
  16490. && def.references.every((ref) =>
  16491. def.scope === ref.scope
  16492. )) {
  16493. replace = fixed;
  16494. }
  16495. } else {
  16496. var ev = fixed.evaluate(compressor);
  16497. if (
  16498. ev !== fixed
  16499. && (compressor.option("unsafe_regexp") || !(ev instanceof RegExp))
  16500. ) {
  16501. replace = make_node_from_constant(ev, fixed);
  16502. }
  16503. }
  16504. if (replace) {
  16505. const name_length = self.size(compressor);
  16506. const replace_size = replace.size(compressor);
  16507. let overhead = 0;
  16508. if (compressor.option("unused") && !compressor.exposed(def)) {
  16509. overhead =
  16510. (name_length + 2 + replace_size) /
  16511. (def.references.length - def.assignments);
  16512. }
  16513. if (replace_size <= name_length + overhead) {
  16514. return replace;
  16515. }
  16516. }
  16517. }
  16518. }
  16519. return self;
  16520. });
  16521. function scope_encloses_variables_in_this_scope(scope, pulled_scope) {
  16522. for (const enclosed of pulled_scope.enclosed) {
  16523. if (pulled_scope.variables.has(enclosed.name)) {
  16524. continue;
  16525. }
  16526. const looked_up = scope.find_variable(enclosed.name);
  16527. if (looked_up) {
  16528. if (looked_up === enclosed) continue;
  16529. return true;
  16530. }
  16531. }
  16532. return false;
  16533. }
  16534. function is_atomic(lhs, self) {
  16535. return lhs instanceof AST_SymbolRef || lhs.TYPE === self.TYPE;
  16536. }
  16537. def_optimize(AST_Undefined, function(self, compressor) {
  16538. if (compressor.option("unsafe_undefined")) {
  16539. var undef = find_variable(compressor, "undefined");
  16540. if (undef) {
  16541. var ref = make_node(AST_SymbolRef, self, {
  16542. name : "undefined",
  16543. scope : undef.scope,
  16544. thedef : undef
  16545. });
  16546. set_flag(ref, UNDEFINED);
  16547. return ref;
  16548. }
  16549. }
  16550. var lhs = is_lhs(compressor.self(), compressor.parent());
  16551. if (lhs && is_atomic(lhs, self)) return self;
  16552. return make_node(AST_UnaryPrefix, self, {
  16553. operator: "void",
  16554. expression: make_node(AST_Number, self, {
  16555. value: 0
  16556. })
  16557. });
  16558. });
  16559. def_optimize(AST_Infinity, function(self, compressor) {
  16560. var lhs = is_lhs(compressor.self(), compressor.parent());
  16561. if (lhs && is_atomic(lhs, self)) return self;
  16562. if (
  16563. compressor.option("keep_infinity")
  16564. && !(lhs && !is_atomic(lhs, self))
  16565. && !find_variable(compressor, "Infinity")
  16566. ) {
  16567. return self;
  16568. }
  16569. return make_node(AST_Binary, self, {
  16570. operator: "/",
  16571. left: make_node(AST_Number, self, {
  16572. value: 1
  16573. }),
  16574. right: make_node(AST_Number, self, {
  16575. value: 0
  16576. })
  16577. });
  16578. });
  16579. def_optimize(AST_NaN, function(self, compressor) {
  16580. var lhs = is_lhs(compressor.self(), compressor.parent());
  16581. if (lhs && !is_atomic(lhs, self)
  16582. || find_variable(compressor, "NaN")) {
  16583. return make_node(AST_Binary, self, {
  16584. operator: "/",
  16585. left: make_node(AST_Number, self, {
  16586. value: 0
  16587. }),
  16588. right: make_node(AST_Number, self, {
  16589. value: 0
  16590. })
  16591. });
  16592. }
  16593. return self;
  16594. });
  16595. function is_reachable(self, defs) {
  16596. const find_ref = node => {
  16597. if (node instanceof AST_SymbolRef && member(node.definition(), defs)) {
  16598. return walk_abort;
  16599. }
  16600. };
  16601. return walk_parent(self, (node, info) => {
  16602. if (node instanceof AST_Scope && node !== self) {
  16603. var parent = info.parent();
  16604. if (
  16605. parent instanceof AST_Call
  16606. && parent.expression === node
  16607. // Async/Generators aren't guaranteed to sync evaluate all of
  16608. // their body steps, so it's possible they close over the variable.
  16609. && !(node.async || node.is_generator)
  16610. ) {
  16611. return;
  16612. }
  16613. if (walk(node, find_ref)) return walk_abort;
  16614. return true;
  16615. }
  16616. });
  16617. }
  16618. const ASSIGN_OPS = makePredicate("+ - / * % >> << >>> | ^ &");
  16619. const ASSIGN_OPS_COMMUTATIVE = makePredicate("* | ^ &");
  16620. def_optimize(AST_Assign, function(self, compressor) {
  16621. if (self.logical) {
  16622. return self.lift_sequences(compressor);
  16623. }
  16624. var def;
  16625. if (compressor.option("dead_code")
  16626. && self.left instanceof AST_SymbolRef
  16627. && (def = self.left.definition()).scope === compressor.find_parent(AST_Lambda)) {
  16628. var level = 0, node, parent = self;
  16629. do {
  16630. node = parent;
  16631. parent = compressor.parent(level++);
  16632. if (parent instanceof AST_Exit) {
  16633. if (in_try(level, parent)) break;
  16634. if (is_reachable(def.scope, [ def ])) break;
  16635. if (self.operator == "=") return self.right;
  16636. def.fixed = false;
  16637. return make_node(AST_Binary, self, {
  16638. operator: self.operator.slice(0, -1),
  16639. left: self.left,
  16640. right: self.right
  16641. }).optimize(compressor);
  16642. }
  16643. } while (parent instanceof AST_Binary && parent.right === node
  16644. || parent instanceof AST_Sequence && parent.tail_node() === node);
  16645. }
  16646. self = self.lift_sequences(compressor);
  16647. if (self.operator == "=" && self.left instanceof AST_SymbolRef && self.right instanceof AST_Binary) {
  16648. // x = expr1 OP expr2
  16649. if (self.right.left instanceof AST_SymbolRef
  16650. && self.right.left.name == self.left.name
  16651. && ASSIGN_OPS.has(self.right.operator)) {
  16652. // x = x - 2 ---> x -= 2
  16653. self.operator = self.right.operator + "=";
  16654. self.right = self.right.right;
  16655. } else if (self.right.right instanceof AST_SymbolRef
  16656. && self.right.right.name == self.left.name
  16657. && ASSIGN_OPS_COMMUTATIVE.has(self.right.operator)
  16658. && !self.right.left.has_side_effects(compressor)) {
  16659. // x = 2 & x ---> x &= 2
  16660. self.operator = self.right.operator + "=";
  16661. self.right = self.right.left;
  16662. }
  16663. }
  16664. return self;
  16665. function in_try(level, node) {
  16666. var right = self.right;
  16667. self.right = make_node(AST_Null, right);
  16668. var may_throw = node.may_throw(compressor);
  16669. self.right = right;
  16670. var scope = self.left.definition().scope;
  16671. var parent;
  16672. while ((parent = compressor.parent(level++)) !== scope) {
  16673. if (parent instanceof AST_Try) {
  16674. if (parent.bfinally) return true;
  16675. if (may_throw && parent.bcatch) return true;
  16676. }
  16677. }
  16678. }
  16679. });
  16680. def_optimize(AST_DefaultAssign, function(self, compressor) {
  16681. if (!compressor.option("evaluate")) {
  16682. return self;
  16683. }
  16684. var evaluateRight = self.right.evaluate(compressor);
  16685. // `[x = undefined] = foo` ---> `[x] = foo`
  16686. if (evaluateRight === undefined) {
  16687. self = self.left;
  16688. } else if (evaluateRight !== self.right) {
  16689. evaluateRight = make_node_from_constant(evaluateRight, self.right);
  16690. self.right = best_of_expression(evaluateRight, self.right);
  16691. }
  16692. return self;
  16693. });
  16694. function is_nullish_check(check, check_subject, compressor) {
  16695. if (check_subject.may_throw(compressor)) return false;
  16696. let nullish_side;
  16697. // foo == null
  16698. if (
  16699. check instanceof AST_Binary
  16700. && check.operator === "=="
  16701. // which side is nullish?
  16702. && (
  16703. (nullish_side = is_nullish(check.left, compressor) && check.left)
  16704. || (nullish_side = is_nullish(check.right, compressor) && check.right)
  16705. )
  16706. // is the other side the same as the check_subject
  16707. && (
  16708. nullish_side === check.left
  16709. ? check.right
  16710. : check.left
  16711. ).equivalent_to(check_subject)
  16712. ) {
  16713. return true;
  16714. }
  16715. // foo === null || foo === undefined
  16716. if (check instanceof AST_Binary && check.operator === "||") {
  16717. let null_cmp;
  16718. let undefined_cmp;
  16719. const find_comparison = cmp => {
  16720. if (!(
  16721. cmp instanceof AST_Binary
  16722. && (cmp.operator === "===" || cmp.operator === "==")
  16723. )) {
  16724. return false;
  16725. }
  16726. let found = 0;
  16727. let defined_side;
  16728. if (cmp.left instanceof AST_Null) {
  16729. found++;
  16730. null_cmp = cmp;
  16731. defined_side = cmp.right;
  16732. }
  16733. if (cmp.right instanceof AST_Null) {
  16734. found++;
  16735. null_cmp = cmp;
  16736. defined_side = cmp.left;
  16737. }
  16738. if (is_undefined(cmp.left, compressor)) {
  16739. found++;
  16740. undefined_cmp = cmp;
  16741. defined_side = cmp.right;
  16742. }
  16743. if (is_undefined(cmp.right, compressor)) {
  16744. found++;
  16745. undefined_cmp = cmp;
  16746. defined_side = cmp.left;
  16747. }
  16748. if (found !== 1) {
  16749. return false;
  16750. }
  16751. if (!defined_side.equivalent_to(check_subject)) {
  16752. return false;
  16753. }
  16754. return true;
  16755. };
  16756. if (!find_comparison(check.left)) return false;
  16757. if (!find_comparison(check.right)) return false;
  16758. if (null_cmp && undefined_cmp && null_cmp !== undefined_cmp) {
  16759. return true;
  16760. }
  16761. }
  16762. return false;
  16763. }
  16764. def_optimize(AST_Conditional, function(self, compressor) {
  16765. if (!compressor.option("conditionals")) return self;
  16766. // This looks like lift_sequences(), should probably be under "sequences"
  16767. if (self.condition instanceof AST_Sequence) {
  16768. var expressions = self.condition.expressions.slice();
  16769. self.condition = expressions.pop();
  16770. expressions.push(self);
  16771. return make_sequence(self, expressions);
  16772. }
  16773. var cond = self.condition.evaluate(compressor);
  16774. if (cond !== self.condition) {
  16775. if (cond) {
  16776. return maintain_this_binding(compressor.parent(), compressor.self(), self.consequent);
  16777. } else {
  16778. return maintain_this_binding(compressor.parent(), compressor.self(), self.alternative);
  16779. }
  16780. }
  16781. var negated = cond.negate(compressor, first_in_statement(compressor));
  16782. if (best_of(compressor, cond, negated) === negated) {
  16783. self = make_node(AST_Conditional, self, {
  16784. condition: negated,
  16785. consequent: self.alternative,
  16786. alternative: self.consequent
  16787. });
  16788. }
  16789. var condition = self.condition;
  16790. var consequent = self.consequent;
  16791. var alternative = self.alternative;
  16792. // x?x:y --> x||y
  16793. if (condition instanceof AST_SymbolRef
  16794. && consequent instanceof AST_SymbolRef
  16795. && condition.definition() === consequent.definition()) {
  16796. return make_node(AST_Binary, self, {
  16797. operator: "||",
  16798. left: condition,
  16799. right: alternative
  16800. });
  16801. }
  16802. // if (foo) exp = something; else exp = something_else;
  16803. // |
  16804. // v
  16805. // exp = foo ? something : something_else;
  16806. if (
  16807. consequent instanceof AST_Assign
  16808. && alternative instanceof AST_Assign
  16809. && consequent.operator === alternative.operator
  16810. && consequent.logical === alternative.logical
  16811. && consequent.left.equivalent_to(alternative.left)
  16812. && (!self.condition.has_side_effects(compressor)
  16813. || consequent.operator == "="
  16814. && !consequent.left.has_side_effects(compressor))
  16815. ) {
  16816. return make_node(AST_Assign, self, {
  16817. operator: consequent.operator,
  16818. left: consequent.left,
  16819. logical: consequent.logical,
  16820. right: make_node(AST_Conditional, self, {
  16821. condition: self.condition,
  16822. consequent: consequent.right,
  16823. alternative: alternative.right
  16824. })
  16825. });
  16826. }
  16827. // x ? y(a) : y(b) --> y(x ? a : b)
  16828. var arg_index;
  16829. if (consequent instanceof AST_Call
  16830. && alternative.TYPE === consequent.TYPE
  16831. && consequent.args.length > 0
  16832. && consequent.args.length == alternative.args.length
  16833. && consequent.expression.equivalent_to(alternative.expression)
  16834. && !self.condition.has_side_effects(compressor)
  16835. && !consequent.expression.has_side_effects(compressor)
  16836. && typeof (arg_index = single_arg_diff()) == "number") {
  16837. var node = consequent.clone();
  16838. node.args[arg_index] = make_node(AST_Conditional, self, {
  16839. condition: self.condition,
  16840. consequent: consequent.args[arg_index],
  16841. alternative: alternative.args[arg_index]
  16842. });
  16843. return node;
  16844. }
  16845. // a ? b : c ? b : d --> (a || c) ? b : d
  16846. if (alternative instanceof AST_Conditional
  16847. && consequent.equivalent_to(alternative.consequent)) {
  16848. return make_node(AST_Conditional, self, {
  16849. condition: make_node(AST_Binary, self, {
  16850. operator: "||",
  16851. left: condition,
  16852. right: alternative.condition
  16853. }),
  16854. consequent: consequent,
  16855. alternative: alternative.alternative
  16856. }).optimize(compressor);
  16857. }
  16858. // a == null ? b : a -> a ?? b
  16859. if (
  16860. compressor.option("ecma") >= 2020 &&
  16861. is_nullish_check(condition, alternative, compressor)
  16862. ) {
  16863. return make_node(AST_Binary, self, {
  16864. operator: "??",
  16865. left: alternative,
  16866. right: consequent
  16867. }).optimize(compressor);
  16868. }
  16869. // a ? b : (c, b) --> (a || c), b
  16870. if (alternative instanceof AST_Sequence
  16871. && consequent.equivalent_to(alternative.expressions[alternative.expressions.length - 1])) {
  16872. return make_sequence(self, [
  16873. make_node(AST_Binary, self, {
  16874. operator: "||",
  16875. left: condition,
  16876. right: make_sequence(self, alternative.expressions.slice(0, -1))
  16877. }),
  16878. consequent
  16879. ]).optimize(compressor);
  16880. }
  16881. // a ? b : (c && b) --> (a || c) && b
  16882. if (alternative instanceof AST_Binary
  16883. && alternative.operator == "&&"
  16884. && consequent.equivalent_to(alternative.right)) {
  16885. return make_node(AST_Binary, self, {
  16886. operator: "&&",
  16887. left: make_node(AST_Binary, self, {
  16888. operator: "||",
  16889. left: condition,
  16890. right: alternative.left
  16891. }),
  16892. right: consequent
  16893. }).optimize(compressor);
  16894. }
  16895. // x?y?z:a:a --> x&&y?z:a
  16896. if (consequent instanceof AST_Conditional
  16897. && consequent.alternative.equivalent_to(alternative)) {
  16898. return make_node(AST_Conditional, self, {
  16899. condition: make_node(AST_Binary, self, {
  16900. left: self.condition,
  16901. operator: "&&",
  16902. right: consequent.condition
  16903. }),
  16904. consequent: consequent.consequent,
  16905. alternative: alternative
  16906. });
  16907. }
  16908. // x ? y : y --> x, y
  16909. if (consequent.equivalent_to(alternative)) {
  16910. return make_sequence(self, [
  16911. self.condition,
  16912. consequent
  16913. ]).optimize(compressor);
  16914. }
  16915. // x ? y || z : z --> x && y || z
  16916. if (consequent instanceof AST_Binary
  16917. && consequent.operator == "||"
  16918. && consequent.right.equivalent_to(alternative)) {
  16919. return make_node(AST_Binary, self, {
  16920. operator: "||",
  16921. left: make_node(AST_Binary, self, {
  16922. operator: "&&",
  16923. left: self.condition,
  16924. right: consequent.left
  16925. }),
  16926. right: alternative
  16927. }).optimize(compressor);
  16928. }
  16929. const in_bool = compressor.in_boolean_context();
  16930. if (is_true(self.consequent)) {
  16931. if (is_false(self.alternative)) {
  16932. // c ? true : false ---> !!c
  16933. return booleanize(self.condition);
  16934. }
  16935. // c ? true : x ---> !!c || x
  16936. return make_node(AST_Binary, self, {
  16937. operator: "||",
  16938. left: booleanize(self.condition),
  16939. right: self.alternative
  16940. });
  16941. }
  16942. if (is_false(self.consequent)) {
  16943. if (is_true(self.alternative)) {
  16944. // c ? false : true ---> !c
  16945. return booleanize(self.condition.negate(compressor));
  16946. }
  16947. // c ? false : x ---> !c && x
  16948. return make_node(AST_Binary, self, {
  16949. operator: "&&",
  16950. left: booleanize(self.condition.negate(compressor)),
  16951. right: self.alternative
  16952. });
  16953. }
  16954. if (is_true(self.alternative)) {
  16955. // c ? x : true ---> !c || x
  16956. return make_node(AST_Binary, self, {
  16957. operator: "||",
  16958. left: booleanize(self.condition.negate(compressor)),
  16959. right: self.consequent
  16960. });
  16961. }
  16962. if (is_false(self.alternative)) {
  16963. // c ? x : false ---> !!c && x
  16964. return make_node(AST_Binary, self, {
  16965. operator: "&&",
  16966. left: booleanize(self.condition),
  16967. right: self.consequent
  16968. });
  16969. }
  16970. return self;
  16971. function booleanize(node) {
  16972. if (node.is_boolean()) return node;
  16973. // !!expression
  16974. return make_node(AST_UnaryPrefix, node, {
  16975. operator: "!",
  16976. expression: node.negate(compressor)
  16977. });
  16978. }
  16979. // AST_True or !0
  16980. function is_true(node) {
  16981. return node instanceof AST_True
  16982. || in_bool
  16983. && node instanceof AST_Constant
  16984. && node.getValue()
  16985. || (node instanceof AST_UnaryPrefix
  16986. && node.operator == "!"
  16987. && node.expression instanceof AST_Constant
  16988. && !node.expression.getValue());
  16989. }
  16990. // AST_False or !1
  16991. function is_false(node) {
  16992. return node instanceof AST_False
  16993. || in_bool
  16994. && node instanceof AST_Constant
  16995. && !node.getValue()
  16996. || (node instanceof AST_UnaryPrefix
  16997. && node.operator == "!"
  16998. && node.expression instanceof AST_Constant
  16999. && node.expression.getValue());
  17000. }
  17001. function single_arg_diff() {
  17002. var a = consequent.args;
  17003. var b = alternative.args;
  17004. for (var i = 0, len = a.length; i < len; i++) {
  17005. if (a[i] instanceof AST_Expansion) return;
  17006. if (!a[i].equivalent_to(b[i])) {
  17007. if (b[i] instanceof AST_Expansion) return;
  17008. for (var j = i + 1; j < len; j++) {
  17009. if (a[j] instanceof AST_Expansion) return;
  17010. if (!a[j].equivalent_to(b[j])) return;
  17011. }
  17012. return i;
  17013. }
  17014. }
  17015. }
  17016. });
  17017. def_optimize(AST_Boolean, function(self, compressor) {
  17018. if (compressor.in_boolean_context()) return make_node(AST_Number, self, {
  17019. value: +self.value
  17020. });
  17021. var p = compressor.parent();
  17022. if (compressor.option("booleans_as_integers")) {
  17023. if (p instanceof AST_Binary && (p.operator == "===" || p.operator == "!==")) {
  17024. p.operator = p.operator.replace(/=$/, "");
  17025. }
  17026. return make_node(AST_Number, self, {
  17027. value: +self.value
  17028. });
  17029. }
  17030. if (compressor.option("booleans")) {
  17031. if (p instanceof AST_Binary && (p.operator == "=="
  17032. || p.operator == "!=")) {
  17033. return make_node(AST_Number, self, {
  17034. value: +self.value
  17035. });
  17036. }
  17037. return make_node(AST_UnaryPrefix, self, {
  17038. operator: "!",
  17039. expression: make_node(AST_Number, self, {
  17040. value: 1 - self.value
  17041. })
  17042. });
  17043. }
  17044. return self;
  17045. });
  17046. function safe_to_flatten(value, compressor) {
  17047. if (value instanceof AST_SymbolRef) {
  17048. value = value.fixed_value();
  17049. }
  17050. if (!value) return false;
  17051. if (!(value instanceof AST_Lambda || value instanceof AST_Class)) return true;
  17052. if (!(value instanceof AST_Lambda && value.contains_this())) return true;
  17053. return compressor.parent() instanceof AST_New;
  17054. }
  17055. AST_PropAccess.DEFMETHOD("flatten_object", function(key, compressor) {
  17056. if (!compressor.option("properties")) return;
  17057. if (key === "__proto__") return;
  17058. var arrows = compressor.option("unsafe_arrows") && compressor.option("ecma") >= 2015;
  17059. var expr = this.expression;
  17060. if (expr instanceof AST_Object) {
  17061. var props = expr.properties;
  17062. for (var i = props.length; --i >= 0;) {
  17063. var prop = props[i];
  17064. if ("" + (prop instanceof AST_ConciseMethod ? prop.key.name : prop.key) == key) {
  17065. const all_props_flattenable = props.every((p) =>
  17066. (p instanceof AST_ObjectKeyVal
  17067. || arrows && p instanceof AST_ConciseMethod && !p.is_generator
  17068. )
  17069. && !p.computed_key()
  17070. );
  17071. if (!all_props_flattenable) return;
  17072. if (!safe_to_flatten(prop.value, compressor)) return;
  17073. return make_node(AST_Sub, this, {
  17074. expression: make_node(AST_Array, expr, {
  17075. elements: props.map(function(prop) {
  17076. var v = prop.value;
  17077. if (v instanceof AST_Accessor) {
  17078. v = make_node(AST_Function, v, v);
  17079. }
  17080. var k = prop.key;
  17081. if (k instanceof AST_Node && !(k instanceof AST_SymbolMethod)) {
  17082. return make_sequence(prop, [ k, v ]);
  17083. }
  17084. return v;
  17085. })
  17086. }),
  17087. property: make_node(AST_Number, this, {
  17088. value: i
  17089. })
  17090. });
  17091. }
  17092. }
  17093. }
  17094. });
  17095. def_optimize(AST_Sub, function(self, compressor) {
  17096. var expr = self.expression;
  17097. var prop = self.property;
  17098. if (compressor.option("properties")) {
  17099. var key = prop.evaluate(compressor);
  17100. if (key !== prop) {
  17101. if (typeof key == "string") {
  17102. if (key == "undefined") {
  17103. key = undefined;
  17104. } else {
  17105. var value = parseFloat(key);
  17106. if (value.toString() == key) {
  17107. key = value;
  17108. }
  17109. }
  17110. }
  17111. prop = self.property = best_of_expression(prop, make_node_from_constant(key, prop).transform(compressor));
  17112. var property = "" + key;
  17113. if (is_basic_identifier_string(property)
  17114. && property.length <= prop.size() + 1) {
  17115. return make_node(AST_Dot, self, {
  17116. expression: expr,
  17117. optional: self.optional,
  17118. property: property,
  17119. quote: prop.quote,
  17120. }).optimize(compressor);
  17121. }
  17122. }
  17123. }
  17124. var fn;
  17125. OPT_ARGUMENTS: if (compressor.option("arguments")
  17126. && expr instanceof AST_SymbolRef
  17127. && expr.name == "arguments"
  17128. && expr.definition().orig.length == 1
  17129. && (fn = expr.scope) instanceof AST_Lambda
  17130. && fn.uses_arguments
  17131. && !(fn instanceof AST_Arrow)
  17132. && prop instanceof AST_Number) {
  17133. var index = prop.getValue();
  17134. var params = new Set();
  17135. var argnames = fn.argnames;
  17136. for (var n = 0; n < argnames.length; n++) {
  17137. if (!(argnames[n] instanceof AST_SymbolFunarg)) {
  17138. break OPT_ARGUMENTS; // destructuring parameter - bail
  17139. }
  17140. var param = argnames[n].name;
  17141. if (params.has(param)) {
  17142. break OPT_ARGUMENTS; // duplicate parameter - bail
  17143. }
  17144. params.add(param);
  17145. }
  17146. var argname = fn.argnames[index];
  17147. if (argname && compressor.has_directive("use strict")) {
  17148. var def = argname.definition();
  17149. if (!compressor.option("reduce_vars") || def.assignments || def.orig.length > 1) {
  17150. argname = null;
  17151. }
  17152. } else if (!argname && !compressor.option("keep_fargs") && index < fn.argnames.length + 5) {
  17153. while (index >= fn.argnames.length) {
  17154. argname = fn.create_symbol(AST_SymbolFunarg, {
  17155. source: fn,
  17156. scope: fn,
  17157. tentative_name: "argument_" + fn.argnames.length,
  17158. });
  17159. fn.argnames.push(argname);
  17160. }
  17161. }
  17162. if (argname) {
  17163. var sym = make_node(AST_SymbolRef, self, argname);
  17164. sym.reference({});
  17165. clear_flag(argname, UNUSED);
  17166. return sym;
  17167. }
  17168. }
  17169. if (is_lhs(self, compressor.parent())) return self;
  17170. if (key !== prop) {
  17171. var sub = self.flatten_object(property, compressor);
  17172. if (sub) {
  17173. expr = self.expression = sub.expression;
  17174. prop = self.property = sub.property;
  17175. }
  17176. }
  17177. if (compressor.option("properties") && compressor.option("side_effects")
  17178. && prop instanceof AST_Number && expr instanceof AST_Array) {
  17179. var index = prop.getValue();
  17180. var elements = expr.elements;
  17181. var retValue = elements[index];
  17182. FLATTEN: if (safe_to_flatten(retValue, compressor)) {
  17183. var flatten = true;
  17184. var values = [];
  17185. for (var i = elements.length; --i > index;) {
  17186. var value = elements[i].drop_side_effect_free(compressor);
  17187. if (value) {
  17188. values.unshift(value);
  17189. if (flatten && value.has_side_effects(compressor)) flatten = false;
  17190. }
  17191. }
  17192. if (retValue instanceof AST_Expansion) break FLATTEN;
  17193. retValue = retValue instanceof AST_Hole ? make_node(AST_Undefined, retValue) : retValue;
  17194. if (!flatten) values.unshift(retValue);
  17195. while (--i >= 0) {
  17196. var value = elements[i];
  17197. if (value instanceof AST_Expansion) break FLATTEN;
  17198. value = value.drop_side_effect_free(compressor);
  17199. if (value) values.unshift(value);
  17200. else index--;
  17201. }
  17202. if (flatten) {
  17203. values.push(retValue);
  17204. return make_sequence(self, values).optimize(compressor);
  17205. } else return make_node(AST_Sub, self, {
  17206. expression: make_node(AST_Array, expr, {
  17207. elements: values
  17208. }),
  17209. property: make_node(AST_Number, prop, {
  17210. value: index
  17211. })
  17212. });
  17213. }
  17214. }
  17215. var ev = self.evaluate(compressor);
  17216. if (ev !== self) {
  17217. ev = make_node_from_constant(ev, self).optimize(compressor);
  17218. return best_of(compressor, ev, self);
  17219. }
  17220. return self;
  17221. });
  17222. def_optimize(AST_Chain, function (self, compressor) {
  17223. if (is_nullish(self.expression, compressor)) {
  17224. let parent = compressor.parent();
  17225. // It's valid to delete a nullish optional chain, but if we optimized
  17226. // this to `delete undefined` then it would appear to be a syntax error
  17227. // when we try to optimize the delete. Thankfully, `delete 0` is fine.
  17228. if (parent instanceof AST_UnaryPrefix && parent.operator === "delete") {
  17229. return make_node_from_constant(0, self);
  17230. }
  17231. return make_node(AST_Undefined, self);
  17232. }
  17233. return self;
  17234. });
  17235. AST_Lambda.DEFMETHOD("contains_this", function() {
  17236. return walk(this, node => {
  17237. if (node instanceof AST_This) return walk_abort;
  17238. if (
  17239. node !== this
  17240. && node instanceof AST_Scope
  17241. && !(node instanceof AST_Arrow)
  17242. ) {
  17243. return true;
  17244. }
  17245. });
  17246. });
  17247. def_optimize(AST_Dot, function(self, compressor) {
  17248. const parent = compressor.parent();
  17249. if (is_lhs(self, parent)) return self;
  17250. if (compressor.option("unsafe_proto")
  17251. && self.expression instanceof AST_Dot
  17252. && self.expression.property == "prototype") {
  17253. var exp = self.expression.expression;
  17254. if (is_undeclared_ref(exp)) switch (exp.name) {
  17255. case "Array":
  17256. self.expression = make_node(AST_Array, self.expression, {
  17257. elements: []
  17258. });
  17259. break;
  17260. case "Function":
  17261. self.expression = make_node(AST_Function, self.expression, {
  17262. argnames: [],
  17263. body: []
  17264. });
  17265. break;
  17266. case "Number":
  17267. self.expression = make_node(AST_Number, self.expression, {
  17268. value: 0
  17269. });
  17270. break;
  17271. case "Object":
  17272. self.expression = make_node(AST_Object, self.expression, {
  17273. properties: []
  17274. });
  17275. break;
  17276. case "RegExp":
  17277. self.expression = make_node(AST_RegExp, self.expression, {
  17278. value: { source: "t", flags: "" }
  17279. });
  17280. break;
  17281. case "String":
  17282. self.expression = make_node(AST_String, self.expression, {
  17283. value: ""
  17284. });
  17285. break;
  17286. }
  17287. }
  17288. if (!(parent instanceof AST_Call) || !has_annotation(parent, _NOINLINE)) {
  17289. const sub = self.flatten_object(self.property, compressor);
  17290. if (sub) return sub.optimize(compressor);
  17291. }
  17292. let ev = self.evaluate(compressor);
  17293. if (ev !== self) {
  17294. ev = make_node_from_constant(ev, self).optimize(compressor);
  17295. return best_of(compressor, ev, self);
  17296. }
  17297. return self;
  17298. });
  17299. function literals_in_boolean_context(self, compressor) {
  17300. if (compressor.in_boolean_context()) {
  17301. return best_of(compressor, self, make_sequence(self, [
  17302. self,
  17303. make_node(AST_True, self)
  17304. ]).optimize(compressor));
  17305. }
  17306. return self;
  17307. }
  17308. function inline_array_like_spread(elements) {
  17309. for (var i = 0; i < elements.length; i++) {
  17310. var el = elements[i];
  17311. if (el instanceof AST_Expansion) {
  17312. var expr = el.expression;
  17313. if (
  17314. expr instanceof AST_Array
  17315. && !expr.elements.some(elm => elm instanceof AST_Hole)
  17316. ) {
  17317. elements.splice(i, 1, ...expr.elements);
  17318. // Step back one, as the element at i is now new.
  17319. i--;
  17320. }
  17321. // In array-like spread, spreading a non-iterable value is TypeError.
  17322. // We therefore can’t optimize anything else, unlike with object spread.
  17323. }
  17324. }
  17325. }
  17326. def_optimize(AST_Array, function(self, compressor) {
  17327. var optimized = literals_in_boolean_context(self, compressor);
  17328. if (optimized !== self) {
  17329. return optimized;
  17330. }
  17331. inline_array_like_spread(self.elements);
  17332. return self;
  17333. });
  17334. function inline_object_prop_spread(props, compressor) {
  17335. for (var i = 0; i < props.length; i++) {
  17336. var prop = props[i];
  17337. if (prop instanceof AST_Expansion) {
  17338. const expr = prop.expression;
  17339. if (
  17340. expr instanceof AST_Object
  17341. && expr.properties.every(prop => prop instanceof AST_ObjectKeyVal)
  17342. ) {
  17343. props.splice(i, 1, ...expr.properties);
  17344. // Step back one, as the property at i is now new.
  17345. i--;
  17346. } else if (expr instanceof AST_Constant
  17347. && !(expr instanceof AST_String)) {
  17348. // Unlike array-like spread, in object spread, spreading a
  17349. // non-iterable value silently does nothing; it is thus safe
  17350. // to remove. AST_String is the only iterable AST_Constant.
  17351. props.splice(i, 1);
  17352. i--;
  17353. } else if (is_nullish(expr, compressor)) {
  17354. // Likewise, null and undefined can be silently removed.
  17355. props.splice(i, 1);
  17356. i--;
  17357. }
  17358. }
  17359. }
  17360. }
  17361. def_optimize(AST_Object, function(self, compressor) {
  17362. var optimized = literals_in_boolean_context(self, compressor);
  17363. if (optimized !== self) {
  17364. return optimized;
  17365. }
  17366. inline_object_prop_spread(self.properties, compressor);
  17367. return self;
  17368. });
  17369. def_optimize(AST_RegExp, literals_in_boolean_context);
  17370. def_optimize(AST_Return, function(self, compressor) {
  17371. if (self.value && is_undefined(self.value, compressor)) {
  17372. self.value = null;
  17373. }
  17374. return self;
  17375. });
  17376. def_optimize(AST_Arrow, opt_AST_Lambda);
  17377. def_optimize(AST_Function, function(self, compressor) {
  17378. self = opt_AST_Lambda(self, compressor);
  17379. if (compressor.option("unsafe_arrows")
  17380. && compressor.option("ecma") >= 2015
  17381. && !self.name
  17382. && !self.is_generator
  17383. && !self.uses_arguments
  17384. && !self.pinned()) {
  17385. const uses_this = walk(self, node => {
  17386. if (node instanceof AST_This) return walk_abort;
  17387. });
  17388. if (!uses_this) return make_node(AST_Arrow, self, self).optimize(compressor);
  17389. }
  17390. return self;
  17391. });
  17392. def_optimize(AST_Class, function(self) {
  17393. // HACK to avoid compress failure.
  17394. // AST_Class is not really an AST_Scope/AST_Block as it lacks a body.
  17395. return self;
  17396. });
  17397. def_optimize(AST_Yield, function(self, compressor) {
  17398. if (self.expression && !self.is_star && is_undefined(self.expression, compressor)) {
  17399. self.expression = null;
  17400. }
  17401. return self;
  17402. });
  17403. def_optimize(AST_TemplateString, function(self, compressor) {
  17404. if (
  17405. !compressor.option("evaluate")
  17406. || compressor.parent() instanceof AST_PrefixedTemplateString
  17407. ) {
  17408. return self;
  17409. }
  17410. var segments = [];
  17411. for (var i = 0; i < self.segments.length; i++) {
  17412. var segment = self.segments[i];
  17413. if (segment instanceof AST_Node) {
  17414. var result = segment.evaluate(compressor);
  17415. // Evaluate to constant value
  17416. // Constant value shorter than ${segment}
  17417. if (result !== segment && (result + "").length <= segment.size() + "${}".length) {
  17418. // There should always be a previous and next segment if segment is a node
  17419. segments[segments.length - 1].value = segments[segments.length - 1].value + result + self.segments[++i].value;
  17420. continue;
  17421. }
  17422. // `before ${`innerBefore ${any} innerAfter`} after` => `before innerBefore ${any} innerAfter after`
  17423. // TODO:
  17424. // `before ${'test' + foo} after` => `before innerBefore ${any} innerAfter after`
  17425. // `before ${foo + 'test} after` => `before innerBefore ${any} innerAfter after`
  17426. if (segment instanceof AST_TemplateString) {
  17427. var inners = segment.segments;
  17428. segments[segments.length - 1].value += inners[0].value;
  17429. for (var j = 1; j < inners.length; j++) {
  17430. segment = inners[j];
  17431. segments.push(segment);
  17432. }
  17433. continue;
  17434. }
  17435. }
  17436. segments.push(segment);
  17437. }
  17438. self.segments = segments;
  17439. // `foo` => "foo"
  17440. if (segments.length == 1) {
  17441. return make_node(AST_String, self, segments[0]);
  17442. }
  17443. if (
  17444. segments.length === 3
  17445. && segments[1] instanceof AST_Node
  17446. && (
  17447. segments[1].is_string(compressor)
  17448. || segments[1].is_number(compressor)
  17449. || is_nullish(segments[1], compressor)
  17450. || compressor.option("unsafe")
  17451. )
  17452. ) {
  17453. // `foo${bar}` => "foo" + bar
  17454. if (segments[2].value === "") {
  17455. return make_node(AST_Binary, self, {
  17456. operator: "+",
  17457. left: make_node(AST_String, self, {
  17458. value: segments[0].value,
  17459. }),
  17460. right: segments[1],
  17461. });
  17462. }
  17463. // `${bar}baz` => bar + "baz"
  17464. if (segments[0].value === "") {
  17465. return make_node(AST_Binary, self, {
  17466. operator: "+",
  17467. left: segments[1],
  17468. right: make_node(AST_String, self, {
  17469. value: segments[2].value,
  17470. }),
  17471. });
  17472. }
  17473. }
  17474. return self;
  17475. });
  17476. def_optimize(AST_PrefixedTemplateString, function(self) {
  17477. return self;
  17478. });
  17479. // ["p"]:1 ---> p:1
  17480. // [42]:1 ---> 42:1
  17481. function lift_key(self, compressor) {
  17482. if (!compressor.option("computed_props")) return self;
  17483. // save a comparison in the typical case
  17484. if (!(self.key instanceof AST_Constant)) return self;
  17485. // allow certain acceptable props as not all AST_Constants are true constants
  17486. if (self.key instanceof AST_String || self.key instanceof AST_Number) {
  17487. if (self.key.value === "__proto__") return self;
  17488. if (self.key.value == "constructor"
  17489. && compressor.parent() instanceof AST_Class) return self;
  17490. if (self instanceof AST_ObjectKeyVal) {
  17491. self.quote = self.key.quote;
  17492. self.key = self.key.value;
  17493. } else if (self instanceof AST_ClassProperty) {
  17494. self.quote = self.key.quote;
  17495. self.key = make_node(AST_SymbolClassProperty, self.key, {
  17496. name: self.key.value
  17497. });
  17498. } else {
  17499. self.quote = self.key.quote;
  17500. self.key = make_node(AST_SymbolMethod, self.key, {
  17501. name: self.key.value
  17502. });
  17503. }
  17504. }
  17505. return self;
  17506. }
  17507. def_optimize(AST_ObjectProperty, lift_key);
  17508. def_optimize(AST_ConciseMethod, function(self, compressor) {
  17509. lift_key(self, compressor);
  17510. // p(){return x;} ---> p:()=>x
  17511. if (compressor.option("arrows")
  17512. && compressor.parent() instanceof AST_Object
  17513. && !self.is_generator
  17514. && !self.value.uses_arguments
  17515. && !self.value.pinned()
  17516. && self.value.body.length == 1
  17517. && self.value.body[0] instanceof AST_Return
  17518. && self.value.body[0].value
  17519. && !self.value.contains_this()) {
  17520. var arrow = make_node(AST_Arrow, self.value, self.value);
  17521. arrow.async = self.async;
  17522. arrow.is_generator = self.is_generator;
  17523. return make_node(AST_ObjectKeyVal, self, {
  17524. key: self.key instanceof AST_SymbolMethod ? self.key.name : self.key,
  17525. value: arrow,
  17526. quote: self.quote,
  17527. });
  17528. }
  17529. return self;
  17530. });
  17531. def_optimize(AST_ObjectKeyVal, function(self, compressor) {
  17532. lift_key(self, compressor);
  17533. // p:function(){} ---> p(){}
  17534. // p:function*(){} ---> *p(){}
  17535. // p:async function(){} ---> async p(){}
  17536. // p:()=>{} ---> p(){}
  17537. // p:async()=>{} ---> async p(){}
  17538. var unsafe_methods = compressor.option("unsafe_methods");
  17539. if (unsafe_methods
  17540. && compressor.option("ecma") >= 2015
  17541. && (!(unsafe_methods instanceof RegExp) || unsafe_methods.test(self.key + ""))) {
  17542. var key = self.key;
  17543. var value = self.value;
  17544. var is_arrow_with_block = value instanceof AST_Arrow
  17545. && Array.isArray(value.body)
  17546. && !value.contains_this();
  17547. if ((is_arrow_with_block || value instanceof AST_Function) && !value.name) {
  17548. return make_node(AST_ConciseMethod, self, {
  17549. async: value.async,
  17550. is_generator: value.is_generator,
  17551. key: key instanceof AST_Node ? key : make_node(AST_SymbolMethod, self, {
  17552. name: key,
  17553. }),
  17554. value: make_node(AST_Accessor, value, value),
  17555. quote: self.quote,
  17556. });
  17557. }
  17558. }
  17559. return self;
  17560. });
  17561. def_optimize(AST_Destructuring, function(self, compressor) {
  17562. if (compressor.option("pure_getters") == true
  17563. && compressor.option("unused")
  17564. && !self.is_array
  17565. && Array.isArray(self.names)
  17566. && !is_destructuring_export_decl(compressor)
  17567. && !(self.names[self.names.length - 1] instanceof AST_Expansion)) {
  17568. var keep = [];
  17569. for (var i = 0; i < self.names.length; i++) {
  17570. var elem = self.names[i];
  17571. if (!(elem instanceof AST_ObjectKeyVal
  17572. && typeof elem.key == "string"
  17573. && elem.value instanceof AST_SymbolDeclaration
  17574. && !should_retain(compressor, elem.value.definition()))) {
  17575. keep.push(elem);
  17576. }
  17577. }
  17578. if (keep.length != self.names.length) {
  17579. self.names = keep;
  17580. }
  17581. }
  17582. return self;
  17583. function is_destructuring_export_decl(compressor) {
  17584. var ancestors = [/^VarDef$/, /^(Const|Let|Var)$/, /^Export$/];
  17585. for (var a = 0, p = 0, len = ancestors.length; a < len; p++) {
  17586. var parent = compressor.parent(p);
  17587. if (!parent) return false;
  17588. if (a === 0 && parent.TYPE == "Destructuring") continue;
  17589. if (!ancestors[a].test(parent.TYPE)) {
  17590. return false;
  17591. }
  17592. a++;
  17593. }
  17594. return true;
  17595. }
  17596. function should_retain(compressor, def) {
  17597. if (def.references.length) return true;
  17598. if (!def.global) return false;
  17599. if (compressor.toplevel.vars) {
  17600. if (compressor.top_retain) {
  17601. return compressor.top_retain(def);
  17602. }
  17603. return false;
  17604. }
  17605. return true;
  17606. }
  17607. });
  17608. /***********************************************************************
  17609. A JavaScript tokenizer / parser / beautifier / compressor.
  17610. https://github.com/mishoo/UglifyJS2
  17611. -------------------------------- (C) ---------------------------------
  17612. Author: Mihai Bazon
  17613. <mihai.bazon@gmail.com>
  17614. http://mihai.bazon.net/blog
  17615. Distributed under the BSD license:
  17616. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  17617. Redistribution and use in source and binary forms, with or without
  17618. modification, are permitted provided that the following conditions
  17619. are met:
  17620. * Redistributions of source code must retain the above
  17621. copyright notice, this list of conditions and the following
  17622. disclaimer.
  17623. * Redistributions in binary form must reproduce the above
  17624. copyright notice, this list of conditions and the following
  17625. disclaimer in the documentation and/or other materials
  17626. provided with the distribution.
  17627. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  17628. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17629. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17630. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  17631. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  17632. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17633. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  17634. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  17635. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17636. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  17637. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  17638. SUCH DAMAGE.
  17639. ***********************************************************************/
  17640. // a small wrapper around fitzgen's source-map library
  17641. async function SourceMap(options) {
  17642. options = defaults(options, {
  17643. file : null,
  17644. root : null,
  17645. orig : null,
  17646. orig_line_diff : 0,
  17647. dest_line_diff : 0,
  17648. });
  17649. var orig_map;
  17650. var generator = new MOZ_SourceMap__default['default'].SourceMapGenerator({
  17651. file : options.file,
  17652. sourceRoot : options.root
  17653. });
  17654. if (options.orig) {
  17655. orig_map = await new MOZ_SourceMap__default['default'].SourceMapConsumer(options.orig);
  17656. orig_map.sources.forEach(function(source) {
  17657. var sourceContent = orig_map.sourceContentFor(source, true);
  17658. if (sourceContent) {
  17659. generator.setSourceContent(source, sourceContent);
  17660. }
  17661. });
  17662. }
  17663. function add(source, gen_line, gen_col, orig_line, orig_col, name) {
  17664. if (orig_map) {
  17665. var info = orig_map.originalPositionFor({
  17666. line: orig_line,
  17667. column: orig_col
  17668. });
  17669. if (info.source === null) {
  17670. return;
  17671. }
  17672. source = info.source;
  17673. orig_line = info.line;
  17674. orig_col = info.column;
  17675. name = info.name || name;
  17676. }
  17677. generator.addMapping({
  17678. generated : { line: gen_line + options.dest_line_diff, column: gen_col },
  17679. original : { line: orig_line + options.orig_line_diff, column: orig_col },
  17680. source : source,
  17681. name : name
  17682. });
  17683. }
  17684. return {
  17685. add : add,
  17686. get : function() { return generator; },
  17687. toString : function() { return generator.toString(); },
  17688. destroy : function () {
  17689. if (orig_map && orig_map.destroy) {
  17690. orig_map.destroy();
  17691. }
  17692. }
  17693. };
  17694. }
  17695. var domprops = [
  17696. "$&",
  17697. "$'",
  17698. "$*",
  17699. "$+",
  17700. "$1",
  17701. "$2",
  17702. "$3",
  17703. "$4",
  17704. "$5",
  17705. "$6",
  17706. "$7",
  17707. "$8",
  17708. "$9",
  17709. "$_",
  17710. "$`",
  17711. "$input",
  17712. "-moz-animation",
  17713. "-moz-animation-delay",
  17714. "-moz-animation-direction",
  17715. "-moz-animation-duration",
  17716. "-moz-animation-fill-mode",
  17717. "-moz-animation-iteration-count",
  17718. "-moz-animation-name",
  17719. "-moz-animation-play-state",
  17720. "-moz-animation-timing-function",
  17721. "-moz-appearance",
  17722. "-moz-backface-visibility",
  17723. "-moz-border-end",
  17724. "-moz-border-end-color",
  17725. "-moz-border-end-style",
  17726. "-moz-border-end-width",
  17727. "-moz-border-image",
  17728. "-moz-border-start",
  17729. "-moz-border-start-color",
  17730. "-moz-border-start-style",
  17731. "-moz-border-start-width",
  17732. "-moz-box-align",
  17733. "-moz-box-direction",
  17734. "-moz-box-flex",
  17735. "-moz-box-ordinal-group",
  17736. "-moz-box-orient",
  17737. "-moz-box-pack",
  17738. "-moz-box-sizing",
  17739. "-moz-float-edge",
  17740. "-moz-font-feature-settings",
  17741. "-moz-font-language-override",
  17742. "-moz-force-broken-image-icon",
  17743. "-moz-hyphens",
  17744. "-moz-image-region",
  17745. "-moz-margin-end",
  17746. "-moz-margin-start",
  17747. "-moz-orient",
  17748. "-moz-osx-font-smoothing",
  17749. "-moz-outline-radius",
  17750. "-moz-outline-radius-bottomleft",
  17751. "-moz-outline-radius-bottomright",
  17752. "-moz-outline-radius-topleft",
  17753. "-moz-outline-radius-topright",
  17754. "-moz-padding-end",
  17755. "-moz-padding-start",
  17756. "-moz-perspective",
  17757. "-moz-perspective-origin",
  17758. "-moz-tab-size",
  17759. "-moz-text-size-adjust",
  17760. "-moz-transform",
  17761. "-moz-transform-origin",
  17762. "-moz-transform-style",
  17763. "-moz-transition",
  17764. "-moz-transition-delay",
  17765. "-moz-transition-duration",
  17766. "-moz-transition-property",
  17767. "-moz-transition-timing-function",
  17768. "-moz-user-focus",
  17769. "-moz-user-input",
  17770. "-moz-user-modify",
  17771. "-moz-user-select",
  17772. "-moz-window-dragging",
  17773. "-webkit-align-content",
  17774. "-webkit-align-items",
  17775. "-webkit-align-self",
  17776. "-webkit-animation",
  17777. "-webkit-animation-delay",
  17778. "-webkit-animation-direction",
  17779. "-webkit-animation-duration",
  17780. "-webkit-animation-fill-mode",
  17781. "-webkit-animation-iteration-count",
  17782. "-webkit-animation-name",
  17783. "-webkit-animation-play-state",
  17784. "-webkit-animation-timing-function",
  17785. "-webkit-appearance",
  17786. "-webkit-backface-visibility",
  17787. "-webkit-background-clip",
  17788. "-webkit-background-origin",
  17789. "-webkit-background-size",
  17790. "-webkit-border-bottom-left-radius",
  17791. "-webkit-border-bottom-right-radius",
  17792. "-webkit-border-image",
  17793. "-webkit-border-radius",
  17794. "-webkit-border-top-left-radius",
  17795. "-webkit-border-top-right-radius",
  17796. "-webkit-box-align",
  17797. "-webkit-box-direction",
  17798. "-webkit-box-flex",
  17799. "-webkit-box-ordinal-group",
  17800. "-webkit-box-orient",
  17801. "-webkit-box-pack",
  17802. "-webkit-box-shadow",
  17803. "-webkit-box-sizing",
  17804. "-webkit-filter",
  17805. "-webkit-flex",
  17806. "-webkit-flex-basis",
  17807. "-webkit-flex-direction",
  17808. "-webkit-flex-flow",
  17809. "-webkit-flex-grow",
  17810. "-webkit-flex-shrink",
  17811. "-webkit-flex-wrap",
  17812. "-webkit-justify-content",
  17813. "-webkit-line-clamp",
  17814. "-webkit-mask",
  17815. "-webkit-mask-clip",
  17816. "-webkit-mask-composite",
  17817. "-webkit-mask-image",
  17818. "-webkit-mask-origin",
  17819. "-webkit-mask-position",
  17820. "-webkit-mask-position-x",
  17821. "-webkit-mask-position-y",
  17822. "-webkit-mask-repeat",
  17823. "-webkit-mask-size",
  17824. "-webkit-order",
  17825. "-webkit-perspective",
  17826. "-webkit-perspective-origin",
  17827. "-webkit-text-fill-color",
  17828. "-webkit-text-size-adjust",
  17829. "-webkit-text-stroke",
  17830. "-webkit-text-stroke-color",
  17831. "-webkit-text-stroke-width",
  17832. "-webkit-transform",
  17833. "-webkit-transform-origin",
  17834. "-webkit-transform-style",
  17835. "-webkit-transition",
  17836. "-webkit-transition-delay",
  17837. "-webkit-transition-duration",
  17838. "-webkit-transition-property",
  17839. "-webkit-transition-timing-function",
  17840. "-webkit-user-select",
  17841. "0",
  17842. "1",
  17843. "10",
  17844. "11",
  17845. "12",
  17846. "13",
  17847. "14",
  17848. "15",
  17849. "16",
  17850. "17",
  17851. "18",
  17852. "19",
  17853. "2",
  17854. "20",
  17855. "3",
  17856. "4",
  17857. "5",
  17858. "6",
  17859. "7",
  17860. "8",
  17861. "9",
  17862. "@@iterator",
  17863. "ABORT_ERR",
  17864. "ACTIVE",
  17865. "ACTIVE_ATTRIBUTES",
  17866. "ACTIVE_TEXTURE",
  17867. "ACTIVE_UNIFORMS",
  17868. "ACTIVE_UNIFORM_BLOCKS",
  17869. "ADDITION",
  17870. "ALIASED_LINE_WIDTH_RANGE",
  17871. "ALIASED_POINT_SIZE_RANGE",
  17872. "ALLOW_KEYBOARD_INPUT",
  17873. "ALLPASS",
  17874. "ALPHA",
  17875. "ALPHA_BITS",
  17876. "ALREADY_SIGNALED",
  17877. "ALT_MASK",
  17878. "ALWAYS",
  17879. "ANY_SAMPLES_PASSED",
  17880. "ANY_SAMPLES_PASSED_CONSERVATIVE",
  17881. "ANY_TYPE",
  17882. "ANY_UNORDERED_NODE_TYPE",
  17883. "ARRAY_BUFFER",
  17884. "ARRAY_BUFFER_BINDING",
  17885. "ATTACHED_SHADERS",
  17886. "ATTRIBUTE_NODE",
  17887. "AT_TARGET",
  17888. "AbortController",
  17889. "AbortSignal",
  17890. "AbsoluteOrientationSensor",
  17891. "AbstractRange",
  17892. "Accelerometer",
  17893. "AddSearchProvider",
  17894. "AggregateError",
  17895. "AnalyserNode",
  17896. "Animation",
  17897. "AnimationEffect",
  17898. "AnimationEvent",
  17899. "AnimationPlaybackEvent",
  17900. "AnimationTimeline",
  17901. "AnonXMLHttpRequest",
  17902. "Any",
  17903. "ApplicationCache",
  17904. "ApplicationCacheErrorEvent",
  17905. "Array",
  17906. "ArrayBuffer",
  17907. "ArrayType",
  17908. "Atomics",
  17909. "Attr",
  17910. "Audio",
  17911. "AudioBuffer",
  17912. "AudioBufferSourceNode",
  17913. "AudioContext",
  17914. "AudioDestinationNode",
  17915. "AudioListener",
  17916. "AudioNode",
  17917. "AudioParam",
  17918. "AudioParamMap",
  17919. "AudioProcessingEvent",
  17920. "AudioScheduledSourceNode",
  17921. "AudioStreamTrack",
  17922. "AudioWorklet",
  17923. "AudioWorkletNode",
  17924. "AuthenticatorAssertionResponse",
  17925. "AuthenticatorAttestationResponse",
  17926. "AuthenticatorResponse",
  17927. "AutocompleteErrorEvent",
  17928. "BACK",
  17929. "BAD_BOUNDARYPOINTS_ERR",
  17930. "BAD_REQUEST",
  17931. "BANDPASS",
  17932. "BLEND",
  17933. "BLEND_COLOR",
  17934. "BLEND_DST_ALPHA",
  17935. "BLEND_DST_RGB",
  17936. "BLEND_EQUATION",
  17937. "BLEND_EQUATION_ALPHA",
  17938. "BLEND_EQUATION_RGB",
  17939. "BLEND_SRC_ALPHA",
  17940. "BLEND_SRC_RGB",
  17941. "BLUE_BITS",
  17942. "BLUR",
  17943. "BOOL",
  17944. "BOOLEAN_TYPE",
  17945. "BOOL_VEC2",
  17946. "BOOL_VEC3",
  17947. "BOOL_VEC4",
  17948. "BOTH",
  17949. "BROWSER_DEFAULT_WEBGL",
  17950. "BUBBLING_PHASE",
  17951. "BUFFER_SIZE",
  17952. "BUFFER_USAGE",
  17953. "BYTE",
  17954. "BYTES_PER_ELEMENT",
  17955. "BackgroundFetchManager",
  17956. "BackgroundFetchRecord",
  17957. "BackgroundFetchRegistration",
  17958. "BarProp",
  17959. "BarcodeDetector",
  17960. "BaseAudioContext",
  17961. "BaseHref",
  17962. "BatteryManager",
  17963. "BeforeInstallPromptEvent",
  17964. "BeforeLoadEvent",
  17965. "BeforeUnloadEvent",
  17966. "BigInt",
  17967. "BigInt64Array",
  17968. "BigUint64Array",
  17969. "BiquadFilterNode",
  17970. "Blob",
  17971. "BlobEvent",
  17972. "Bluetooth",
  17973. "BluetoothCharacteristicProperties",
  17974. "BluetoothDevice",
  17975. "BluetoothRemoteGATTCharacteristic",
  17976. "BluetoothRemoteGATTDescriptor",
  17977. "BluetoothRemoteGATTServer",
  17978. "BluetoothRemoteGATTService",
  17979. "BluetoothUUID",
  17980. "Boolean",
  17981. "BroadcastChannel",
  17982. "ByteLengthQueuingStrategy",
  17983. "CAPTURING_PHASE",
  17984. "CCW",
  17985. "CDATASection",
  17986. "CDATA_SECTION_NODE",
  17987. "CHANGE",
  17988. "CHARSET_RULE",
  17989. "CHECKING",
  17990. "CLAMP_TO_EDGE",
  17991. "CLICK",
  17992. "CLOSED",
  17993. "CLOSING",
  17994. "COLOR",
  17995. "COLOR_ATTACHMENT0",
  17996. "COLOR_ATTACHMENT1",
  17997. "COLOR_ATTACHMENT10",
  17998. "COLOR_ATTACHMENT11",
  17999. "COLOR_ATTACHMENT12",
  18000. "COLOR_ATTACHMENT13",
  18001. "COLOR_ATTACHMENT14",
  18002. "COLOR_ATTACHMENT15",
  18003. "COLOR_ATTACHMENT2",
  18004. "COLOR_ATTACHMENT3",
  18005. "COLOR_ATTACHMENT4",
  18006. "COLOR_ATTACHMENT5",
  18007. "COLOR_ATTACHMENT6",
  18008. "COLOR_ATTACHMENT7",
  18009. "COLOR_ATTACHMENT8",
  18010. "COLOR_ATTACHMENT9",
  18011. "COLOR_BUFFER_BIT",
  18012. "COLOR_CLEAR_VALUE",
  18013. "COLOR_WRITEMASK",
  18014. "COMMENT_NODE",
  18015. "COMPARE_REF_TO_TEXTURE",
  18016. "COMPILE_STATUS",
  18017. "COMPRESSED_RGBA_S3TC_DXT1_EXT",
  18018. "COMPRESSED_RGBA_S3TC_DXT3_EXT",
  18019. "COMPRESSED_RGBA_S3TC_DXT5_EXT",
  18020. "COMPRESSED_RGB_S3TC_DXT1_EXT",
  18021. "COMPRESSED_TEXTURE_FORMATS",
  18022. "CONDITION_SATISFIED",
  18023. "CONFIGURATION_UNSUPPORTED",
  18024. "CONNECTING",
  18025. "CONSTANT_ALPHA",
  18026. "CONSTANT_COLOR",
  18027. "CONSTRAINT_ERR",
  18028. "CONTEXT_LOST_WEBGL",
  18029. "CONTROL_MASK",
  18030. "COPY_READ_BUFFER",
  18031. "COPY_READ_BUFFER_BINDING",
  18032. "COPY_WRITE_BUFFER",
  18033. "COPY_WRITE_BUFFER_BINDING",
  18034. "COUNTER_STYLE_RULE",
  18035. "CSS",
  18036. "CSS2Properties",
  18037. "CSSAnimation",
  18038. "CSSCharsetRule",
  18039. "CSSConditionRule",
  18040. "CSSCounterStyleRule",
  18041. "CSSFontFaceRule",
  18042. "CSSFontFeatureValuesRule",
  18043. "CSSGroupingRule",
  18044. "CSSImageValue",
  18045. "CSSImportRule",
  18046. "CSSKeyframeRule",
  18047. "CSSKeyframesRule",
  18048. "CSSKeywordValue",
  18049. "CSSMathInvert",
  18050. "CSSMathMax",
  18051. "CSSMathMin",
  18052. "CSSMathNegate",
  18053. "CSSMathProduct",
  18054. "CSSMathSum",
  18055. "CSSMathValue",
  18056. "CSSMatrixComponent",
  18057. "CSSMediaRule",
  18058. "CSSMozDocumentRule",
  18059. "CSSNameSpaceRule",
  18060. "CSSNamespaceRule",
  18061. "CSSNumericArray",
  18062. "CSSNumericValue",
  18063. "CSSPageRule",
  18064. "CSSPerspective",
  18065. "CSSPositionValue",
  18066. "CSSPrimitiveValue",
  18067. "CSSRotate",
  18068. "CSSRule",
  18069. "CSSRuleList",
  18070. "CSSScale",
  18071. "CSSSkew",
  18072. "CSSSkewX",
  18073. "CSSSkewY",
  18074. "CSSStyleDeclaration",
  18075. "CSSStyleRule",
  18076. "CSSStyleSheet",
  18077. "CSSStyleValue",
  18078. "CSSSupportsRule",
  18079. "CSSTransformComponent",
  18080. "CSSTransformValue",
  18081. "CSSTransition",
  18082. "CSSTranslate",
  18083. "CSSUnitValue",
  18084. "CSSUnknownRule",
  18085. "CSSUnparsedValue",
  18086. "CSSValue",
  18087. "CSSValueList",
  18088. "CSSVariableReferenceValue",
  18089. "CSSVariablesDeclaration",
  18090. "CSSVariablesRule",
  18091. "CSSViewportRule",
  18092. "CSS_ATTR",
  18093. "CSS_CM",
  18094. "CSS_COUNTER",
  18095. "CSS_CUSTOM",
  18096. "CSS_DEG",
  18097. "CSS_DIMENSION",
  18098. "CSS_EMS",
  18099. "CSS_EXS",
  18100. "CSS_FILTER_BLUR",
  18101. "CSS_FILTER_BRIGHTNESS",
  18102. "CSS_FILTER_CONTRAST",
  18103. "CSS_FILTER_CUSTOM",
  18104. "CSS_FILTER_DROP_SHADOW",
  18105. "CSS_FILTER_GRAYSCALE",
  18106. "CSS_FILTER_HUE_ROTATE",
  18107. "CSS_FILTER_INVERT",
  18108. "CSS_FILTER_OPACITY",
  18109. "CSS_FILTER_REFERENCE",
  18110. "CSS_FILTER_SATURATE",
  18111. "CSS_FILTER_SEPIA",
  18112. "CSS_GRAD",
  18113. "CSS_HZ",
  18114. "CSS_IDENT",
  18115. "CSS_IN",
  18116. "CSS_INHERIT",
  18117. "CSS_KHZ",
  18118. "CSS_MATRIX",
  18119. "CSS_MATRIX3D",
  18120. "CSS_MM",
  18121. "CSS_MS",
  18122. "CSS_NUMBER",
  18123. "CSS_PC",
  18124. "CSS_PERCENTAGE",
  18125. "CSS_PERSPECTIVE",
  18126. "CSS_PRIMITIVE_VALUE",
  18127. "CSS_PT",
  18128. "CSS_PX",
  18129. "CSS_RAD",
  18130. "CSS_RECT",
  18131. "CSS_RGBCOLOR",
  18132. "CSS_ROTATE",
  18133. "CSS_ROTATE3D",
  18134. "CSS_ROTATEX",
  18135. "CSS_ROTATEY",
  18136. "CSS_ROTATEZ",
  18137. "CSS_S",
  18138. "CSS_SCALE",
  18139. "CSS_SCALE3D",
  18140. "CSS_SCALEX",
  18141. "CSS_SCALEY",
  18142. "CSS_SCALEZ",
  18143. "CSS_SKEW",
  18144. "CSS_SKEWX",
  18145. "CSS_SKEWY",
  18146. "CSS_STRING",
  18147. "CSS_TRANSLATE",
  18148. "CSS_TRANSLATE3D",
  18149. "CSS_TRANSLATEX",
  18150. "CSS_TRANSLATEY",
  18151. "CSS_TRANSLATEZ",
  18152. "CSS_UNKNOWN",
  18153. "CSS_URI",
  18154. "CSS_VALUE_LIST",
  18155. "CSS_VH",
  18156. "CSS_VMAX",
  18157. "CSS_VMIN",
  18158. "CSS_VW",
  18159. "CULL_FACE",
  18160. "CULL_FACE_MODE",
  18161. "CURRENT_PROGRAM",
  18162. "CURRENT_QUERY",
  18163. "CURRENT_VERTEX_ATTRIB",
  18164. "CUSTOM",
  18165. "CW",
  18166. "Cache",
  18167. "CacheStorage",
  18168. "CanvasCaptureMediaStream",
  18169. "CanvasCaptureMediaStreamTrack",
  18170. "CanvasGradient",
  18171. "CanvasPattern",
  18172. "CanvasRenderingContext2D",
  18173. "CaretPosition",
  18174. "ChannelMergerNode",
  18175. "ChannelSplitterNode",
  18176. "CharacterData",
  18177. "ClientRect",
  18178. "ClientRectList",
  18179. "Clipboard",
  18180. "ClipboardEvent",
  18181. "ClipboardItem",
  18182. "CloseEvent",
  18183. "Collator",
  18184. "CommandEvent",
  18185. "Comment",
  18186. "CompileError",
  18187. "CompositionEvent",
  18188. "CompressionStream",
  18189. "Console",
  18190. "ConstantSourceNode",
  18191. "Controllers",
  18192. "ConvolverNode",
  18193. "CountQueuingStrategy",
  18194. "Counter",
  18195. "Credential",
  18196. "CredentialsContainer",
  18197. "Crypto",
  18198. "CryptoKey",
  18199. "CustomElementRegistry",
  18200. "CustomEvent",
  18201. "DATABASE_ERR",
  18202. "DATA_CLONE_ERR",
  18203. "DATA_ERR",
  18204. "DBLCLICK",
  18205. "DECR",
  18206. "DECR_WRAP",
  18207. "DELETE_STATUS",
  18208. "DEPTH",
  18209. "DEPTH24_STENCIL8",
  18210. "DEPTH32F_STENCIL8",
  18211. "DEPTH_ATTACHMENT",
  18212. "DEPTH_BITS",
  18213. "DEPTH_BUFFER_BIT",
  18214. "DEPTH_CLEAR_VALUE",
  18215. "DEPTH_COMPONENT",
  18216. "DEPTH_COMPONENT16",
  18217. "DEPTH_COMPONENT24",
  18218. "DEPTH_COMPONENT32F",
  18219. "DEPTH_FUNC",
  18220. "DEPTH_RANGE",
  18221. "DEPTH_STENCIL",
  18222. "DEPTH_STENCIL_ATTACHMENT",
  18223. "DEPTH_TEST",
  18224. "DEPTH_WRITEMASK",
  18225. "DEVICE_INELIGIBLE",
  18226. "DIRECTION_DOWN",
  18227. "DIRECTION_LEFT",
  18228. "DIRECTION_RIGHT",
  18229. "DIRECTION_UP",
  18230. "DISABLED",
  18231. "DISPATCH_REQUEST_ERR",
  18232. "DITHER",
  18233. "DOCUMENT_FRAGMENT_NODE",
  18234. "DOCUMENT_NODE",
  18235. "DOCUMENT_POSITION_CONTAINED_BY",
  18236. "DOCUMENT_POSITION_CONTAINS",
  18237. "DOCUMENT_POSITION_DISCONNECTED",
  18238. "DOCUMENT_POSITION_FOLLOWING",
  18239. "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
  18240. "DOCUMENT_POSITION_PRECEDING",
  18241. "DOCUMENT_TYPE_NODE",
  18242. "DOMCursor",
  18243. "DOMError",
  18244. "DOMException",
  18245. "DOMImplementation",
  18246. "DOMImplementationLS",
  18247. "DOMMatrix",
  18248. "DOMMatrixReadOnly",
  18249. "DOMParser",
  18250. "DOMPoint",
  18251. "DOMPointReadOnly",
  18252. "DOMQuad",
  18253. "DOMRect",
  18254. "DOMRectList",
  18255. "DOMRectReadOnly",
  18256. "DOMRequest",
  18257. "DOMSTRING_SIZE_ERR",
  18258. "DOMSettableTokenList",
  18259. "DOMStringList",
  18260. "DOMStringMap",
  18261. "DOMTokenList",
  18262. "DOMTransactionEvent",
  18263. "DOM_DELTA_LINE",
  18264. "DOM_DELTA_PAGE",
  18265. "DOM_DELTA_PIXEL",
  18266. "DOM_INPUT_METHOD_DROP",
  18267. "DOM_INPUT_METHOD_HANDWRITING",
  18268. "DOM_INPUT_METHOD_IME",
  18269. "DOM_INPUT_METHOD_KEYBOARD",
  18270. "DOM_INPUT_METHOD_MULTIMODAL",
  18271. "DOM_INPUT_METHOD_OPTION",
  18272. "DOM_INPUT_METHOD_PASTE",
  18273. "DOM_INPUT_METHOD_SCRIPT",
  18274. "DOM_INPUT_METHOD_UNKNOWN",
  18275. "DOM_INPUT_METHOD_VOICE",
  18276. "DOM_KEY_LOCATION_JOYSTICK",
  18277. "DOM_KEY_LOCATION_LEFT",
  18278. "DOM_KEY_LOCATION_MOBILE",
  18279. "DOM_KEY_LOCATION_NUMPAD",
  18280. "DOM_KEY_LOCATION_RIGHT",
  18281. "DOM_KEY_LOCATION_STANDARD",
  18282. "DOM_VK_0",
  18283. "DOM_VK_1",
  18284. "DOM_VK_2",
  18285. "DOM_VK_3",
  18286. "DOM_VK_4",
  18287. "DOM_VK_5",
  18288. "DOM_VK_6",
  18289. "DOM_VK_7",
  18290. "DOM_VK_8",
  18291. "DOM_VK_9",
  18292. "DOM_VK_A",
  18293. "DOM_VK_ACCEPT",
  18294. "DOM_VK_ADD",
  18295. "DOM_VK_ALT",
  18296. "DOM_VK_ALTGR",
  18297. "DOM_VK_AMPERSAND",
  18298. "DOM_VK_ASTERISK",
  18299. "DOM_VK_AT",
  18300. "DOM_VK_ATTN",
  18301. "DOM_VK_B",
  18302. "DOM_VK_BACKSPACE",
  18303. "DOM_VK_BACK_QUOTE",
  18304. "DOM_VK_BACK_SLASH",
  18305. "DOM_VK_BACK_SPACE",
  18306. "DOM_VK_C",
  18307. "DOM_VK_CANCEL",
  18308. "DOM_VK_CAPS_LOCK",
  18309. "DOM_VK_CIRCUMFLEX",
  18310. "DOM_VK_CLEAR",
  18311. "DOM_VK_CLOSE_BRACKET",
  18312. "DOM_VK_CLOSE_CURLY_BRACKET",
  18313. "DOM_VK_CLOSE_PAREN",
  18314. "DOM_VK_COLON",
  18315. "DOM_VK_COMMA",
  18316. "DOM_VK_CONTEXT_MENU",
  18317. "DOM_VK_CONTROL",
  18318. "DOM_VK_CONVERT",
  18319. "DOM_VK_CRSEL",
  18320. "DOM_VK_CTRL",
  18321. "DOM_VK_D",
  18322. "DOM_VK_DECIMAL",
  18323. "DOM_VK_DELETE",
  18324. "DOM_VK_DIVIDE",
  18325. "DOM_VK_DOLLAR",
  18326. "DOM_VK_DOUBLE_QUOTE",
  18327. "DOM_VK_DOWN",
  18328. "DOM_VK_E",
  18329. "DOM_VK_EISU",
  18330. "DOM_VK_END",
  18331. "DOM_VK_ENTER",
  18332. "DOM_VK_EQUALS",
  18333. "DOM_VK_EREOF",
  18334. "DOM_VK_ESCAPE",
  18335. "DOM_VK_EXCLAMATION",
  18336. "DOM_VK_EXECUTE",
  18337. "DOM_VK_EXSEL",
  18338. "DOM_VK_F",
  18339. "DOM_VK_F1",
  18340. "DOM_VK_F10",
  18341. "DOM_VK_F11",
  18342. "DOM_VK_F12",
  18343. "DOM_VK_F13",
  18344. "DOM_VK_F14",
  18345. "DOM_VK_F15",
  18346. "DOM_VK_F16",
  18347. "DOM_VK_F17",
  18348. "DOM_VK_F18",
  18349. "DOM_VK_F19",
  18350. "DOM_VK_F2",
  18351. "DOM_VK_F20",
  18352. "DOM_VK_F21",
  18353. "DOM_VK_F22",
  18354. "DOM_VK_F23",
  18355. "DOM_VK_F24",
  18356. "DOM_VK_F25",
  18357. "DOM_VK_F26",
  18358. "DOM_VK_F27",
  18359. "DOM_VK_F28",
  18360. "DOM_VK_F29",
  18361. "DOM_VK_F3",
  18362. "DOM_VK_F30",
  18363. "DOM_VK_F31",
  18364. "DOM_VK_F32",
  18365. "DOM_VK_F33",
  18366. "DOM_VK_F34",
  18367. "DOM_VK_F35",
  18368. "DOM_VK_F36",
  18369. "DOM_VK_F4",
  18370. "DOM_VK_F5",
  18371. "DOM_VK_F6",
  18372. "DOM_VK_F7",
  18373. "DOM_VK_F8",
  18374. "DOM_VK_F9",
  18375. "DOM_VK_FINAL",
  18376. "DOM_VK_FRONT",
  18377. "DOM_VK_G",
  18378. "DOM_VK_GREATER_THAN",
  18379. "DOM_VK_H",
  18380. "DOM_VK_HANGUL",
  18381. "DOM_VK_HANJA",
  18382. "DOM_VK_HASH",
  18383. "DOM_VK_HELP",
  18384. "DOM_VK_HK_TOGGLE",
  18385. "DOM_VK_HOME",
  18386. "DOM_VK_HYPHEN_MINUS",
  18387. "DOM_VK_I",
  18388. "DOM_VK_INSERT",
  18389. "DOM_VK_J",
  18390. "DOM_VK_JUNJA",
  18391. "DOM_VK_K",
  18392. "DOM_VK_KANA",
  18393. "DOM_VK_KANJI",
  18394. "DOM_VK_L",
  18395. "DOM_VK_LEFT",
  18396. "DOM_VK_LEFT_TAB",
  18397. "DOM_VK_LESS_THAN",
  18398. "DOM_VK_M",
  18399. "DOM_VK_META",
  18400. "DOM_VK_MODECHANGE",
  18401. "DOM_VK_MULTIPLY",
  18402. "DOM_VK_N",
  18403. "DOM_VK_NONCONVERT",
  18404. "DOM_VK_NUMPAD0",
  18405. "DOM_VK_NUMPAD1",
  18406. "DOM_VK_NUMPAD2",
  18407. "DOM_VK_NUMPAD3",
  18408. "DOM_VK_NUMPAD4",
  18409. "DOM_VK_NUMPAD5",
  18410. "DOM_VK_NUMPAD6",
  18411. "DOM_VK_NUMPAD7",
  18412. "DOM_VK_NUMPAD8",
  18413. "DOM_VK_NUMPAD9",
  18414. "DOM_VK_NUM_LOCK",
  18415. "DOM_VK_O",
  18416. "DOM_VK_OEM_1",
  18417. "DOM_VK_OEM_102",
  18418. "DOM_VK_OEM_2",
  18419. "DOM_VK_OEM_3",
  18420. "DOM_VK_OEM_4",
  18421. "DOM_VK_OEM_5",
  18422. "DOM_VK_OEM_6",
  18423. "DOM_VK_OEM_7",
  18424. "DOM_VK_OEM_8",
  18425. "DOM_VK_OEM_COMMA",
  18426. "DOM_VK_OEM_MINUS",
  18427. "DOM_VK_OEM_PERIOD",
  18428. "DOM_VK_OEM_PLUS",
  18429. "DOM_VK_OPEN_BRACKET",
  18430. "DOM_VK_OPEN_CURLY_BRACKET",
  18431. "DOM_VK_OPEN_PAREN",
  18432. "DOM_VK_P",
  18433. "DOM_VK_PA1",
  18434. "DOM_VK_PAGEDOWN",
  18435. "DOM_VK_PAGEUP",
  18436. "DOM_VK_PAGE_DOWN",
  18437. "DOM_VK_PAGE_UP",
  18438. "DOM_VK_PAUSE",
  18439. "DOM_VK_PERCENT",
  18440. "DOM_VK_PERIOD",
  18441. "DOM_VK_PIPE",
  18442. "DOM_VK_PLAY",
  18443. "DOM_VK_PLUS",
  18444. "DOM_VK_PRINT",
  18445. "DOM_VK_PRINTSCREEN",
  18446. "DOM_VK_PROCESSKEY",
  18447. "DOM_VK_PROPERITES",
  18448. "DOM_VK_Q",
  18449. "DOM_VK_QUESTION_MARK",
  18450. "DOM_VK_QUOTE",
  18451. "DOM_VK_R",
  18452. "DOM_VK_REDO",
  18453. "DOM_VK_RETURN",
  18454. "DOM_VK_RIGHT",
  18455. "DOM_VK_S",
  18456. "DOM_VK_SCROLL_LOCK",
  18457. "DOM_VK_SELECT",
  18458. "DOM_VK_SEMICOLON",
  18459. "DOM_VK_SEPARATOR",
  18460. "DOM_VK_SHIFT",
  18461. "DOM_VK_SLASH",
  18462. "DOM_VK_SLEEP",
  18463. "DOM_VK_SPACE",
  18464. "DOM_VK_SUBTRACT",
  18465. "DOM_VK_T",
  18466. "DOM_VK_TAB",
  18467. "DOM_VK_TILDE",
  18468. "DOM_VK_U",
  18469. "DOM_VK_UNDERSCORE",
  18470. "DOM_VK_UNDO",
  18471. "DOM_VK_UNICODE",
  18472. "DOM_VK_UP",
  18473. "DOM_VK_V",
  18474. "DOM_VK_VOLUME_DOWN",
  18475. "DOM_VK_VOLUME_MUTE",
  18476. "DOM_VK_VOLUME_UP",
  18477. "DOM_VK_W",
  18478. "DOM_VK_WIN",
  18479. "DOM_VK_WINDOW",
  18480. "DOM_VK_WIN_ICO_00",
  18481. "DOM_VK_WIN_ICO_CLEAR",
  18482. "DOM_VK_WIN_ICO_HELP",
  18483. "DOM_VK_WIN_OEM_ATTN",
  18484. "DOM_VK_WIN_OEM_AUTO",
  18485. "DOM_VK_WIN_OEM_BACKTAB",
  18486. "DOM_VK_WIN_OEM_CLEAR",
  18487. "DOM_VK_WIN_OEM_COPY",
  18488. "DOM_VK_WIN_OEM_CUSEL",
  18489. "DOM_VK_WIN_OEM_ENLW",
  18490. "DOM_VK_WIN_OEM_FINISH",
  18491. "DOM_VK_WIN_OEM_FJ_JISHO",
  18492. "DOM_VK_WIN_OEM_FJ_LOYA",
  18493. "DOM_VK_WIN_OEM_FJ_MASSHOU",
  18494. "DOM_VK_WIN_OEM_FJ_ROYA",
  18495. "DOM_VK_WIN_OEM_FJ_TOUROKU",
  18496. "DOM_VK_WIN_OEM_JUMP",
  18497. "DOM_VK_WIN_OEM_PA1",
  18498. "DOM_VK_WIN_OEM_PA2",
  18499. "DOM_VK_WIN_OEM_PA3",
  18500. "DOM_VK_WIN_OEM_RESET",
  18501. "DOM_VK_WIN_OEM_WSCTRL",
  18502. "DOM_VK_X",
  18503. "DOM_VK_XF86XK_ADD_FAVORITE",
  18504. "DOM_VK_XF86XK_APPLICATION_LEFT",
  18505. "DOM_VK_XF86XK_APPLICATION_RIGHT",
  18506. "DOM_VK_XF86XK_AUDIO_CYCLE_TRACK",
  18507. "DOM_VK_XF86XK_AUDIO_FORWARD",
  18508. "DOM_VK_XF86XK_AUDIO_LOWER_VOLUME",
  18509. "DOM_VK_XF86XK_AUDIO_MEDIA",
  18510. "DOM_VK_XF86XK_AUDIO_MUTE",
  18511. "DOM_VK_XF86XK_AUDIO_NEXT",
  18512. "DOM_VK_XF86XK_AUDIO_PAUSE",
  18513. "DOM_VK_XF86XK_AUDIO_PLAY",
  18514. "DOM_VK_XF86XK_AUDIO_PREV",
  18515. "DOM_VK_XF86XK_AUDIO_RAISE_VOLUME",
  18516. "DOM_VK_XF86XK_AUDIO_RANDOM_PLAY",
  18517. "DOM_VK_XF86XK_AUDIO_RECORD",
  18518. "DOM_VK_XF86XK_AUDIO_REPEAT",
  18519. "DOM_VK_XF86XK_AUDIO_REWIND",
  18520. "DOM_VK_XF86XK_AUDIO_STOP",
  18521. "DOM_VK_XF86XK_AWAY",
  18522. "DOM_VK_XF86XK_BACK",
  18523. "DOM_VK_XF86XK_BACK_FORWARD",
  18524. "DOM_VK_XF86XK_BATTERY",
  18525. "DOM_VK_XF86XK_BLUE",
  18526. "DOM_VK_XF86XK_BLUETOOTH",
  18527. "DOM_VK_XF86XK_BOOK",
  18528. "DOM_VK_XF86XK_BRIGHTNESS_ADJUST",
  18529. "DOM_VK_XF86XK_CALCULATOR",
  18530. "DOM_VK_XF86XK_CALENDAR",
  18531. "DOM_VK_XF86XK_CD",
  18532. "DOM_VK_XF86XK_CLOSE",
  18533. "DOM_VK_XF86XK_COMMUNITY",
  18534. "DOM_VK_XF86XK_CONTRAST_ADJUST",
  18535. "DOM_VK_XF86XK_COPY",
  18536. "DOM_VK_XF86XK_CUT",
  18537. "DOM_VK_XF86XK_CYCLE_ANGLE",
  18538. "DOM_VK_XF86XK_DISPLAY",
  18539. "DOM_VK_XF86XK_DOCUMENTS",
  18540. "DOM_VK_XF86XK_DOS",
  18541. "DOM_VK_XF86XK_EJECT",
  18542. "DOM_VK_XF86XK_EXCEL",
  18543. "DOM_VK_XF86XK_EXPLORER",
  18544. "DOM_VK_XF86XK_FAVORITES",
  18545. "DOM_VK_XF86XK_FINANCE",
  18546. "DOM_VK_XF86XK_FORWARD",
  18547. "DOM_VK_XF86XK_FRAME_BACK",
  18548. "DOM_VK_XF86XK_FRAME_FORWARD",
  18549. "DOM_VK_XF86XK_GAME",
  18550. "DOM_VK_XF86XK_GO",
  18551. "DOM_VK_XF86XK_GREEN",
  18552. "DOM_VK_XF86XK_HIBERNATE",
  18553. "DOM_VK_XF86XK_HISTORY",
  18554. "DOM_VK_XF86XK_HOME_PAGE",
  18555. "DOM_VK_XF86XK_HOT_LINKS",
  18556. "DOM_VK_XF86XK_I_TOUCH",
  18557. "DOM_VK_XF86XK_KBD_BRIGHTNESS_DOWN",
  18558. "DOM_VK_XF86XK_KBD_BRIGHTNESS_UP",
  18559. "DOM_VK_XF86XK_KBD_LIGHT_ON_OFF",
  18560. "DOM_VK_XF86XK_LAUNCH0",
  18561. "DOM_VK_XF86XK_LAUNCH1",
  18562. "DOM_VK_XF86XK_LAUNCH2",
  18563. "DOM_VK_XF86XK_LAUNCH3",
  18564. "DOM_VK_XF86XK_LAUNCH4",
  18565. "DOM_VK_XF86XK_LAUNCH5",
  18566. "DOM_VK_XF86XK_LAUNCH6",
  18567. "DOM_VK_XF86XK_LAUNCH7",
  18568. "DOM_VK_XF86XK_LAUNCH8",
  18569. "DOM_VK_XF86XK_LAUNCH9",
  18570. "DOM_VK_XF86XK_LAUNCH_A",
  18571. "DOM_VK_XF86XK_LAUNCH_B",
  18572. "DOM_VK_XF86XK_LAUNCH_C",
  18573. "DOM_VK_XF86XK_LAUNCH_D",
  18574. "DOM_VK_XF86XK_LAUNCH_E",
  18575. "DOM_VK_XF86XK_LAUNCH_F",
  18576. "DOM_VK_XF86XK_LIGHT_BULB",
  18577. "DOM_VK_XF86XK_LOG_OFF",
  18578. "DOM_VK_XF86XK_MAIL",
  18579. "DOM_VK_XF86XK_MAIL_FORWARD",
  18580. "DOM_VK_XF86XK_MARKET",
  18581. "DOM_VK_XF86XK_MEETING",
  18582. "DOM_VK_XF86XK_MEMO",
  18583. "DOM_VK_XF86XK_MENU_KB",
  18584. "DOM_VK_XF86XK_MENU_PB",
  18585. "DOM_VK_XF86XK_MESSENGER",
  18586. "DOM_VK_XF86XK_MON_BRIGHTNESS_DOWN",
  18587. "DOM_VK_XF86XK_MON_BRIGHTNESS_UP",
  18588. "DOM_VK_XF86XK_MUSIC",
  18589. "DOM_VK_XF86XK_MY_COMPUTER",
  18590. "DOM_VK_XF86XK_MY_SITES",
  18591. "DOM_VK_XF86XK_NEW",
  18592. "DOM_VK_XF86XK_NEWS",
  18593. "DOM_VK_XF86XK_OFFICE_HOME",
  18594. "DOM_VK_XF86XK_OPEN",
  18595. "DOM_VK_XF86XK_OPEN_URL",
  18596. "DOM_VK_XF86XK_OPTION",
  18597. "DOM_VK_XF86XK_PASTE",
  18598. "DOM_VK_XF86XK_PHONE",
  18599. "DOM_VK_XF86XK_PICTURES",
  18600. "DOM_VK_XF86XK_POWER_DOWN",
  18601. "DOM_VK_XF86XK_POWER_OFF",
  18602. "DOM_VK_XF86XK_RED",
  18603. "DOM_VK_XF86XK_REFRESH",
  18604. "DOM_VK_XF86XK_RELOAD",
  18605. "DOM_VK_XF86XK_REPLY",
  18606. "DOM_VK_XF86XK_ROCKER_DOWN",
  18607. "DOM_VK_XF86XK_ROCKER_ENTER",
  18608. "DOM_VK_XF86XK_ROCKER_UP",
  18609. "DOM_VK_XF86XK_ROTATE_WINDOWS",
  18610. "DOM_VK_XF86XK_ROTATION_KB",
  18611. "DOM_VK_XF86XK_ROTATION_PB",
  18612. "DOM_VK_XF86XK_SAVE",
  18613. "DOM_VK_XF86XK_SCREEN_SAVER",
  18614. "DOM_VK_XF86XK_SCROLL_CLICK",
  18615. "DOM_VK_XF86XK_SCROLL_DOWN",
  18616. "DOM_VK_XF86XK_SCROLL_UP",
  18617. "DOM_VK_XF86XK_SEARCH",
  18618. "DOM_VK_XF86XK_SEND",
  18619. "DOM_VK_XF86XK_SHOP",
  18620. "DOM_VK_XF86XK_SPELL",
  18621. "DOM_VK_XF86XK_SPLIT_SCREEN",
  18622. "DOM_VK_XF86XK_STANDBY",
  18623. "DOM_VK_XF86XK_START",
  18624. "DOM_VK_XF86XK_STOP",
  18625. "DOM_VK_XF86XK_SUBTITLE",
  18626. "DOM_VK_XF86XK_SUPPORT",
  18627. "DOM_VK_XF86XK_SUSPEND",
  18628. "DOM_VK_XF86XK_TASK_PANE",
  18629. "DOM_VK_XF86XK_TERMINAL",
  18630. "DOM_VK_XF86XK_TIME",
  18631. "DOM_VK_XF86XK_TOOLS",
  18632. "DOM_VK_XF86XK_TOP_MENU",
  18633. "DOM_VK_XF86XK_TO_DO_LIST",
  18634. "DOM_VK_XF86XK_TRAVEL",
  18635. "DOM_VK_XF86XK_USER1KB",
  18636. "DOM_VK_XF86XK_USER2KB",
  18637. "DOM_VK_XF86XK_USER_PB",
  18638. "DOM_VK_XF86XK_UWB",
  18639. "DOM_VK_XF86XK_VENDOR_HOME",
  18640. "DOM_VK_XF86XK_VIDEO",
  18641. "DOM_VK_XF86XK_VIEW",
  18642. "DOM_VK_XF86XK_WAKE_UP",
  18643. "DOM_VK_XF86XK_WEB_CAM",
  18644. "DOM_VK_XF86XK_WHEEL_BUTTON",
  18645. "DOM_VK_XF86XK_WLAN",
  18646. "DOM_VK_XF86XK_WORD",
  18647. "DOM_VK_XF86XK_WWW",
  18648. "DOM_VK_XF86XK_XFER",
  18649. "DOM_VK_XF86XK_YELLOW",
  18650. "DOM_VK_XF86XK_ZOOM_IN",
  18651. "DOM_VK_XF86XK_ZOOM_OUT",
  18652. "DOM_VK_Y",
  18653. "DOM_VK_Z",
  18654. "DOM_VK_ZOOM",
  18655. "DONE",
  18656. "DONT_CARE",
  18657. "DOWNLOADING",
  18658. "DRAGDROP",
  18659. "DRAW_BUFFER0",
  18660. "DRAW_BUFFER1",
  18661. "DRAW_BUFFER10",
  18662. "DRAW_BUFFER11",
  18663. "DRAW_BUFFER12",
  18664. "DRAW_BUFFER13",
  18665. "DRAW_BUFFER14",
  18666. "DRAW_BUFFER15",
  18667. "DRAW_BUFFER2",
  18668. "DRAW_BUFFER3",
  18669. "DRAW_BUFFER4",
  18670. "DRAW_BUFFER5",
  18671. "DRAW_BUFFER6",
  18672. "DRAW_BUFFER7",
  18673. "DRAW_BUFFER8",
  18674. "DRAW_BUFFER9",
  18675. "DRAW_FRAMEBUFFER",
  18676. "DRAW_FRAMEBUFFER_BINDING",
  18677. "DST_ALPHA",
  18678. "DST_COLOR",
  18679. "DYNAMIC_COPY",
  18680. "DYNAMIC_DRAW",
  18681. "DYNAMIC_READ",
  18682. "DataChannel",
  18683. "DataTransfer",
  18684. "DataTransferItem",
  18685. "DataTransferItemList",
  18686. "DataView",
  18687. "Date",
  18688. "DateTimeFormat",
  18689. "DecompressionStream",
  18690. "DelayNode",
  18691. "DeprecationReportBody",
  18692. "DesktopNotification",
  18693. "DesktopNotificationCenter",
  18694. "DeviceLightEvent",
  18695. "DeviceMotionEvent",
  18696. "DeviceMotionEventAcceleration",
  18697. "DeviceMotionEventRotationRate",
  18698. "DeviceOrientationEvent",
  18699. "DeviceProximityEvent",
  18700. "DeviceStorage",
  18701. "DeviceStorageChangeEvent",
  18702. "Directory",
  18703. "DisplayNames",
  18704. "Document",
  18705. "DocumentFragment",
  18706. "DocumentTimeline",
  18707. "DocumentType",
  18708. "DragEvent",
  18709. "DynamicsCompressorNode",
  18710. "E",
  18711. "ELEMENT_ARRAY_BUFFER",
  18712. "ELEMENT_ARRAY_BUFFER_BINDING",
  18713. "ELEMENT_NODE",
  18714. "EMPTY",
  18715. "ENCODING_ERR",
  18716. "ENDED",
  18717. "END_TO_END",
  18718. "END_TO_START",
  18719. "ENTITY_NODE",
  18720. "ENTITY_REFERENCE_NODE",
  18721. "EPSILON",
  18722. "EQUAL",
  18723. "EQUALPOWER",
  18724. "ERROR",
  18725. "EXPONENTIAL_DISTANCE",
  18726. "Element",
  18727. "ElementInternals",
  18728. "ElementQuery",
  18729. "EnterPictureInPictureEvent",
  18730. "Entity",
  18731. "EntityReference",
  18732. "Error",
  18733. "ErrorEvent",
  18734. "EvalError",
  18735. "Event",
  18736. "EventException",
  18737. "EventSource",
  18738. "EventTarget",
  18739. "External",
  18740. "FASTEST",
  18741. "FIDOSDK",
  18742. "FILTER_ACCEPT",
  18743. "FILTER_INTERRUPT",
  18744. "FILTER_REJECT",
  18745. "FILTER_SKIP",
  18746. "FINISHED_STATE",
  18747. "FIRST_ORDERED_NODE_TYPE",
  18748. "FLOAT",
  18749. "FLOAT_32_UNSIGNED_INT_24_8_REV",
  18750. "FLOAT_MAT2",
  18751. "FLOAT_MAT2x3",
  18752. "FLOAT_MAT2x4",
  18753. "FLOAT_MAT3",
  18754. "FLOAT_MAT3x2",
  18755. "FLOAT_MAT3x4",
  18756. "FLOAT_MAT4",
  18757. "FLOAT_MAT4x2",
  18758. "FLOAT_MAT4x3",
  18759. "FLOAT_VEC2",
  18760. "FLOAT_VEC3",
  18761. "FLOAT_VEC4",
  18762. "FOCUS",
  18763. "FONT_FACE_RULE",
  18764. "FONT_FEATURE_VALUES_RULE",
  18765. "FRAGMENT_SHADER",
  18766. "FRAGMENT_SHADER_DERIVATIVE_HINT",
  18767. "FRAGMENT_SHADER_DERIVATIVE_HINT_OES",
  18768. "FRAMEBUFFER",
  18769. "FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",
  18770. "FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",
  18771. "FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",
  18772. "FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",
  18773. "FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",
  18774. "FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",
  18775. "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",
  18776. "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",
  18777. "FRAMEBUFFER_ATTACHMENT_RED_SIZE",
  18778. "FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",
  18779. "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",
  18780. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",
  18781. "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",
  18782. "FRAMEBUFFER_BINDING",
  18783. "FRAMEBUFFER_COMPLETE",
  18784. "FRAMEBUFFER_DEFAULT",
  18785. "FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
  18786. "FRAMEBUFFER_INCOMPLETE_DIMENSIONS",
  18787. "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",
  18788. "FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",
  18789. "FRAMEBUFFER_UNSUPPORTED",
  18790. "FRONT",
  18791. "FRONT_AND_BACK",
  18792. "FRONT_FACE",
  18793. "FUNC_ADD",
  18794. "FUNC_REVERSE_SUBTRACT",
  18795. "FUNC_SUBTRACT",
  18796. "FeaturePolicy",
  18797. "FeaturePolicyViolationReportBody",
  18798. "FederatedCredential",
  18799. "Feed",
  18800. "FeedEntry",
  18801. "File",
  18802. "FileError",
  18803. "FileList",
  18804. "FileReader",
  18805. "FileSystem",
  18806. "FileSystemDirectoryEntry",
  18807. "FileSystemDirectoryReader",
  18808. "FileSystemEntry",
  18809. "FileSystemFileEntry",
  18810. "FinalizationRegistry",
  18811. "FindInPage",
  18812. "Float32Array",
  18813. "Float64Array",
  18814. "FocusEvent",
  18815. "FontFace",
  18816. "FontFaceSet",
  18817. "FontFaceSetLoadEvent",
  18818. "FormData",
  18819. "FormDataEvent",
  18820. "FragmentDirective",
  18821. "Function",
  18822. "GENERATE_MIPMAP_HINT",
  18823. "GEQUAL",
  18824. "GREATER",
  18825. "GREEN_BITS",
  18826. "GainNode",
  18827. "Gamepad",
  18828. "GamepadAxisMoveEvent",
  18829. "GamepadButton",
  18830. "GamepadButtonEvent",
  18831. "GamepadEvent",
  18832. "GamepadHapticActuator",
  18833. "GamepadPose",
  18834. "Geolocation",
  18835. "GeolocationCoordinates",
  18836. "GeolocationPosition",
  18837. "GeolocationPositionError",
  18838. "GestureEvent",
  18839. "Global",
  18840. "Gyroscope",
  18841. "HALF_FLOAT",
  18842. "HAVE_CURRENT_DATA",
  18843. "HAVE_ENOUGH_DATA",
  18844. "HAVE_FUTURE_DATA",
  18845. "HAVE_METADATA",
  18846. "HAVE_NOTHING",
  18847. "HEADERS_RECEIVED",
  18848. "HIDDEN",
  18849. "HIERARCHY_REQUEST_ERR",
  18850. "HIGHPASS",
  18851. "HIGHSHELF",
  18852. "HIGH_FLOAT",
  18853. "HIGH_INT",
  18854. "HORIZONTAL",
  18855. "HORIZONTAL_AXIS",
  18856. "HRTF",
  18857. "HTMLAllCollection",
  18858. "HTMLAnchorElement",
  18859. "HTMLAppletElement",
  18860. "HTMLAreaElement",
  18861. "HTMLAudioElement",
  18862. "HTMLBRElement",
  18863. "HTMLBaseElement",
  18864. "HTMLBaseFontElement",
  18865. "HTMLBlockquoteElement",
  18866. "HTMLBodyElement",
  18867. "HTMLButtonElement",
  18868. "HTMLCanvasElement",
  18869. "HTMLCollection",
  18870. "HTMLCommandElement",
  18871. "HTMLContentElement",
  18872. "HTMLDListElement",
  18873. "HTMLDataElement",
  18874. "HTMLDataListElement",
  18875. "HTMLDetailsElement",
  18876. "HTMLDialogElement",
  18877. "HTMLDirectoryElement",
  18878. "HTMLDivElement",
  18879. "HTMLDocument",
  18880. "HTMLElement",
  18881. "HTMLEmbedElement",
  18882. "HTMLFieldSetElement",
  18883. "HTMLFontElement",
  18884. "HTMLFormControlsCollection",
  18885. "HTMLFormElement",
  18886. "HTMLFrameElement",
  18887. "HTMLFrameSetElement",
  18888. "HTMLHRElement",
  18889. "HTMLHeadElement",
  18890. "HTMLHeadingElement",
  18891. "HTMLHtmlElement",
  18892. "HTMLIFrameElement",
  18893. "HTMLImageElement",
  18894. "HTMLInputElement",
  18895. "HTMLIsIndexElement",
  18896. "HTMLKeygenElement",
  18897. "HTMLLIElement",
  18898. "HTMLLabelElement",
  18899. "HTMLLegendElement",
  18900. "HTMLLinkElement",
  18901. "HTMLMapElement",
  18902. "HTMLMarqueeElement",
  18903. "HTMLMediaElement",
  18904. "HTMLMenuElement",
  18905. "HTMLMenuItemElement",
  18906. "HTMLMetaElement",
  18907. "HTMLMeterElement",
  18908. "HTMLModElement",
  18909. "HTMLOListElement",
  18910. "HTMLObjectElement",
  18911. "HTMLOptGroupElement",
  18912. "HTMLOptionElement",
  18913. "HTMLOptionsCollection",
  18914. "HTMLOutputElement",
  18915. "HTMLParagraphElement",
  18916. "HTMLParamElement",
  18917. "HTMLPictureElement",
  18918. "HTMLPreElement",
  18919. "HTMLProgressElement",
  18920. "HTMLPropertiesCollection",
  18921. "HTMLQuoteElement",
  18922. "HTMLScriptElement",
  18923. "HTMLSelectElement",
  18924. "HTMLShadowElement",
  18925. "HTMLSlotElement",
  18926. "HTMLSourceElement",
  18927. "HTMLSpanElement",
  18928. "HTMLStyleElement",
  18929. "HTMLTableCaptionElement",
  18930. "HTMLTableCellElement",
  18931. "HTMLTableColElement",
  18932. "HTMLTableElement",
  18933. "HTMLTableRowElement",
  18934. "HTMLTableSectionElement",
  18935. "HTMLTemplateElement",
  18936. "HTMLTextAreaElement",
  18937. "HTMLTimeElement",
  18938. "HTMLTitleElement",
  18939. "HTMLTrackElement",
  18940. "HTMLUListElement",
  18941. "HTMLUnknownElement",
  18942. "HTMLVideoElement",
  18943. "HashChangeEvent",
  18944. "Headers",
  18945. "History",
  18946. "Hz",
  18947. "ICE_CHECKING",
  18948. "ICE_CLOSED",
  18949. "ICE_COMPLETED",
  18950. "ICE_CONNECTED",
  18951. "ICE_FAILED",
  18952. "ICE_GATHERING",
  18953. "ICE_WAITING",
  18954. "IDBCursor",
  18955. "IDBCursorWithValue",
  18956. "IDBDatabase",
  18957. "IDBDatabaseException",
  18958. "IDBFactory",
  18959. "IDBFileHandle",
  18960. "IDBFileRequest",
  18961. "IDBIndex",
  18962. "IDBKeyRange",
  18963. "IDBMutableFile",
  18964. "IDBObjectStore",
  18965. "IDBOpenDBRequest",
  18966. "IDBRequest",
  18967. "IDBTransaction",
  18968. "IDBVersionChangeEvent",
  18969. "IDLE",
  18970. "IIRFilterNode",
  18971. "IMPLEMENTATION_COLOR_READ_FORMAT",
  18972. "IMPLEMENTATION_COLOR_READ_TYPE",
  18973. "IMPORT_RULE",
  18974. "INCR",
  18975. "INCR_WRAP",
  18976. "INDEX_SIZE_ERR",
  18977. "INT",
  18978. "INTERLEAVED_ATTRIBS",
  18979. "INT_2_10_10_10_REV",
  18980. "INT_SAMPLER_2D",
  18981. "INT_SAMPLER_2D_ARRAY",
  18982. "INT_SAMPLER_3D",
  18983. "INT_SAMPLER_CUBE",
  18984. "INT_VEC2",
  18985. "INT_VEC3",
  18986. "INT_VEC4",
  18987. "INUSE_ATTRIBUTE_ERR",
  18988. "INVALID_ACCESS_ERR",
  18989. "INVALID_CHARACTER_ERR",
  18990. "INVALID_ENUM",
  18991. "INVALID_EXPRESSION_ERR",
  18992. "INVALID_FRAMEBUFFER_OPERATION",
  18993. "INVALID_INDEX",
  18994. "INVALID_MODIFICATION_ERR",
  18995. "INVALID_NODE_TYPE_ERR",
  18996. "INVALID_OPERATION",
  18997. "INVALID_STATE_ERR",
  18998. "INVALID_VALUE",
  18999. "INVERSE_DISTANCE",
  19000. "INVERT",
  19001. "IceCandidate",
  19002. "IdleDeadline",
  19003. "Image",
  19004. "ImageBitmap",
  19005. "ImageBitmapRenderingContext",
  19006. "ImageCapture",
  19007. "ImageData",
  19008. "Infinity",
  19009. "InputDeviceCapabilities",
  19010. "InputDeviceInfo",
  19011. "InputEvent",
  19012. "InputMethodContext",
  19013. "InstallTrigger",
  19014. "InstallTriggerImpl",
  19015. "Instance",
  19016. "Int16Array",
  19017. "Int32Array",
  19018. "Int8Array",
  19019. "Intent",
  19020. "InternalError",
  19021. "IntersectionObserver",
  19022. "IntersectionObserverEntry",
  19023. "Intl",
  19024. "IsSearchProviderInstalled",
  19025. "Iterator",
  19026. "JSON",
  19027. "KEEP",
  19028. "KEYDOWN",
  19029. "KEYFRAMES_RULE",
  19030. "KEYFRAME_RULE",
  19031. "KEYPRESS",
  19032. "KEYUP",
  19033. "KeyEvent",
  19034. "Keyboard",
  19035. "KeyboardEvent",
  19036. "KeyboardLayoutMap",
  19037. "KeyframeEffect",
  19038. "LENGTHADJUST_SPACING",
  19039. "LENGTHADJUST_SPACINGANDGLYPHS",
  19040. "LENGTHADJUST_UNKNOWN",
  19041. "LEQUAL",
  19042. "LESS",
  19043. "LINEAR",
  19044. "LINEAR_DISTANCE",
  19045. "LINEAR_MIPMAP_LINEAR",
  19046. "LINEAR_MIPMAP_NEAREST",
  19047. "LINES",
  19048. "LINE_LOOP",
  19049. "LINE_STRIP",
  19050. "LINE_WIDTH",
  19051. "LINK_STATUS",
  19052. "LIVE",
  19053. "LN10",
  19054. "LN2",
  19055. "LOADED",
  19056. "LOADING",
  19057. "LOG10E",
  19058. "LOG2E",
  19059. "LOWPASS",
  19060. "LOWSHELF",
  19061. "LOW_FLOAT",
  19062. "LOW_INT",
  19063. "LSException",
  19064. "LSParserFilter",
  19065. "LUMINANCE",
  19066. "LUMINANCE_ALPHA",
  19067. "LargestContentfulPaint",
  19068. "LayoutShift",
  19069. "LayoutShiftAttribution",
  19070. "LinearAccelerationSensor",
  19071. "LinkError",
  19072. "ListFormat",
  19073. "LocalMediaStream",
  19074. "Locale",
  19075. "Location",
  19076. "Lock",
  19077. "LockManager",
  19078. "MAX",
  19079. "MAX_3D_TEXTURE_SIZE",
  19080. "MAX_ARRAY_TEXTURE_LAYERS",
  19081. "MAX_CLIENT_WAIT_TIMEOUT_WEBGL",
  19082. "MAX_COLOR_ATTACHMENTS",
  19083. "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",
  19084. "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
  19085. "MAX_COMBINED_UNIFORM_BLOCKS",
  19086. "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",
  19087. "MAX_CUBE_MAP_TEXTURE_SIZE",
  19088. "MAX_DRAW_BUFFERS",
  19089. "MAX_ELEMENTS_INDICES",
  19090. "MAX_ELEMENTS_VERTICES",
  19091. "MAX_ELEMENT_INDEX",
  19092. "MAX_FRAGMENT_INPUT_COMPONENTS",
  19093. "MAX_FRAGMENT_UNIFORM_BLOCKS",
  19094. "MAX_FRAGMENT_UNIFORM_COMPONENTS",
  19095. "MAX_FRAGMENT_UNIFORM_VECTORS",
  19096. "MAX_PROGRAM_TEXEL_OFFSET",
  19097. "MAX_RENDERBUFFER_SIZE",
  19098. "MAX_SAFE_INTEGER",
  19099. "MAX_SAMPLES",
  19100. "MAX_SERVER_WAIT_TIMEOUT",
  19101. "MAX_TEXTURE_IMAGE_UNITS",
  19102. "MAX_TEXTURE_LOD_BIAS",
  19103. "MAX_TEXTURE_MAX_ANISOTROPY_EXT",
  19104. "MAX_TEXTURE_SIZE",
  19105. "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",
  19106. "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",
  19107. "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",
  19108. "MAX_UNIFORM_BLOCK_SIZE",
  19109. "MAX_UNIFORM_BUFFER_BINDINGS",
  19110. "MAX_VALUE",
  19111. "MAX_VARYING_COMPONENTS",
  19112. "MAX_VARYING_VECTORS",
  19113. "MAX_VERTEX_ATTRIBS",
  19114. "MAX_VERTEX_OUTPUT_COMPONENTS",
  19115. "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
  19116. "MAX_VERTEX_UNIFORM_BLOCKS",
  19117. "MAX_VERTEX_UNIFORM_COMPONENTS",
  19118. "MAX_VERTEX_UNIFORM_VECTORS",
  19119. "MAX_VIEWPORT_DIMS",
  19120. "MEDIA_ERR_ABORTED",
  19121. "MEDIA_ERR_DECODE",
  19122. "MEDIA_ERR_ENCRYPTED",
  19123. "MEDIA_ERR_NETWORK",
  19124. "MEDIA_ERR_SRC_NOT_SUPPORTED",
  19125. "MEDIA_KEYERR_CLIENT",
  19126. "MEDIA_KEYERR_DOMAIN",
  19127. "MEDIA_KEYERR_HARDWARECHANGE",
  19128. "MEDIA_KEYERR_OUTPUT",
  19129. "MEDIA_KEYERR_SERVICE",
  19130. "MEDIA_KEYERR_UNKNOWN",
  19131. "MEDIA_RULE",
  19132. "MEDIUM_FLOAT",
  19133. "MEDIUM_INT",
  19134. "META_MASK",
  19135. "MIDIAccess",
  19136. "MIDIConnectionEvent",
  19137. "MIDIInput",
  19138. "MIDIInputMap",
  19139. "MIDIMessageEvent",
  19140. "MIDIOutput",
  19141. "MIDIOutputMap",
  19142. "MIDIPort",
  19143. "MIN",
  19144. "MIN_PROGRAM_TEXEL_OFFSET",
  19145. "MIN_SAFE_INTEGER",
  19146. "MIN_VALUE",
  19147. "MIRRORED_REPEAT",
  19148. "MODE_ASYNCHRONOUS",
  19149. "MODE_SYNCHRONOUS",
  19150. "MODIFICATION",
  19151. "MOUSEDOWN",
  19152. "MOUSEDRAG",
  19153. "MOUSEMOVE",
  19154. "MOUSEOUT",
  19155. "MOUSEOVER",
  19156. "MOUSEUP",
  19157. "MOZ_KEYFRAMES_RULE",
  19158. "MOZ_KEYFRAME_RULE",
  19159. "MOZ_SOURCE_CURSOR",
  19160. "MOZ_SOURCE_ERASER",
  19161. "MOZ_SOURCE_KEYBOARD",
  19162. "MOZ_SOURCE_MOUSE",
  19163. "MOZ_SOURCE_PEN",
  19164. "MOZ_SOURCE_TOUCH",
  19165. "MOZ_SOURCE_UNKNOWN",
  19166. "MSGESTURE_FLAG_BEGIN",
  19167. "MSGESTURE_FLAG_CANCEL",
  19168. "MSGESTURE_FLAG_END",
  19169. "MSGESTURE_FLAG_INERTIA",
  19170. "MSGESTURE_FLAG_NONE",
  19171. "MSPOINTER_TYPE_MOUSE",
  19172. "MSPOINTER_TYPE_PEN",
  19173. "MSPOINTER_TYPE_TOUCH",
  19174. "MS_ASYNC_CALLBACK_STATUS_ASSIGN_DELEGATE",
  19175. "MS_ASYNC_CALLBACK_STATUS_CANCEL",
  19176. "MS_ASYNC_CALLBACK_STATUS_CHOOSEANY",
  19177. "MS_ASYNC_CALLBACK_STATUS_ERROR",
  19178. "MS_ASYNC_CALLBACK_STATUS_JOIN",
  19179. "MS_ASYNC_OP_STATUS_CANCELED",
  19180. "MS_ASYNC_OP_STATUS_ERROR",
  19181. "MS_ASYNC_OP_STATUS_SUCCESS",
  19182. "MS_MANIPULATION_STATE_ACTIVE",
  19183. "MS_MANIPULATION_STATE_CANCELLED",
  19184. "MS_MANIPULATION_STATE_COMMITTED",
  19185. "MS_MANIPULATION_STATE_DRAGGING",
  19186. "MS_MANIPULATION_STATE_INERTIA",
  19187. "MS_MANIPULATION_STATE_PRESELECT",
  19188. "MS_MANIPULATION_STATE_SELECTING",
  19189. "MS_MANIPULATION_STATE_STOPPED",
  19190. "MS_MEDIA_ERR_ENCRYPTED",
  19191. "MS_MEDIA_KEYERR_CLIENT",
  19192. "MS_MEDIA_KEYERR_DOMAIN",
  19193. "MS_MEDIA_KEYERR_HARDWARECHANGE",
  19194. "MS_MEDIA_KEYERR_OUTPUT",
  19195. "MS_MEDIA_KEYERR_SERVICE",
  19196. "MS_MEDIA_KEYERR_UNKNOWN",
  19197. "Map",
  19198. "Math",
  19199. "MathMLElement",
  19200. "MediaCapabilities",
  19201. "MediaCapabilitiesInfo",
  19202. "MediaController",
  19203. "MediaDeviceInfo",
  19204. "MediaDevices",
  19205. "MediaElementAudioSourceNode",
  19206. "MediaEncryptedEvent",
  19207. "MediaError",
  19208. "MediaKeyError",
  19209. "MediaKeyEvent",
  19210. "MediaKeyMessageEvent",
  19211. "MediaKeyNeededEvent",
  19212. "MediaKeySession",
  19213. "MediaKeyStatusMap",
  19214. "MediaKeySystemAccess",
  19215. "MediaKeys",
  19216. "MediaList",
  19217. "MediaMetadata",
  19218. "MediaQueryList",
  19219. "MediaQueryListEvent",
  19220. "MediaRecorder",
  19221. "MediaRecorderErrorEvent",
  19222. "MediaSession",
  19223. "MediaSettingsRange",
  19224. "MediaSource",
  19225. "MediaStream",
  19226. "MediaStreamAudioDestinationNode",
  19227. "MediaStreamAudioSourceNode",
  19228. "MediaStreamEvent",
  19229. "MediaStreamTrack",
  19230. "MediaStreamTrackAudioSourceNode",
  19231. "MediaStreamTrackEvent",
  19232. "Memory",
  19233. "MessageChannel",
  19234. "MessageEvent",
  19235. "MessagePort",
  19236. "Methods",
  19237. "MimeType",
  19238. "MimeTypeArray",
  19239. "Module",
  19240. "MouseEvent",
  19241. "MouseScrollEvent",
  19242. "MozAnimation",
  19243. "MozAnimationDelay",
  19244. "MozAnimationDirection",
  19245. "MozAnimationDuration",
  19246. "MozAnimationFillMode",
  19247. "MozAnimationIterationCount",
  19248. "MozAnimationName",
  19249. "MozAnimationPlayState",
  19250. "MozAnimationTimingFunction",
  19251. "MozAppearance",
  19252. "MozBackfaceVisibility",
  19253. "MozBinding",
  19254. "MozBorderBottomColors",
  19255. "MozBorderEnd",
  19256. "MozBorderEndColor",
  19257. "MozBorderEndStyle",
  19258. "MozBorderEndWidth",
  19259. "MozBorderImage",
  19260. "MozBorderLeftColors",
  19261. "MozBorderRightColors",
  19262. "MozBorderStart",
  19263. "MozBorderStartColor",
  19264. "MozBorderStartStyle",
  19265. "MozBorderStartWidth",
  19266. "MozBorderTopColors",
  19267. "MozBoxAlign",
  19268. "MozBoxDirection",
  19269. "MozBoxFlex",
  19270. "MozBoxOrdinalGroup",
  19271. "MozBoxOrient",
  19272. "MozBoxPack",
  19273. "MozBoxSizing",
  19274. "MozCSSKeyframeRule",
  19275. "MozCSSKeyframesRule",
  19276. "MozColumnCount",
  19277. "MozColumnFill",
  19278. "MozColumnGap",
  19279. "MozColumnRule",
  19280. "MozColumnRuleColor",
  19281. "MozColumnRuleStyle",
  19282. "MozColumnRuleWidth",
  19283. "MozColumnWidth",
  19284. "MozColumns",
  19285. "MozContactChangeEvent",
  19286. "MozFloatEdge",
  19287. "MozFontFeatureSettings",
  19288. "MozFontLanguageOverride",
  19289. "MozForceBrokenImageIcon",
  19290. "MozHyphens",
  19291. "MozImageRegion",
  19292. "MozMarginEnd",
  19293. "MozMarginStart",
  19294. "MozMmsEvent",
  19295. "MozMmsMessage",
  19296. "MozMobileMessageThread",
  19297. "MozOSXFontSmoothing",
  19298. "MozOrient",
  19299. "MozOsxFontSmoothing",
  19300. "MozOutlineRadius",
  19301. "MozOutlineRadiusBottomleft",
  19302. "MozOutlineRadiusBottomright",
  19303. "MozOutlineRadiusTopleft",
  19304. "MozOutlineRadiusTopright",
  19305. "MozPaddingEnd",
  19306. "MozPaddingStart",
  19307. "MozPerspective",
  19308. "MozPerspectiveOrigin",
  19309. "MozPowerManager",
  19310. "MozSettingsEvent",
  19311. "MozSmsEvent",
  19312. "MozSmsMessage",
  19313. "MozStackSizing",
  19314. "MozTabSize",
  19315. "MozTextAlignLast",
  19316. "MozTextDecorationColor",
  19317. "MozTextDecorationLine",
  19318. "MozTextDecorationStyle",
  19319. "MozTextSizeAdjust",
  19320. "MozTransform",
  19321. "MozTransformOrigin",
  19322. "MozTransformStyle",
  19323. "MozTransition",
  19324. "MozTransitionDelay",
  19325. "MozTransitionDuration",
  19326. "MozTransitionProperty",
  19327. "MozTransitionTimingFunction",
  19328. "MozUserFocus",
  19329. "MozUserInput",
  19330. "MozUserModify",
  19331. "MozUserSelect",
  19332. "MozWindowDragging",
  19333. "MozWindowShadow",
  19334. "MutationEvent",
  19335. "MutationObserver",
  19336. "MutationRecord",
  19337. "NAMESPACE_ERR",
  19338. "NAMESPACE_RULE",
  19339. "NEAREST",
  19340. "NEAREST_MIPMAP_LINEAR",
  19341. "NEAREST_MIPMAP_NEAREST",
  19342. "NEGATIVE_INFINITY",
  19343. "NETWORK_EMPTY",
  19344. "NETWORK_ERR",
  19345. "NETWORK_IDLE",
  19346. "NETWORK_LOADED",
  19347. "NETWORK_LOADING",
  19348. "NETWORK_NO_SOURCE",
  19349. "NEVER",
  19350. "NEW",
  19351. "NEXT",
  19352. "NEXT_NO_DUPLICATE",
  19353. "NICEST",
  19354. "NODE_AFTER",
  19355. "NODE_BEFORE",
  19356. "NODE_BEFORE_AND_AFTER",
  19357. "NODE_INSIDE",
  19358. "NONE",
  19359. "NON_TRANSIENT_ERR",
  19360. "NOTATION_NODE",
  19361. "NOTCH",
  19362. "NOTEQUAL",
  19363. "NOT_ALLOWED_ERR",
  19364. "NOT_FOUND_ERR",
  19365. "NOT_READABLE_ERR",
  19366. "NOT_SUPPORTED_ERR",
  19367. "NO_DATA_ALLOWED_ERR",
  19368. "NO_ERR",
  19369. "NO_ERROR",
  19370. "NO_MODIFICATION_ALLOWED_ERR",
  19371. "NUMBER_TYPE",
  19372. "NUM_COMPRESSED_TEXTURE_FORMATS",
  19373. "NaN",
  19374. "NamedNodeMap",
  19375. "NavigationPreloadManager",
  19376. "Navigator",
  19377. "NearbyLinks",
  19378. "NetworkInformation",
  19379. "Node",
  19380. "NodeFilter",
  19381. "NodeIterator",
  19382. "NodeList",
  19383. "Notation",
  19384. "Notification",
  19385. "NotifyPaintEvent",
  19386. "Number",
  19387. "NumberFormat",
  19388. "OBJECT_TYPE",
  19389. "OBSOLETE",
  19390. "OK",
  19391. "ONE",
  19392. "ONE_MINUS_CONSTANT_ALPHA",
  19393. "ONE_MINUS_CONSTANT_COLOR",
  19394. "ONE_MINUS_DST_ALPHA",
  19395. "ONE_MINUS_DST_COLOR",
  19396. "ONE_MINUS_SRC_ALPHA",
  19397. "ONE_MINUS_SRC_COLOR",
  19398. "OPEN",
  19399. "OPENED",
  19400. "OPENING",
  19401. "ORDERED_NODE_ITERATOR_TYPE",
  19402. "ORDERED_NODE_SNAPSHOT_TYPE",
  19403. "OTHER_ERROR",
  19404. "OUT_OF_MEMORY",
  19405. "Object",
  19406. "OfflineAudioCompletionEvent",
  19407. "OfflineAudioContext",
  19408. "OfflineResourceList",
  19409. "OffscreenCanvas",
  19410. "OffscreenCanvasRenderingContext2D",
  19411. "Option",
  19412. "OrientationSensor",
  19413. "OscillatorNode",
  19414. "OverconstrainedError",
  19415. "OverflowEvent",
  19416. "PACK_ALIGNMENT",
  19417. "PACK_ROW_LENGTH",
  19418. "PACK_SKIP_PIXELS",
  19419. "PACK_SKIP_ROWS",
  19420. "PAGE_RULE",
  19421. "PARSE_ERR",
  19422. "PATHSEG_ARC_ABS",
  19423. "PATHSEG_ARC_REL",
  19424. "PATHSEG_CLOSEPATH",
  19425. "PATHSEG_CURVETO_CUBIC_ABS",
  19426. "PATHSEG_CURVETO_CUBIC_REL",
  19427. "PATHSEG_CURVETO_CUBIC_SMOOTH_ABS",
  19428. "PATHSEG_CURVETO_CUBIC_SMOOTH_REL",
  19429. "PATHSEG_CURVETO_QUADRATIC_ABS",
  19430. "PATHSEG_CURVETO_QUADRATIC_REL",
  19431. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS",
  19432. "PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL",
  19433. "PATHSEG_LINETO_ABS",
  19434. "PATHSEG_LINETO_HORIZONTAL_ABS",
  19435. "PATHSEG_LINETO_HORIZONTAL_REL",
  19436. "PATHSEG_LINETO_REL",
  19437. "PATHSEG_LINETO_VERTICAL_ABS",
  19438. "PATHSEG_LINETO_VERTICAL_REL",
  19439. "PATHSEG_MOVETO_ABS",
  19440. "PATHSEG_MOVETO_REL",
  19441. "PATHSEG_UNKNOWN",
  19442. "PATH_EXISTS_ERR",
  19443. "PEAKING",
  19444. "PERMISSION_DENIED",
  19445. "PERSISTENT",
  19446. "PI",
  19447. "PIXEL_PACK_BUFFER",
  19448. "PIXEL_PACK_BUFFER_BINDING",
  19449. "PIXEL_UNPACK_BUFFER",
  19450. "PIXEL_UNPACK_BUFFER_BINDING",
  19451. "PLAYING_STATE",
  19452. "POINTS",
  19453. "POLYGON_OFFSET_FACTOR",
  19454. "POLYGON_OFFSET_FILL",
  19455. "POLYGON_OFFSET_UNITS",
  19456. "POSITION_UNAVAILABLE",
  19457. "POSITIVE_INFINITY",
  19458. "PREV",
  19459. "PREV_NO_DUPLICATE",
  19460. "PROCESSING_INSTRUCTION_NODE",
  19461. "PageChangeEvent",
  19462. "PageTransitionEvent",
  19463. "PaintRequest",
  19464. "PaintRequestList",
  19465. "PannerNode",
  19466. "PasswordCredential",
  19467. "Path2D",
  19468. "PaymentAddress",
  19469. "PaymentInstruments",
  19470. "PaymentManager",
  19471. "PaymentMethodChangeEvent",
  19472. "PaymentRequest",
  19473. "PaymentRequestUpdateEvent",
  19474. "PaymentResponse",
  19475. "Performance",
  19476. "PerformanceElementTiming",
  19477. "PerformanceEntry",
  19478. "PerformanceEventTiming",
  19479. "PerformanceLongTaskTiming",
  19480. "PerformanceMark",
  19481. "PerformanceMeasure",
  19482. "PerformanceNavigation",
  19483. "PerformanceNavigationTiming",
  19484. "PerformanceObserver",
  19485. "PerformanceObserverEntryList",
  19486. "PerformancePaintTiming",
  19487. "PerformanceResourceTiming",
  19488. "PerformanceServerTiming",
  19489. "PerformanceTiming",
  19490. "PeriodicSyncManager",
  19491. "PeriodicWave",
  19492. "PermissionStatus",
  19493. "Permissions",
  19494. "PhotoCapabilities",
  19495. "PictureInPictureWindow",
  19496. "Plugin",
  19497. "PluginArray",
  19498. "PluralRules",
  19499. "PointerEvent",
  19500. "PopStateEvent",
  19501. "PopupBlockedEvent",
  19502. "Presentation",
  19503. "PresentationAvailability",
  19504. "PresentationConnection",
  19505. "PresentationConnectionAvailableEvent",
  19506. "PresentationConnectionCloseEvent",
  19507. "PresentationConnectionList",
  19508. "PresentationReceiver",
  19509. "PresentationRequest",
  19510. "ProcessingInstruction",
  19511. "ProgressEvent",
  19512. "Promise",
  19513. "PromiseRejectionEvent",
  19514. "PropertyNodeList",
  19515. "Proxy",
  19516. "PublicKeyCredential",
  19517. "PushManager",
  19518. "PushSubscription",
  19519. "PushSubscriptionOptions",
  19520. "Q",
  19521. "QUERY_RESULT",
  19522. "QUERY_RESULT_AVAILABLE",
  19523. "QUOTA_ERR",
  19524. "QUOTA_EXCEEDED_ERR",
  19525. "QueryInterface",
  19526. "R11F_G11F_B10F",
  19527. "R16F",
  19528. "R16I",
  19529. "R16UI",
  19530. "R32F",
  19531. "R32I",
  19532. "R32UI",
  19533. "R8",
  19534. "R8I",
  19535. "R8UI",
  19536. "R8_SNORM",
  19537. "RASTERIZER_DISCARD",
  19538. "READ_BUFFER",
  19539. "READ_FRAMEBUFFER",
  19540. "READ_FRAMEBUFFER_BINDING",
  19541. "READ_ONLY",
  19542. "READ_ONLY_ERR",
  19543. "READ_WRITE",
  19544. "RED",
  19545. "RED_BITS",
  19546. "RED_INTEGER",
  19547. "REMOVAL",
  19548. "RENDERBUFFER",
  19549. "RENDERBUFFER_ALPHA_SIZE",
  19550. "RENDERBUFFER_BINDING",
  19551. "RENDERBUFFER_BLUE_SIZE",
  19552. "RENDERBUFFER_DEPTH_SIZE",
  19553. "RENDERBUFFER_GREEN_SIZE",
  19554. "RENDERBUFFER_HEIGHT",
  19555. "RENDERBUFFER_INTERNAL_FORMAT",
  19556. "RENDERBUFFER_RED_SIZE",
  19557. "RENDERBUFFER_SAMPLES",
  19558. "RENDERBUFFER_STENCIL_SIZE",
  19559. "RENDERBUFFER_WIDTH",
  19560. "RENDERER",
  19561. "RENDERING_INTENT_ABSOLUTE_COLORIMETRIC",
  19562. "RENDERING_INTENT_AUTO",
  19563. "RENDERING_INTENT_PERCEPTUAL",
  19564. "RENDERING_INTENT_RELATIVE_COLORIMETRIC",
  19565. "RENDERING_INTENT_SATURATION",
  19566. "RENDERING_INTENT_UNKNOWN",
  19567. "REPEAT",
  19568. "REPLACE",
  19569. "RG",
  19570. "RG16F",
  19571. "RG16I",
  19572. "RG16UI",
  19573. "RG32F",
  19574. "RG32I",
  19575. "RG32UI",
  19576. "RG8",
  19577. "RG8I",
  19578. "RG8UI",
  19579. "RG8_SNORM",
  19580. "RGB",
  19581. "RGB10_A2",
  19582. "RGB10_A2UI",
  19583. "RGB16F",
  19584. "RGB16I",
  19585. "RGB16UI",
  19586. "RGB32F",
  19587. "RGB32I",
  19588. "RGB32UI",
  19589. "RGB565",
  19590. "RGB5_A1",
  19591. "RGB8",
  19592. "RGB8I",
  19593. "RGB8UI",
  19594. "RGB8_SNORM",
  19595. "RGB9_E5",
  19596. "RGBA",
  19597. "RGBA16F",
  19598. "RGBA16I",
  19599. "RGBA16UI",
  19600. "RGBA32F",
  19601. "RGBA32I",
  19602. "RGBA32UI",
  19603. "RGBA4",
  19604. "RGBA8",
  19605. "RGBA8I",
  19606. "RGBA8UI",
  19607. "RGBA8_SNORM",
  19608. "RGBA_INTEGER",
  19609. "RGBColor",
  19610. "RGB_INTEGER",
  19611. "RG_INTEGER",
  19612. "ROTATION_CLOCKWISE",
  19613. "ROTATION_COUNTERCLOCKWISE",
  19614. "RTCCertificate",
  19615. "RTCDTMFSender",
  19616. "RTCDTMFToneChangeEvent",
  19617. "RTCDataChannel",
  19618. "RTCDataChannelEvent",
  19619. "RTCDtlsTransport",
  19620. "RTCError",
  19621. "RTCErrorEvent",
  19622. "RTCIceCandidate",
  19623. "RTCIceTransport",
  19624. "RTCPeerConnection",
  19625. "RTCPeerConnectionIceErrorEvent",
  19626. "RTCPeerConnectionIceEvent",
  19627. "RTCRtpReceiver",
  19628. "RTCRtpSender",
  19629. "RTCRtpTransceiver",
  19630. "RTCSctpTransport",
  19631. "RTCSessionDescription",
  19632. "RTCStatsReport",
  19633. "RTCTrackEvent",
  19634. "RadioNodeList",
  19635. "Range",
  19636. "RangeError",
  19637. "RangeException",
  19638. "ReadableStream",
  19639. "ReadableStreamDefaultReader",
  19640. "RecordErrorEvent",
  19641. "Rect",
  19642. "ReferenceError",
  19643. "Reflect",
  19644. "RegExp",
  19645. "RelativeOrientationSensor",
  19646. "RelativeTimeFormat",
  19647. "RemotePlayback",
  19648. "Report",
  19649. "ReportBody",
  19650. "ReportingObserver",
  19651. "Request",
  19652. "ResizeObserver",
  19653. "ResizeObserverEntry",
  19654. "ResizeObserverSize",
  19655. "Response",
  19656. "RuntimeError",
  19657. "SAMPLER_2D",
  19658. "SAMPLER_2D_ARRAY",
  19659. "SAMPLER_2D_ARRAY_SHADOW",
  19660. "SAMPLER_2D_SHADOW",
  19661. "SAMPLER_3D",
  19662. "SAMPLER_BINDING",
  19663. "SAMPLER_CUBE",
  19664. "SAMPLER_CUBE_SHADOW",
  19665. "SAMPLES",
  19666. "SAMPLE_ALPHA_TO_COVERAGE",
  19667. "SAMPLE_BUFFERS",
  19668. "SAMPLE_COVERAGE",
  19669. "SAMPLE_COVERAGE_INVERT",
  19670. "SAMPLE_COVERAGE_VALUE",
  19671. "SAWTOOTH",
  19672. "SCHEDULED_STATE",
  19673. "SCISSOR_BOX",
  19674. "SCISSOR_TEST",
  19675. "SCROLL_PAGE_DOWN",
  19676. "SCROLL_PAGE_UP",
  19677. "SDP_ANSWER",
  19678. "SDP_OFFER",
  19679. "SDP_PRANSWER",
  19680. "SECURITY_ERR",
  19681. "SELECT",
  19682. "SEPARATE_ATTRIBS",
  19683. "SERIALIZE_ERR",
  19684. "SEVERITY_ERROR",
  19685. "SEVERITY_FATAL_ERROR",
  19686. "SEVERITY_WARNING",
  19687. "SHADER_COMPILER",
  19688. "SHADER_TYPE",
  19689. "SHADING_LANGUAGE_VERSION",
  19690. "SHIFT_MASK",
  19691. "SHORT",
  19692. "SHOWING",
  19693. "SHOW_ALL",
  19694. "SHOW_ATTRIBUTE",
  19695. "SHOW_CDATA_SECTION",
  19696. "SHOW_COMMENT",
  19697. "SHOW_DOCUMENT",
  19698. "SHOW_DOCUMENT_FRAGMENT",
  19699. "SHOW_DOCUMENT_TYPE",
  19700. "SHOW_ELEMENT",
  19701. "SHOW_ENTITY",
  19702. "SHOW_ENTITY_REFERENCE",
  19703. "SHOW_NOTATION",
  19704. "SHOW_PROCESSING_INSTRUCTION",
  19705. "SHOW_TEXT",
  19706. "SIGNALED",
  19707. "SIGNED_NORMALIZED",
  19708. "SINE",
  19709. "SOUNDFIELD",
  19710. "SQLException",
  19711. "SQRT1_2",
  19712. "SQRT2",
  19713. "SQUARE",
  19714. "SRC_ALPHA",
  19715. "SRC_ALPHA_SATURATE",
  19716. "SRC_COLOR",
  19717. "SRGB",
  19718. "SRGB8",
  19719. "SRGB8_ALPHA8",
  19720. "START_TO_END",
  19721. "START_TO_START",
  19722. "STATIC_COPY",
  19723. "STATIC_DRAW",
  19724. "STATIC_READ",
  19725. "STENCIL",
  19726. "STENCIL_ATTACHMENT",
  19727. "STENCIL_BACK_FAIL",
  19728. "STENCIL_BACK_FUNC",
  19729. "STENCIL_BACK_PASS_DEPTH_FAIL",
  19730. "STENCIL_BACK_PASS_DEPTH_PASS",
  19731. "STENCIL_BACK_REF",
  19732. "STENCIL_BACK_VALUE_MASK",
  19733. "STENCIL_BACK_WRITEMASK",
  19734. "STENCIL_BITS",
  19735. "STENCIL_BUFFER_BIT",
  19736. "STENCIL_CLEAR_VALUE",
  19737. "STENCIL_FAIL",
  19738. "STENCIL_FUNC",
  19739. "STENCIL_INDEX",
  19740. "STENCIL_INDEX8",
  19741. "STENCIL_PASS_DEPTH_FAIL",
  19742. "STENCIL_PASS_DEPTH_PASS",
  19743. "STENCIL_REF",
  19744. "STENCIL_TEST",
  19745. "STENCIL_VALUE_MASK",
  19746. "STENCIL_WRITEMASK",
  19747. "STREAM_COPY",
  19748. "STREAM_DRAW",
  19749. "STREAM_READ",
  19750. "STRING_TYPE",
  19751. "STYLE_RULE",
  19752. "SUBPIXEL_BITS",
  19753. "SUPPORTS_RULE",
  19754. "SVGAElement",
  19755. "SVGAltGlyphDefElement",
  19756. "SVGAltGlyphElement",
  19757. "SVGAltGlyphItemElement",
  19758. "SVGAngle",
  19759. "SVGAnimateColorElement",
  19760. "SVGAnimateElement",
  19761. "SVGAnimateMotionElement",
  19762. "SVGAnimateTransformElement",
  19763. "SVGAnimatedAngle",
  19764. "SVGAnimatedBoolean",
  19765. "SVGAnimatedEnumeration",
  19766. "SVGAnimatedInteger",
  19767. "SVGAnimatedLength",
  19768. "SVGAnimatedLengthList",
  19769. "SVGAnimatedNumber",
  19770. "SVGAnimatedNumberList",
  19771. "SVGAnimatedPreserveAspectRatio",
  19772. "SVGAnimatedRect",
  19773. "SVGAnimatedString",
  19774. "SVGAnimatedTransformList",
  19775. "SVGAnimationElement",
  19776. "SVGCircleElement",
  19777. "SVGClipPathElement",
  19778. "SVGColor",
  19779. "SVGComponentTransferFunctionElement",
  19780. "SVGCursorElement",
  19781. "SVGDefsElement",
  19782. "SVGDescElement",
  19783. "SVGDiscardElement",
  19784. "SVGDocument",
  19785. "SVGElement",
  19786. "SVGElementInstance",
  19787. "SVGElementInstanceList",
  19788. "SVGEllipseElement",
  19789. "SVGException",
  19790. "SVGFEBlendElement",
  19791. "SVGFEColorMatrixElement",
  19792. "SVGFEComponentTransferElement",
  19793. "SVGFECompositeElement",
  19794. "SVGFEConvolveMatrixElement",
  19795. "SVGFEDiffuseLightingElement",
  19796. "SVGFEDisplacementMapElement",
  19797. "SVGFEDistantLightElement",
  19798. "SVGFEDropShadowElement",
  19799. "SVGFEFloodElement",
  19800. "SVGFEFuncAElement",
  19801. "SVGFEFuncBElement",
  19802. "SVGFEFuncGElement",
  19803. "SVGFEFuncRElement",
  19804. "SVGFEGaussianBlurElement",
  19805. "SVGFEImageElement",
  19806. "SVGFEMergeElement",
  19807. "SVGFEMergeNodeElement",
  19808. "SVGFEMorphologyElement",
  19809. "SVGFEOffsetElement",
  19810. "SVGFEPointLightElement",
  19811. "SVGFESpecularLightingElement",
  19812. "SVGFESpotLightElement",
  19813. "SVGFETileElement",
  19814. "SVGFETurbulenceElement",
  19815. "SVGFilterElement",
  19816. "SVGFontElement",
  19817. "SVGFontFaceElement",
  19818. "SVGFontFaceFormatElement",
  19819. "SVGFontFaceNameElement",
  19820. "SVGFontFaceSrcElement",
  19821. "SVGFontFaceUriElement",
  19822. "SVGForeignObjectElement",
  19823. "SVGGElement",
  19824. "SVGGeometryElement",
  19825. "SVGGlyphElement",
  19826. "SVGGlyphRefElement",
  19827. "SVGGradientElement",
  19828. "SVGGraphicsElement",
  19829. "SVGHKernElement",
  19830. "SVGImageElement",
  19831. "SVGLength",
  19832. "SVGLengthList",
  19833. "SVGLineElement",
  19834. "SVGLinearGradientElement",
  19835. "SVGMPathElement",
  19836. "SVGMarkerElement",
  19837. "SVGMaskElement",
  19838. "SVGMatrix",
  19839. "SVGMetadataElement",
  19840. "SVGMissingGlyphElement",
  19841. "SVGNumber",
  19842. "SVGNumberList",
  19843. "SVGPaint",
  19844. "SVGPathElement",
  19845. "SVGPathSeg",
  19846. "SVGPathSegArcAbs",
  19847. "SVGPathSegArcRel",
  19848. "SVGPathSegClosePath",
  19849. "SVGPathSegCurvetoCubicAbs",
  19850. "SVGPathSegCurvetoCubicRel",
  19851. "SVGPathSegCurvetoCubicSmoothAbs",
  19852. "SVGPathSegCurvetoCubicSmoothRel",
  19853. "SVGPathSegCurvetoQuadraticAbs",
  19854. "SVGPathSegCurvetoQuadraticRel",
  19855. "SVGPathSegCurvetoQuadraticSmoothAbs",
  19856. "SVGPathSegCurvetoQuadraticSmoothRel",
  19857. "SVGPathSegLinetoAbs",
  19858. "SVGPathSegLinetoHorizontalAbs",
  19859. "SVGPathSegLinetoHorizontalRel",
  19860. "SVGPathSegLinetoRel",
  19861. "SVGPathSegLinetoVerticalAbs",
  19862. "SVGPathSegLinetoVerticalRel",
  19863. "SVGPathSegList",
  19864. "SVGPathSegMovetoAbs",
  19865. "SVGPathSegMovetoRel",
  19866. "SVGPatternElement",
  19867. "SVGPoint",
  19868. "SVGPointList",
  19869. "SVGPolygonElement",
  19870. "SVGPolylineElement",
  19871. "SVGPreserveAspectRatio",
  19872. "SVGRadialGradientElement",
  19873. "SVGRect",
  19874. "SVGRectElement",
  19875. "SVGRenderingIntent",
  19876. "SVGSVGElement",
  19877. "SVGScriptElement",
  19878. "SVGSetElement",
  19879. "SVGStopElement",
  19880. "SVGStringList",
  19881. "SVGStyleElement",
  19882. "SVGSwitchElement",
  19883. "SVGSymbolElement",
  19884. "SVGTRefElement",
  19885. "SVGTSpanElement",
  19886. "SVGTextContentElement",
  19887. "SVGTextElement",
  19888. "SVGTextPathElement",
  19889. "SVGTextPositioningElement",
  19890. "SVGTitleElement",
  19891. "SVGTransform",
  19892. "SVGTransformList",
  19893. "SVGUnitTypes",
  19894. "SVGUseElement",
  19895. "SVGVKernElement",
  19896. "SVGViewElement",
  19897. "SVGViewSpec",
  19898. "SVGZoomAndPan",
  19899. "SVGZoomEvent",
  19900. "SVG_ANGLETYPE_DEG",
  19901. "SVG_ANGLETYPE_GRAD",
  19902. "SVG_ANGLETYPE_RAD",
  19903. "SVG_ANGLETYPE_UNKNOWN",
  19904. "SVG_ANGLETYPE_UNSPECIFIED",
  19905. "SVG_CHANNEL_A",
  19906. "SVG_CHANNEL_B",
  19907. "SVG_CHANNEL_G",
  19908. "SVG_CHANNEL_R",
  19909. "SVG_CHANNEL_UNKNOWN",
  19910. "SVG_COLORTYPE_CURRENTCOLOR",
  19911. "SVG_COLORTYPE_RGBCOLOR",
  19912. "SVG_COLORTYPE_RGBCOLOR_ICCCOLOR",
  19913. "SVG_COLORTYPE_UNKNOWN",
  19914. "SVG_EDGEMODE_DUPLICATE",
  19915. "SVG_EDGEMODE_NONE",
  19916. "SVG_EDGEMODE_UNKNOWN",
  19917. "SVG_EDGEMODE_WRAP",
  19918. "SVG_FEBLEND_MODE_COLOR",
  19919. "SVG_FEBLEND_MODE_COLOR_BURN",
  19920. "SVG_FEBLEND_MODE_COLOR_DODGE",
  19921. "SVG_FEBLEND_MODE_DARKEN",
  19922. "SVG_FEBLEND_MODE_DIFFERENCE",
  19923. "SVG_FEBLEND_MODE_EXCLUSION",
  19924. "SVG_FEBLEND_MODE_HARD_LIGHT",
  19925. "SVG_FEBLEND_MODE_HUE",
  19926. "SVG_FEBLEND_MODE_LIGHTEN",
  19927. "SVG_FEBLEND_MODE_LUMINOSITY",
  19928. "SVG_FEBLEND_MODE_MULTIPLY",
  19929. "SVG_FEBLEND_MODE_NORMAL",
  19930. "SVG_FEBLEND_MODE_OVERLAY",
  19931. "SVG_FEBLEND_MODE_SATURATION",
  19932. "SVG_FEBLEND_MODE_SCREEN",
  19933. "SVG_FEBLEND_MODE_SOFT_LIGHT",
  19934. "SVG_FEBLEND_MODE_UNKNOWN",
  19935. "SVG_FECOLORMATRIX_TYPE_HUEROTATE",
  19936. "SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA",
  19937. "SVG_FECOLORMATRIX_TYPE_MATRIX",
  19938. "SVG_FECOLORMATRIX_TYPE_SATURATE",
  19939. "SVG_FECOLORMATRIX_TYPE_UNKNOWN",
  19940. "SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE",
  19941. "SVG_FECOMPONENTTRANSFER_TYPE_GAMMA",
  19942. "SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY",
  19943. "SVG_FECOMPONENTTRANSFER_TYPE_LINEAR",
  19944. "SVG_FECOMPONENTTRANSFER_TYPE_TABLE",
  19945. "SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN",
  19946. "SVG_FECOMPOSITE_OPERATOR_ARITHMETIC",
  19947. "SVG_FECOMPOSITE_OPERATOR_ATOP",
  19948. "SVG_FECOMPOSITE_OPERATOR_IN",
  19949. "SVG_FECOMPOSITE_OPERATOR_OUT",
  19950. "SVG_FECOMPOSITE_OPERATOR_OVER",
  19951. "SVG_FECOMPOSITE_OPERATOR_UNKNOWN",
  19952. "SVG_FECOMPOSITE_OPERATOR_XOR",
  19953. "SVG_INVALID_VALUE_ERR",
  19954. "SVG_LENGTHTYPE_CM",
  19955. "SVG_LENGTHTYPE_EMS",
  19956. "SVG_LENGTHTYPE_EXS",
  19957. "SVG_LENGTHTYPE_IN",
  19958. "SVG_LENGTHTYPE_MM",
  19959. "SVG_LENGTHTYPE_NUMBER",
  19960. "SVG_LENGTHTYPE_PC",
  19961. "SVG_LENGTHTYPE_PERCENTAGE",
  19962. "SVG_LENGTHTYPE_PT",
  19963. "SVG_LENGTHTYPE_PX",
  19964. "SVG_LENGTHTYPE_UNKNOWN",
  19965. "SVG_MARKERUNITS_STROKEWIDTH",
  19966. "SVG_MARKERUNITS_UNKNOWN",
  19967. "SVG_MARKERUNITS_USERSPACEONUSE",
  19968. "SVG_MARKER_ORIENT_ANGLE",
  19969. "SVG_MARKER_ORIENT_AUTO",
  19970. "SVG_MARKER_ORIENT_UNKNOWN",
  19971. "SVG_MASKTYPE_ALPHA",
  19972. "SVG_MASKTYPE_LUMINANCE",
  19973. "SVG_MATRIX_NOT_INVERTABLE",
  19974. "SVG_MEETORSLICE_MEET",
  19975. "SVG_MEETORSLICE_SLICE",
  19976. "SVG_MEETORSLICE_UNKNOWN",
  19977. "SVG_MORPHOLOGY_OPERATOR_DILATE",
  19978. "SVG_MORPHOLOGY_OPERATOR_ERODE",
  19979. "SVG_MORPHOLOGY_OPERATOR_UNKNOWN",
  19980. "SVG_PAINTTYPE_CURRENTCOLOR",
  19981. "SVG_PAINTTYPE_NONE",
  19982. "SVG_PAINTTYPE_RGBCOLOR",
  19983. "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR",
  19984. "SVG_PAINTTYPE_UNKNOWN",
  19985. "SVG_PAINTTYPE_URI",
  19986. "SVG_PAINTTYPE_URI_CURRENTCOLOR",
  19987. "SVG_PAINTTYPE_URI_NONE",
  19988. "SVG_PAINTTYPE_URI_RGBCOLOR",
  19989. "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR",
  19990. "SVG_PRESERVEASPECTRATIO_NONE",
  19991. "SVG_PRESERVEASPECTRATIO_UNKNOWN",
  19992. "SVG_PRESERVEASPECTRATIO_XMAXYMAX",
  19993. "SVG_PRESERVEASPECTRATIO_XMAXYMID",
  19994. "SVG_PRESERVEASPECTRATIO_XMAXYMIN",
  19995. "SVG_PRESERVEASPECTRATIO_XMIDYMAX",
  19996. "SVG_PRESERVEASPECTRATIO_XMIDYMID",
  19997. "SVG_PRESERVEASPECTRATIO_XMIDYMIN",
  19998. "SVG_PRESERVEASPECTRATIO_XMINYMAX",
  19999. "SVG_PRESERVEASPECTRATIO_XMINYMID",
  20000. "SVG_PRESERVEASPECTRATIO_XMINYMIN",
  20001. "SVG_SPREADMETHOD_PAD",
  20002. "SVG_SPREADMETHOD_REFLECT",
  20003. "SVG_SPREADMETHOD_REPEAT",
  20004. "SVG_SPREADMETHOD_UNKNOWN",
  20005. "SVG_STITCHTYPE_NOSTITCH",
  20006. "SVG_STITCHTYPE_STITCH",
  20007. "SVG_STITCHTYPE_UNKNOWN",
  20008. "SVG_TRANSFORM_MATRIX",
  20009. "SVG_TRANSFORM_ROTATE",
  20010. "SVG_TRANSFORM_SCALE",
  20011. "SVG_TRANSFORM_SKEWX",
  20012. "SVG_TRANSFORM_SKEWY",
  20013. "SVG_TRANSFORM_TRANSLATE",
  20014. "SVG_TRANSFORM_UNKNOWN",
  20015. "SVG_TURBULENCE_TYPE_FRACTALNOISE",
  20016. "SVG_TURBULENCE_TYPE_TURBULENCE",
  20017. "SVG_TURBULENCE_TYPE_UNKNOWN",
  20018. "SVG_UNIT_TYPE_OBJECTBOUNDINGBOX",
  20019. "SVG_UNIT_TYPE_UNKNOWN",
  20020. "SVG_UNIT_TYPE_USERSPACEONUSE",
  20021. "SVG_WRONG_TYPE_ERR",
  20022. "SVG_ZOOMANDPAN_DISABLE",
  20023. "SVG_ZOOMANDPAN_MAGNIFY",
  20024. "SVG_ZOOMANDPAN_UNKNOWN",
  20025. "SYNC_CONDITION",
  20026. "SYNC_FENCE",
  20027. "SYNC_FLAGS",
  20028. "SYNC_FLUSH_COMMANDS_BIT",
  20029. "SYNC_GPU_COMMANDS_COMPLETE",
  20030. "SYNC_STATUS",
  20031. "SYNTAX_ERR",
  20032. "SavedPages",
  20033. "Screen",
  20034. "ScreenOrientation",
  20035. "Script",
  20036. "ScriptProcessorNode",
  20037. "ScrollAreaEvent",
  20038. "SecurityPolicyViolationEvent",
  20039. "Selection",
  20040. "Sensor",
  20041. "SensorErrorEvent",
  20042. "ServiceWorker",
  20043. "ServiceWorkerContainer",
  20044. "ServiceWorkerRegistration",
  20045. "SessionDescription",
  20046. "Set",
  20047. "ShadowRoot",
  20048. "SharedArrayBuffer",
  20049. "SharedWorker",
  20050. "SimpleGestureEvent",
  20051. "SourceBuffer",
  20052. "SourceBufferList",
  20053. "SpeechSynthesis",
  20054. "SpeechSynthesisErrorEvent",
  20055. "SpeechSynthesisEvent",
  20056. "SpeechSynthesisUtterance",
  20057. "SpeechSynthesisVoice",
  20058. "StaticRange",
  20059. "StereoPannerNode",
  20060. "StopIteration",
  20061. "Storage",
  20062. "StorageEvent",
  20063. "StorageManager",
  20064. "String",
  20065. "StructType",
  20066. "StylePropertyMap",
  20067. "StylePropertyMapReadOnly",
  20068. "StyleSheet",
  20069. "StyleSheetList",
  20070. "SubmitEvent",
  20071. "SubtleCrypto",
  20072. "Symbol",
  20073. "SyncManager",
  20074. "SyntaxError",
  20075. "TEMPORARY",
  20076. "TEXTPATH_METHODTYPE_ALIGN",
  20077. "TEXTPATH_METHODTYPE_STRETCH",
  20078. "TEXTPATH_METHODTYPE_UNKNOWN",
  20079. "TEXTPATH_SPACINGTYPE_AUTO",
  20080. "TEXTPATH_SPACINGTYPE_EXACT",
  20081. "TEXTPATH_SPACINGTYPE_UNKNOWN",
  20082. "TEXTURE",
  20083. "TEXTURE0",
  20084. "TEXTURE1",
  20085. "TEXTURE10",
  20086. "TEXTURE11",
  20087. "TEXTURE12",
  20088. "TEXTURE13",
  20089. "TEXTURE14",
  20090. "TEXTURE15",
  20091. "TEXTURE16",
  20092. "TEXTURE17",
  20093. "TEXTURE18",
  20094. "TEXTURE19",
  20095. "TEXTURE2",
  20096. "TEXTURE20",
  20097. "TEXTURE21",
  20098. "TEXTURE22",
  20099. "TEXTURE23",
  20100. "TEXTURE24",
  20101. "TEXTURE25",
  20102. "TEXTURE26",
  20103. "TEXTURE27",
  20104. "TEXTURE28",
  20105. "TEXTURE29",
  20106. "TEXTURE3",
  20107. "TEXTURE30",
  20108. "TEXTURE31",
  20109. "TEXTURE4",
  20110. "TEXTURE5",
  20111. "TEXTURE6",
  20112. "TEXTURE7",
  20113. "TEXTURE8",
  20114. "TEXTURE9",
  20115. "TEXTURE_2D",
  20116. "TEXTURE_2D_ARRAY",
  20117. "TEXTURE_3D",
  20118. "TEXTURE_BASE_LEVEL",
  20119. "TEXTURE_BINDING_2D",
  20120. "TEXTURE_BINDING_2D_ARRAY",
  20121. "TEXTURE_BINDING_3D",
  20122. "TEXTURE_BINDING_CUBE_MAP",
  20123. "TEXTURE_COMPARE_FUNC",
  20124. "TEXTURE_COMPARE_MODE",
  20125. "TEXTURE_CUBE_MAP",
  20126. "TEXTURE_CUBE_MAP_NEGATIVE_X",
  20127. "TEXTURE_CUBE_MAP_NEGATIVE_Y",
  20128. "TEXTURE_CUBE_MAP_NEGATIVE_Z",
  20129. "TEXTURE_CUBE_MAP_POSITIVE_X",
  20130. "TEXTURE_CUBE_MAP_POSITIVE_Y",
  20131. "TEXTURE_CUBE_MAP_POSITIVE_Z",
  20132. "TEXTURE_IMMUTABLE_FORMAT",
  20133. "TEXTURE_IMMUTABLE_LEVELS",
  20134. "TEXTURE_MAG_FILTER",
  20135. "TEXTURE_MAX_ANISOTROPY_EXT",
  20136. "TEXTURE_MAX_LEVEL",
  20137. "TEXTURE_MAX_LOD",
  20138. "TEXTURE_MIN_FILTER",
  20139. "TEXTURE_MIN_LOD",
  20140. "TEXTURE_WRAP_R",
  20141. "TEXTURE_WRAP_S",
  20142. "TEXTURE_WRAP_T",
  20143. "TEXT_NODE",
  20144. "TIMEOUT",
  20145. "TIMEOUT_ERR",
  20146. "TIMEOUT_EXPIRED",
  20147. "TIMEOUT_IGNORED",
  20148. "TOO_LARGE_ERR",
  20149. "TRANSACTION_INACTIVE_ERR",
  20150. "TRANSFORM_FEEDBACK",
  20151. "TRANSFORM_FEEDBACK_ACTIVE",
  20152. "TRANSFORM_FEEDBACK_BINDING",
  20153. "TRANSFORM_FEEDBACK_BUFFER",
  20154. "TRANSFORM_FEEDBACK_BUFFER_BINDING",
  20155. "TRANSFORM_FEEDBACK_BUFFER_MODE",
  20156. "TRANSFORM_FEEDBACK_BUFFER_SIZE",
  20157. "TRANSFORM_FEEDBACK_BUFFER_START",
  20158. "TRANSFORM_FEEDBACK_PAUSED",
  20159. "TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",
  20160. "TRANSFORM_FEEDBACK_VARYINGS",
  20161. "TRIANGLE",
  20162. "TRIANGLES",
  20163. "TRIANGLE_FAN",
  20164. "TRIANGLE_STRIP",
  20165. "TYPE_BACK_FORWARD",
  20166. "TYPE_ERR",
  20167. "TYPE_MISMATCH_ERR",
  20168. "TYPE_NAVIGATE",
  20169. "TYPE_RELOAD",
  20170. "TYPE_RESERVED",
  20171. "Table",
  20172. "TaskAttributionTiming",
  20173. "Text",
  20174. "TextDecoder",
  20175. "TextDecoderStream",
  20176. "TextEncoder",
  20177. "TextEncoderStream",
  20178. "TextEvent",
  20179. "TextMetrics",
  20180. "TextTrack",
  20181. "TextTrackCue",
  20182. "TextTrackCueList",
  20183. "TextTrackList",
  20184. "TimeEvent",
  20185. "TimeRanges",
  20186. "Touch",
  20187. "TouchEvent",
  20188. "TouchList",
  20189. "TrackEvent",
  20190. "TransformStream",
  20191. "TransitionEvent",
  20192. "TreeWalker",
  20193. "TrustedHTML",
  20194. "TrustedScript",
  20195. "TrustedScriptURL",
  20196. "TrustedTypePolicy",
  20197. "TrustedTypePolicyFactory",
  20198. "TypeError",
  20199. "TypedObject",
  20200. "U2F",
  20201. "UIEvent",
  20202. "UNCACHED",
  20203. "UNIFORM_ARRAY_STRIDE",
  20204. "UNIFORM_BLOCK_ACTIVE_UNIFORMS",
  20205. "UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",
  20206. "UNIFORM_BLOCK_BINDING",
  20207. "UNIFORM_BLOCK_DATA_SIZE",
  20208. "UNIFORM_BLOCK_INDEX",
  20209. "UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",
  20210. "UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",
  20211. "UNIFORM_BUFFER",
  20212. "UNIFORM_BUFFER_BINDING",
  20213. "UNIFORM_BUFFER_OFFSET_ALIGNMENT",
  20214. "UNIFORM_BUFFER_SIZE",
  20215. "UNIFORM_BUFFER_START",
  20216. "UNIFORM_IS_ROW_MAJOR",
  20217. "UNIFORM_MATRIX_STRIDE",
  20218. "UNIFORM_OFFSET",
  20219. "UNIFORM_SIZE",
  20220. "UNIFORM_TYPE",
  20221. "UNKNOWN_ERR",
  20222. "UNKNOWN_RULE",
  20223. "UNMASKED_RENDERER_WEBGL",
  20224. "UNMASKED_VENDOR_WEBGL",
  20225. "UNORDERED_NODE_ITERATOR_TYPE",
  20226. "UNORDERED_NODE_SNAPSHOT_TYPE",
  20227. "UNPACK_ALIGNMENT",
  20228. "UNPACK_COLORSPACE_CONVERSION_WEBGL",
  20229. "UNPACK_FLIP_Y_WEBGL",
  20230. "UNPACK_IMAGE_HEIGHT",
  20231. "UNPACK_PREMULTIPLY_ALPHA_WEBGL",
  20232. "UNPACK_ROW_LENGTH",
  20233. "UNPACK_SKIP_IMAGES",
  20234. "UNPACK_SKIP_PIXELS",
  20235. "UNPACK_SKIP_ROWS",
  20236. "UNSCHEDULED_STATE",
  20237. "UNSENT",
  20238. "UNSIGNALED",
  20239. "UNSIGNED_BYTE",
  20240. "UNSIGNED_INT",
  20241. "UNSIGNED_INT_10F_11F_11F_REV",
  20242. "UNSIGNED_INT_24_8",
  20243. "UNSIGNED_INT_2_10_10_10_REV",
  20244. "UNSIGNED_INT_5_9_9_9_REV",
  20245. "UNSIGNED_INT_SAMPLER_2D",
  20246. "UNSIGNED_INT_SAMPLER_2D_ARRAY",
  20247. "UNSIGNED_INT_SAMPLER_3D",
  20248. "UNSIGNED_INT_SAMPLER_CUBE",
  20249. "UNSIGNED_INT_VEC2",
  20250. "UNSIGNED_INT_VEC3",
  20251. "UNSIGNED_INT_VEC4",
  20252. "UNSIGNED_NORMALIZED",
  20253. "UNSIGNED_SHORT",
  20254. "UNSIGNED_SHORT_4_4_4_4",
  20255. "UNSIGNED_SHORT_5_5_5_1",
  20256. "UNSIGNED_SHORT_5_6_5",
  20257. "UNSPECIFIED_EVENT_TYPE_ERR",
  20258. "UPDATEREADY",
  20259. "URIError",
  20260. "URL",
  20261. "URLSearchParams",
  20262. "URLUnencoded",
  20263. "URL_MISMATCH_ERR",
  20264. "USB",
  20265. "USBAlternateInterface",
  20266. "USBConfiguration",
  20267. "USBConnectionEvent",
  20268. "USBDevice",
  20269. "USBEndpoint",
  20270. "USBInTransferResult",
  20271. "USBInterface",
  20272. "USBIsochronousInTransferPacket",
  20273. "USBIsochronousInTransferResult",
  20274. "USBIsochronousOutTransferPacket",
  20275. "USBIsochronousOutTransferResult",
  20276. "USBOutTransferResult",
  20277. "UTC",
  20278. "Uint16Array",
  20279. "Uint32Array",
  20280. "Uint8Array",
  20281. "Uint8ClampedArray",
  20282. "UserActivation",
  20283. "UserMessageHandler",
  20284. "UserMessageHandlersNamespace",
  20285. "UserProximityEvent",
  20286. "VALIDATE_STATUS",
  20287. "VALIDATION_ERR",
  20288. "VARIABLES_RULE",
  20289. "VENDOR",
  20290. "VERSION",
  20291. "VERSION_CHANGE",
  20292. "VERSION_ERR",
  20293. "VERTEX_ARRAY_BINDING",
  20294. "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",
  20295. "VERTEX_ATTRIB_ARRAY_DIVISOR",
  20296. "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",
  20297. "VERTEX_ATTRIB_ARRAY_ENABLED",
  20298. "VERTEX_ATTRIB_ARRAY_INTEGER",
  20299. "VERTEX_ATTRIB_ARRAY_NORMALIZED",
  20300. "VERTEX_ATTRIB_ARRAY_POINTER",
  20301. "VERTEX_ATTRIB_ARRAY_SIZE",
  20302. "VERTEX_ATTRIB_ARRAY_STRIDE",
  20303. "VERTEX_ATTRIB_ARRAY_TYPE",
  20304. "VERTEX_SHADER",
  20305. "VERTICAL",
  20306. "VERTICAL_AXIS",
  20307. "VER_ERR",
  20308. "VIEWPORT",
  20309. "VIEWPORT_RULE",
  20310. "VRDisplay",
  20311. "VRDisplayCapabilities",
  20312. "VRDisplayEvent",
  20313. "VREyeParameters",
  20314. "VRFieldOfView",
  20315. "VRFrameData",
  20316. "VRPose",
  20317. "VRStageParameters",
  20318. "VTTCue",
  20319. "VTTRegion",
  20320. "ValidityState",
  20321. "VideoPlaybackQuality",
  20322. "VideoStreamTrack",
  20323. "VisualViewport",
  20324. "WAIT_FAILED",
  20325. "WEBKIT_FILTER_RULE",
  20326. "WEBKIT_KEYFRAMES_RULE",
  20327. "WEBKIT_KEYFRAME_RULE",
  20328. "WEBKIT_REGION_RULE",
  20329. "WRONG_DOCUMENT_ERR",
  20330. "WakeLock",
  20331. "WakeLockSentinel",
  20332. "WasmAnyRef",
  20333. "WaveShaperNode",
  20334. "WeakMap",
  20335. "WeakRef",
  20336. "WeakSet",
  20337. "WebAssembly",
  20338. "WebGL2RenderingContext",
  20339. "WebGLActiveInfo",
  20340. "WebGLBuffer",
  20341. "WebGLContextEvent",
  20342. "WebGLFramebuffer",
  20343. "WebGLProgram",
  20344. "WebGLQuery",
  20345. "WebGLRenderbuffer",
  20346. "WebGLRenderingContext",
  20347. "WebGLSampler",
  20348. "WebGLShader",
  20349. "WebGLShaderPrecisionFormat",
  20350. "WebGLSync",
  20351. "WebGLTexture",
  20352. "WebGLTransformFeedback",
  20353. "WebGLUniformLocation",
  20354. "WebGLVertexArray",
  20355. "WebGLVertexArrayObject",
  20356. "WebKitAnimationEvent",
  20357. "WebKitBlobBuilder",
  20358. "WebKitCSSFilterRule",
  20359. "WebKitCSSFilterValue",
  20360. "WebKitCSSKeyframeRule",
  20361. "WebKitCSSKeyframesRule",
  20362. "WebKitCSSMatrix",
  20363. "WebKitCSSRegionRule",
  20364. "WebKitCSSTransformValue",
  20365. "WebKitDataCue",
  20366. "WebKitGamepad",
  20367. "WebKitMediaKeyError",
  20368. "WebKitMediaKeyMessageEvent",
  20369. "WebKitMediaKeySession",
  20370. "WebKitMediaKeys",
  20371. "WebKitMediaSource",
  20372. "WebKitMutationObserver",
  20373. "WebKitNamespace",
  20374. "WebKitPlaybackTargetAvailabilityEvent",
  20375. "WebKitPoint",
  20376. "WebKitShadowRoot",
  20377. "WebKitSourceBuffer",
  20378. "WebKitSourceBufferList",
  20379. "WebKitTransitionEvent",
  20380. "WebSocket",
  20381. "WebkitAlignContent",
  20382. "WebkitAlignItems",
  20383. "WebkitAlignSelf",
  20384. "WebkitAnimation",
  20385. "WebkitAnimationDelay",
  20386. "WebkitAnimationDirection",
  20387. "WebkitAnimationDuration",
  20388. "WebkitAnimationFillMode",
  20389. "WebkitAnimationIterationCount",
  20390. "WebkitAnimationName",
  20391. "WebkitAnimationPlayState",
  20392. "WebkitAnimationTimingFunction",
  20393. "WebkitAppearance",
  20394. "WebkitBackfaceVisibility",
  20395. "WebkitBackgroundClip",
  20396. "WebkitBackgroundOrigin",
  20397. "WebkitBackgroundSize",
  20398. "WebkitBorderBottomLeftRadius",
  20399. "WebkitBorderBottomRightRadius",
  20400. "WebkitBorderImage",
  20401. "WebkitBorderRadius",
  20402. "WebkitBorderTopLeftRadius",
  20403. "WebkitBorderTopRightRadius",
  20404. "WebkitBoxAlign",
  20405. "WebkitBoxDirection",
  20406. "WebkitBoxFlex",
  20407. "WebkitBoxOrdinalGroup",
  20408. "WebkitBoxOrient",
  20409. "WebkitBoxPack",
  20410. "WebkitBoxShadow",
  20411. "WebkitBoxSizing",
  20412. "WebkitFilter",
  20413. "WebkitFlex",
  20414. "WebkitFlexBasis",
  20415. "WebkitFlexDirection",
  20416. "WebkitFlexFlow",
  20417. "WebkitFlexGrow",
  20418. "WebkitFlexShrink",
  20419. "WebkitFlexWrap",
  20420. "WebkitJustifyContent",
  20421. "WebkitLineClamp",
  20422. "WebkitMask",
  20423. "WebkitMaskClip",
  20424. "WebkitMaskComposite",
  20425. "WebkitMaskImage",
  20426. "WebkitMaskOrigin",
  20427. "WebkitMaskPosition",
  20428. "WebkitMaskPositionX",
  20429. "WebkitMaskPositionY",
  20430. "WebkitMaskRepeat",
  20431. "WebkitMaskSize",
  20432. "WebkitOrder",
  20433. "WebkitPerspective",
  20434. "WebkitPerspectiveOrigin",
  20435. "WebkitTextFillColor",
  20436. "WebkitTextSizeAdjust",
  20437. "WebkitTextStroke",
  20438. "WebkitTextStrokeColor",
  20439. "WebkitTextStrokeWidth",
  20440. "WebkitTransform",
  20441. "WebkitTransformOrigin",
  20442. "WebkitTransformStyle",
  20443. "WebkitTransition",
  20444. "WebkitTransitionDelay",
  20445. "WebkitTransitionDuration",
  20446. "WebkitTransitionProperty",
  20447. "WebkitTransitionTimingFunction",
  20448. "WebkitUserSelect",
  20449. "WheelEvent",
  20450. "Window",
  20451. "Worker",
  20452. "Worklet",
  20453. "WritableStream",
  20454. "WritableStreamDefaultWriter",
  20455. "XMLDocument",
  20456. "XMLHttpRequest",
  20457. "XMLHttpRequestEventTarget",
  20458. "XMLHttpRequestException",
  20459. "XMLHttpRequestProgressEvent",
  20460. "XMLHttpRequestUpload",
  20461. "XMLSerializer",
  20462. "XMLStylesheetProcessingInstruction",
  20463. "XPathEvaluator",
  20464. "XPathException",
  20465. "XPathExpression",
  20466. "XPathNSResolver",
  20467. "XPathResult",
  20468. "XRBoundedReferenceSpace",
  20469. "XRDOMOverlayState",
  20470. "XRFrame",
  20471. "XRHitTestResult",
  20472. "XRHitTestSource",
  20473. "XRInputSource",
  20474. "XRInputSourceArray",
  20475. "XRInputSourceEvent",
  20476. "XRInputSourcesChangeEvent",
  20477. "XRLayer",
  20478. "XRPose",
  20479. "XRRay",
  20480. "XRReferenceSpace",
  20481. "XRReferenceSpaceEvent",
  20482. "XRRenderState",
  20483. "XRRigidTransform",
  20484. "XRSession",
  20485. "XRSessionEvent",
  20486. "XRSpace",
  20487. "XRSystem",
  20488. "XRTransientInputHitTestResult",
  20489. "XRTransientInputHitTestSource",
  20490. "XRView",
  20491. "XRViewerPose",
  20492. "XRViewport",
  20493. "XRWebGLLayer",
  20494. "XSLTProcessor",
  20495. "ZERO",
  20496. "_XD0M_",
  20497. "_YD0M_",
  20498. "__defineGetter__",
  20499. "__defineSetter__",
  20500. "__lookupGetter__",
  20501. "__lookupSetter__",
  20502. "__opera",
  20503. "__proto__",
  20504. "_browserjsran",
  20505. "a",
  20506. "aLink",
  20507. "abbr",
  20508. "abort",
  20509. "aborted",
  20510. "abs",
  20511. "absolute",
  20512. "acceleration",
  20513. "accelerationIncludingGravity",
  20514. "accelerator",
  20515. "accept",
  20516. "acceptCharset",
  20517. "acceptNode",
  20518. "accessKey",
  20519. "accessKeyLabel",
  20520. "accuracy",
  20521. "acos",
  20522. "acosh",
  20523. "action",
  20524. "actionURL",
  20525. "actions",
  20526. "activated",
  20527. "active",
  20528. "activeCues",
  20529. "activeElement",
  20530. "activeSourceBuffers",
  20531. "activeSourceCount",
  20532. "activeTexture",
  20533. "activeVRDisplays",
  20534. "actualBoundingBoxAscent",
  20535. "actualBoundingBoxDescent",
  20536. "actualBoundingBoxLeft",
  20537. "actualBoundingBoxRight",
  20538. "add",
  20539. "addAll",
  20540. "addBehavior",
  20541. "addCandidate",
  20542. "addColorStop",
  20543. "addCue",
  20544. "addElement",
  20545. "addEventListener",
  20546. "addFilter",
  20547. "addFromString",
  20548. "addFromUri",
  20549. "addIceCandidate",
  20550. "addImport",
  20551. "addListener",
  20552. "addModule",
  20553. "addNamed",
  20554. "addPageRule",
  20555. "addPath",
  20556. "addPointer",
  20557. "addRange",
  20558. "addRegion",
  20559. "addRule",
  20560. "addSearchEngine",
  20561. "addSourceBuffer",
  20562. "addStream",
  20563. "addTextTrack",
  20564. "addTrack",
  20565. "addTransceiver",
  20566. "addWakeLockListener",
  20567. "added",
  20568. "addedNodes",
  20569. "additionalName",
  20570. "additiveSymbols",
  20571. "addons",
  20572. "address",
  20573. "addressLine",
  20574. "adoptNode",
  20575. "adoptedStyleSheets",
  20576. "adr",
  20577. "advance",
  20578. "after",
  20579. "album",
  20580. "alert",
  20581. "algorithm",
  20582. "align",
  20583. "align-content",
  20584. "align-items",
  20585. "align-self",
  20586. "alignContent",
  20587. "alignItems",
  20588. "alignSelf",
  20589. "alignmentBaseline",
  20590. "alinkColor",
  20591. "all",
  20592. "allSettled",
  20593. "allow",
  20594. "allowFullscreen",
  20595. "allowPaymentRequest",
  20596. "allowedDirections",
  20597. "allowedFeatures",
  20598. "allowedToPlay",
  20599. "allowsFeature",
  20600. "alpha",
  20601. "alt",
  20602. "altGraphKey",
  20603. "altHtml",
  20604. "altKey",
  20605. "altLeft",
  20606. "alternate",
  20607. "alternateSetting",
  20608. "alternates",
  20609. "altitude",
  20610. "altitudeAccuracy",
  20611. "amplitude",
  20612. "ancestorOrigins",
  20613. "anchor",
  20614. "anchorNode",
  20615. "anchorOffset",
  20616. "anchors",
  20617. "and",
  20618. "angle",
  20619. "angularAcceleration",
  20620. "angularVelocity",
  20621. "animVal",
  20622. "animate",
  20623. "animatedInstanceRoot",
  20624. "animatedNormalizedPathSegList",
  20625. "animatedPathSegList",
  20626. "animatedPoints",
  20627. "animation",
  20628. "animation-delay",
  20629. "animation-direction",
  20630. "animation-duration",
  20631. "animation-fill-mode",
  20632. "animation-iteration-count",
  20633. "animation-name",
  20634. "animation-play-state",
  20635. "animation-timing-function",
  20636. "animationDelay",
  20637. "animationDirection",
  20638. "animationDuration",
  20639. "animationFillMode",
  20640. "animationIterationCount",
  20641. "animationName",
  20642. "animationPlayState",
  20643. "animationStartTime",
  20644. "animationTimingFunction",
  20645. "animationsPaused",
  20646. "anniversary",
  20647. "antialias",
  20648. "anticipatedRemoval",
  20649. "any",
  20650. "app",
  20651. "appCodeName",
  20652. "appMinorVersion",
  20653. "appName",
  20654. "appNotifications",
  20655. "appVersion",
  20656. "appearance",
  20657. "append",
  20658. "appendBuffer",
  20659. "appendChild",
  20660. "appendData",
  20661. "appendItem",
  20662. "appendMedium",
  20663. "appendNamed",
  20664. "appendRule",
  20665. "appendStream",
  20666. "appendWindowEnd",
  20667. "appendWindowStart",
  20668. "applets",
  20669. "applicationCache",
  20670. "applicationServerKey",
  20671. "apply",
  20672. "applyConstraints",
  20673. "applyElement",
  20674. "arc",
  20675. "arcTo",
  20676. "archive",
  20677. "areas",
  20678. "arguments",
  20679. "ariaAtomic",
  20680. "ariaAutoComplete",
  20681. "ariaBusy",
  20682. "ariaChecked",
  20683. "ariaColCount",
  20684. "ariaColIndex",
  20685. "ariaColSpan",
  20686. "ariaCurrent",
  20687. "ariaDescription",
  20688. "ariaDisabled",
  20689. "ariaExpanded",
  20690. "ariaHasPopup",
  20691. "ariaHidden",
  20692. "ariaKeyShortcuts",
  20693. "ariaLabel",
  20694. "ariaLevel",
  20695. "ariaLive",
  20696. "ariaModal",
  20697. "ariaMultiLine",
  20698. "ariaMultiSelectable",
  20699. "ariaOrientation",
  20700. "ariaPlaceholder",
  20701. "ariaPosInSet",
  20702. "ariaPressed",
  20703. "ariaReadOnly",
  20704. "ariaRelevant",
  20705. "ariaRequired",
  20706. "ariaRoleDescription",
  20707. "ariaRowCount",
  20708. "ariaRowIndex",
  20709. "ariaRowSpan",
  20710. "ariaSelected",
  20711. "ariaSetSize",
  20712. "ariaSort",
  20713. "ariaValueMax",
  20714. "ariaValueMin",
  20715. "ariaValueNow",
  20716. "ariaValueText",
  20717. "arrayBuffer",
  20718. "artist",
  20719. "artwork",
  20720. "as",
  20721. "asIntN",
  20722. "asUintN",
  20723. "asin",
  20724. "asinh",
  20725. "assert",
  20726. "assign",
  20727. "assignedElements",
  20728. "assignedNodes",
  20729. "assignedSlot",
  20730. "async",
  20731. "asyncIterator",
  20732. "atEnd",
  20733. "atan",
  20734. "atan2",
  20735. "atanh",
  20736. "atob",
  20737. "attachEvent",
  20738. "attachInternals",
  20739. "attachShader",
  20740. "attachShadow",
  20741. "attachments",
  20742. "attack",
  20743. "attestationObject",
  20744. "attrChange",
  20745. "attrName",
  20746. "attributeFilter",
  20747. "attributeName",
  20748. "attributeNamespace",
  20749. "attributeOldValue",
  20750. "attributeStyleMap",
  20751. "attributes",
  20752. "attribution",
  20753. "audioBitsPerSecond",
  20754. "audioTracks",
  20755. "audioWorklet",
  20756. "authenticatedSignedWrites",
  20757. "authenticatorData",
  20758. "autoIncrement",
  20759. "autobuffer",
  20760. "autocapitalize",
  20761. "autocomplete",
  20762. "autocorrect",
  20763. "autofocus",
  20764. "automationRate",
  20765. "autoplay",
  20766. "availHeight",
  20767. "availLeft",
  20768. "availTop",
  20769. "availWidth",
  20770. "availability",
  20771. "available",
  20772. "aversion",
  20773. "ax",
  20774. "axes",
  20775. "axis",
  20776. "ay",
  20777. "azimuth",
  20778. "b",
  20779. "back",
  20780. "backface-visibility",
  20781. "backfaceVisibility",
  20782. "background",
  20783. "background-attachment",
  20784. "background-blend-mode",
  20785. "background-clip",
  20786. "background-color",
  20787. "background-image",
  20788. "background-origin",
  20789. "background-position",
  20790. "background-position-x",
  20791. "background-position-y",
  20792. "background-repeat",
  20793. "background-size",
  20794. "backgroundAttachment",
  20795. "backgroundBlendMode",
  20796. "backgroundClip",
  20797. "backgroundColor",
  20798. "backgroundFetch",
  20799. "backgroundImage",
  20800. "backgroundOrigin",
  20801. "backgroundPosition",
  20802. "backgroundPositionX",
  20803. "backgroundPositionY",
  20804. "backgroundRepeat",
  20805. "backgroundSize",
  20806. "badInput",
  20807. "badge",
  20808. "balance",
  20809. "baseFrequencyX",
  20810. "baseFrequencyY",
  20811. "baseLatency",
  20812. "baseLayer",
  20813. "baseNode",
  20814. "baseOffset",
  20815. "baseURI",
  20816. "baseVal",
  20817. "baselineShift",
  20818. "battery",
  20819. "bday",
  20820. "before",
  20821. "beginElement",
  20822. "beginElementAt",
  20823. "beginPath",
  20824. "beginQuery",
  20825. "beginTransformFeedback",
  20826. "behavior",
  20827. "behaviorCookie",
  20828. "behaviorPart",
  20829. "behaviorUrns",
  20830. "beta",
  20831. "bezierCurveTo",
  20832. "bgColor",
  20833. "bgProperties",
  20834. "bias",
  20835. "big",
  20836. "bigint64",
  20837. "biguint64",
  20838. "binaryType",
  20839. "bind",
  20840. "bindAttribLocation",
  20841. "bindBuffer",
  20842. "bindBufferBase",
  20843. "bindBufferRange",
  20844. "bindFramebuffer",
  20845. "bindRenderbuffer",
  20846. "bindSampler",
  20847. "bindTexture",
  20848. "bindTransformFeedback",
  20849. "bindVertexArray",
  20850. "blendColor",
  20851. "blendEquation",
  20852. "blendEquationSeparate",
  20853. "blendFunc",
  20854. "blendFuncSeparate",
  20855. "blink",
  20856. "blitFramebuffer",
  20857. "blob",
  20858. "block-size",
  20859. "blockDirection",
  20860. "blockSize",
  20861. "blockedURI",
  20862. "blue",
  20863. "bluetooth",
  20864. "blur",
  20865. "body",
  20866. "bodyUsed",
  20867. "bold",
  20868. "bookmarks",
  20869. "booleanValue",
  20870. "border",
  20871. "border-block",
  20872. "border-block-color",
  20873. "border-block-end",
  20874. "border-block-end-color",
  20875. "border-block-end-style",
  20876. "border-block-end-width",
  20877. "border-block-start",
  20878. "border-block-start-color",
  20879. "border-block-start-style",
  20880. "border-block-start-width",
  20881. "border-block-style",
  20882. "border-block-width",
  20883. "border-bottom",
  20884. "border-bottom-color",
  20885. "border-bottom-left-radius",
  20886. "border-bottom-right-radius",
  20887. "border-bottom-style",
  20888. "border-bottom-width",
  20889. "border-collapse",
  20890. "border-color",
  20891. "border-end-end-radius",
  20892. "border-end-start-radius",
  20893. "border-image",
  20894. "border-image-outset",
  20895. "border-image-repeat",
  20896. "border-image-slice",
  20897. "border-image-source",
  20898. "border-image-width",
  20899. "border-inline",
  20900. "border-inline-color",
  20901. "border-inline-end",
  20902. "border-inline-end-color",
  20903. "border-inline-end-style",
  20904. "border-inline-end-width",
  20905. "border-inline-start",
  20906. "border-inline-start-color",
  20907. "border-inline-start-style",
  20908. "border-inline-start-width",
  20909. "border-inline-style",
  20910. "border-inline-width",
  20911. "border-left",
  20912. "border-left-color",
  20913. "border-left-style",
  20914. "border-left-width",
  20915. "border-radius",
  20916. "border-right",
  20917. "border-right-color",
  20918. "border-right-style",
  20919. "border-right-width",
  20920. "border-spacing",
  20921. "border-start-end-radius",
  20922. "border-start-start-radius",
  20923. "border-style",
  20924. "border-top",
  20925. "border-top-color",
  20926. "border-top-left-radius",
  20927. "border-top-right-radius",
  20928. "border-top-style",
  20929. "border-top-width",
  20930. "border-width",
  20931. "borderBlock",
  20932. "borderBlockColor",
  20933. "borderBlockEnd",
  20934. "borderBlockEndColor",
  20935. "borderBlockEndStyle",
  20936. "borderBlockEndWidth",
  20937. "borderBlockStart",
  20938. "borderBlockStartColor",
  20939. "borderBlockStartStyle",
  20940. "borderBlockStartWidth",
  20941. "borderBlockStyle",
  20942. "borderBlockWidth",
  20943. "borderBottom",
  20944. "borderBottomColor",
  20945. "borderBottomLeftRadius",
  20946. "borderBottomRightRadius",
  20947. "borderBottomStyle",
  20948. "borderBottomWidth",
  20949. "borderBoxSize",
  20950. "borderCollapse",
  20951. "borderColor",
  20952. "borderColorDark",
  20953. "borderColorLight",
  20954. "borderEndEndRadius",
  20955. "borderEndStartRadius",
  20956. "borderImage",
  20957. "borderImageOutset",
  20958. "borderImageRepeat",
  20959. "borderImageSlice",
  20960. "borderImageSource",
  20961. "borderImageWidth",
  20962. "borderInline",
  20963. "borderInlineColor",
  20964. "borderInlineEnd",
  20965. "borderInlineEndColor",
  20966. "borderInlineEndStyle",
  20967. "borderInlineEndWidth",
  20968. "borderInlineStart",
  20969. "borderInlineStartColor",
  20970. "borderInlineStartStyle",
  20971. "borderInlineStartWidth",
  20972. "borderInlineStyle",
  20973. "borderInlineWidth",
  20974. "borderLeft",
  20975. "borderLeftColor",
  20976. "borderLeftStyle",
  20977. "borderLeftWidth",
  20978. "borderRadius",
  20979. "borderRight",
  20980. "borderRightColor",
  20981. "borderRightStyle",
  20982. "borderRightWidth",
  20983. "borderSpacing",
  20984. "borderStartEndRadius",
  20985. "borderStartStartRadius",
  20986. "borderStyle",
  20987. "borderTop",
  20988. "borderTopColor",
  20989. "borderTopLeftRadius",
  20990. "borderTopRightRadius",
  20991. "borderTopStyle",
  20992. "borderTopWidth",
  20993. "borderWidth",
  20994. "bottom",
  20995. "bottomMargin",
  20996. "bound",
  20997. "boundElements",
  20998. "boundingClientRect",
  20999. "boundingHeight",
  21000. "boundingLeft",
  21001. "boundingTop",
  21002. "boundingWidth",
  21003. "bounds",
  21004. "boundsGeometry",
  21005. "box-decoration-break",
  21006. "box-shadow",
  21007. "box-sizing",
  21008. "boxDecorationBreak",
  21009. "boxShadow",
  21010. "boxSizing",
  21011. "break-after",
  21012. "break-before",
  21013. "break-inside",
  21014. "breakAfter",
  21015. "breakBefore",
  21016. "breakInside",
  21017. "broadcast",
  21018. "browserLanguage",
  21019. "btoa",
  21020. "bubbles",
  21021. "buffer",
  21022. "bufferData",
  21023. "bufferDepth",
  21024. "bufferSize",
  21025. "bufferSubData",
  21026. "buffered",
  21027. "bufferedAmount",
  21028. "bufferedAmountLowThreshold",
  21029. "buildID",
  21030. "buildNumber",
  21031. "button",
  21032. "buttonID",
  21033. "buttons",
  21034. "byteLength",
  21035. "byteOffset",
  21036. "bytesWritten",
  21037. "c",
  21038. "cache",
  21039. "caches",
  21040. "call",
  21041. "caller",
  21042. "canBeFormatted",
  21043. "canBeMounted",
  21044. "canBeShared",
  21045. "canHaveChildren",
  21046. "canHaveHTML",
  21047. "canInsertDTMF",
  21048. "canMakePayment",
  21049. "canPlayType",
  21050. "canPresent",
  21051. "canTrickleIceCandidates",
  21052. "cancel",
  21053. "cancelAndHoldAtTime",
  21054. "cancelAnimationFrame",
  21055. "cancelBubble",
  21056. "cancelIdleCallback",
  21057. "cancelScheduledValues",
  21058. "cancelVideoFrameCallback",
  21059. "cancelWatchAvailability",
  21060. "cancelable",
  21061. "candidate",
  21062. "canonicalUUID",
  21063. "canvas",
  21064. "capabilities",
  21065. "caption",
  21066. "caption-side",
  21067. "captionSide",
  21068. "capture",
  21069. "captureEvents",
  21070. "captureStackTrace",
  21071. "captureStream",
  21072. "caret-color",
  21073. "caretBidiLevel",
  21074. "caretColor",
  21075. "caretPositionFromPoint",
  21076. "caretRangeFromPoint",
  21077. "cast",
  21078. "catch",
  21079. "category",
  21080. "cbrt",
  21081. "cd",
  21082. "ceil",
  21083. "cellIndex",
  21084. "cellPadding",
  21085. "cellSpacing",
  21086. "cells",
  21087. "ch",
  21088. "chOff",
  21089. "chain",
  21090. "challenge",
  21091. "changeType",
  21092. "changedTouches",
  21093. "channel",
  21094. "channelCount",
  21095. "channelCountMode",
  21096. "channelInterpretation",
  21097. "char",
  21098. "charAt",
  21099. "charCode",
  21100. "charCodeAt",
  21101. "charIndex",
  21102. "charLength",
  21103. "characterData",
  21104. "characterDataOldValue",
  21105. "characterSet",
  21106. "characteristic",
  21107. "charging",
  21108. "chargingTime",
  21109. "charset",
  21110. "check",
  21111. "checkEnclosure",
  21112. "checkFramebufferStatus",
  21113. "checkIntersection",
  21114. "checkValidity",
  21115. "checked",
  21116. "childElementCount",
  21117. "childList",
  21118. "childNodes",
  21119. "children",
  21120. "chrome",
  21121. "ciphertext",
  21122. "cite",
  21123. "city",
  21124. "claimInterface",
  21125. "claimed",
  21126. "classList",
  21127. "className",
  21128. "classid",
  21129. "clear",
  21130. "clearAppBadge",
  21131. "clearAttributes",
  21132. "clearBufferfi",
  21133. "clearBufferfv",
  21134. "clearBufferiv",
  21135. "clearBufferuiv",
  21136. "clearColor",
  21137. "clearData",
  21138. "clearDepth",
  21139. "clearHalt",
  21140. "clearImmediate",
  21141. "clearInterval",
  21142. "clearLiveSeekableRange",
  21143. "clearMarks",
  21144. "clearMaxGCPauseAccumulator",
  21145. "clearMeasures",
  21146. "clearParameters",
  21147. "clearRect",
  21148. "clearResourceTimings",
  21149. "clearShadow",
  21150. "clearStencil",
  21151. "clearTimeout",
  21152. "clearWatch",
  21153. "click",
  21154. "clickCount",
  21155. "clientDataJSON",
  21156. "clientHeight",
  21157. "clientInformation",
  21158. "clientLeft",
  21159. "clientRect",
  21160. "clientRects",
  21161. "clientTop",
  21162. "clientWaitSync",
  21163. "clientWidth",
  21164. "clientX",
  21165. "clientY",
  21166. "clip",
  21167. "clip-path",
  21168. "clip-rule",
  21169. "clipBottom",
  21170. "clipLeft",
  21171. "clipPath",
  21172. "clipPathUnits",
  21173. "clipRight",
  21174. "clipRule",
  21175. "clipTop",
  21176. "clipboard",
  21177. "clipboardData",
  21178. "clone",
  21179. "cloneContents",
  21180. "cloneNode",
  21181. "cloneRange",
  21182. "close",
  21183. "closePath",
  21184. "closed",
  21185. "closest",
  21186. "clz",
  21187. "clz32",
  21188. "cm",
  21189. "cmp",
  21190. "code",
  21191. "codeBase",
  21192. "codePointAt",
  21193. "codeType",
  21194. "colSpan",
  21195. "collapse",
  21196. "collapseToEnd",
  21197. "collapseToStart",
  21198. "collapsed",
  21199. "collect",
  21200. "colno",
  21201. "color",
  21202. "color-adjust",
  21203. "color-interpolation",
  21204. "color-interpolation-filters",
  21205. "colorAdjust",
  21206. "colorDepth",
  21207. "colorInterpolation",
  21208. "colorInterpolationFilters",
  21209. "colorMask",
  21210. "colorType",
  21211. "cols",
  21212. "column-count",
  21213. "column-fill",
  21214. "column-gap",
  21215. "column-rule",
  21216. "column-rule-color",
  21217. "column-rule-style",
  21218. "column-rule-width",
  21219. "column-span",
  21220. "column-width",
  21221. "columnCount",
  21222. "columnFill",
  21223. "columnGap",
  21224. "columnNumber",
  21225. "columnRule",
  21226. "columnRuleColor",
  21227. "columnRuleStyle",
  21228. "columnRuleWidth",
  21229. "columnSpan",
  21230. "columnWidth",
  21231. "columns",
  21232. "command",
  21233. "commit",
  21234. "commitPreferences",
  21235. "commitStyles",
  21236. "commonAncestorContainer",
  21237. "compact",
  21238. "compareBoundaryPoints",
  21239. "compareDocumentPosition",
  21240. "compareEndPoints",
  21241. "compareExchange",
  21242. "compareNode",
  21243. "comparePoint",
  21244. "compatMode",
  21245. "compatible",
  21246. "compile",
  21247. "compileShader",
  21248. "compileStreaming",
  21249. "complete",
  21250. "component",
  21251. "componentFromPoint",
  21252. "composed",
  21253. "composedPath",
  21254. "composite",
  21255. "compositionEndOffset",
  21256. "compositionStartOffset",
  21257. "compressedTexImage2D",
  21258. "compressedTexImage3D",
  21259. "compressedTexSubImage2D",
  21260. "compressedTexSubImage3D",
  21261. "computedStyleMap",
  21262. "concat",
  21263. "conditionText",
  21264. "coneInnerAngle",
  21265. "coneOuterAngle",
  21266. "coneOuterGain",
  21267. "configuration",
  21268. "configurationName",
  21269. "configurationValue",
  21270. "configurations",
  21271. "confirm",
  21272. "confirmComposition",
  21273. "confirmSiteSpecificTrackingException",
  21274. "confirmWebWideTrackingException",
  21275. "connect",
  21276. "connectEnd",
  21277. "connectShark",
  21278. "connectStart",
  21279. "connected",
  21280. "connection",
  21281. "connectionList",
  21282. "connectionSpeed",
  21283. "connectionState",
  21284. "connections",
  21285. "console",
  21286. "consolidate",
  21287. "constraint",
  21288. "constrictionActive",
  21289. "construct",
  21290. "constructor",
  21291. "contactID",
  21292. "contain",
  21293. "containerId",
  21294. "containerName",
  21295. "containerSrc",
  21296. "containerType",
  21297. "contains",
  21298. "containsNode",
  21299. "content",
  21300. "contentBoxSize",
  21301. "contentDocument",
  21302. "contentEditable",
  21303. "contentHint",
  21304. "contentOverflow",
  21305. "contentRect",
  21306. "contentScriptType",
  21307. "contentStyleType",
  21308. "contentType",
  21309. "contentWindow",
  21310. "context",
  21311. "contextMenu",
  21312. "contextmenu",
  21313. "continue",
  21314. "continuePrimaryKey",
  21315. "continuous",
  21316. "control",
  21317. "controlTransferIn",
  21318. "controlTransferOut",
  21319. "controller",
  21320. "controls",
  21321. "controlsList",
  21322. "convertPointFromNode",
  21323. "convertQuadFromNode",
  21324. "convertRectFromNode",
  21325. "convertToBlob",
  21326. "convertToSpecifiedUnits",
  21327. "cookie",
  21328. "cookieEnabled",
  21329. "coords",
  21330. "copyBufferSubData",
  21331. "copyFromChannel",
  21332. "copyTexImage2D",
  21333. "copyTexSubImage2D",
  21334. "copyTexSubImage3D",
  21335. "copyToChannel",
  21336. "copyWithin",
  21337. "correspondingElement",
  21338. "correspondingUseElement",
  21339. "corruptedVideoFrames",
  21340. "cos",
  21341. "cosh",
  21342. "count",
  21343. "countReset",
  21344. "counter-increment",
  21345. "counter-reset",
  21346. "counter-set",
  21347. "counterIncrement",
  21348. "counterReset",
  21349. "counterSet",
  21350. "country",
  21351. "cpuClass",
  21352. "cpuSleepAllowed",
  21353. "create",
  21354. "createAnalyser",
  21355. "createAnswer",
  21356. "createAttribute",
  21357. "createAttributeNS",
  21358. "createBiquadFilter",
  21359. "createBuffer",
  21360. "createBufferSource",
  21361. "createCDATASection",
  21362. "createCSSStyleSheet",
  21363. "createCaption",
  21364. "createChannelMerger",
  21365. "createChannelSplitter",
  21366. "createComment",
  21367. "createConstantSource",
  21368. "createContextualFragment",
  21369. "createControlRange",
  21370. "createConvolver",
  21371. "createDTMFSender",
  21372. "createDataChannel",
  21373. "createDelay",
  21374. "createDelayNode",
  21375. "createDocument",
  21376. "createDocumentFragment",
  21377. "createDocumentType",
  21378. "createDynamicsCompressor",
  21379. "createElement",
  21380. "createElementNS",
  21381. "createEntityReference",
  21382. "createEvent",
  21383. "createEventObject",
  21384. "createExpression",
  21385. "createFramebuffer",
  21386. "createFunction",
  21387. "createGain",
  21388. "createGainNode",
  21389. "createHTML",
  21390. "createHTMLDocument",
  21391. "createIIRFilter",
  21392. "createImageBitmap",
  21393. "createImageData",
  21394. "createIndex",
  21395. "createJavaScriptNode",
  21396. "createLinearGradient",
  21397. "createMediaElementSource",
  21398. "createMediaKeys",
  21399. "createMediaStreamDestination",
  21400. "createMediaStreamSource",
  21401. "createMediaStreamTrackSource",
  21402. "createMutableFile",
  21403. "createNSResolver",
  21404. "createNodeIterator",
  21405. "createNotification",
  21406. "createObjectStore",
  21407. "createObjectURL",
  21408. "createOffer",
  21409. "createOscillator",
  21410. "createPanner",
  21411. "createPattern",
  21412. "createPeriodicWave",
  21413. "createPolicy",
  21414. "createPopup",
  21415. "createProcessingInstruction",
  21416. "createProgram",
  21417. "createQuery",
  21418. "createRadialGradient",
  21419. "createRange",
  21420. "createRangeCollection",
  21421. "createReader",
  21422. "createRenderbuffer",
  21423. "createSVGAngle",
  21424. "createSVGLength",
  21425. "createSVGMatrix",
  21426. "createSVGNumber",
  21427. "createSVGPathSegArcAbs",
  21428. "createSVGPathSegArcRel",
  21429. "createSVGPathSegClosePath",
  21430. "createSVGPathSegCurvetoCubicAbs",
  21431. "createSVGPathSegCurvetoCubicRel",
  21432. "createSVGPathSegCurvetoCubicSmoothAbs",
  21433. "createSVGPathSegCurvetoCubicSmoothRel",
  21434. "createSVGPathSegCurvetoQuadraticAbs",
  21435. "createSVGPathSegCurvetoQuadraticRel",
  21436. "createSVGPathSegCurvetoQuadraticSmoothAbs",
  21437. "createSVGPathSegCurvetoQuadraticSmoothRel",
  21438. "createSVGPathSegLinetoAbs",
  21439. "createSVGPathSegLinetoHorizontalAbs",
  21440. "createSVGPathSegLinetoHorizontalRel",
  21441. "createSVGPathSegLinetoRel",
  21442. "createSVGPathSegLinetoVerticalAbs",
  21443. "createSVGPathSegLinetoVerticalRel",
  21444. "createSVGPathSegMovetoAbs",
  21445. "createSVGPathSegMovetoRel",
  21446. "createSVGPoint",
  21447. "createSVGRect",
  21448. "createSVGTransform",
  21449. "createSVGTransformFromMatrix",
  21450. "createSampler",
  21451. "createScript",
  21452. "createScriptProcessor",
  21453. "createScriptURL",
  21454. "createSession",
  21455. "createShader",
  21456. "createShadowRoot",
  21457. "createStereoPanner",
  21458. "createStyleSheet",
  21459. "createTBody",
  21460. "createTFoot",
  21461. "createTHead",
  21462. "createTextNode",
  21463. "createTextRange",
  21464. "createTexture",
  21465. "createTouch",
  21466. "createTouchList",
  21467. "createTransformFeedback",
  21468. "createTreeWalker",
  21469. "createVertexArray",
  21470. "createWaveShaper",
  21471. "creationTime",
  21472. "credentials",
  21473. "crossOrigin",
  21474. "crossOriginIsolated",
  21475. "crypto",
  21476. "csi",
  21477. "csp",
  21478. "cssFloat",
  21479. "cssRules",
  21480. "cssText",
  21481. "cssValueType",
  21482. "ctrlKey",
  21483. "ctrlLeft",
  21484. "cues",
  21485. "cullFace",
  21486. "currentDirection",
  21487. "currentLocalDescription",
  21488. "currentNode",
  21489. "currentPage",
  21490. "currentRect",
  21491. "currentRemoteDescription",
  21492. "currentScale",
  21493. "currentScript",
  21494. "currentSrc",
  21495. "currentState",
  21496. "currentStyle",
  21497. "currentTarget",
  21498. "currentTime",
  21499. "currentTranslate",
  21500. "currentView",
  21501. "cursor",
  21502. "curve",
  21503. "customElements",
  21504. "customError",
  21505. "cx",
  21506. "cy",
  21507. "d",
  21508. "data",
  21509. "dataFld",
  21510. "dataFormatAs",
  21511. "dataLoss",
  21512. "dataLossMessage",
  21513. "dataPageSize",
  21514. "dataSrc",
  21515. "dataTransfer",
  21516. "database",
  21517. "databases",
  21518. "dataset",
  21519. "dateTime",
  21520. "db",
  21521. "debug",
  21522. "debuggerEnabled",
  21523. "declare",
  21524. "decode",
  21525. "decodeAudioData",
  21526. "decodeURI",
  21527. "decodeURIComponent",
  21528. "decodedBodySize",
  21529. "decoding",
  21530. "decodingInfo",
  21531. "decrypt",
  21532. "default",
  21533. "defaultCharset",
  21534. "defaultChecked",
  21535. "defaultMuted",
  21536. "defaultPlaybackRate",
  21537. "defaultPolicy",
  21538. "defaultPrevented",
  21539. "defaultRequest",
  21540. "defaultSelected",
  21541. "defaultStatus",
  21542. "defaultURL",
  21543. "defaultValue",
  21544. "defaultView",
  21545. "defaultstatus",
  21546. "defer",
  21547. "define",
  21548. "defineMagicFunction",
  21549. "defineMagicVariable",
  21550. "defineProperties",
  21551. "defineProperty",
  21552. "deg",
  21553. "delay",
  21554. "delayTime",
  21555. "delegatesFocus",
  21556. "delete",
  21557. "deleteBuffer",
  21558. "deleteCaption",
  21559. "deleteCell",
  21560. "deleteContents",
  21561. "deleteData",
  21562. "deleteDatabase",
  21563. "deleteFramebuffer",
  21564. "deleteFromDocument",
  21565. "deleteIndex",
  21566. "deleteMedium",
  21567. "deleteObjectStore",
  21568. "deleteProgram",
  21569. "deleteProperty",
  21570. "deleteQuery",
  21571. "deleteRenderbuffer",
  21572. "deleteRow",
  21573. "deleteRule",
  21574. "deleteSampler",
  21575. "deleteShader",
  21576. "deleteSync",
  21577. "deleteTFoot",
  21578. "deleteTHead",
  21579. "deleteTexture",
  21580. "deleteTransformFeedback",
  21581. "deleteVertexArray",
  21582. "deliverChangeRecords",
  21583. "delivery",
  21584. "deliveryInfo",
  21585. "deliveryStatus",
  21586. "deliveryTimestamp",
  21587. "delta",
  21588. "deltaMode",
  21589. "deltaX",
  21590. "deltaY",
  21591. "deltaZ",
  21592. "dependentLocality",
  21593. "depthFar",
  21594. "depthFunc",
  21595. "depthMask",
  21596. "depthNear",
  21597. "depthRange",
  21598. "deref",
  21599. "deriveBits",
  21600. "deriveKey",
  21601. "description",
  21602. "deselectAll",
  21603. "designMode",
  21604. "desiredSize",
  21605. "destination",
  21606. "destinationURL",
  21607. "detach",
  21608. "detachEvent",
  21609. "detachShader",
  21610. "detail",
  21611. "details",
  21612. "detect",
  21613. "detune",
  21614. "device",
  21615. "deviceClass",
  21616. "deviceId",
  21617. "deviceMemory",
  21618. "devicePixelContentBoxSize",
  21619. "devicePixelRatio",
  21620. "deviceProtocol",
  21621. "deviceSubclass",
  21622. "deviceVersionMajor",
  21623. "deviceVersionMinor",
  21624. "deviceVersionSubminor",
  21625. "deviceXDPI",
  21626. "deviceYDPI",
  21627. "didTimeout",
  21628. "diffuseConstant",
  21629. "digest",
  21630. "dimensions",
  21631. "dir",
  21632. "dirName",
  21633. "direction",
  21634. "dirxml",
  21635. "disable",
  21636. "disablePictureInPicture",
  21637. "disableRemotePlayback",
  21638. "disableVertexAttribArray",
  21639. "disabled",
  21640. "dischargingTime",
  21641. "disconnect",
  21642. "disconnectShark",
  21643. "dispatchEvent",
  21644. "display",
  21645. "displayId",
  21646. "displayName",
  21647. "disposition",
  21648. "distanceModel",
  21649. "div",
  21650. "divisor",
  21651. "djsapi",
  21652. "djsproxy",
  21653. "doImport",
  21654. "doNotTrack",
  21655. "doScroll",
  21656. "doctype",
  21657. "document",
  21658. "documentElement",
  21659. "documentMode",
  21660. "documentURI",
  21661. "dolphin",
  21662. "dolphinGameCenter",
  21663. "dolphininfo",
  21664. "dolphinmeta",
  21665. "domComplete",
  21666. "domContentLoadedEventEnd",
  21667. "domContentLoadedEventStart",
  21668. "domInteractive",
  21669. "domLoading",
  21670. "domOverlayState",
  21671. "domain",
  21672. "domainLookupEnd",
  21673. "domainLookupStart",
  21674. "dominant-baseline",
  21675. "dominantBaseline",
  21676. "done",
  21677. "dopplerFactor",
  21678. "dotAll",
  21679. "downDegrees",
  21680. "downlink",
  21681. "download",
  21682. "downloadTotal",
  21683. "downloaded",
  21684. "dpcm",
  21685. "dpi",
  21686. "dppx",
  21687. "dragDrop",
  21688. "draggable",
  21689. "drawArrays",
  21690. "drawArraysInstanced",
  21691. "drawArraysInstancedANGLE",
  21692. "drawBuffers",
  21693. "drawCustomFocusRing",
  21694. "drawElements",
  21695. "drawElementsInstanced",
  21696. "drawElementsInstancedANGLE",
  21697. "drawFocusIfNeeded",
  21698. "drawImage",
  21699. "drawImageFromRect",
  21700. "drawRangeElements",
  21701. "drawSystemFocusRing",
  21702. "drawingBufferHeight",
  21703. "drawingBufferWidth",
  21704. "dropEffect",
  21705. "droppedVideoFrames",
  21706. "dropzone",
  21707. "dtmf",
  21708. "dump",
  21709. "dumpProfile",
  21710. "duplicate",
  21711. "durability",
  21712. "duration",
  21713. "dvname",
  21714. "dvnum",
  21715. "dx",
  21716. "dy",
  21717. "dynsrc",
  21718. "e",
  21719. "edgeMode",
  21720. "effect",
  21721. "effectAllowed",
  21722. "effectiveDirective",
  21723. "effectiveType",
  21724. "elapsedTime",
  21725. "element",
  21726. "elementFromPoint",
  21727. "elementTiming",
  21728. "elements",
  21729. "elementsFromPoint",
  21730. "elevation",
  21731. "ellipse",
  21732. "em",
  21733. "email",
  21734. "embeds",
  21735. "emma",
  21736. "empty",
  21737. "empty-cells",
  21738. "emptyCells",
  21739. "emptyHTML",
  21740. "emptyScript",
  21741. "emulatedPosition",
  21742. "enable",
  21743. "enableBackground",
  21744. "enableDelegations",
  21745. "enableStyleSheetsForSet",
  21746. "enableVertexAttribArray",
  21747. "enabled",
  21748. "enabledPlugin",
  21749. "encode",
  21750. "encodeInto",
  21751. "encodeURI",
  21752. "encodeURIComponent",
  21753. "encodedBodySize",
  21754. "encoding",
  21755. "encodingInfo",
  21756. "encrypt",
  21757. "enctype",
  21758. "end",
  21759. "endContainer",
  21760. "endElement",
  21761. "endElementAt",
  21762. "endOfStream",
  21763. "endOffset",
  21764. "endQuery",
  21765. "endTime",
  21766. "endTransformFeedback",
  21767. "ended",
  21768. "endpoint",
  21769. "endpointNumber",
  21770. "endpoints",
  21771. "endsWith",
  21772. "enterKeyHint",
  21773. "entities",
  21774. "entries",
  21775. "entryType",
  21776. "enumerate",
  21777. "enumerateDevices",
  21778. "enumerateEditable",
  21779. "environmentBlendMode",
  21780. "equals",
  21781. "error",
  21782. "errorCode",
  21783. "errorDetail",
  21784. "errorText",
  21785. "escape",
  21786. "estimate",
  21787. "eval",
  21788. "evaluate",
  21789. "event",
  21790. "eventPhase",
  21791. "every",
  21792. "ex",
  21793. "exception",
  21794. "exchange",
  21795. "exec",
  21796. "execCommand",
  21797. "execCommandShowHelp",
  21798. "execScript",
  21799. "exitFullscreen",
  21800. "exitPictureInPicture",
  21801. "exitPointerLock",
  21802. "exitPresent",
  21803. "exp",
  21804. "expand",
  21805. "expandEntityReferences",
  21806. "expando",
  21807. "expansion",
  21808. "expiration",
  21809. "expirationTime",
  21810. "expires",
  21811. "expiryDate",
  21812. "explicitOriginalTarget",
  21813. "expm1",
  21814. "exponent",
  21815. "exponentialRampToValueAtTime",
  21816. "exportKey",
  21817. "exports",
  21818. "extend",
  21819. "extensions",
  21820. "extentNode",
  21821. "extentOffset",
  21822. "external",
  21823. "externalResourcesRequired",
  21824. "extractContents",
  21825. "extractable",
  21826. "eye",
  21827. "f",
  21828. "face",
  21829. "factoryReset",
  21830. "failureReason",
  21831. "fallback",
  21832. "family",
  21833. "familyName",
  21834. "farthestViewportElement",
  21835. "fastSeek",
  21836. "fatal",
  21837. "featureId",
  21838. "featurePolicy",
  21839. "featureSettings",
  21840. "features",
  21841. "fenceSync",
  21842. "fetch",
  21843. "fetchStart",
  21844. "fftSize",
  21845. "fgColor",
  21846. "fieldOfView",
  21847. "file",
  21848. "fileCreatedDate",
  21849. "fileHandle",
  21850. "fileModifiedDate",
  21851. "fileName",
  21852. "fileSize",
  21853. "fileUpdatedDate",
  21854. "filename",
  21855. "files",
  21856. "filesystem",
  21857. "fill",
  21858. "fill-opacity",
  21859. "fill-rule",
  21860. "fillLightMode",
  21861. "fillOpacity",
  21862. "fillRect",
  21863. "fillRule",
  21864. "fillStyle",
  21865. "fillText",
  21866. "filter",
  21867. "filterResX",
  21868. "filterResY",
  21869. "filterUnits",
  21870. "filters",
  21871. "finally",
  21872. "find",
  21873. "findIndex",
  21874. "findRule",
  21875. "findText",
  21876. "finish",
  21877. "finished",
  21878. "fireEvent",
  21879. "firesTouchEvents",
  21880. "firstChild",
  21881. "firstElementChild",
  21882. "firstPage",
  21883. "fixed",
  21884. "flags",
  21885. "flat",
  21886. "flatMap",
  21887. "flex",
  21888. "flex-basis",
  21889. "flex-direction",
  21890. "flex-flow",
  21891. "flex-grow",
  21892. "flex-shrink",
  21893. "flex-wrap",
  21894. "flexBasis",
  21895. "flexDirection",
  21896. "flexFlow",
  21897. "flexGrow",
  21898. "flexShrink",
  21899. "flexWrap",
  21900. "flipX",
  21901. "flipY",
  21902. "float",
  21903. "float32",
  21904. "float64",
  21905. "flood-color",
  21906. "flood-opacity",
  21907. "floodColor",
  21908. "floodOpacity",
  21909. "floor",
  21910. "flush",
  21911. "focus",
  21912. "focusNode",
  21913. "focusOffset",
  21914. "font",
  21915. "font-family",
  21916. "font-feature-settings",
  21917. "font-kerning",
  21918. "font-language-override",
  21919. "font-optical-sizing",
  21920. "font-size",
  21921. "font-size-adjust",
  21922. "font-stretch",
  21923. "font-style",
  21924. "font-synthesis",
  21925. "font-variant",
  21926. "font-variant-alternates",
  21927. "font-variant-caps",
  21928. "font-variant-east-asian",
  21929. "font-variant-ligatures",
  21930. "font-variant-numeric",
  21931. "font-variant-position",
  21932. "font-variation-settings",
  21933. "font-weight",
  21934. "fontFamily",
  21935. "fontFeatureSettings",
  21936. "fontKerning",
  21937. "fontLanguageOverride",
  21938. "fontOpticalSizing",
  21939. "fontSize",
  21940. "fontSizeAdjust",
  21941. "fontSmoothingEnabled",
  21942. "fontStretch",
  21943. "fontStyle",
  21944. "fontSynthesis",
  21945. "fontVariant",
  21946. "fontVariantAlternates",
  21947. "fontVariantCaps",
  21948. "fontVariantEastAsian",
  21949. "fontVariantLigatures",
  21950. "fontVariantNumeric",
  21951. "fontVariantPosition",
  21952. "fontVariationSettings",
  21953. "fontWeight",
  21954. "fontcolor",
  21955. "fontfaces",
  21956. "fonts",
  21957. "fontsize",
  21958. "for",
  21959. "forEach",
  21960. "force",
  21961. "forceRedraw",
  21962. "form",
  21963. "formAction",
  21964. "formData",
  21965. "formEnctype",
  21966. "formMethod",
  21967. "formNoValidate",
  21968. "formTarget",
  21969. "format",
  21970. "formatToParts",
  21971. "forms",
  21972. "forward",
  21973. "forwardX",
  21974. "forwardY",
  21975. "forwardZ",
  21976. "foundation",
  21977. "fr",
  21978. "fragmentDirective",
  21979. "frame",
  21980. "frameBorder",
  21981. "frameElement",
  21982. "frameSpacing",
  21983. "framebuffer",
  21984. "framebufferHeight",
  21985. "framebufferRenderbuffer",
  21986. "framebufferTexture2D",
  21987. "framebufferTextureLayer",
  21988. "framebufferWidth",
  21989. "frames",
  21990. "freeSpace",
  21991. "freeze",
  21992. "frequency",
  21993. "frequencyBinCount",
  21994. "from",
  21995. "fromCharCode",
  21996. "fromCodePoint",
  21997. "fromElement",
  21998. "fromEntries",
  21999. "fromFloat32Array",
  22000. "fromFloat64Array",
  22001. "fromMatrix",
  22002. "fromPoint",
  22003. "fromQuad",
  22004. "fromRect",
  22005. "frontFace",
  22006. "fround",
  22007. "fullPath",
  22008. "fullScreen",
  22009. "fullscreen",
  22010. "fullscreenElement",
  22011. "fullscreenEnabled",
  22012. "fx",
  22013. "fy",
  22014. "gain",
  22015. "gamepad",
  22016. "gamma",
  22017. "gap",
  22018. "gatheringState",
  22019. "gatt",
  22020. "genderIdentity",
  22021. "generateCertificate",
  22022. "generateKey",
  22023. "generateMipmap",
  22024. "generateRequest",
  22025. "geolocation",
  22026. "gestureObject",
  22027. "get",
  22028. "getActiveAttrib",
  22029. "getActiveUniform",
  22030. "getActiveUniformBlockName",
  22031. "getActiveUniformBlockParameter",
  22032. "getActiveUniforms",
  22033. "getAdjacentText",
  22034. "getAll",
  22035. "getAllKeys",
  22036. "getAllResponseHeaders",
  22037. "getAllowlistForFeature",
  22038. "getAnimations",
  22039. "getAsFile",
  22040. "getAsString",
  22041. "getAttachedShaders",
  22042. "getAttribLocation",
  22043. "getAttribute",
  22044. "getAttributeNS",
  22045. "getAttributeNames",
  22046. "getAttributeNode",
  22047. "getAttributeNodeNS",
  22048. "getAttributeType",
  22049. "getAudioTracks",
  22050. "getAvailability",
  22051. "getBBox",
  22052. "getBattery",
  22053. "getBigInt64",
  22054. "getBigUint64",
  22055. "getBlob",
  22056. "getBookmark",
  22057. "getBoundingClientRect",
  22058. "getBounds",
  22059. "getBoxQuads",
  22060. "getBufferParameter",
  22061. "getBufferSubData",
  22062. "getByteFrequencyData",
  22063. "getByteTimeDomainData",
  22064. "getCSSCanvasContext",
  22065. "getCTM",
  22066. "getCandidateWindowClientRect",
  22067. "getCanonicalLocales",
  22068. "getCapabilities",
  22069. "getChannelData",
  22070. "getCharNumAtPosition",
  22071. "getCharacteristic",
  22072. "getCharacteristics",
  22073. "getClientExtensionResults",
  22074. "getClientRect",
  22075. "getClientRects",
  22076. "getCoalescedEvents",
  22077. "getCompositionAlternatives",
  22078. "getComputedStyle",
  22079. "getComputedTextLength",
  22080. "getComputedTiming",
  22081. "getConfiguration",
  22082. "getConstraints",
  22083. "getContext",
  22084. "getContextAttributes",
  22085. "getContributingSources",
  22086. "getCounterValue",
  22087. "getCueAsHTML",
  22088. "getCueById",
  22089. "getCurrentPosition",
  22090. "getCurrentTime",
  22091. "getData",
  22092. "getDatabaseNames",
  22093. "getDate",
  22094. "getDay",
  22095. "getDefaultComputedStyle",
  22096. "getDescriptor",
  22097. "getDescriptors",
  22098. "getDestinationInsertionPoints",
  22099. "getDevices",
  22100. "getDirectory",
  22101. "getDisplayMedia",
  22102. "getDistributedNodes",
  22103. "getEditable",
  22104. "getElementById",
  22105. "getElementsByClassName",
  22106. "getElementsByName",
  22107. "getElementsByTagName",
  22108. "getElementsByTagNameNS",
  22109. "getEnclosureList",
  22110. "getEndPositionOfChar",
  22111. "getEntries",
  22112. "getEntriesByName",
  22113. "getEntriesByType",
  22114. "getError",
  22115. "getExtension",
  22116. "getExtentOfChar",
  22117. "getEyeParameters",
  22118. "getFeature",
  22119. "getFile",
  22120. "getFiles",
  22121. "getFilesAndDirectories",
  22122. "getFingerprints",
  22123. "getFloat32",
  22124. "getFloat64",
  22125. "getFloatFrequencyData",
  22126. "getFloatTimeDomainData",
  22127. "getFloatValue",
  22128. "getFragDataLocation",
  22129. "getFrameData",
  22130. "getFramebufferAttachmentParameter",
  22131. "getFrequencyResponse",
  22132. "getFullYear",
  22133. "getGamepads",
  22134. "getHitTestResults",
  22135. "getHitTestResultsForTransientInput",
  22136. "getHours",
  22137. "getIdentityAssertion",
  22138. "getIds",
  22139. "getImageData",
  22140. "getIndexedParameter",
  22141. "getInstalledRelatedApps",
  22142. "getInt16",
  22143. "getInt32",
  22144. "getInt8",
  22145. "getInternalformatParameter",
  22146. "getIntersectionList",
  22147. "getItem",
  22148. "getItems",
  22149. "getKey",
  22150. "getKeyframes",
  22151. "getLayers",
  22152. "getLayoutMap",
  22153. "getLineDash",
  22154. "getLocalCandidates",
  22155. "getLocalParameters",
  22156. "getLocalStreams",
  22157. "getMarks",
  22158. "getMatchedCSSRules",
  22159. "getMaxGCPauseSinceClear",
  22160. "getMeasures",
  22161. "getMetadata",
  22162. "getMilliseconds",
  22163. "getMinutes",
  22164. "getModifierState",
  22165. "getMonth",
  22166. "getNamedItem",
  22167. "getNamedItemNS",
  22168. "getNativeFramebufferScaleFactor",
  22169. "getNotifications",
  22170. "getNotifier",
  22171. "getNumberOfChars",
  22172. "getOffsetReferenceSpace",
  22173. "getOutputTimestamp",
  22174. "getOverrideHistoryNavigationMode",
  22175. "getOverrideStyle",
  22176. "getOwnPropertyDescriptor",
  22177. "getOwnPropertyDescriptors",
  22178. "getOwnPropertyNames",
  22179. "getOwnPropertySymbols",
  22180. "getParameter",
  22181. "getParameters",
  22182. "getParent",
  22183. "getPathSegAtLength",
  22184. "getPhotoCapabilities",
  22185. "getPhotoSettings",
  22186. "getPointAtLength",
  22187. "getPose",
  22188. "getPredictedEvents",
  22189. "getPreference",
  22190. "getPreferenceDefault",
  22191. "getPresentationAttribute",
  22192. "getPreventDefault",
  22193. "getPrimaryService",
  22194. "getPrimaryServices",
  22195. "getProgramInfoLog",
  22196. "getProgramParameter",
  22197. "getPropertyCSSValue",
  22198. "getPropertyPriority",
  22199. "getPropertyShorthand",
  22200. "getPropertyType",
  22201. "getPropertyValue",
  22202. "getPrototypeOf",
  22203. "getQuery",
  22204. "getQueryParameter",
  22205. "getRGBColorValue",
  22206. "getRandomValues",
  22207. "getRangeAt",
  22208. "getReader",
  22209. "getReceivers",
  22210. "getRectValue",
  22211. "getRegistration",
  22212. "getRegistrations",
  22213. "getRemoteCandidates",
  22214. "getRemoteCertificates",
  22215. "getRemoteParameters",
  22216. "getRemoteStreams",
  22217. "getRenderbufferParameter",
  22218. "getResponseHeader",
  22219. "getRoot",
  22220. "getRootNode",
  22221. "getRotationOfChar",
  22222. "getSVGDocument",
  22223. "getSamplerParameter",
  22224. "getScreenCTM",
  22225. "getSeconds",
  22226. "getSelectedCandidatePair",
  22227. "getSelection",
  22228. "getSenders",
  22229. "getService",
  22230. "getSettings",
  22231. "getShaderInfoLog",
  22232. "getShaderParameter",
  22233. "getShaderPrecisionFormat",
  22234. "getShaderSource",
  22235. "getSimpleDuration",
  22236. "getSiteIcons",
  22237. "getSources",
  22238. "getSpeculativeParserUrls",
  22239. "getStartPositionOfChar",
  22240. "getStartTime",
  22241. "getState",
  22242. "getStats",
  22243. "getStatusForPolicy",
  22244. "getStorageUpdates",
  22245. "getStreamById",
  22246. "getStringValue",
  22247. "getSubStringLength",
  22248. "getSubscription",
  22249. "getSupportedConstraints",
  22250. "getSupportedExtensions",
  22251. "getSupportedFormats",
  22252. "getSyncParameter",
  22253. "getSynchronizationSources",
  22254. "getTags",
  22255. "getTargetRanges",
  22256. "getTexParameter",
  22257. "getTime",
  22258. "getTimezoneOffset",
  22259. "getTiming",
  22260. "getTotalLength",
  22261. "getTrackById",
  22262. "getTracks",
  22263. "getTransceivers",
  22264. "getTransform",
  22265. "getTransformFeedbackVarying",
  22266. "getTransformToElement",
  22267. "getTransports",
  22268. "getType",
  22269. "getTypeMapping",
  22270. "getUTCDate",
  22271. "getUTCDay",
  22272. "getUTCFullYear",
  22273. "getUTCHours",
  22274. "getUTCMilliseconds",
  22275. "getUTCMinutes",
  22276. "getUTCMonth",
  22277. "getUTCSeconds",
  22278. "getUint16",
  22279. "getUint32",
  22280. "getUint8",
  22281. "getUniform",
  22282. "getUniformBlockIndex",
  22283. "getUniformIndices",
  22284. "getUniformLocation",
  22285. "getUserMedia",
  22286. "getVRDisplays",
  22287. "getValues",
  22288. "getVarDate",
  22289. "getVariableValue",
  22290. "getVertexAttrib",
  22291. "getVertexAttribOffset",
  22292. "getVideoPlaybackQuality",
  22293. "getVideoTracks",
  22294. "getViewerPose",
  22295. "getViewport",
  22296. "getVoices",
  22297. "getWakeLockState",
  22298. "getWriter",
  22299. "getYear",
  22300. "givenName",
  22301. "global",
  22302. "globalAlpha",
  22303. "globalCompositeOperation",
  22304. "globalThis",
  22305. "glyphOrientationHorizontal",
  22306. "glyphOrientationVertical",
  22307. "glyphRef",
  22308. "go",
  22309. "grabFrame",
  22310. "grad",
  22311. "gradientTransform",
  22312. "gradientUnits",
  22313. "grammars",
  22314. "green",
  22315. "grid",
  22316. "grid-area",
  22317. "grid-auto-columns",
  22318. "grid-auto-flow",
  22319. "grid-auto-rows",
  22320. "grid-column",
  22321. "grid-column-end",
  22322. "grid-column-gap",
  22323. "grid-column-start",
  22324. "grid-gap",
  22325. "grid-row",
  22326. "grid-row-end",
  22327. "grid-row-gap",
  22328. "grid-row-start",
  22329. "grid-template",
  22330. "grid-template-areas",
  22331. "grid-template-columns",
  22332. "grid-template-rows",
  22333. "gridArea",
  22334. "gridAutoColumns",
  22335. "gridAutoFlow",
  22336. "gridAutoRows",
  22337. "gridColumn",
  22338. "gridColumnEnd",
  22339. "gridColumnGap",
  22340. "gridColumnStart",
  22341. "gridGap",
  22342. "gridRow",
  22343. "gridRowEnd",
  22344. "gridRowGap",
  22345. "gridRowStart",
  22346. "gridTemplate",
  22347. "gridTemplateAreas",
  22348. "gridTemplateColumns",
  22349. "gridTemplateRows",
  22350. "gripSpace",
  22351. "group",
  22352. "groupCollapsed",
  22353. "groupEnd",
  22354. "groupId",
  22355. "hadRecentInput",
  22356. "hand",
  22357. "handedness",
  22358. "hapticActuators",
  22359. "hardwareConcurrency",
  22360. "has",
  22361. "hasAttribute",
  22362. "hasAttributeNS",
  22363. "hasAttributes",
  22364. "hasBeenActive",
  22365. "hasChildNodes",
  22366. "hasComposition",
  22367. "hasEnrolledInstrument",
  22368. "hasExtension",
  22369. "hasExternalDisplay",
  22370. "hasFeature",
  22371. "hasFocus",
  22372. "hasInstance",
  22373. "hasLayout",
  22374. "hasOrientation",
  22375. "hasOwnProperty",
  22376. "hasPointerCapture",
  22377. "hasPosition",
  22378. "hasReading",
  22379. "hasStorageAccess",
  22380. "hash",
  22381. "head",
  22382. "headers",
  22383. "heading",
  22384. "height",
  22385. "hidden",
  22386. "hide",
  22387. "hideFocus",
  22388. "high",
  22389. "highWaterMark",
  22390. "hint",
  22391. "history",
  22392. "honorificPrefix",
  22393. "honorificSuffix",
  22394. "horizontalOverflow",
  22395. "host",
  22396. "hostCandidate",
  22397. "hostname",
  22398. "href",
  22399. "hrefTranslate",
  22400. "hreflang",
  22401. "hspace",
  22402. "html5TagCheckInerface",
  22403. "htmlFor",
  22404. "htmlText",
  22405. "httpEquiv",
  22406. "httpRequestStatusCode",
  22407. "hwTimestamp",
  22408. "hyphens",
  22409. "hypot",
  22410. "iccId",
  22411. "iceConnectionState",
  22412. "iceGatheringState",
  22413. "iceTransport",
  22414. "icon",
  22415. "iconURL",
  22416. "id",
  22417. "identifier",
  22418. "identity",
  22419. "idpLoginUrl",
  22420. "ignoreBOM",
  22421. "ignoreCase",
  22422. "ignoreDepthValues",
  22423. "image-orientation",
  22424. "image-rendering",
  22425. "imageHeight",
  22426. "imageOrientation",
  22427. "imageRendering",
  22428. "imageSizes",
  22429. "imageSmoothingEnabled",
  22430. "imageSmoothingQuality",
  22431. "imageSrcset",
  22432. "imageWidth",
  22433. "images",
  22434. "ime-mode",
  22435. "imeMode",
  22436. "implementation",
  22437. "importKey",
  22438. "importNode",
  22439. "importStylesheet",
  22440. "imports",
  22441. "impp",
  22442. "imul",
  22443. "in",
  22444. "in1",
  22445. "in2",
  22446. "inBandMetadataTrackDispatchType",
  22447. "inRange",
  22448. "includes",
  22449. "incremental",
  22450. "indeterminate",
  22451. "index",
  22452. "indexNames",
  22453. "indexOf",
  22454. "indexedDB",
  22455. "indicate",
  22456. "inertiaDestinationX",
  22457. "inertiaDestinationY",
  22458. "info",
  22459. "init",
  22460. "initAnimationEvent",
  22461. "initBeforeLoadEvent",
  22462. "initClipboardEvent",
  22463. "initCloseEvent",
  22464. "initCommandEvent",
  22465. "initCompositionEvent",
  22466. "initCustomEvent",
  22467. "initData",
  22468. "initDataType",
  22469. "initDeviceMotionEvent",
  22470. "initDeviceOrientationEvent",
  22471. "initDragEvent",
  22472. "initErrorEvent",
  22473. "initEvent",
  22474. "initFocusEvent",
  22475. "initGestureEvent",
  22476. "initHashChangeEvent",
  22477. "initKeyEvent",
  22478. "initKeyboardEvent",
  22479. "initMSManipulationEvent",
  22480. "initMessageEvent",
  22481. "initMouseEvent",
  22482. "initMouseScrollEvent",
  22483. "initMouseWheelEvent",
  22484. "initMutationEvent",
  22485. "initNSMouseEvent",
  22486. "initOverflowEvent",
  22487. "initPageEvent",
  22488. "initPageTransitionEvent",
  22489. "initPointerEvent",
  22490. "initPopStateEvent",
  22491. "initProgressEvent",
  22492. "initScrollAreaEvent",
  22493. "initSimpleGestureEvent",
  22494. "initStorageEvent",
  22495. "initTextEvent",
  22496. "initTimeEvent",
  22497. "initTouchEvent",
  22498. "initTransitionEvent",
  22499. "initUIEvent",
  22500. "initWebKitAnimationEvent",
  22501. "initWebKitTransitionEvent",
  22502. "initWebKitWheelEvent",
  22503. "initWheelEvent",
  22504. "initialTime",
  22505. "initialize",
  22506. "initiatorType",
  22507. "inline-size",
  22508. "inlineSize",
  22509. "inlineVerticalFieldOfView",
  22510. "inner",
  22511. "innerHTML",
  22512. "innerHeight",
  22513. "innerText",
  22514. "innerWidth",
  22515. "input",
  22516. "inputBuffer",
  22517. "inputEncoding",
  22518. "inputMethod",
  22519. "inputMode",
  22520. "inputSource",
  22521. "inputSources",
  22522. "inputType",
  22523. "inputs",
  22524. "insertAdjacentElement",
  22525. "insertAdjacentHTML",
  22526. "insertAdjacentText",
  22527. "insertBefore",
  22528. "insertCell",
  22529. "insertDTMF",
  22530. "insertData",
  22531. "insertItemBefore",
  22532. "insertNode",
  22533. "insertRow",
  22534. "insertRule",
  22535. "inset",
  22536. "inset-block",
  22537. "inset-block-end",
  22538. "inset-block-start",
  22539. "inset-inline",
  22540. "inset-inline-end",
  22541. "inset-inline-start",
  22542. "insetBlock",
  22543. "insetBlockEnd",
  22544. "insetBlockStart",
  22545. "insetInline",
  22546. "insetInlineEnd",
  22547. "insetInlineStart",
  22548. "installing",
  22549. "instanceRoot",
  22550. "instantiate",
  22551. "instantiateStreaming",
  22552. "instruments",
  22553. "int16",
  22554. "int32",
  22555. "int8",
  22556. "integrity",
  22557. "interactionMode",
  22558. "intercept",
  22559. "interfaceClass",
  22560. "interfaceName",
  22561. "interfaceNumber",
  22562. "interfaceProtocol",
  22563. "interfaceSubclass",
  22564. "interfaces",
  22565. "interimResults",
  22566. "internalSubset",
  22567. "interpretation",
  22568. "intersectionRatio",
  22569. "intersectionRect",
  22570. "intersectsNode",
  22571. "interval",
  22572. "invalidIteratorState",
  22573. "invalidateFramebuffer",
  22574. "invalidateSubFramebuffer",
  22575. "inverse",
  22576. "invertSelf",
  22577. "is",
  22578. "is2D",
  22579. "isActive",
  22580. "isAlternate",
  22581. "isArray",
  22582. "isBingCurrentSearchDefault",
  22583. "isBuffer",
  22584. "isCandidateWindowVisible",
  22585. "isChar",
  22586. "isCollapsed",
  22587. "isComposing",
  22588. "isConcatSpreadable",
  22589. "isConnected",
  22590. "isContentEditable",
  22591. "isContentHandlerRegistered",
  22592. "isContextLost",
  22593. "isDefaultNamespace",
  22594. "isDirectory",
  22595. "isDisabled",
  22596. "isEnabled",
  22597. "isEqual",
  22598. "isEqualNode",
  22599. "isExtensible",
  22600. "isExternalCTAP2SecurityKeySupported",
  22601. "isFile",
  22602. "isFinite",
  22603. "isFramebuffer",
  22604. "isFrozen",
  22605. "isGenerator",
  22606. "isHTML",
  22607. "isHistoryNavigation",
  22608. "isId",
  22609. "isIdentity",
  22610. "isInjected",
  22611. "isInteger",
  22612. "isIntersecting",
  22613. "isLockFree",
  22614. "isMap",
  22615. "isMultiLine",
  22616. "isNaN",
  22617. "isOpen",
  22618. "isPointInFill",
  22619. "isPointInPath",
  22620. "isPointInRange",
  22621. "isPointInStroke",
  22622. "isPrefAlternate",
  22623. "isPresenting",
  22624. "isPrimary",
  22625. "isProgram",
  22626. "isPropertyImplicit",
  22627. "isProtocolHandlerRegistered",
  22628. "isPrototypeOf",
  22629. "isQuery",
  22630. "isRenderbuffer",
  22631. "isSafeInteger",
  22632. "isSameNode",
  22633. "isSampler",
  22634. "isScript",
  22635. "isScriptURL",
  22636. "isSealed",
  22637. "isSecureContext",
  22638. "isSessionSupported",
  22639. "isShader",
  22640. "isSupported",
  22641. "isSync",
  22642. "isTextEdit",
  22643. "isTexture",
  22644. "isTransformFeedback",
  22645. "isTrusted",
  22646. "isTypeSupported",
  22647. "isUserVerifyingPlatformAuthenticatorAvailable",
  22648. "isVertexArray",
  22649. "isView",
  22650. "isVisible",
  22651. "isochronousTransferIn",
  22652. "isochronousTransferOut",
  22653. "isolation",
  22654. "italics",
  22655. "item",
  22656. "itemId",
  22657. "itemProp",
  22658. "itemRef",
  22659. "itemScope",
  22660. "itemType",
  22661. "itemValue",
  22662. "items",
  22663. "iterateNext",
  22664. "iterationComposite",
  22665. "iterator",
  22666. "javaEnabled",
  22667. "jobTitle",
  22668. "join",
  22669. "json",
  22670. "justify-content",
  22671. "justify-items",
  22672. "justify-self",
  22673. "justifyContent",
  22674. "justifyItems",
  22675. "justifySelf",
  22676. "k1",
  22677. "k2",
  22678. "k3",
  22679. "k4",
  22680. "kHz",
  22681. "keepalive",
  22682. "kernelMatrix",
  22683. "kernelUnitLengthX",
  22684. "kernelUnitLengthY",
  22685. "kerning",
  22686. "key",
  22687. "keyCode",
  22688. "keyFor",
  22689. "keyIdentifier",
  22690. "keyLightEnabled",
  22691. "keyLocation",
  22692. "keyPath",
  22693. "keyStatuses",
  22694. "keySystem",
  22695. "keyText",
  22696. "keyUsage",
  22697. "keyboard",
  22698. "keys",
  22699. "keytype",
  22700. "kind",
  22701. "knee",
  22702. "label",
  22703. "labels",
  22704. "lang",
  22705. "language",
  22706. "languages",
  22707. "largeArcFlag",
  22708. "lastChild",
  22709. "lastElementChild",
  22710. "lastEventId",
  22711. "lastIndex",
  22712. "lastIndexOf",
  22713. "lastInputTime",
  22714. "lastMatch",
  22715. "lastMessageSubject",
  22716. "lastMessageType",
  22717. "lastModified",
  22718. "lastModifiedDate",
  22719. "lastPage",
  22720. "lastParen",
  22721. "lastState",
  22722. "lastStyleSheetSet",
  22723. "latitude",
  22724. "layerX",
  22725. "layerY",
  22726. "layoutFlow",
  22727. "layoutGrid",
  22728. "layoutGridChar",
  22729. "layoutGridLine",
  22730. "layoutGridMode",
  22731. "layoutGridType",
  22732. "lbound",
  22733. "left",
  22734. "leftContext",
  22735. "leftDegrees",
  22736. "leftMargin",
  22737. "leftProjectionMatrix",
  22738. "leftViewMatrix",
  22739. "length",
  22740. "lengthAdjust",
  22741. "lengthComputable",
  22742. "letter-spacing",
  22743. "letterSpacing",
  22744. "level",
  22745. "lighting-color",
  22746. "lightingColor",
  22747. "limitingConeAngle",
  22748. "line",
  22749. "line-break",
  22750. "line-height",
  22751. "lineAlign",
  22752. "lineBreak",
  22753. "lineCap",
  22754. "lineDashOffset",
  22755. "lineHeight",
  22756. "lineJoin",
  22757. "lineNumber",
  22758. "lineTo",
  22759. "lineWidth",
  22760. "linearAcceleration",
  22761. "linearRampToValueAtTime",
  22762. "linearVelocity",
  22763. "lineno",
  22764. "lines",
  22765. "link",
  22766. "linkColor",
  22767. "linkProgram",
  22768. "links",
  22769. "list",
  22770. "list-style",
  22771. "list-style-image",
  22772. "list-style-position",
  22773. "list-style-type",
  22774. "listStyle",
  22775. "listStyleImage",
  22776. "listStylePosition",
  22777. "listStyleType",
  22778. "listener",
  22779. "load",
  22780. "loadEventEnd",
  22781. "loadEventStart",
  22782. "loadTime",
  22783. "loadTimes",
  22784. "loaded",
  22785. "loading",
  22786. "localDescription",
  22787. "localName",
  22788. "localService",
  22789. "localStorage",
  22790. "locale",
  22791. "localeCompare",
  22792. "location",
  22793. "locationbar",
  22794. "lock",
  22795. "locked",
  22796. "lockedFile",
  22797. "locks",
  22798. "log",
  22799. "log10",
  22800. "log1p",
  22801. "log2",
  22802. "logicalXDPI",
  22803. "logicalYDPI",
  22804. "longDesc",
  22805. "longitude",
  22806. "lookupNamespaceURI",
  22807. "lookupPrefix",
  22808. "loop",
  22809. "loopEnd",
  22810. "loopStart",
  22811. "looping",
  22812. "low",
  22813. "lower",
  22814. "lowerBound",
  22815. "lowerOpen",
  22816. "lowsrc",
  22817. "m11",
  22818. "m12",
  22819. "m13",
  22820. "m14",
  22821. "m21",
  22822. "m22",
  22823. "m23",
  22824. "m24",
  22825. "m31",
  22826. "m32",
  22827. "m33",
  22828. "m34",
  22829. "m41",
  22830. "m42",
  22831. "m43",
  22832. "m44",
  22833. "makeXRCompatible",
  22834. "manifest",
  22835. "manufacturer",
  22836. "manufacturerName",
  22837. "map",
  22838. "mapping",
  22839. "margin",
  22840. "margin-block",
  22841. "margin-block-end",
  22842. "margin-block-start",
  22843. "margin-bottom",
  22844. "margin-inline",
  22845. "margin-inline-end",
  22846. "margin-inline-start",
  22847. "margin-left",
  22848. "margin-right",
  22849. "margin-top",
  22850. "marginBlock",
  22851. "marginBlockEnd",
  22852. "marginBlockStart",
  22853. "marginBottom",
  22854. "marginHeight",
  22855. "marginInline",
  22856. "marginInlineEnd",
  22857. "marginInlineStart",
  22858. "marginLeft",
  22859. "marginRight",
  22860. "marginTop",
  22861. "marginWidth",
  22862. "mark",
  22863. "marker",
  22864. "marker-end",
  22865. "marker-mid",
  22866. "marker-offset",
  22867. "marker-start",
  22868. "markerEnd",
  22869. "markerHeight",
  22870. "markerMid",
  22871. "markerOffset",
  22872. "markerStart",
  22873. "markerUnits",
  22874. "markerWidth",
  22875. "marks",
  22876. "mask",
  22877. "mask-clip",
  22878. "mask-composite",
  22879. "mask-image",
  22880. "mask-mode",
  22881. "mask-origin",
  22882. "mask-position",
  22883. "mask-position-x",
  22884. "mask-position-y",
  22885. "mask-repeat",
  22886. "mask-size",
  22887. "mask-type",
  22888. "maskClip",
  22889. "maskComposite",
  22890. "maskContentUnits",
  22891. "maskImage",
  22892. "maskMode",
  22893. "maskOrigin",
  22894. "maskPosition",
  22895. "maskPositionX",
  22896. "maskPositionY",
  22897. "maskRepeat",
  22898. "maskSize",
  22899. "maskType",
  22900. "maskUnits",
  22901. "match",
  22902. "matchAll",
  22903. "matchMedia",
  22904. "matchMedium",
  22905. "matches",
  22906. "matrix",
  22907. "matrixTransform",
  22908. "max",
  22909. "max-block-size",
  22910. "max-height",
  22911. "max-inline-size",
  22912. "max-width",
  22913. "maxActions",
  22914. "maxAlternatives",
  22915. "maxBlockSize",
  22916. "maxChannelCount",
  22917. "maxChannels",
  22918. "maxConnectionsPerServer",
  22919. "maxDecibels",
  22920. "maxDistance",
  22921. "maxHeight",
  22922. "maxInlineSize",
  22923. "maxLayers",
  22924. "maxLength",
  22925. "maxMessageSize",
  22926. "maxPacketLifeTime",
  22927. "maxRetransmits",
  22928. "maxTouchPoints",
  22929. "maxValue",
  22930. "maxWidth",
  22931. "measure",
  22932. "measureText",
  22933. "media",
  22934. "mediaCapabilities",
  22935. "mediaDevices",
  22936. "mediaElement",
  22937. "mediaGroup",
  22938. "mediaKeys",
  22939. "mediaSession",
  22940. "mediaStream",
  22941. "mediaText",
  22942. "meetOrSlice",
  22943. "memory",
  22944. "menubar",
  22945. "mergeAttributes",
  22946. "message",
  22947. "messageClass",
  22948. "messageHandlers",
  22949. "messageType",
  22950. "metaKey",
  22951. "metadata",
  22952. "method",
  22953. "methodDetails",
  22954. "methodName",
  22955. "mid",
  22956. "mimeType",
  22957. "mimeTypes",
  22958. "min",
  22959. "min-block-size",
  22960. "min-height",
  22961. "min-inline-size",
  22962. "min-width",
  22963. "minBlockSize",
  22964. "minDecibels",
  22965. "minHeight",
  22966. "minInlineSize",
  22967. "minLength",
  22968. "minValue",
  22969. "minWidth",
  22970. "miterLimit",
  22971. "mix-blend-mode",
  22972. "mixBlendMode",
  22973. "mm",
  22974. "mode",
  22975. "modify",
  22976. "mount",
  22977. "move",
  22978. "moveBy",
  22979. "moveEnd",
  22980. "moveFirst",
  22981. "moveFocusDown",
  22982. "moveFocusLeft",
  22983. "moveFocusRight",
  22984. "moveFocusUp",
  22985. "moveNext",
  22986. "moveRow",
  22987. "moveStart",
  22988. "moveTo",
  22989. "moveToBookmark",
  22990. "moveToElementText",
  22991. "moveToPoint",
  22992. "movementX",
  22993. "movementY",
  22994. "mozAdd",
  22995. "mozAnimationStartTime",
  22996. "mozAnon",
  22997. "mozApps",
  22998. "mozAudioCaptured",
  22999. "mozAudioChannelType",
  23000. "mozAutoplayEnabled",
  23001. "mozCancelAnimationFrame",
  23002. "mozCancelFullScreen",
  23003. "mozCancelRequestAnimationFrame",
  23004. "mozCaptureStream",
  23005. "mozCaptureStreamUntilEnded",
  23006. "mozClearDataAt",
  23007. "mozContact",
  23008. "mozContacts",
  23009. "mozCreateFileHandle",
  23010. "mozCurrentTransform",
  23011. "mozCurrentTransformInverse",
  23012. "mozCursor",
  23013. "mozDash",
  23014. "mozDashOffset",
  23015. "mozDecodedFrames",
  23016. "mozExitPointerLock",
  23017. "mozFillRule",
  23018. "mozFragmentEnd",
  23019. "mozFrameDelay",
  23020. "mozFullScreen",
  23021. "mozFullScreenElement",
  23022. "mozFullScreenEnabled",
  23023. "mozGetAll",
  23024. "mozGetAllKeys",
  23025. "mozGetAsFile",
  23026. "mozGetDataAt",
  23027. "mozGetMetadata",
  23028. "mozGetUserMedia",
  23029. "mozHasAudio",
  23030. "mozHasItem",
  23031. "mozHidden",
  23032. "mozImageSmoothingEnabled",
  23033. "mozIndexedDB",
  23034. "mozInnerScreenX",
  23035. "mozInnerScreenY",
  23036. "mozInputSource",
  23037. "mozIsTextField",
  23038. "mozItem",
  23039. "mozItemCount",
  23040. "mozItems",
  23041. "mozLength",
  23042. "mozLockOrientation",
  23043. "mozMatchesSelector",
  23044. "mozMovementX",
  23045. "mozMovementY",
  23046. "mozOpaque",
  23047. "mozOrientation",
  23048. "mozPaintCount",
  23049. "mozPaintedFrames",
  23050. "mozParsedFrames",
  23051. "mozPay",
  23052. "mozPointerLockElement",
  23053. "mozPresentedFrames",
  23054. "mozPreservesPitch",
  23055. "mozPressure",
  23056. "mozPrintCallback",
  23057. "mozRTCIceCandidate",
  23058. "mozRTCPeerConnection",
  23059. "mozRTCSessionDescription",
  23060. "mozRemove",
  23061. "mozRequestAnimationFrame",
  23062. "mozRequestFullScreen",
  23063. "mozRequestPointerLock",
  23064. "mozSetDataAt",
  23065. "mozSetImageElement",
  23066. "mozSourceNode",
  23067. "mozSrcObject",
  23068. "mozSystem",
  23069. "mozTCPSocket",
  23070. "mozTextStyle",
  23071. "mozTypesAt",
  23072. "mozUnlockOrientation",
  23073. "mozUserCancelled",
  23074. "mozVisibilityState",
  23075. "ms",
  23076. "msAnimation",
  23077. "msAnimationDelay",
  23078. "msAnimationDirection",
  23079. "msAnimationDuration",
  23080. "msAnimationFillMode",
  23081. "msAnimationIterationCount",
  23082. "msAnimationName",
  23083. "msAnimationPlayState",
  23084. "msAnimationStartTime",
  23085. "msAnimationTimingFunction",
  23086. "msBackfaceVisibility",
  23087. "msBlockProgression",
  23088. "msCSSOMElementFloatMetrics",
  23089. "msCaching",
  23090. "msCachingEnabled",
  23091. "msCancelRequestAnimationFrame",
  23092. "msCapsLockWarningOff",
  23093. "msClearImmediate",
  23094. "msClose",
  23095. "msContentZoomChaining",
  23096. "msContentZoomFactor",
  23097. "msContentZoomLimit",
  23098. "msContentZoomLimitMax",
  23099. "msContentZoomLimitMin",
  23100. "msContentZoomSnap",
  23101. "msContentZoomSnapPoints",
  23102. "msContentZoomSnapType",
  23103. "msContentZooming",
  23104. "msConvertURL",
  23105. "msCrypto",
  23106. "msDoNotTrack",
  23107. "msElementsFromPoint",
  23108. "msElementsFromRect",
  23109. "msExitFullscreen",
  23110. "msExtendedCode",
  23111. "msFillRule",
  23112. "msFirstPaint",
  23113. "msFlex",
  23114. "msFlexAlign",
  23115. "msFlexDirection",
  23116. "msFlexFlow",
  23117. "msFlexItemAlign",
  23118. "msFlexLinePack",
  23119. "msFlexNegative",
  23120. "msFlexOrder",
  23121. "msFlexPack",
  23122. "msFlexPositive",
  23123. "msFlexPreferredSize",
  23124. "msFlexWrap",
  23125. "msFlowFrom",
  23126. "msFlowInto",
  23127. "msFontFeatureSettings",
  23128. "msFullscreenElement",
  23129. "msFullscreenEnabled",
  23130. "msGetInputContext",
  23131. "msGetRegionContent",
  23132. "msGetUntransformedBounds",
  23133. "msGraphicsTrustStatus",
  23134. "msGridColumn",
  23135. "msGridColumnAlign",
  23136. "msGridColumnSpan",
  23137. "msGridColumns",
  23138. "msGridRow",
  23139. "msGridRowAlign",
  23140. "msGridRowSpan",
  23141. "msGridRows",
  23142. "msHidden",
  23143. "msHighContrastAdjust",
  23144. "msHyphenateLimitChars",
  23145. "msHyphenateLimitLines",
  23146. "msHyphenateLimitZone",
  23147. "msHyphens",
  23148. "msImageSmoothingEnabled",
  23149. "msImeAlign",
  23150. "msIndexedDB",
  23151. "msInterpolationMode",
  23152. "msIsStaticHTML",
  23153. "msKeySystem",
  23154. "msKeys",
  23155. "msLaunchUri",
  23156. "msLockOrientation",
  23157. "msManipulationViewsEnabled",
  23158. "msMatchMedia",
  23159. "msMatchesSelector",
  23160. "msMaxTouchPoints",
  23161. "msOrientation",
  23162. "msOverflowStyle",
  23163. "msPerspective",
  23164. "msPerspectiveOrigin",
  23165. "msPlayToDisabled",
  23166. "msPlayToPreferredSourceUri",
  23167. "msPlayToPrimary",
  23168. "msPointerEnabled",
  23169. "msRegionOverflow",
  23170. "msReleasePointerCapture",
  23171. "msRequestAnimationFrame",
  23172. "msRequestFullscreen",
  23173. "msSaveBlob",
  23174. "msSaveOrOpenBlob",
  23175. "msScrollChaining",
  23176. "msScrollLimit",
  23177. "msScrollLimitXMax",
  23178. "msScrollLimitXMin",
  23179. "msScrollLimitYMax",
  23180. "msScrollLimitYMin",
  23181. "msScrollRails",
  23182. "msScrollSnapPointsX",
  23183. "msScrollSnapPointsY",
  23184. "msScrollSnapType",
  23185. "msScrollSnapX",
  23186. "msScrollSnapY",
  23187. "msScrollTranslation",
  23188. "msSetImmediate",
  23189. "msSetMediaKeys",
  23190. "msSetPointerCapture",
  23191. "msTextCombineHorizontal",
  23192. "msTextSizeAdjust",
  23193. "msToBlob",
  23194. "msTouchAction",
  23195. "msTouchSelect",
  23196. "msTraceAsyncCallbackCompleted",
  23197. "msTraceAsyncCallbackStarting",
  23198. "msTraceAsyncOperationCompleted",
  23199. "msTraceAsyncOperationStarting",
  23200. "msTransform",
  23201. "msTransformOrigin",
  23202. "msTransformStyle",
  23203. "msTransition",
  23204. "msTransitionDelay",
  23205. "msTransitionDuration",
  23206. "msTransitionProperty",
  23207. "msTransitionTimingFunction",
  23208. "msUnlockOrientation",
  23209. "msUpdateAsyncCallbackRelation",
  23210. "msUserSelect",
  23211. "msVisibilityState",
  23212. "msWrapFlow",
  23213. "msWrapMargin",
  23214. "msWrapThrough",
  23215. "msWriteProfilerMark",
  23216. "msZoom",
  23217. "msZoomTo",
  23218. "mt",
  23219. "mul",
  23220. "multiEntry",
  23221. "multiSelectionObj",
  23222. "multiline",
  23223. "multiple",
  23224. "multiply",
  23225. "multiplySelf",
  23226. "mutableFile",
  23227. "muted",
  23228. "n",
  23229. "name",
  23230. "nameProp",
  23231. "namedItem",
  23232. "namedRecordset",
  23233. "names",
  23234. "namespaceURI",
  23235. "namespaces",
  23236. "naturalHeight",
  23237. "naturalWidth",
  23238. "navigate",
  23239. "navigation",
  23240. "navigationMode",
  23241. "navigationPreload",
  23242. "navigationStart",
  23243. "navigator",
  23244. "near",
  23245. "nearestViewportElement",
  23246. "negative",
  23247. "negotiated",
  23248. "netscape",
  23249. "networkState",
  23250. "newScale",
  23251. "newTranslate",
  23252. "newURL",
  23253. "newValue",
  23254. "newValueSpecifiedUnits",
  23255. "newVersion",
  23256. "newhome",
  23257. "next",
  23258. "nextElementSibling",
  23259. "nextHopProtocol",
  23260. "nextNode",
  23261. "nextPage",
  23262. "nextSibling",
  23263. "nickname",
  23264. "noHref",
  23265. "noModule",
  23266. "noResize",
  23267. "noShade",
  23268. "noValidate",
  23269. "noWrap",
  23270. "node",
  23271. "nodeName",
  23272. "nodeType",
  23273. "nodeValue",
  23274. "nonce",
  23275. "normalize",
  23276. "normalizedPathSegList",
  23277. "notationName",
  23278. "notations",
  23279. "note",
  23280. "noteGrainOn",
  23281. "noteOff",
  23282. "noteOn",
  23283. "notify",
  23284. "now",
  23285. "numOctaves",
  23286. "number",
  23287. "numberOfChannels",
  23288. "numberOfInputs",
  23289. "numberOfItems",
  23290. "numberOfOutputs",
  23291. "numberValue",
  23292. "oMatchesSelector",
  23293. "object",
  23294. "object-fit",
  23295. "object-position",
  23296. "objectFit",
  23297. "objectPosition",
  23298. "objectStore",
  23299. "objectStoreNames",
  23300. "objectType",
  23301. "observe",
  23302. "of",
  23303. "offscreenBuffering",
  23304. "offset",
  23305. "offset-anchor",
  23306. "offset-distance",
  23307. "offset-path",
  23308. "offset-rotate",
  23309. "offsetAnchor",
  23310. "offsetDistance",
  23311. "offsetHeight",
  23312. "offsetLeft",
  23313. "offsetNode",
  23314. "offsetParent",
  23315. "offsetPath",
  23316. "offsetRotate",
  23317. "offsetTop",
  23318. "offsetWidth",
  23319. "offsetX",
  23320. "offsetY",
  23321. "ok",
  23322. "oldURL",
  23323. "oldValue",
  23324. "oldVersion",
  23325. "olderShadowRoot",
  23326. "onLine",
  23327. "onabort",
  23328. "onabsolutedeviceorientation",
  23329. "onactivate",
  23330. "onactive",
  23331. "onaddsourcebuffer",
  23332. "onaddstream",
  23333. "onaddtrack",
  23334. "onafterprint",
  23335. "onafterscriptexecute",
  23336. "onafterupdate",
  23337. "onanimationcancel",
  23338. "onanimationend",
  23339. "onanimationiteration",
  23340. "onanimationstart",
  23341. "onappinstalled",
  23342. "onaudioend",
  23343. "onaudioprocess",
  23344. "onaudiostart",
  23345. "onautocomplete",
  23346. "onautocompleteerror",
  23347. "onauxclick",
  23348. "onbeforeactivate",
  23349. "onbeforecopy",
  23350. "onbeforecut",
  23351. "onbeforedeactivate",
  23352. "onbeforeeditfocus",
  23353. "onbeforeinstallprompt",
  23354. "onbeforepaste",
  23355. "onbeforeprint",
  23356. "onbeforescriptexecute",
  23357. "onbeforeunload",
  23358. "onbeforeupdate",
  23359. "onbeforexrselect",
  23360. "onbegin",
  23361. "onblocked",
  23362. "onblur",
  23363. "onbounce",
  23364. "onboundary",
  23365. "onbufferedamountlow",
  23366. "oncached",
  23367. "oncancel",
  23368. "oncandidatewindowhide",
  23369. "oncandidatewindowshow",
  23370. "oncandidatewindowupdate",
  23371. "oncanplay",
  23372. "oncanplaythrough",
  23373. "once",
  23374. "oncellchange",
  23375. "onchange",
  23376. "oncharacteristicvaluechanged",
  23377. "onchargingchange",
  23378. "onchargingtimechange",
  23379. "onchecking",
  23380. "onclick",
  23381. "onclose",
  23382. "onclosing",
  23383. "oncompassneedscalibration",
  23384. "oncomplete",
  23385. "onconnect",
  23386. "onconnecting",
  23387. "onconnectionavailable",
  23388. "onconnectionstatechange",
  23389. "oncontextmenu",
  23390. "oncontrollerchange",
  23391. "oncontrolselect",
  23392. "oncopy",
  23393. "oncuechange",
  23394. "oncut",
  23395. "ondataavailable",
  23396. "ondatachannel",
  23397. "ondatasetchanged",
  23398. "ondatasetcomplete",
  23399. "ondblclick",
  23400. "ondeactivate",
  23401. "ondevicechange",
  23402. "ondevicelight",
  23403. "ondevicemotion",
  23404. "ondeviceorientation",
  23405. "ondeviceorientationabsolute",
  23406. "ondeviceproximity",
  23407. "ondischargingtimechange",
  23408. "ondisconnect",
  23409. "ondisplay",
  23410. "ondownloading",
  23411. "ondrag",
  23412. "ondragend",
  23413. "ondragenter",
  23414. "ondragexit",
  23415. "ondragleave",
  23416. "ondragover",
  23417. "ondragstart",
  23418. "ondrop",
  23419. "ondurationchange",
  23420. "onemptied",
  23421. "onencrypted",
  23422. "onend",
  23423. "onended",
  23424. "onenter",
  23425. "onenterpictureinpicture",
  23426. "onerror",
  23427. "onerrorupdate",
  23428. "onexit",
  23429. "onfilterchange",
  23430. "onfinish",
  23431. "onfocus",
  23432. "onfocusin",
  23433. "onfocusout",
  23434. "onformdata",
  23435. "onfreeze",
  23436. "onfullscreenchange",
  23437. "onfullscreenerror",
  23438. "ongatheringstatechange",
  23439. "ongattserverdisconnected",
  23440. "ongesturechange",
  23441. "ongestureend",
  23442. "ongesturestart",
  23443. "ongotpointercapture",
  23444. "onhashchange",
  23445. "onhelp",
  23446. "onicecandidate",
  23447. "onicecandidateerror",
  23448. "oniceconnectionstatechange",
  23449. "onicegatheringstatechange",
  23450. "oninactive",
  23451. "oninput",
  23452. "oninputsourceschange",
  23453. "oninvalid",
  23454. "onkeydown",
  23455. "onkeypress",
  23456. "onkeystatuseschange",
  23457. "onkeyup",
  23458. "onlanguagechange",
  23459. "onlayoutcomplete",
  23460. "onleavepictureinpicture",
  23461. "onlevelchange",
  23462. "onload",
  23463. "onloadeddata",
  23464. "onloadedmetadata",
  23465. "onloadend",
  23466. "onloading",
  23467. "onloadingdone",
  23468. "onloadingerror",
  23469. "onloadstart",
  23470. "onlosecapture",
  23471. "onlostpointercapture",
  23472. "only",
  23473. "onmark",
  23474. "onmessage",
  23475. "onmessageerror",
  23476. "onmidimessage",
  23477. "onmousedown",
  23478. "onmouseenter",
  23479. "onmouseleave",
  23480. "onmousemove",
  23481. "onmouseout",
  23482. "onmouseover",
  23483. "onmouseup",
  23484. "onmousewheel",
  23485. "onmove",
  23486. "onmoveend",
  23487. "onmovestart",
  23488. "onmozfullscreenchange",
  23489. "onmozfullscreenerror",
  23490. "onmozorientationchange",
  23491. "onmozpointerlockchange",
  23492. "onmozpointerlockerror",
  23493. "onmscontentzoom",
  23494. "onmsfullscreenchange",
  23495. "onmsfullscreenerror",
  23496. "onmsgesturechange",
  23497. "onmsgesturedoubletap",
  23498. "onmsgestureend",
  23499. "onmsgesturehold",
  23500. "onmsgesturestart",
  23501. "onmsgesturetap",
  23502. "onmsgotpointercapture",
  23503. "onmsinertiastart",
  23504. "onmslostpointercapture",
  23505. "onmsmanipulationstatechanged",
  23506. "onmsneedkey",
  23507. "onmsorientationchange",
  23508. "onmspointercancel",
  23509. "onmspointerdown",
  23510. "onmspointerenter",
  23511. "onmspointerhover",
  23512. "onmspointerleave",
  23513. "onmspointermove",
  23514. "onmspointerout",
  23515. "onmspointerover",
  23516. "onmspointerup",
  23517. "onmssitemodejumplistitemremoved",
  23518. "onmsthumbnailclick",
  23519. "onmute",
  23520. "onnegotiationneeded",
  23521. "onnomatch",
  23522. "onnoupdate",
  23523. "onobsolete",
  23524. "onoffline",
  23525. "ononline",
  23526. "onopen",
  23527. "onorientationchange",
  23528. "onpagechange",
  23529. "onpagehide",
  23530. "onpageshow",
  23531. "onpaste",
  23532. "onpause",
  23533. "onpayerdetailchange",
  23534. "onpaymentmethodchange",
  23535. "onplay",
  23536. "onplaying",
  23537. "onpluginstreamstart",
  23538. "onpointercancel",
  23539. "onpointerdown",
  23540. "onpointerenter",
  23541. "onpointerleave",
  23542. "onpointerlockchange",
  23543. "onpointerlockerror",
  23544. "onpointermove",
  23545. "onpointerout",
  23546. "onpointerover",
  23547. "onpointerrawupdate",
  23548. "onpointerup",
  23549. "onpopstate",
  23550. "onprocessorerror",
  23551. "onprogress",
  23552. "onpropertychange",
  23553. "onratechange",
  23554. "onreading",
  23555. "onreadystatechange",
  23556. "onrejectionhandled",
  23557. "onrelease",
  23558. "onremove",
  23559. "onremovesourcebuffer",
  23560. "onremovestream",
  23561. "onremovetrack",
  23562. "onrepeat",
  23563. "onreset",
  23564. "onresize",
  23565. "onresizeend",
  23566. "onresizestart",
  23567. "onresourcetimingbufferfull",
  23568. "onresult",
  23569. "onresume",
  23570. "onrowenter",
  23571. "onrowexit",
  23572. "onrowsdelete",
  23573. "onrowsinserted",
  23574. "onscroll",
  23575. "onsearch",
  23576. "onsecuritypolicyviolation",
  23577. "onseeked",
  23578. "onseeking",
  23579. "onselect",
  23580. "onselectedcandidatepairchange",
  23581. "onselectend",
  23582. "onselectionchange",
  23583. "onselectstart",
  23584. "onshippingaddresschange",
  23585. "onshippingoptionchange",
  23586. "onshow",
  23587. "onsignalingstatechange",
  23588. "onsoundend",
  23589. "onsoundstart",
  23590. "onsourceclose",
  23591. "onsourceclosed",
  23592. "onsourceended",
  23593. "onsourceopen",
  23594. "onspeechend",
  23595. "onspeechstart",
  23596. "onsqueeze",
  23597. "onsqueezeend",
  23598. "onsqueezestart",
  23599. "onstalled",
  23600. "onstart",
  23601. "onstatechange",
  23602. "onstop",
  23603. "onstorage",
  23604. "onstoragecommit",
  23605. "onsubmit",
  23606. "onsuccess",
  23607. "onsuspend",
  23608. "onterminate",
  23609. "ontextinput",
  23610. "ontimeout",
  23611. "ontimeupdate",
  23612. "ontoggle",
  23613. "ontonechange",
  23614. "ontouchcancel",
  23615. "ontouchend",
  23616. "ontouchmove",
  23617. "ontouchstart",
  23618. "ontrack",
  23619. "ontransitioncancel",
  23620. "ontransitionend",
  23621. "ontransitionrun",
  23622. "ontransitionstart",
  23623. "onunhandledrejection",
  23624. "onunload",
  23625. "onunmute",
  23626. "onupdate",
  23627. "onupdateend",
  23628. "onupdatefound",
  23629. "onupdateready",
  23630. "onupdatestart",
  23631. "onupgradeneeded",
  23632. "onuserproximity",
  23633. "onversionchange",
  23634. "onvisibilitychange",
  23635. "onvoiceschanged",
  23636. "onvolumechange",
  23637. "onvrdisplayactivate",
  23638. "onvrdisplayconnect",
  23639. "onvrdisplaydeactivate",
  23640. "onvrdisplaydisconnect",
  23641. "onvrdisplaypresentchange",
  23642. "onwaiting",
  23643. "onwaitingforkey",
  23644. "onwarning",
  23645. "onwebkitanimationend",
  23646. "onwebkitanimationiteration",
  23647. "onwebkitanimationstart",
  23648. "onwebkitcurrentplaybacktargetiswirelesschanged",
  23649. "onwebkitfullscreenchange",
  23650. "onwebkitfullscreenerror",
  23651. "onwebkitkeyadded",
  23652. "onwebkitkeyerror",
  23653. "onwebkitkeymessage",
  23654. "onwebkitneedkey",
  23655. "onwebkitorientationchange",
  23656. "onwebkitplaybacktargetavailabilitychanged",
  23657. "onwebkitpointerlockchange",
  23658. "onwebkitpointerlockerror",
  23659. "onwebkitresourcetimingbufferfull",
  23660. "onwebkittransitionend",
  23661. "onwheel",
  23662. "onzoom",
  23663. "opacity",
  23664. "open",
  23665. "openCursor",
  23666. "openDatabase",
  23667. "openKeyCursor",
  23668. "opened",
  23669. "opener",
  23670. "opera",
  23671. "operationType",
  23672. "operator",
  23673. "opr",
  23674. "optimum",
  23675. "options",
  23676. "or",
  23677. "order",
  23678. "orderX",
  23679. "orderY",
  23680. "ordered",
  23681. "org",
  23682. "organization",
  23683. "orient",
  23684. "orientAngle",
  23685. "orientType",
  23686. "orientation",
  23687. "orientationX",
  23688. "orientationY",
  23689. "orientationZ",
  23690. "origin",
  23691. "originalPolicy",
  23692. "originalTarget",
  23693. "orphans",
  23694. "oscpu",
  23695. "outerHTML",
  23696. "outerHeight",
  23697. "outerText",
  23698. "outerWidth",
  23699. "outline",
  23700. "outline-color",
  23701. "outline-offset",
  23702. "outline-style",
  23703. "outline-width",
  23704. "outlineColor",
  23705. "outlineOffset",
  23706. "outlineStyle",
  23707. "outlineWidth",
  23708. "outputBuffer",
  23709. "outputLatency",
  23710. "outputs",
  23711. "overflow",
  23712. "overflow-anchor",
  23713. "overflow-block",
  23714. "overflow-inline",
  23715. "overflow-wrap",
  23716. "overflow-x",
  23717. "overflow-y",
  23718. "overflowAnchor",
  23719. "overflowBlock",
  23720. "overflowInline",
  23721. "overflowWrap",
  23722. "overflowX",
  23723. "overflowY",
  23724. "overrideMimeType",
  23725. "oversample",
  23726. "overscroll-behavior",
  23727. "overscroll-behavior-block",
  23728. "overscroll-behavior-inline",
  23729. "overscroll-behavior-x",
  23730. "overscroll-behavior-y",
  23731. "overscrollBehavior",
  23732. "overscrollBehaviorBlock",
  23733. "overscrollBehaviorInline",
  23734. "overscrollBehaviorX",
  23735. "overscrollBehaviorY",
  23736. "ownKeys",
  23737. "ownerDocument",
  23738. "ownerElement",
  23739. "ownerNode",
  23740. "ownerRule",
  23741. "ownerSVGElement",
  23742. "owningElement",
  23743. "p1",
  23744. "p2",
  23745. "p3",
  23746. "p4",
  23747. "packetSize",
  23748. "packets",
  23749. "pad",
  23750. "padEnd",
  23751. "padStart",
  23752. "padding",
  23753. "padding-block",
  23754. "padding-block-end",
  23755. "padding-block-start",
  23756. "padding-bottom",
  23757. "padding-inline",
  23758. "padding-inline-end",
  23759. "padding-inline-start",
  23760. "padding-left",
  23761. "padding-right",
  23762. "padding-top",
  23763. "paddingBlock",
  23764. "paddingBlockEnd",
  23765. "paddingBlockStart",
  23766. "paddingBottom",
  23767. "paddingInline",
  23768. "paddingInlineEnd",
  23769. "paddingInlineStart",
  23770. "paddingLeft",
  23771. "paddingRight",
  23772. "paddingTop",
  23773. "page",
  23774. "page-break-after",
  23775. "page-break-before",
  23776. "page-break-inside",
  23777. "pageBreakAfter",
  23778. "pageBreakBefore",
  23779. "pageBreakInside",
  23780. "pageCount",
  23781. "pageLeft",
  23782. "pageTop",
  23783. "pageX",
  23784. "pageXOffset",
  23785. "pageY",
  23786. "pageYOffset",
  23787. "pages",
  23788. "paint-order",
  23789. "paintOrder",
  23790. "paintRequests",
  23791. "paintType",
  23792. "paintWorklet",
  23793. "palette",
  23794. "pan",
  23795. "panningModel",
  23796. "parameters",
  23797. "parent",
  23798. "parentElement",
  23799. "parentNode",
  23800. "parentRule",
  23801. "parentStyleSheet",
  23802. "parentTextEdit",
  23803. "parentWindow",
  23804. "parse",
  23805. "parseAll",
  23806. "parseFloat",
  23807. "parseFromString",
  23808. "parseInt",
  23809. "part",
  23810. "participants",
  23811. "passive",
  23812. "password",
  23813. "pasteHTML",
  23814. "path",
  23815. "pathLength",
  23816. "pathSegList",
  23817. "pathSegType",
  23818. "pathSegTypeAsLetter",
  23819. "pathname",
  23820. "pattern",
  23821. "patternContentUnits",
  23822. "patternMismatch",
  23823. "patternTransform",
  23824. "patternUnits",
  23825. "pause",
  23826. "pauseAnimations",
  23827. "pauseOnExit",
  23828. "pauseProfilers",
  23829. "pauseTransformFeedback",
  23830. "paused",
  23831. "payerEmail",
  23832. "payerName",
  23833. "payerPhone",
  23834. "paymentManager",
  23835. "pc",
  23836. "peerIdentity",
  23837. "pending",
  23838. "pendingLocalDescription",
  23839. "pendingRemoteDescription",
  23840. "percent",
  23841. "performance",
  23842. "periodicSync",
  23843. "permission",
  23844. "permissionState",
  23845. "permissions",
  23846. "persist",
  23847. "persisted",
  23848. "personalbar",
  23849. "perspective",
  23850. "perspective-origin",
  23851. "perspectiveOrigin",
  23852. "phone",
  23853. "phoneticFamilyName",
  23854. "phoneticGivenName",
  23855. "photo",
  23856. "pictureInPictureElement",
  23857. "pictureInPictureEnabled",
  23858. "pictureInPictureWindow",
  23859. "ping",
  23860. "pipeThrough",
  23861. "pipeTo",
  23862. "pitch",
  23863. "pixelBottom",
  23864. "pixelDepth",
  23865. "pixelHeight",
  23866. "pixelLeft",
  23867. "pixelRight",
  23868. "pixelStorei",
  23869. "pixelTop",
  23870. "pixelUnitToMillimeterX",
  23871. "pixelUnitToMillimeterY",
  23872. "pixelWidth",
  23873. "place-content",
  23874. "place-items",
  23875. "place-self",
  23876. "placeContent",
  23877. "placeItems",
  23878. "placeSelf",
  23879. "placeholder",
  23880. "platform",
  23881. "platforms",
  23882. "play",
  23883. "playEffect",
  23884. "playState",
  23885. "playbackRate",
  23886. "playbackState",
  23887. "playbackTime",
  23888. "played",
  23889. "playoutDelayHint",
  23890. "playsInline",
  23891. "plugins",
  23892. "pluginspage",
  23893. "pname",
  23894. "pointer-events",
  23895. "pointerBeforeReferenceNode",
  23896. "pointerEnabled",
  23897. "pointerEvents",
  23898. "pointerId",
  23899. "pointerLockElement",
  23900. "pointerType",
  23901. "points",
  23902. "pointsAtX",
  23903. "pointsAtY",
  23904. "pointsAtZ",
  23905. "polygonOffset",
  23906. "pop",
  23907. "populateMatrix",
  23908. "popupWindowFeatures",
  23909. "popupWindowName",
  23910. "popupWindowURI",
  23911. "port",
  23912. "port1",
  23913. "port2",
  23914. "ports",
  23915. "posBottom",
  23916. "posHeight",
  23917. "posLeft",
  23918. "posRight",
  23919. "posTop",
  23920. "posWidth",
  23921. "pose",
  23922. "position",
  23923. "positionAlign",
  23924. "positionX",
  23925. "positionY",
  23926. "positionZ",
  23927. "postError",
  23928. "postMessage",
  23929. "postalCode",
  23930. "poster",
  23931. "pow",
  23932. "powerEfficient",
  23933. "powerOff",
  23934. "preMultiplySelf",
  23935. "precision",
  23936. "preferredStyleSheetSet",
  23937. "preferredStylesheetSet",
  23938. "prefix",
  23939. "preload",
  23940. "prepend",
  23941. "presentation",
  23942. "preserveAlpha",
  23943. "preserveAspectRatio",
  23944. "preserveAspectRatioString",
  23945. "pressed",
  23946. "pressure",
  23947. "prevValue",
  23948. "preventDefault",
  23949. "preventExtensions",
  23950. "preventSilentAccess",
  23951. "previousElementSibling",
  23952. "previousNode",
  23953. "previousPage",
  23954. "previousRect",
  23955. "previousScale",
  23956. "previousSibling",
  23957. "previousTranslate",
  23958. "primaryKey",
  23959. "primitiveType",
  23960. "primitiveUnits",
  23961. "principals",
  23962. "print",
  23963. "priority",
  23964. "privateKey",
  23965. "probablySupportsContext",
  23966. "process",
  23967. "processIceMessage",
  23968. "processingEnd",
  23969. "processingStart",
  23970. "product",
  23971. "productId",
  23972. "productName",
  23973. "productSub",
  23974. "profile",
  23975. "profileEnd",
  23976. "profiles",
  23977. "projectionMatrix",
  23978. "promise",
  23979. "prompt",
  23980. "properties",
  23981. "propertyIsEnumerable",
  23982. "propertyName",
  23983. "protocol",
  23984. "protocolLong",
  23985. "prototype",
  23986. "provider",
  23987. "pseudoClass",
  23988. "pseudoElement",
  23989. "pt",
  23990. "publicId",
  23991. "publicKey",
  23992. "published",
  23993. "pulse",
  23994. "push",
  23995. "pushManager",
  23996. "pushNotification",
  23997. "pushState",
  23998. "put",
  23999. "putImageData",
  24000. "px",
  24001. "quadraticCurveTo",
  24002. "qualifier",
  24003. "quaternion",
  24004. "query",
  24005. "queryCommandEnabled",
  24006. "queryCommandIndeterm",
  24007. "queryCommandState",
  24008. "queryCommandSupported",
  24009. "queryCommandText",
  24010. "queryCommandValue",
  24011. "querySelector",
  24012. "querySelectorAll",
  24013. "queueMicrotask",
  24014. "quote",
  24015. "quotes",
  24016. "r",
  24017. "r1",
  24018. "r2",
  24019. "race",
  24020. "rad",
  24021. "radiogroup",
  24022. "radiusX",
  24023. "radiusY",
  24024. "random",
  24025. "range",
  24026. "rangeCount",
  24027. "rangeMax",
  24028. "rangeMin",
  24029. "rangeOffset",
  24030. "rangeOverflow",
  24031. "rangeParent",
  24032. "rangeUnderflow",
  24033. "rate",
  24034. "ratio",
  24035. "raw",
  24036. "rawId",
  24037. "read",
  24038. "readAsArrayBuffer",
  24039. "readAsBinaryString",
  24040. "readAsBlob",
  24041. "readAsDataURL",
  24042. "readAsText",
  24043. "readBuffer",
  24044. "readEntries",
  24045. "readOnly",
  24046. "readPixels",
  24047. "readReportRequested",
  24048. "readText",
  24049. "readValue",
  24050. "readable",
  24051. "ready",
  24052. "readyState",
  24053. "reason",
  24054. "reboot",
  24055. "receivedAlert",
  24056. "receiver",
  24057. "receivers",
  24058. "recipient",
  24059. "reconnect",
  24060. "recordNumber",
  24061. "recordsAvailable",
  24062. "recordset",
  24063. "rect",
  24064. "red",
  24065. "redEyeReduction",
  24066. "redirect",
  24067. "redirectCount",
  24068. "redirectEnd",
  24069. "redirectStart",
  24070. "redirected",
  24071. "reduce",
  24072. "reduceRight",
  24073. "reduction",
  24074. "refDistance",
  24075. "refX",
  24076. "refY",
  24077. "referenceNode",
  24078. "referenceSpace",
  24079. "referrer",
  24080. "referrerPolicy",
  24081. "refresh",
  24082. "region",
  24083. "regionAnchorX",
  24084. "regionAnchorY",
  24085. "regionId",
  24086. "regions",
  24087. "register",
  24088. "registerContentHandler",
  24089. "registerElement",
  24090. "registerProperty",
  24091. "registerProtocolHandler",
  24092. "reject",
  24093. "rel",
  24094. "relList",
  24095. "relatedAddress",
  24096. "relatedNode",
  24097. "relatedPort",
  24098. "relatedTarget",
  24099. "release",
  24100. "releaseCapture",
  24101. "releaseEvents",
  24102. "releaseInterface",
  24103. "releaseLock",
  24104. "releasePointerCapture",
  24105. "releaseShaderCompiler",
  24106. "reliable",
  24107. "reliableWrite",
  24108. "reload",
  24109. "rem",
  24110. "remainingSpace",
  24111. "remote",
  24112. "remoteDescription",
  24113. "remove",
  24114. "removeAllRanges",
  24115. "removeAttribute",
  24116. "removeAttributeNS",
  24117. "removeAttributeNode",
  24118. "removeBehavior",
  24119. "removeChild",
  24120. "removeCue",
  24121. "removeEventListener",
  24122. "removeFilter",
  24123. "removeImport",
  24124. "removeItem",
  24125. "removeListener",
  24126. "removeNamedItem",
  24127. "removeNamedItemNS",
  24128. "removeNode",
  24129. "removeParameter",
  24130. "removeProperty",
  24131. "removeRange",
  24132. "removeRegion",
  24133. "removeRule",
  24134. "removeSiteSpecificTrackingException",
  24135. "removeSourceBuffer",
  24136. "removeStream",
  24137. "removeTrack",
  24138. "removeVariable",
  24139. "removeWakeLockListener",
  24140. "removeWebWideTrackingException",
  24141. "removed",
  24142. "removedNodes",
  24143. "renderHeight",
  24144. "renderState",
  24145. "renderTime",
  24146. "renderWidth",
  24147. "renderbufferStorage",
  24148. "renderbufferStorageMultisample",
  24149. "renderedBuffer",
  24150. "renderingMode",
  24151. "renotify",
  24152. "repeat",
  24153. "replace",
  24154. "replaceAdjacentText",
  24155. "replaceAll",
  24156. "replaceChild",
  24157. "replaceChildren",
  24158. "replaceData",
  24159. "replaceId",
  24160. "replaceItem",
  24161. "replaceNode",
  24162. "replaceState",
  24163. "replaceSync",
  24164. "replaceTrack",
  24165. "replaceWholeText",
  24166. "replaceWith",
  24167. "reportValidity",
  24168. "request",
  24169. "requestAnimationFrame",
  24170. "requestAutocomplete",
  24171. "requestData",
  24172. "requestDevice",
  24173. "requestFrame",
  24174. "requestFullscreen",
  24175. "requestHitTestSource",
  24176. "requestHitTestSourceForTransientInput",
  24177. "requestId",
  24178. "requestIdleCallback",
  24179. "requestMIDIAccess",
  24180. "requestMediaKeySystemAccess",
  24181. "requestPermission",
  24182. "requestPictureInPicture",
  24183. "requestPointerLock",
  24184. "requestPresent",
  24185. "requestReferenceSpace",
  24186. "requestSession",
  24187. "requestStart",
  24188. "requestStorageAccess",
  24189. "requestSubmit",
  24190. "requestVideoFrameCallback",
  24191. "requestingWindow",
  24192. "requireInteraction",
  24193. "required",
  24194. "requiredExtensions",
  24195. "requiredFeatures",
  24196. "reset",
  24197. "resetPose",
  24198. "resetTransform",
  24199. "resize",
  24200. "resizeBy",
  24201. "resizeTo",
  24202. "resolve",
  24203. "response",
  24204. "responseBody",
  24205. "responseEnd",
  24206. "responseReady",
  24207. "responseStart",
  24208. "responseText",
  24209. "responseType",
  24210. "responseURL",
  24211. "responseXML",
  24212. "restartIce",
  24213. "restore",
  24214. "result",
  24215. "resultIndex",
  24216. "resultType",
  24217. "results",
  24218. "resume",
  24219. "resumeProfilers",
  24220. "resumeTransformFeedback",
  24221. "retry",
  24222. "returnValue",
  24223. "rev",
  24224. "reverse",
  24225. "reversed",
  24226. "revocable",
  24227. "revokeObjectURL",
  24228. "rgbColor",
  24229. "right",
  24230. "rightContext",
  24231. "rightDegrees",
  24232. "rightMargin",
  24233. "rightProjectionMatrix",
  24234. "rightViewMatrix",
  24235. "role",
  24236. "rolloffFactor",
  24237. "root",
  24238. "rootBounds",
  24239. "rootElement",
  24240. "rootMargin",
  24241. "rotate",
  24242. "rotateAxisAngle",
  24243. "rotateAxisAngleSelf",
  24244. "rotateFromVector",
  24245. "rotateFromVectorSelf",
  24246. "rotateSelf",
  24247. "rotation",
  24248. "rotationAngle",
  24249. "rotationRate",
  24250. "round",
  24251. "row-gap",
  24252. "rowGap",
  24253. "rowIndex",
  24254. "rowSpan",
  24255. "rows",
  24256. "rtcpTransport",
  24257. "rtt",
  24258. "ruby-align",
  24259. "ruby-position",
  24260. "rubyAlign",
  24261. "rubyOverhang",
  24262. "rubyPosition",
  24263. "rules",
  24264. "runtime",
  24265. "runtimeStyle",
  24266. "rx",
  24267. "ry",
  24268. "s",
  24269. "safari",
  24270. "sample",
  24271. "sampleCoverage",
  24272. "sampleRate",
  24273. "samplerParameterf",
  24274. "samplerParameteri",
  24275. "sandbox",
  24276. "save",
  24277. "saveData",
  24278. "scale",
  24279. "scale3d",
  24280. "scale3dSelf",
  24281. "scaleNonUniform",
  24282. "scaleNonUniformSelf",
  24283. "scaleSelf",
  24284. "scheme",
  24285. "scissor",
  24286. "scope",
  24287. "scopeName",
  24288. "scoped",
  24289. "screen",
  24290. "screenBrightness",
  24291. "screenEnabled",
  24292. "screenLeft",
  24293. "screenPixelToMillimeterX",
  24294. "screenPixelToMillimeterY",
  24295. "screenTop",
  24296. "screenX",
  24297. "screenY",
  24298. "scriptURL",
  24299. "scripts",
  24300. "scroll",
  24301. "scroll-behavior",
  24302. "scroll-margin",
  24303. "scroll-margin-block",
  24304. "scroll-margin-block-end",
  24305. "scroll-margin-block-start",
  24306. "scroll-margin-bottom",
  24307. "scroll-margin-inline",
  24308. "scroll-margin-inline-end",
  24309. "scroll-margin-inline-start",
  24310. "scroll-margin-left",
  24311. "scroll-margin-right",
  24312. "scroll-margin-top",
  24313. "scroll-padding",
  24314. "scroll-padding-block",
  24315. "scroll-padding-block-end",
  24316. "scroll-padding-block-start",
  24317. "scroll-padding-bottom",
  24318. "scroll-padding-inline",
  24319. "scroll-padding-inline-end",
  24320. "scroll-padding-inline-start",
  24321. "scroll-padding-left",
  24322. "scroll-padding-right",
  24323. "scroll-padding-top",
  24324. "scroll-snap-align",
  24325. "scroll-snap-type",
  24326. "scrollAmount",
  24327. "scrollBehavior",
  24328. "scrollBy",
  24329. "scrollByLines",
  24330. "scrollByPages",
  24331. "scrollDelay",
  24332. "scrollHeight",
  24333. "scrollIntoView",
  24334. "scrollIntoViewIfNeeded",
  24335. "scrollLeft",
  24336. "scrollLeftMax",
  24337. "scrollMargin",
  24338. "scrollMarginBlock",
  24339. "scrollMarginBlockEnd",
  24340. "scrollMarginBlockStart",
  24341. "scrollMarginBottom",
  24342. "scrollMarginInline",
  24343. "scrollMarginInlineEnd",
  24344. "scrollMarginInlineStart",
  24345. "scrollMarginLeft",
  24346. "scrollMarginRight",
  24347. "scrollMarginTop",
  24348. "scrollMaxX",
  24349. "scrollMaxY",
  24350. "scrollPadding",
  24351. "scrollPaddingBlock",
  24352. "scrollPaddingBlockEnd",
  24353. "scrollPaddingBlockStart",
  24354. "scrollPaddingBottom",
  24355. "scrollPaddingInline",
  24356. "scrollPaddingInlineEnd",
  24357. "scrollPaddingInlineStart",
  24358. "scrollPaddingLeft",
  24359. "scrollPaddingRight",
  24360. "scrollPaddingTop",
  24361. "scrollRestoration",
  24362. "scrollSnapAlign",
  24363. "scrollSnapType",
  24364. "scrollTo",
  24365. "scrollTop",
  24366. "scrollTopMax",
  24367. "scrollWidth",
  24368. "scrollX",
  24369. "scrollY",
  24370. "scrollbar-color",
  24371. "scrollbar-width",
  24372. "scrollbar3dLightColor",
  24373. "scrollbarArrowColor",
  24374. "scrollbarBaseColor",
  24375. "scrollbarColor",
  24376. "scrollbarDarkShadowColor",
  24377. "scrollbarFaceColor",
  24378. "scrollbarHighlightColor",
  24379. "scrollbarShadowColor",
  24380. "scrollbarTrackColor",
  24381. "scrollbarWidth",
  24382. "scrollbars",
  24383. "scrolling",
  24384. "scrollingElement",
  24385. "sctp",
  24386. "sctpCauseCode",
  24387. "sdp",
  24388. "sdpLineNumber",
  24389. "sdpMLineIndex",
  24390. "sdpMid",
  24391. "seal",
  24392. "search",
  24393. "searchBox",
  24394. "searchBoxJavaBridge_",
  24395. "searchParams",
  24396. "sectionRowIndex",
  24397. "secureConnectionStart",
  24398. "security",
  24399. "seed",
  24400. "seekToNextFrame",
  24401. "seekable",
  24402. "seeking",
  24403. "select",
  24404. "selectAllChildren",
  24405. "selectAlternateInterface",
  24406. "selectConfiguration",
  24407. "selectNode",
  24408. "selectNodeContents",
  24409. "selectNodes",
  24410. "selectSingleNode",
  24411. "selectSubString",
  24412. "selected",
  24413. "selectedIndex",
  24414. "selectedOptions",
  24415. "selectedStyleSheetSet",
  24416. "selectedStylesheetSet",
  24417. "selection",
  24418. "selectionDirection",
  24419. "selectionEnd",
  24420. "selectionStart",
  24421. "selector",
  24422. "selectorText",
  24423. "self",
  24424. "send",
  24425. "sendAsBinary",
  24426. "sendBeacon",
  24427. "sender",
  24428. "sentAlert",
  24429. "sentTimestamp",
  24430. "separator",
  24431. "serialNumber",
  24432. "serializeToString",
  24433. "serverTiming",
  24434. "service",
  24435. "serviceWorker",
  24436. "session",
  24437. "sessionId",
  24438. "sessionStorage",
  24439. "set",
  24440. "setActionHandler",
  24441. "setActive",
  24442. "setAlpha",
  24443. "setAppBadge",
  24444. "setAttribute",
  24445. "setAttributeNS",
  24446. "setAttributeNode",
  24447. "setAttributeNodeNS",
  24448. "setBaseAndExtent",
  24449. "setBigInt64",
  24450. "setBigUint64",
  24451. "setBingCurrentSearchDefault",
  24452. "setCapture",
  24453. "setCodecPreferences",
  24454. "setColor",
  24455. "setCompositeOperation",
  24456. "setConfiguration",
  24457. "setCurrentTime",
  24458. "setCustomValidity",
  24459. "setData",
  24460. "setDate",
  24461. "setDragImage",
  24462. "setEnd",
  24463. "setEndAfter",
  24464. "setEndBefore",
  24465. "setEndPoint",
  24466. "setFillColor",
  24467. "setFilterRes",
  24468. "setFloat32",
  24469. "setFloat64",
  24470. "setFloatValue",
  24471. "setFormValue",
  24472. "setFullYear",
  24473. "setHeaderValue",
  24474. "setHours",
  24475. "setIdentityProvider",
  24476. "setImmediate",
  24477. "setInt16",
  24478. "setInt32",
  24479. "setInt8",
  24480. "setInterval",
  24481. "setItem",
  24482. "setKeyframes",
  24483. "setLineCap",
  24484. "setLineDash",
  24485. "setLineJoin",
  24486. "setLineWidth",
  24487. "setLiveSeekableRange",
  24488. "setLocalDescription",
  24489. "setMatrix",
  24490. "setMatrixValue",
  24491. "setMediaKeys",
  24492. "setMilliseconds",
  24493. "setMinutes",
  24494. "setMiterLimit",
  24495. "setMonth",
  24496. "setNamedItem",
  24497. "setNamedItemNS",
  24498. "setNonUserCodeExceptions",
  24499. "setOrientToAngle",
  24500. "setOrientToAuto",
  24501. "setOrientation",
  24502. "setOverrideHistoryNavigationMode",
  24503. "setPaint",
  24504. "setParameter",
  24505. "setParameters",
  24506. "setPeriodicWave",
  24507. "setPointerCapture",
  24508. "setPosition",
  24509. "setPositionState",
  24510. "setPreference",
  24511. "setProperty",
  24512. "setPrototypeOf",
  24513. "setRGBColor",
  24514. "setRGBColorICCColor",
  24515. "setRadius",
  24516. "setRangeText",
  24517. "setRemoteDescription",
  24518. "setRequestHeader",
  24519. "setResizable",
  24520. "setResourceTimingBufferSize",
  24521. "setRotate",
  24522. "setScale",
  24523. "setSeconds",
  24524. "setSelectionRange",
  24525. "setServerCertificate",
  24526. "setShadow",
  24527. "setSinkId",
  24528. "setSkewX",
  24529. "setSkewY",
  24530. "setStart",
  24531. "setStartAfter",
  24532. "setStartBefore",
  24533. "setStdDeviation",
  24534. "setStreams",
  24535. "setStringValue",
  24536. "setStrokeColor",
  24537. "setSuggestResult",
  24538. "setTargetAtTime",
  24539. "setTargetValueAtTime",
  24540. "setTime",
  24541. "setTimeout",
  24542. "setTransform",
  24543. "setTranslate",
  24544. "setUTCDate",
  24545. "setUTCFullYear",
  24546. "setUTCHours",
  24547. "setUTCMilliseconds",
  24548. "setUTCMinutes",
  24549. "setUTCMonth",
  24550. "setUTCSeconds",
  24551. "setUint16",
  24552. "setUint32",
  24553. "setUint8",
  24554. "setUri",
  24555. "setValidity",
  24556. "setValueAtTime",
  24557. "setValueCurveAtTime",
  24558. "setVariable",
  24559. "setVelocity",
  24560. "setVersion",
  24561. "setYear",
  24562. "settingName",
  24563. "settingValue",
  24564. "sex",
  24565. "shaderSource",
  24566. "shadowBlur",
  24567. "shadowColor",
  24568. "shadowOffsetX",
  24569. "shadowOffsetY",
  24570. "shadowRoot",
  24571. "shape",
  24572. "shape-image-threshold",
  24573. "shape-margin",
  24574. "shape-outside",
  24575. "shape-rendering",
  24576. "shapeImageThreshold",
  24577. "shapeMargin",
  24578. "shapeOutside",
  24579. "shapeRendering",
  24580. "sheet",
  24581. "shift",
  24582. "shiftKey",
  24583. "shiftLeft",
  24584. "shippingAddress",
  24585. "shippingOption",
  24586. "shippingType",
  24587. "show",
  24588. "showHelp",
  24589. "showModal",
  24590. "showModalDialog",
  24591. "showModelessDialog",
  24592. "showNotification",
  24593. "sidebar",
  24594. "sign",
  24595. "signal",
  24596. "signalingState",
  24597. "signature",
  24598. "silent",
  24599. "sin",
  24600. "singleNodeValue",
  24601. "sinh",
  24602. "sinkId",
  24603. "sittingToStandingTransform",
  24604. "size",
  24605. "sizeToContent",
  24606. "sizeX",
  24607. "sizeZ",
  24608. "sizes",
  24609. "skewX",
  24610. "skewXSelf",
  24611. "skewY",
  24612. "skewYSelf",
  24613. "slice",
  24614. "slope",
  24615. "slot",
  24616. "small",
  24617. "smil",
  24618. "smooth",
  24619. "smoothingTimeConstant",
  24620. "snapToLines",
  24621. "snapshotItem",
  24622. "snapshotLength",
  24623. "some",
  24624. "sort",
  24625. "sortingCode",
  24626. "source",
  24627. "sourceBuffer",
  24628. "sourceBuffers",
  24629. "sourceCapabilities",
  24630. "sourceFile",
  24631. "sourceIndex",
  24632. "sources",
  24633. "spacing",
  24634. "span",
  24635. "speak",
  24636. "speakAs",
  24637. "speaking",
  24638. "species",
  24639. "specified",
  24640. "specularConstant",
  24641. "specularExponent",
  24642. "speechSynthesis",
  24643. "speed",
  24644. "speedOfSound",
  24645. "spellcheck",
  24646. "splice",
  24647. "split",
  24648. "splitText",
  24649. "spreadMethod",
  24650. "sqrt",
  24651. "src",
  24652. "srcElement",
  24653. "srcFilter",
  24654. "srcObject",
  24655. "srcUrn",
  24656. "srcdoc",
  24657. "srclang",
  24658. "srcset",
  24659. "stack",
  24660. "stackTraceLimit",
  24661. "stacktrace",
  24662. "stageParameters",
  24663. "standalone",
  24664. "standby",
  24665. "start",
  24666. "startContainer",
  24667. "startIce",
  24668. "startMessages",
  24669. "startNotifications",
  24670. "startOffset",
  24671. "startProfiling",
  24672. "startRendering",
  24673. "startShark",
  24674. "startTime",
  24675. "startsWith",
  24676. "state",
  24677. "status",
  24678. "statusCode",
  24679. "statusMessage",
  24680. "statusText",
  24681. "statusbar",
  24682. "stdDeviationX",
  24683. "stdDeviationY",
  24684. "stencilFunc",
  24685. "stencilFuncSeparate",
  24686. "stencilMask",
  24687. "stencilMaskSeparate",
  24688. "stencilOp",
  24689. "stencilOpSeparate",
  24690. "step",
  24691. "stepDown",
  24692. "stepMismatch",
  24693. "stepUp",
  24694. "sticky",
  24695. "stitchTiles",
  24696. "stop",
  24697. "stop-color",
  24698. "stop-opacity",
  24699. "stopColor",
  24700. "stopImmediatePropagation",
  24701. "stopNotifications",
  24702. "stopOpacity",
  24703. "stopProfiling",
  24704. "stopPropagation",
  24705. "stopShark",
  24706. "stopped",
  24707. "storage",
  24708. "storageArea",
  24709. "storageName",
  24710. "storageStatus",
  24711. "store",
  24712. "storeSiteSpecificTrackingException",
  24713. "storeWebWideTrackingException",
  24714. "stpVersion",
  24715. "stream",
  24716. "streams",
  24717. "stretch",
  24718. "strike",
  24719. "string",
  24720. "stringValue",
  24721. "stringify",
  24722. "stroke",
  24723. "stroke-dasharray",
  24724. "stroke-dashoffset",
  24725. "stroke-linecap",
  24726. "stroke-linejoin",
  24727. "stroke-miterlimit",
  24728. "stroke-opacity",
  24729. "stroke-width",
  24730. "strokeDasharray",
  24731. "strokeDashoffset",
  24732. "strokeLinecap",
  24733. "strokeLinejoin",
  24734. "strokeMiterlimit",
  24735. "strokeOpacity",
  24736. "strokeRect",
  24737. "strokeStyle",
  24738. "strokeText",
  24739. "strokeWidth",
  24740. "style",
  24741. "styleFloat",
  24742. "styleMap",
  24743. "styleMedia",
  24744. "styleSheet",
  24745. "styleSheetSets",
  24746. "styleSheets",
  24747. "sub",
  24748. "subarray",
  24749. "subject",
  24750. "submit",
  24751. "submitFrame",
  24752. "submitter",
  24753. "subscribe",
  24754. "substr",
  24755. "substring",
  24756. "substringData",
  24757. "subtle",
  24758. "subtree",
  24759. "suffix",
  24760. "suffixes",
  24761. "summary",
  24762. "sup",
  24763. "supported",
  24764. "supportedContentEncodings",
  24765. "supportedEntryTypes",
  24766. "supports",
  24767. "supportsSession",
  24768. "surfaceScale",
  24769. "surroundContents",
  24770. "suspend",
  24771. "suspendRedraw",
  24772. "swapCache",
  24773. "swapNode",
  24774. "sweepFlag",
  24775. "symbols",
  24776. "sync",
  24777. "sysexEnabled",
  24778. "system",
  24779. "systemCode",
  24780. "systemId",
  24781. "systemLanguage",
  24782. "systemXDPI",
  24783. "systemYDPI",
  24784. "tBodies",
  24785. "tFoot",
  24786. "tHead",
  24787. "tabIndex",
  24788. "table",
  24789. "table-layout",
  24790. "tableLayout",
  24791. "tableValues",
  24792. "tag",
  24793. "tagName",
  24794. "tagUrn",
  24795. "tags",
  24796. "taintEnabled",
  24797. "takePhoto",
  24798. "takeRecords",
  24799. "tan",
  24800. "tangentialPressure",
  24801. "tanh",
  24802. "target",
  24803. "targetElement",
  24804. "targetRayMode",
  24805. "targetRaySpace",
  24806. "targetTouches",
  24807. "targetX",
  24808. "targetY",
  24809. "tcpType",
  24810. "tee",
  24811. "tel",
  24812. "terminate",
  24813. "test",
  24814. "texImage2D",
  24815. "texImage3D",
  24816. "texParameterf",
  24817. "texParameteri",
  24818. "texStorage2D",
  24819. "texStorage3D",
  24820. "texSubImage2D",
  24821. "texSubImage3D",
  24822. "text",
  24823. "text-align",
  24824. "text-align-last",
  24825. "text-anchor",
  24826. "text-combine-upright",
  24827. "text-decoration",
  24828. "text-decoration-color",
  24829. "text-decoration-line",
  24830. "text-decoration-skip-ink",
  24831. "text-decoration-style",
  24832. "text-decoration-thickness",
  24833. "text-emphasis",
  24834. "text-emphasis-color",
  24835. "text-emphasis-position",
  24836. "text-emphasis-style",
  24837. "text-indent",
  24838. "text-justify",
  24839. "text-orientation",
  24840. "text-overflow",
  24841. "text-rendering",
  24842. "text-shadow",
  24843. "text-transform",
  24844. "text-underline-offset",
  24845. "text-underline-position",
  24846. "textAlign",
  24847. "textAlignLast",
  24848. "textAnchor",
  24849. "textAutospace",
  24850. "textBaseline",
  24851. "textCombineUpright",
  24852. "textContent",
  24853. "textDecoration",
  24854. "textDecorationBlink",
  24855. "textDecorationColor",
  24856. "textDecorationLine",
  24857. "textDecorationLineThrough",
  24858. "textDecorationNone",
  24859. "textDecorationOverline",
  24860. "textDecorationSkipInk",
  24861. "textDecorationStyle",
  24862. "textDecorationThickness",
  24863. "textDecorationUnderline",
  24864. "textEmphasis",
  24865. "textEmphasisColor",
  24866. "textEmphasisPosition",
  24867. "textEmphasisStyle",
  24868. "textIndent",
  24869. "textJustify",
  24870. "textJustifyTrim",
  24871. "textKashida",
  24872. "textKashidaSpace",
  24873. "textLength",
  24874. "textOrientation",
  24875. "textOverflow",
  24876. "textRendering",
  24877. "textShadow",
  24878. "textTracks",
  24879. "textTransform",
  24880. "textUnderlineOffset",
  24881. "textUnderlinePosition",
  24882. "then",
  24883. "threadId",
  24884. "threshold",
  24885. "thresholds",
  24886. "tiltX",
  24887. "tiltY",
  24888. "time",
  24889. "timeEnd",
  24890. "timeLog",
  24891. "timeOrigin",
  24892. "timeRemaining",
  24893. "timeStamp",
  24894. "timecode",
  24895. "timeline",
  24896. "timelineTime",
  24897. "timeout",
  24898. "timestamp",
  24899. "timestampOffset",
  24900. "timing",
  24901. "title",
  24902. "to",
  24903. "toArray",
  24904. "toBlob",
  24905. "toDataURL",
  24906. "toDateString",
  24907. "toElement",
  24908. "toExponential",
  24909. "toFixed",
  24910. "toFloat32Array",
  24911. "toFloat64Array",
  24912. "toGMTString",
  24913. "toISOString",
  24914. "toJSON",
  24915. "toLocaleDateString",
  24916. "toLocaleFormat",
  24917. "toLocaleLowerCase",
  24918. "toLocaleString",
  24919. "toLocaleTimeString",
  24920. "toLocaleUpperCase",
  24921. "toLowerCase",
  24922. "toMatrix",
  24923. "toMethod",
  24924. "toPrecision",
  24925. "toPrimitive",
  24926. "toSdp",
  24927. "toSource",
  24928. "toStaticHTML",
  24929. "toString",
  24930. "toStringTag",
  24931. "toSum",
  24932. "toTimeString",
  24933. "toUTCString",
  24934. "toUpperCase",
  24935. "toggle",
  24936. "toggleAttribute",
  24937. "toggleLongPressEnabled",
  24938. "tone",
  24939. "toneBuffer",
  24940. "tooLong",
  24941. "tooShort",
  24942. "toolbar",
  24943. "top",
  24944. "topMargin",
  24945. "total",
  24946. "totalFrameDelay",
  24947. "totalVideoFrames",
  24948. "touch-action",
  24949. "touchAction",
  24950. "touched",
  24951. "touches",
  24952. "trace",
  24953. "track",
  24954. "trackVisibility",
  24955. "transaction",
  24956. "transactions",
  24957. "transceiver",
  24958. "transferControlToOffscreen",
  24959. "transferFromImageBitmap",
  24960. "transferImageBitmap",
  24961. "transferIn",
  24962. "transferOut",
  24963. "transferSize",
  24964. "transferToImageBitmap",
  24965. "transform",
  24966. "transform-box",
  24967. "transform-origin",
  24968. "transform-style",
  24969. "transformBox",
  24970. "transformFeedbackVaryings",
  24971. "transformOrigin",
  24972. "transformPoint",
  24973. "transformString",
  24974. "transformStyle",
  24975. "transformToDocument",
  24976. "transformToFragment",
  24977. "transition",
  24978. "transition-delay",
  24979. "transition-duration",
  24980. "transition-property",
  24981. "transition-timing-function",
  24982. "transitionDelay",
  24983. "transitionDuration",
  24984. "transitionProperty",
  24985. "transitionTimingFunction",
  24986. "translate",
  24987. "translateSelf",
  24988. "translationX",
  24989. "translationY",
  24990. "transport",
  24991. "trim",
  24992. "trimEnd",
  24993. "trimLeft",
  24994. "trimRight",
  24995. "trimStart",
  24996. "trueSpeed",
  24997. "trunc",
  24998. "truncate",
  24999. "trustedTypes",
  25000. "turn",
  25001. "twist",
  25002. "type",
  25003. "typeDetail",
  25004. "typeMismatch",
  25005. "typeMustMatch",
  25006. "types",
  25007. "u2f",
  25008. "ubound",
  25009. "uint16",
  25010. "uint32",
  25011. "uint8",
  25012. "uint8Clamped",
  25013. "undefined",
  25014. "unescape",
  25015. "uneval",
  25016. "unicode",
  25017. "unicode-bidi",
  25018. "unicodeBidi",
  25019. "unicodeRange",
  25020. "uniform1f",
  25021. "uniform1fv",
  25022. "uniform1i",
  25023. "uniform1iv",
  25024. "uniform1ui",
  25025. "uniform1uiv",
  25026. "uniform2f",
  25027. "uniform2fv",
  25028. "uniform2i",
  25029. "uniform2iv",
  25030. "uniform2ui",
  25031. "uniform2uiv",
  25032. "uniform3f",
  25033. "uniform3fv",
  25034. "uniform3i",
  25035. "uniform3iv",
  25036. "uniform3ui",
  25037. "uniform3uiv",
  25038. "uniform4f",
  25039. "uniform4fv",
  25040. "uniform4i",
  25041. "uniform4iv",
  25042. "uniform4ui",
  25043. "uniform4uiv",
  25044. "uniformBlockBinding",
  25045. "uniformMatrix2fv",
  25046. "uniformMatrix2x3fv",
  25047. "uniformMatrix2x4fv",
  25048. "uniformMatrix3fv",
  25049. "uniformMatrix3x2fv",
  25050. "uniformMatrix3x4fv",
  25051. "uniformMatrix4fv",
  25052. "uniformMatrix4x2fv",
  25053. "uniformMatrix4x3fv",
  25054. "unique",
  25055. "uniqueID",
  25056. "uniqueNumber",
  25057. "unit",
  25058. "unitType",
  25059. "units",
  25060. "unloadEventEnd",
  25061. "unloadEventStart",
  25062. "unlock",
  25063. "unmount",
  25064. "unobserve",
  25065. "unpause",
  25066. "unpauseAnimations",
  25067. "unreadCount",
  25068. "unregister",
  25069. "unregisterContentHandler",
  25070. "unregisterProtocolHandler",
  25071. "unscopables",
  25072. "unselectable",
  25073. "unshift",
  25074. "unsubscribe",
  25075. "unsuspendRedraw",
  25076. "unsuspendRedrawAll",
  25077. "unwatch",
  25078. "unwrapKey",
  25079. "upDegrees",
  25080. "upX",
  25081. "upY",
  25082. "upZ",
  25083. "update",
  25084. "updateCommands",
  25085. "updateIce",
  25086. "updateInterval",
  25087. "updatePlaybackRate",
  25088. "updateRenderState",
  25089. "updateSettings",
  25090. "updateTiming",
  25091. "updateViaCache",
  25092. "updateWith",
  25093. "updated",
  25094. "updating",
  25095. "upgrade",
  25096. "upload",
  25097. "uploadTotal",
  25098. "uploaded",
  25099. "upper",
  25100. "upperBound",
  25101. "upperOpen",
  25102. "uri",
  25103. "url",
  25104. "urn",
  25105. "urns",
  25106. "usages",
  25107. "usb",
  25108. "usbVersionMajor",
  25109. "usbVersionMinor",
  25110. "usbVersionSubminor",
  25111. "useCurrentView",
  25112. "useMap",
  25113. "useProgram",
  25114. "usedSpace",
  25115. "user-select",
  25116. "userActivation",
  25117. "userAgent",
  25118. "userChoice",
  25119. "userHandle",
  25120. "userHint",
  25121. "userLanguage",
  25122. "userSelect",
  25123. "userVisibleOnly",
  25124. "username",
  25125. "usernameFragment",
  25126. "utterance",
  25127. "uuid",
  25128. "v8BreakIterator",
  25129. "vAlign",
  25130. "vLink",
  25131. "valid",
  25132. "validate",
  25133. "validateProgram",
  25134. "validationMessage",
  25135. "validity",
  25136. "value",
  25137. "valueAsDate",
  25138. "valueAsNumber",
  25139. "valueAsString",
  25140. "valueInSpecifiedUnits",
  25141. "valueMissing",
  25142. "valueOf",
  25143. "valueText",
  25144. "valueType",
  25145. "values",
  25146. "variable",
  25147. "variant",
  25148. "variationSettings",
  25149. "vector-effect",
  25150. "vectorEffect",
  25151. "velocityAngular",
  25152. "velocityExpansion",
  25153. "velocityX",
  25154. "velocityY",
  25155. "vendor",
  25156. "vendorId",
  25157. "vendorSub",
  25158. "verify",
  25159. "version",
  25160. "vertexAttrib1f",
  25161. "vertexAttrib1fv",
  25162. "vertexAttrib2f",
  25163. "vertexAttrib2fv",
  25164. "vertexAttrib3f",
  25165. "vertexAttrib3fv",
  25166. "vertexAttrib4f",
  25167. "vertexAttrib4fv",
  25168. "vertexAttribDivisor",
  25169. "vertexAttribDivisorANGLE",
  25170. "vertexAttribI4i",
  25171. "vertexAttribI4iv",
  25172. "vertexAttribI4ui",
  25173. "vertexAttribI4uiv",
  25174. "vertexAttribIPointer",
  25175. "vertexAttribPointer",
  25176. "vertical",
  25177. "vertical-align",
  25178. "verticalAlign",
  25179. "verticalOverflow",
  25180. "vh",
  25181. "vibrate",
  25182. "vibrationActuator",
  25183. "videoBitsPerSecond",
  25184. "videoHeight",
  25185. "videoTracks",
  25186. "videoWidth",
  25187. "view",
  25188. "viewBox",
  25189. "viewBoxString",
  25190. "viewTarget",
  25191. "viewTargetString",
  25192. "viewport",
  25193. "viewportAnchorX",
  25194. "viewportAnchorY",
  25195. "viewportElement",
  25196. "views",
  25197. "violatedDirective",
  25198. "visibility",
  25199. "visibilityState",
  25200. "visible",
  25201. "visualViewport",
  25202. "vlinkColor",
  25203. "vmax",
  25204. "vmin",
  25205. "voice",
  25206. "voiceURI",
  25207. "volume",
  25208. "vrml",
  25209. "vspace",
  25210. "vw",
  25211. "w",
  25212. "wait",
  25213. "waitSync",
  25214. "waiting",
  25215. "wake",
  25216. "wakeLock",
  25217. "wand",
  25218. "warn",
  25219. "wasClean",
  25220. "wasDiscarded",
  25221. "watch",
  25222. "watchAvailability",
  25223. "watchPosition",
  25224. "webdriver",
  25225. "webkitAddKey",
  25226. "webkitAlignContent",
  25227. "webkitAlignItems",
  25228. "webkitAlignSelf",
  25229. "webkitAnimation",
  25230. "webkitAnimationDelay",
  25231. "webkitAnimationDirection",
  25232. "webkitAnimationDuration",
  25233. "webkitAnimationFillMode",
  25234. "webkitAnimationIterationCount",
  25235. "webkitAnimationName",
  25236. "webkitAnimationPlayState",
  25237. "webkitAnimationTimingFunction",
  25238. "webkitAppearance",
  25239. "webkitAudioContext",
  25240. "webkitAudioDecodedByteCount",
  25241. "webkitAudioPannerNode",
  25242. "webkitBackfaceVisibility",
  25243. "webkitBackground",
  25244. "webkitBackgroundAttachment",
  25245. "webkitBackgroundClip",
  25246. "webkitBackgroundColor",
  25247. "webkitBackgroundImage",
  25248. "webkitBackgroundOrigin",
  25249. "webkitBackgroundPosition",
  25250. "webkitBackgroundPositionX",
  25251. "webkitBackgroundPositionY",
  25252. "webkitBackgroundRepeat",
  25253. "webkitBackgroundSize",
  25254. "webkitBackingStorePixelRatio",
  25255. "webkitBorderBottomLeftRadius",
  25256. "webkitBorderBottomRightRadius",
  25257. "webkitBorderImage",
  25258. "webkitBorderImageOutset",
  25259. "webkitBorderImageRepeat",
  25260. "webkitBorderImageSlice",
  25261. "webkitBorderImageSource",
  25262. "webkitBorderImageWidth",
  25263. "webkitBorderRadius",
  25264. "webkitBorderTopLeftRadius",
  25265. "webkitBorderTopRightRadius",
  25266. "webkitBoxAlign",
  25267. "webkitBoxDirection",
  25268. "webkitBoxFlex",
  25269. "webkitBoxOrdinalGroup",
  25270. "webkitBoxOrient",
  25271. "webkitBoxPack",
  25272. "webkitBoxShadow",
  25273. "webkitBoxSizing",
  25274. "webkitCancelAnimationFrame",
  25275. "webkitCancelFullScreen",
  25276. "webkitCancelKeyRequest",
  25277. "webkitCancelRequestAnimationFrame",
  25278. "webkitClearResourceTimings",
  25279. "webkitClosedCaptionsVisible",
  25280. "webkitConvertPointFromNodeToPage",
  25281. "webkitConvertPointFromPageToNode",
  25282. "webkitCreateShadowRoot",
  25283. "webkitCurrentFullScreenElement",
  25284. "webkitCurrentPlaybackTargetIsWireless",
  25285. "webkitDecodedFrameCount",
  25286. "webkitDirectionInvertedFromDevice",
  25287. "webkitDisplayingFullscreen",
  25288. "webkitDroppedFrameCount",
  25289. "webkitEnterFullScreen",
  25290. "webkitEnterFullscreen",
  25291. "webkitEntries",
  25292. "webkitExitFullScreen",
  25293. "webkitExitFullscreen",
  25294. "webkitExitPointerLock",
  25295. "webkitFilter",
  25296. "webkitFlex",
  25297. "webkitFlexBasis",
  25298. "webkitFlexDirection",
  25299. "webkitFlexFlow",
  25300. "webkitFlexGrow",
  25301. "webkitFlexShrink",
  25302. "webkitFlexWrap",
  25303. "webkitFullScreenKeyboardInputAllowed",
  25304. "webkitFullscreenElement",
  25305. "webkitFullscreenEnabled",
  25306. "webkitGenerateKeyRequest",
  25307. "webkitGetAsEntry",
  25308. "webkitGetDatabaseNames",
  25309. "webkitGetEntries",
  25310. "webkitGetEntriesByName",
  25311. "webkitGetEntriesByType",
  25312. "webkitGetFlowByName",
  25313. "webkitGetGamepads",
  25314. "webkitGetImageDataHD",
  25315. "webkitGetNamedFlows",
  25316. "webkitGetRegionFlowRanges",
  25317. "webkitGetUserMedia",
  25318. "webkitHasClosedCaptions",
  25319. "webkitHidden",
  25320. "webkitIDBCursor",
  25321. "webkitIDBDatabase",
  25322. "webkitIDBDatabaseError",
  25323. "webkitIDBDatabaseException",
  25324. "webkitIDBFactory",
  25325. "webkitIDBIndex",
  25326. "webkitIDBKeyRange",
  25327. "webkitIDBObjectStore",
  25328. "webkitIDBRequest",
  25329. "webkitIDBTransaction",
  25330. "webkitImageSmoothingEnabled",
  25331. "webkitIndexedDB",
  25332. "webkitInitMessageEvent",
  25333. "webkitIsFullScreen",
  25334. "webkitJustifyContent",
  25335. "webkitKeys",
  25336. "webkitLineClamp",
  25337. "webkitLineDashOffset",
  25338. "webkitLockOrientation",
  25339. "webkitMask",
  25340. "webkitMaskClip",
  25341. "webkitMaskComposite",
  25342. "webkitMaskImage",
  25343. "webkitMaskOrigin",
  25344. "webkitMaskPosition",
  25345. "webkitMaskPositionX",
  25346. "webkitMaskPositionY",
  25347. "webkitMaskRepeat",
  25348. "webkitMaskSize",
  25349. "webkitMatchesSelector",
  25350. "webkitMediaStream",
  25351. "webkitNotifications",
  25352. "webkitOfflineAudioContext",
  25353. "webkitOrder",
  25354. "webkitOrientation",
  25355. "webkitPeerConnection00",
  25356. "webkitPersistentStorage",
  25357. "webkitPerspective",
  25358. "webkitPerspectiveOrigin",
  25359. "webkitPointerLockElement",
  25360. "webkitPostMessage",
  25361. "webkitPreservesPitch",
  25362. "webkitPutImageDataHD",
  25363. "webkitRTCPeerConnection",
  25364. "webkitRegionOverset",
  25365. "webkitRelativePath",
  25366. "webkitRequestAnimationFrame",
  25367. "webkitRequestFileSystem",
  25368. "webkitRequestFullScreen",
  25369. "webkitRequestFullscreen",
  25370. "webkitRequestPointerLock",
  25371. "webkitResolveLocalFileSystemURL",
  25372. "webkitSetMediaKeys",
  25373. "webkitSetResourceTimingBufferSize",
  25374. "webkitShadowRoot",
  25375. "webkitShowPlaybackTargetPicker",
  25376. "webkitSlice",
  25377. "webkitSpeechGrammar",
  25378. "webkitSpeechGrammarList",
  25379. "webkitSpeechRecognition",
  25380. "webkitSpeechRecognitionError",
  25381. "webkitSpeechRecognitionEvent",
  25382. "webkitStorageInfo",
  25383. "webkitSupportsFullscreen",
  25384. "webkitTemporaryStorage",
  25385. "webkitTextFillColor",
  25386. "webkitTextSizeAdjust",
  25387. "webkitTextStroke",
  25388. "webkitTextStrokeColor",
  25389. "webkitTextStrokeWidth",
  25390. "webkitTransform",
  25391. "webkitTransformOrigin",
  25392. "webkitTransformStyle",
  25393. "webkitTransition",
  25394. "webkitTransitionDelay",
  25395. "webkitTransitionDuration",
  25396. "webkitTransitionProperty",
  25397. "webkitTransitionTimingFunction",
  25398. "webkitURL",
  25399. "webkitUnlockOrientation",
  25400. "webkitUserSelect",
  25401. "webkitVideoDecodedByteCount",
  25402. "webkitVisibilityState",
  25403. "webkitWirelessVideoPlaybackDisabled",
  25404. "webkitdirectory",
  25405. "webkitdropzone",
  25406. "webstore",
  25407. "weight",
  25408. "whatToShow",
  25409. "wheelDelta",
  25410. "wheelDeltaX",
  25411. "wheelDeltaY",
  25412. "whenDefined",
  25413. "which",
  25414. "white-space",
  25415. "whiteSpace",
  25416. "wholeText",
  25417. "widows",
  25418. "width",
  25419. "will-change",
  25420. "willChange",
  25421. "willValidate",
  25422. "window",
  25423. "withCredentials",
  25424. "word-break",
  25425. "word-spacing",
  25426. "word-wrap",
  25427. "wordBreak",
  25428. "wordSpacing",
  25429. "wordWrap",
  25430. "workerStart",
  25431. "wrap",
  25432. "wrapKey",
  25433. "writable",
  25434. "writableAuxiliaries",
  25435. "write",
  25436. "writeText",
  25437. "writeValue",
  25438. "writeWithoutResponse",
  25439. "writeln",
  25440. "writing-mode",
  25441. "writingMode",
  25442. "x",
  25443. "x1",
  25444. "x2",
  25445. "xChannelSelector",
  25446. "xmlEncoding",
  25447. "xmlStandalone",
  25448. "xmlVersion",
  25449. "xmlbase",
  25450. "xmllang",
  25451. "xmlspace",
  25452. "xor",
  25453. "xr",
  25454. "y",
  25455. "y1",
  25456. "y2",
  25457. "yChannelSelector",
  25458. "yandex",
  25459. "z",
  25460. "z-index",
  25461. "zIndex",
  25462. "zoom",
  25463. "zoomAndPan",
  25464. "zoomRectScreen",
  25465. ];
  25466. /***********************************************************************
  25467. A JavaScript tokenizer / parser / beautifier / compressor.
  25468. https://github.com/mishoo/UglifyJS2
  25469. -------------------------------- (C) ---------------------------------
  25470. Author: Mihai Bazon
  25471. <mihai.bazon@gmail.com>
  25472. http://mihai.bazon.net/blog
  25473. Distributed under the BSD license:
  25474. Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
  25475. Redistribution and use in source and binary forms, with or without
  25476. modification, are permitted provided that the following conditions
  25477. are met:
  25478. * Redistributions of source code must retain the above
  25479. copyright notice, this list of conditions and the following
  25480. disclaimer.
  25481. * Redistributions in binary form must reproduce the above
  25482. copyright notice, this list of conditions and the following
  25483. disclaimer in the documentation and/or other materials
  25484. provided with the distribution.
  25485. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
  25486. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25487. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  25488. PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
  25489. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  25490. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25491. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25492. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25493. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  25494. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  25495. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25496. SUCH DAMAGE.
  25497. ***********************************************************************/
  25498. function find_builtins(reserved) {
  25499. domprops.forEach(add);
  25500. // Compatibility fix for some standard defined globals not defined on every js environment
  25501. var new_globals = ["Symbol", "Map", "Promise", "Proxy", "Reflect", "Set", "WeakMap", "WeakSet"];
  25502. var objects = {};
  25503. var global_ref = typeof global === "object" ? global : self;
  25504. new_globals.forEach(function (new_global) {
  25505. objects[new_global] = global_ref[new_global] || new Function();
  25506. });
  25507. [
  25508. "null",
  25509. "true",
  25510. "false",
  25511. "NaN",
  25512. "Infinity",
  25513. "-Infinity",
  25514. "undefined",
  25515. ].forEach(add);
  25516. [ Object, Array, Function, Number,
  25517. String, Boolean, Error, Math,
  25518. Date, RegExp, objects.Symbol, ArrayBuffer,
  25519. DataView, decodeURI, decodeURIComponent,
  25520. encodeURI, encodeURIComponent, eval, EvalError,
  25521. Float32Array, Float64Array, Int8Array, Int16Array,
  25522. Int32Array, isFinite, isNaN, JSON, objects.Map, parseFloat,
  25523. parseInt, objects.Promise, objects.Proxy, RangeError, ReferenceError,
  25524. objects.Reflect, objects.Set, SyntaxError, TypeError, Uint8Array,
  25525. Uint8ClampedArray, Uint16Array, Uint32Array, URIError,
  25526. objects.WeakMap, objects.WeakSet
  25527. ].forEach(function(ctor) {
  25528. Object.getOwnPropertyNames(ctor).map(add);
  25529. if (ctor.prototype) {
  25530. Object.getOwnPropertyNames(ctor.prototype).map(add);
  25531. }
  25532. });
  25533. function add(name) {
  25534. reserved.add(name);
  25535. }
  25536. }
  25537. function reserve_quoted_keys(ast, reserved) {
  25538. function add(name) {
  25539. push_uniq(reserved, name);
  25540. }
  25541. ast.walk(new TreeWalker(function(node) {
  25542. if (node instanceof AST_ObjectKeyVal && node.quote) {
  25543. add(node.key);
  25544. } else if (node instanceof AST_ObjectProperty && node.quote) {
  25545. add(node.key.name);
  25546. } else if (node instanceof AST_Sub) {
  25547. addStrings(node.property, add);
  25548. }
  25549. }));
  25550. }
  25551. function addStrings(node, add) {
  25552. node.walk(new TreeWalker(function(node) {
  25553. if (node instanceof AST_Sequence) {
  25554. addStrings(node.tail_node(), add);
  25555. } else if (node instanceof AST_String) {
  25556. add(node.value);
  25557. } else if (node instanceof AST_Conditional) {
  25558. addStrings(node.consequent, add);
  25559. addStrings(node.alternative, add);
  25560. }
  25561. return true;
  25562. }));
  25563. }
  25564. function mangle_private_properties(ast, options) {
  25565. var cprivate = -1;
  25566. var private_cache = new Map();
  25567. var nth_identifier = options.nth_identifier || base54;
  25568. ast = ast.transform(new TreeTransformer(function(node) {
  25569. if (
  25570. node instanceof AST_ClassPrivateProperty
  25571. || node instanceof AST_PrivateMethod
  25572. || node instanceof AST_PrivateGetter
  25573. || node instanceof AST_PrivateSetter
  25574. ) {
  25575. node.key.name = mangle_private(node.key.name);
  25576. } else if (node instanceof AST_DotHash) {
  25577. node.property = mangle_private(node.property);
  25578. }
  25579. }));
  25580. return ast;
  25581. function mangle_private(name) {
  25582. let mangled = private_cache.get(name);
  25583. if (!mangled) {
  25584. mangled = nth_identifier.get(++cprivate);
  25585. private_cache.set(name, mangled);
  25586. }
  25587. return mangled;
  25588. }
  25589. }
  25590. function mangle_properties(ast, options) {
  25591. options = defaults(options, {
  25592. builtins: false,
  25593. cache: null,
  25594. debug: false,
  25595. keep_quoted: false,
  25596. nth_identifier: base54,
  25597. only_cache: false,
  25598. regex: null,
  25599. reserved: null,
  25600. undeclared: false,
  25601. }, true);
  25602. var nth_identifier = options.nth_identifier;
  25603. var reserved_option = options.reserved;
  25604. if (!Array.isArray(reserved_option)) reserved_option = [reserved_option];
  25605. var reserved = new Set(reserved_option);
  25606. if (!options.builtins) find_builtins(reserved);
  25607. var cname = -1;
  25608. var cache;
  25609. if (options.cache) {
  25610. cache = options.cache.props;
  25611. } else {
  25612. cache = new Map();
  25613. }
  25614. var regex = options.regex && new RegExp(options.regex);
  25615. // note debug is either false (disabled), or a string of the debug suffix to use (enabled).
  25616. // note debug may be enabled as an empty string, which is falsey. Also treat passing 'true'
  25617. // the same as passing an empty string.
  25618. var debug = options.debug !== false;
  25619. var debug_name_suffix;
  25620. if (debug) {
  25621. debug_name_suffix = (options.debug === true ? "" : options.debug);
  25622. }
  25623. var names_to_mangle = new Set();
  25624. var unmangleable = new Set();
  25625. // Track each already-mangled name to prevent nth_identifier from generating
  25626. // the same name.
  25627. cache.forEach((mangled_name) => unmangleable.add(mangled_name));
  25628. var keep_quoted = !!options.keep_quoted;
  25629. // step 1: find candidates to mangle
  25630. ast.walk(new TreeWalker(function(node) {
  25631. if (
  25632. node instanceof AST_ClassPrivateProperty
  25633. || node instanceof AST_PrivateMethod
  25634. || node instanceof AST_PrivateGetter
  25635. || node instanceof AST_PrivateSetter
  25636. || node instanceof AST_DotHash
  25637. ) ; else if (node instanceof AST_ObjectKeyVal) {
  25638. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  25639. add(node.key);
  25640. }
  25641. } else if (node instanceof AST_ObjectProperty) {
  25642. // setter or getter, since KeyVal is handled above
  25643. if (!keep_quoted || !node.quote) {
  25644. add(node.key.name);
  25645. }
  25646. } else if (node instanceof AST_Dot) {
  25647. var declared = !!options.undeclared;
  25648. if (!declared) {
  25649. var root = node;
  25650. while (root.expression) {
  25651. root = root.expression;
  25652. }
  25653. declared = !(root.thedef && root.thedef.undeclared);
  25654. }
  25655. if (declared &&
  25656. (!keep_quoted || !node.quote)) {
  25657. add(node.property);
  25658. }
  25659. } else if (node instanceof AST_Sub) {
  25660. if (!keep_quoted) {
  25661. addStrings(node.property, add);
  25662. }
  25663. } else if (node instanceof AST_Call
  25664. && node.expression.print_to_string() == "Object.defineProperty") {
  25665. addStrings(node.args[1], add);
  25666. } else if (node instanceof AST_Binary && node.operator === "in") {
  25667. addStrings(node.left, add);
  25668. }
  25669. }));
  25670. // step 2: transform the tree, renaming properties
  25671. return ast.transform(new TreeTransformer(function(node) {
  25672. if (
  25673. node instanceof AST_ClassPrivateProperty
  25674. || node instanceof AST_PrivateMethod
  25675. || node instanceof AST_PrivateGetter
  25676. || node instanceof AST_PrivateSetter
  25677. || node instanceof AST_DotHash
  25678. ) ; else if (node instanceof AST_ObjectKeyVal) {
  25679. if (typeof node.key == "string" && (!keep_quoted || !node.quote)) {
  25680. node.key = mangle(node.key);
  25681. }
  25682. } else if (node instanceof AST_ObjectProperty) {
  25683. // setter, getter, method or class field
  25684. if (!keep_quoted || !node.quote) {
  25685. node.key.name = mangle(node.key.name);
  25686. }
  25687. } else if (node instanceof AST_Dot) {
  25688. if (!keep_quoted || !node.quote) {
  25689. node.property = mangle(node.property);
  25690. }
  25691. } else if (!keep_quoted && node instanceof AST_Sub) {
  25692. node.property = mangleStrings(node.property);
  25693. } else if (node instanceof AST_Call
  25694. && node.expression.print_to_string() == "Object.defineProperty") {
  25695. node.args[1] = mangleStrings(node.args[1]);
  25696. } else if (node instanceof AST_Binary && node.operator === "in") {
  25697. node.left = mangleStrings(node.left);
  25698. }
  25699. }));
  25700. // only function declarations after this line
  25701. function can_mangle(name) {
  25702. if (unmangleable.has(name)) return false;
  25703. if (reserved.has(name)) return false;
  25704. if (options.only_cache) {
  25705. return cache.has(name);
  25706. }
  25707. if (/^-?[0-9]+(\.[0-9]+)?(e[+-][0-9]+)?$/.test(name)) return false;
  25708. return true;
  25709. }
  25710. function should_mangle(name) {
  25711. if (regex && !regex.test(name)) return false;
  25712. if (reserved.has(name)) return false;
  25713. return cache.has(name)
  25714. || names_to_mangle.has(name);
  25715. }
  25716. function add(name) {
  25717. if (can_mangle(name))
  25718. names_to_mangle.add(name);
  25719. if (!should_mangle(name)) {
  25720. unmangleable.add(name);
  25721. }
  25722. }
  25723. function mangle(name) {
  25724. if (!should_mangle(name)) {
  25725. return name;
  25726. }
  25727. var mangled = cache.get(name);
  25728. if (!mangled) {
  25729. if (debug) {
  25730. // debug mode: use a prefix and suffix to preserve readability, e.g. o.foo -> o._$foo$NNN_.
  25731. var debug_mangled = "_$" + name + "$" + debug_name_suffix + "_";
  25732. if (can_mangle(debug_mangled)) {
  25733. mangled = debug_mangled;
  25734. }
  25735. }
  25736. // either debug mode is off, or it is on and we could not use the mangled name
  25737. if (!mangled) {
  25738. do {
  25739. mangled = nth_identifier.get(++cname);
  25740. } while (!can_mangle(mangled));
  25741. }
  25742. cache.set(name, mangled);
  25743. }
  25744. return mangled;
  25745. }
  25746. function mangleStrings(node) {
  25747. return node.transform(new TreeTransformer(function(node) {
  25748. if (node instanceof AST_Sequence) {
  25749. var last = node.expressions.length - 1;
  25750. node.expressions[last] = mangleStrings(node.expressions[last]);
  25751. } else if (node instanceof AST_String) {
  25752. node.value = mangle(node.value);
  25753. } else if (node instanceof AST_Conditional) {
  25754. node.consequent = mangleStrings(node.consequent);
  25755. node.alternative = mangleStrings(node.alternative);
  25756. }
  25757. return node;
  25758. }));
  25759. }
  25760. }
  25761. var to_ascii = typeof atob == "undefined" ? function(b64) {
  25762. return Buffer.from(b64, "base64").toString();
  25763. } : atob;
  25764. var to_base64 = typeof btoa == "undefined" ? function(str) {
  25765. return Buffer.from(str).toString("base64");
  25766. } : btoa;
  25767. function read_source_map(code) {
  25768. var match = /(?:^|[^.])\/\/# sourceMappingURL=data:application\/json(;[\w=-]*)?;base64,([+/0-9A-Za-z]*=*)\s*$/.exec(code);
  25769. if (!match) {
  25770. console.warn("inline source map not found");
  25771. return null;
  25772. }
  25773. return to_ascii(match[2]);
  25774. }
  25775. function set_shorthand(name, options, keys) {
  25776. if (options[name]) {
  25777. keys.forEach(function(key) {
  25778. if (options[key]) {
  25779. if (typeof options[key] != "object") options[key] = {};
  25780. if (!(name in options[key])) options[key][name] = options[name];
  25781. }
  25782. });
  25783. }
  25784. }
  25785. function init_cache(cache) {
  25786. if (!cache) return;
  25787. if (!("props" in cache)) {
  25788. cache.props = new Map();
  25789. } else if (!(cache.props instanceof Map)) {
  25790. cache.props = map_from_object(cache.props);
  25791. }
  25792. }
  25793. function cache_to_json(cache) {
  25794. return {
  25795. props: map_to_object(cache.props)
  25796. };
  25797. }
  25798. async function minify(files, options) {
  25799. options = defaults(options, {
  25800. compress: {},
  25801. ecma: undefined,
  25802. enclose: false,
  25803. ie8: false,
  25804. keep_classnames: undefined,
  25805. keep_fnames: false,
  25806. mangle: {},
  25807. module: false,
  25808. nameCache: null,
  25809. output: null,
  25810. format: null,
  25811. parse: {},
  25812. rename: undefined,
  25813. safari10: false,
  25814. sourceMap: false,
  25815. spidermonkey: false,
  25816. timings: false,
  25817. toplevel: false,
  25818. warnings: false,
  25819. wrap: false,
  25820. }, true);
  25821. var timings = options.timings && {
  25822. start: Date.now()
  25823. };
  25824. if (options.keep_classnames === undefined) {
  25825. options.keep_classnames = options.keep_fnames;
  25826. }
  25827. if (options.rename === undefined) {
  25828. options.rename = options.compress && options.mangle;
  25829. }
  25830. if (options.output && options.format) {
  25831. throw new Error("Please only specify either output or format option, preferrably format.");
  25832. }
  25833. options.format = options.format || options.output || {};
  25834. set_shorthand("ecma", options, [ "parse", "compress", "format" ]);
  25835. set_shorthand("ie8", options, [ "compress", "mangle", "format" ]);
  25836. set_shorthand("keep_classnames", options, [ "compress", "mangle" ]);
  25837. set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);
  25838. set_shorthand("module", options, [ "parse", "compress", "mangle" ]);
  25839. set_shorthand("safari10", options, [ "mangle", "format" ]);
  25840. set_shorthand("toplevel", options, [ "compress", "mangle" ]);
  25841. set_shorthand("warnings", options, [ "compress" ]); // legacy
  25842. var quoted_props;
  25843. if (options.mangle) {
  25844. options.mangle = defaults(options.mangle, {
  25845. cache: options.nameCache && (options.nameCache.vars || {}),
  25846. eval: false,
  25847. ie8: false,
  25848. keep_classnames: false,
  25849. keep_fnames: false,
  25850. module: false,
  25851. nth_identifier: base54,
  25852. properties: false,
  25853. reserved: [],
  25854. safari10: false,
  25855. toplevel: false,
  25856. }, true);
  25857. if (options.mangle.properties) {
  25858. if (typeof options.mangle.properties != "object") {
  25859. options.mangle.properties = {};
  25860. }
  25861. if (options.mangle.properties.keep_quoted) {
  25862. quoted_props = options.mangle.properties.reserved;
  25863. if (!Array.isArray(quoted_props)) quoted_props = [];
  25864. options.mangle.properties.reserved = quoted_props;
  25865. }
  25866. if (options.nameCache && !("cache" in options.mangle.properties)) {
  25867. options.mangle.properties.cache = options.nameCache.props || {};
  25868. }
  25869. }
  25870. init_cache(options.mangle.cache);
  25871. init_cache(options.mangle.properties.cache);
  25872. }
  25873. if (options.sourceMap) {
  25874. options.sourceMap = defaults(options.sourceMap, {
  25875. asObject: false,
  25876. content: null,
  25877. filename: null,
  25878. includeSources: false,
  25879. root: null,
  25880. url: null,
  25881. }, true);
  25882. }
  25883. if (timings) timings.parse = Date.now();
  25884. var toplevel;
  25885. if (files instanceof AST_Toplevel) {
  25886. toplevel = files;
  25887. } else {
  25888. if (typeof files == "string" || (options.parse.spidermonkey && !Array.isArray(files))) {
  25889. files = [ files ];
  25890. }
  25891. options.parse = options.parse || {};
  25892. options.parse.toplevel = null;
  25893. if (options.parse.spidermonkey) {
  25894. options.parse.toplevel = AST_Node.from_mozilla_ast(Object.keys(files).reduce(function(toplevel, name) {
  25895. if (!toplevel) return files[name];
  25896. toplevel.body = toplevel.body.concat(files[name].body);
  25897. return toplevel;
  25898. }, null));
  25899. } else {
  25900. delete options.parse.spidermonkey;
  25901. for (var name in files) if (HOP(files, name)) {
  25902. options.parse.filename = name;
  25903. options.parse.toplevel = parse(files[name], options.parse);
  25904. if (options.sourceMap && options.sourceMap.content == "inline") {
  25905. if (Object.keys(files).length > 1)
  25906. throw new Error("inline source map only works with singular input");
  25907. options.sourceMap.content = read_source_map(files[name]);
  25908. }
  25909. }
  25910. }
  25911. toplevel = options.parse.toplevel;
  25912. }
  25913. if (quoted_props && options.mangle.properties.keep_quoted !== "strict") {
  25914. reserve_quoted_keys(toplevel, quoted_props);
  25915. }
  25916. if (options.wrap) {
  25917. toplevel = toplevel.wrap_commonjs(options.wrap);
  25918. }
  25919. if (options.enclose) {
  25920. toplevel = toplevel.wrap_enclose(options.enclose);
  25921. }
  25922. if (timings) timings.rename = Date.now();
  25923. if (timings) timings.compress = Date.now();
  25924. if (options.compress) {
  25925. toplevel = new Compressor(options.compress, {
  25926. mangle_options: options.mangle
  25927. }).compress(toplevel);
  25928. }
  25929. if (timings) timings.scope = Date.now();
  25930. if (options.mangle) toplevel.figure_out_scope(options.mangle);
  25931. if (timings) timings.mangle = Date.now();
  25932. if (options.mangle) {
  25933. toplevel.compute_char_frequency(options.mangle);
  25934. toplevel.mangle_names(options.mangle);
  25935. toplevel = mangle_private_properties(toplevel, options.mangle);
  25936. }
  25937. if (timings) timings.properties = Date.now();
  25938. if (options.mangle && options.mangle.properties) {
  25939. toplevel = mangle_properties(toplevel, options.mangle.properties);
  25940. }
  25941. if (timings) timings.format = Date.now();
  25942. var result = {};
  25943. if (options.format.ast) {
  25944. result.ast = toplevel;
  25945. }
  25946. if (options.format.spidermonkey) {
  25947. result.ast = toplevel.to_mozilla_ast();
  25948. }
  25949. if (!HOP(options.format, "code") || options.format.code) {
  25950. if (options.sourceMap) {
  25951. options.format.source_map = await SourceMap({
  25952. file: options.sourceMap.filename,
  25953. orig: options.sourceMap.content,
  25954. root: options.sourceMap.root
  25955. });
  25956. if (options.sourceMap.includeSources) {
  25957. if (files instanceof AST_Toplevel) {
  25958. throw new Error("original source content unavailable");
  25959. } else for (var name in files) if (HOP(files, name)) {
  25960. options.format.source_map.get().setSourceContent(name, files[name]);
  25961. }
  25962. }
  25963. }
  25964. delete options.format.ast;
  25965. delete options.format.code;
  25966. delete options.format.spidermonkey;
  25967. var stream = OutputStream(options.format);
  25968. toplevel.print(stream);
  25969. result.code = stream.get();
  25970. if (options.sourceMap) {
  25971. if(options.sourceMap.asObject) {
  25972. result.map = options.format.source_map.get().toJSON();
  25973. } else {
  25974. result.map = options.format.source_map.toString();
  25975. }
  25976. if (options.sourceMap.url == "inline") {
  25977. var sourceMap = typeof result.map === "object" ? JSON.stringify(result.map) : result.map;
  25978. result.code += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64," + to_base64(sourceMap);
  25979. } else if (options.sourceMap.url) {
  25980. result.code += "\n//# sourceMappingURL=" + options.sourceMap.url;
  25981. }
  25982. }
  25983. }
  25984. if (options.nameCache && options.mangle) {
  25985. if (options.mangle.cache) options.nameCache.vars = cache_to_json(options.mangle.cache);
  25986. if (options.mangle.properties && options.mangle.properties.cache) {
  25987. options.nameCache.props = cache_to_json(options.mangle.properties.cache);
  25988. }
  25989. }
  25990. if (options.format && options.format.source_map) {
  25991. options.format.source_map.destroy();
  25992. }
  25993. if (timings) {
  25994. timings.end = Date.now();
  25995. result.timings = {
  25996. parse: 1e-3 * (timings.rename - timings.parse),
  25997. rename: 1e-3 * (timings.compress - timings.rename),
  25998. compress: 1e-3 * (timings.scope - timings.compress),
  25999. scope: 1e-3 * (timings.mangle - timings.scope),
  26000. mangle: 1e-3 * (timings.properties - timings.mangle),
  26001. properties: 1e-3 * (timings.format - timings.properties),
  26002. format: 1e-3 * (timings.end - timings.format),
  26003. total: 1e-3 * (timings.end - timings.start)
  26004. };
  26005. }
  26006. return result;
  26007. }
  26008. async function run_cli({ program, packageJson, fs, path }) {
  26009. const skip_keys = new Set([ "cname", "parent_scope", "scope", "uses_eval", "uses_with" ]);
  26010. var files = {};
  26011. var options = {
  26012. compress: false,
  26013. mangle: false
  26014. };
  26015. const default_options = await _default_options();
  26016. program.version(packageJson.name + " " + packageJson.version);
  26017. program.parseArgv = program.parse;
  26018. program.parse = undefined;
  26019. if (process.argv.includes("ast")) program.helpInformation = describe_ast;
  26020. else if (process.argv.includes("options")) program.helpInformation = function() {
  26021. var text = [];
  26022. for (var option in default_options) {
  26023. text.push("--" + (option === "sourceMap" ? "source-map" : option) + " options:");
  26024. text.push(format_object(default_options[option]));
  26025. text.push("");
  26026. }
  26027. return text.join("\n");
  26028. };
  26029. program.option("-p, --parse <options>", "Specify parser options.", parse_js());
  26030. program.option("-c, --compress [options]", "Enable compressor/specify compressor options.", parse_js());
  26031. program.option("-m, --mangle [options]", "Mangle names/specify mangler options.", parse_js());
  26032. program.option("--mangle-props [options]", "Mangle properties/specify mangler options.", parse_js());
  26033. program.option("-f, --format [options]", "Format options.", parse_js());
  26034. program.option("-b, --beautify [options]", "Alias for --format.", parse_js());
  26035. program.option("-o, --output <file>", "Output file (default STDOUT).");
  26036. program.option("--comments [filter]", "Preserve copyright comments in the output.");
  26037. program.option("--config-file <file>", "Read minify() options from JSON file.");
  26038. program.option("-d, --define <expr>[=value]", "Global definitions.", parse_js("define"));
  26039. program.option("--ecma <version>", "Specify ECMAScript release: 5, 2015, 2016 or 2017...");
  26040. program.option("-e, --enclose [arg[,...][:value[,...]]]", "Embed output in a big function with configurable arguments and values.");
  26041. program.option("--ie8", "Support non-standard Internet Explorer 8.");
  26042. program.option("--keep-classnames", "Do not mangle/drop class names.");
  26043. program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name.");
  26044. program.option("--module", "Input is an ES6 module");
  26045. program.option("--name-cache <file>", "File to hold mangled name mappings.");
  26046. program.option("--rename", "Force symbol expansion.");
  26047. program.option("--no-rename", "Disable symbol expansion.");
  26048. program.option("--safari10", "Support non-standard Safari 10.");
  26049. program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js());
  26050. program.option("--timings", "Display operations run time on STDERR.");
  26051. program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");
  26052. program.option("--wrap <name>", "Embed everything as a function with “exports” corresponding to “name” globally.");
  26053. program.arguments("[files...]").parseArgv(process.argv);
  26054. if (program.configFile) {
  26055. options = JSON.parse(read_file(program.configFile));
  26056. }
  26057. if (!program.output && program.sourceMap && program.sourceMap.url != "inline") {
  26058. fatal("ERROR: cannot write source map to STDOUT");
  26059. }
  26060. [
  26061. "compress",
  26062. "enclose",
  26063. "ie8",
  26064. "mangle",
  26065. "module",
  26066. "safari10",
  26067. "sourceMap",
  26068. "toplevel",
  26069. "wrap"
  26070. ].forEach(function(name) {
  26071. if (name in program) {
  26072. options[name] = program[name];
  26073. }
  26074. });
  26075. if ("ecma" in program) {
  26076. if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
  26077. const ecma = program.ecma | 0;
  26078. if (ecma > 5 && ecma < 2015)
  26079. options.ecma = ecma + 2009;
  26080. else
  26081. options.ecma = ecma;
  26082. }
  26083. if (program.format || program.beautify) {
  26084. const chosenOption = program.format || program.beautify;
  26085. options.format = typeof chosenOption === "object" ? chosenOption : {};
  26086. }
  26087. if (program.comments) {
  26088. if (typeof options.format != "object") options.format = {};
  26089. options.format.comments = typeof program.comments == "string" ? (program.comments == "false" ? false : program.comments) : "some";
  26090. }
  26091. if (program.define) {
  26092. if (typeof options.compress != "object") options.compress = {};
  26093. if (typeof options.compress.global_defs != "object") options.compress.global_defs = {};
  26094. for (var expr in program.define) {
  26095. options.compress.global_defs[expr] = program.define[expr];
  26096. }
  26097. }
  26098. if (program.keepClassnames) {
  26099. options.keep_classnames = true;
  26100. }
  26101. if (program.keepFnames) {
  26102. options.keep_fnames = true;
  26103. }
  26104. if (program.mangleProps) {
  26105. if (program.mangleProps.domprops) {
  26106. delete program.mangleProps.domprops;
  26107. } else {
  26108. if (typeof program.mangleProps != "object") program.mangleProps = {};
  26109. if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
  26110. }
  26111. if (typeof options.mangle != "object") options.mangle = {};
  26112. options.mangle.properties = program.mangleProps;
  26113. }
  26114. if (program.nameCache) {
  26115. options.nameCache = JSON.parse(read_file(program.nameCache, "{}"));
  26116. }
  26117. if (program.output == "ast") {
  26118. options.format = {
  26119. ast: true,
  26120. code: false
  26121. };
  26122. }
  26123. if (program.parse) {
  26124. if (!program.parse.acorn && !program.parse.spidermonkey) {
  26125. options.parse = program.parse;
  26126. } else if (program.sourceMap && program.sourceMap.content == "inline") {
  26127. fatal("ERROR: inline source map only works with built-in parser");
  26128. }
  26129. }
  26130. if (~program.rawArgs.indexOf("--rename")) {
  26131. options.rename = true;
  26132. } else if (!program.rename) {
  26133. options.rename = false;
  26134. }
  26135. let convert_path = name => name;
  26136. if (typeof program.sourceMap == "object" && "base" in program.sourceMap) {
  26137. convert_path = function() {
  26138. var base = program.sourceMap.base;
  26139. delete options.sourceMap.base;
  26140. return function(name) {
  26141. return path.relative(base, name);
  26142. };
  26143. }();
  26144. }
  26145. let filesList;
  26146. if (options.files && options.files.length) {
  26147. filesList = options.files;
  26148. delete options.files;
  26149. } else if (program.args.length) {
  26150. filesList = program.args;
  26151. }
  26152. if (filesList) {
  26153. simple_glob(filesList).forEach(function(name) {
  26154. files[convert_path(name)] = read_file(name);
  26155. });
  26156. } else {
  26157. await new Promise((resolve) => {
  26158. var chunks = [];
  26159. process.stdin.setEncoding("utf8");
  26160. process.stdin.on("data", function(chunk) {
  26161. chunks.push(chunk);
  26162. }).on("end", function() {
  26163. files = [ chunks.join("") ];
  26164. resolve();
  26165. });
  26166. process.stdin.resume();
  26167. });
  26168. }
  26169. await run_cli();
  26170. function convert_ast(fn) {
  26171. return AST_Node.from_mozilla_ast(Object.keys(files).reduce(fn, null));
  26172. }
  26173. async function run_cli() {
  26174. var content = program.sourceMap && program.sourceMap.content;
  26175. if (content && content !== "inline") {
  26176. options.sourceMap.content = read_file(content, content);
  26177. }
  26178. if (program.timings) options.timings = true;
  26179. try {
  26180. if (program.parse) {
  26181. if (program.parse.acorn) {
  26182. files = convert_ast(function(toplevel, name) {
  26183. return require("acorn").parse(files[name], {
  26184. ecmaVersion: 2018,
  26185. locations: true,
  26186. program: toplevel,
  26187. sourceFile: name,
  26188. sourceType: options.module || program.parse.module ? "module" : "script"
  26189. });
  26190. });
  26191. } else if (program.parse.spidermonkey) {
  26192. files = convert_ast(function(toplevel, name) {
  26193. var obj = JSON.parse(files[name]);
  26194. if (!toplevel) return obj;
  26195. toplevel.body = toplevel.body.concat(obj.body);
  26196. return toplevel;
  26197. });
  26198. }
  26199. }
  26200. } catch (ex) {
  26201. fatal(ex);
  26202. }
  26203. let result;
  26204. try {
  26205. result = await minify(files, options);
  26206. } catch (ex) {
  26207. if (ex.name == "SyntaxError") {
  26208. print_error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
  26209. var col = ex.col;
  26210. var lines = files[ex.filename].split(/\r?\n/);
  26211. var line = lines[ex.line - 1];
  26212. if (!line && !col) {
  26213. line = lines[ex.line - 2];
  26214. col = line.length;
  26215. }
  26216. if (line) {
  26217. var limit = 70;
  26218. if (col > limit) {
  26219. line = line.slice(col - limit);
  26220. col = limit;
  26221. }
  26222. print_error(line.slice(0, 80));
  26223. print_error(line.slice(0, col).replace(/\S/g, " ") + "^");
  26224. }
  26225. }
  26226. if (ex.defs) {
  26227. print_error("Supported options:");
  26228. print_error(format_object(ex.defs));
  26229. }
  26230. fatal(ex);
  26231. return;
  26232. }
  26233. if (program.output == "ast") {
  26234. if (!options.compress && !options.mangle) {
  26235. result.ast.figure_out_scope({});
  26236. }
  26237. console.log(JSON.stringify(result.ast, function(key, value) {
  26238. if (value) switch (key) {
  26239. case "thedef":
  26240. return symdef(value);
  26241. case "enclosed":
  26242. return value.length ? value.map(symdef) : undefined;
  26243. case "variables":
  26244. case "globals":
  26245. return value.size ? collect_from_map(value, symdef) : undefined;
  26246. }
  26247. if (skip_keys.has(key)) return;
  26248. if (value instanceof AST_Token) return;
  26249. if (value instanceof Map) return;
  26250. if (value instanceof AST_Node) {
  26251. var result = {
  26252. _class: "AST_" + value.TYPE
  26253. };
  26254. if (value.block_scope) {
  26255. result.variables = value.block_scope.variables;
  26256. result.enclosed = value.block_scope.enclosed;
  26257. }
  26258. value.CTOR.PROPS.forEach(function(prop) {
  26259. result[prop] = value[prop];
  26260. });
  26261. return result;
  26262. }
  26263. return value;
  26264. }, 2));
  26265. } else if (program.output == "spidermonkey") {
  26266. try {
  26267. const minified = await minify(result.code, {
  26268. compress: false,
  26269. mangle: false,
  26270. format: {
  26271. ast: true,
  26272. code: false
  26273. }
  26274. });
  26275. console.log(JSON.stringify(minified.ast.to_mozilla_ast(), null, 2));
  26276. } catch (ex) {
  26277. fatal(ex);
  26278. return;
  26279. }
  26280. } else if (program.output) {
  26281. fs.writeFileSync(program.output, result.code);
  26282. if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
  26283. fs.writeFileSync(program.output + ".map", result.map);
  26284. }
  26285. } else {
  26286. console.log(result.code);
  26287. }
  26288. if (program.nameCache) {
  26289. fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache));
  26290. }
  26291. if (result.timings) for (var phase in result.timings) {
  26292. print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s");
  26293. }
  26294. }
  26295. function fatal(message) {
  26296. if (message instanceof Error) message = message.stack.replace(/^\S*?Error:/, "ERROR:");
  26297. print_error(message);
  26298. process.exit(1);
  26299. }
  26300. // A file glob function that only supports "*" and "?" wildcards in the basename.
  26301. // Example: "foo/bar/*baz??.*.js"
  26302. // Argument `glob` may be a string or an array of strings.
  26303. // Returns an array of strings. Garbage in, garbage out.
  26304. function simple_glob(glob) {
  26305. if (Array.isArray(glob)) {
  26306. return [].concat.apply([], glob.map(simple_glob));
  26307. }
  26308. if (glob && glob.match(/[*?]/)) {
  26309. var dir = path.dirname(glob);
  26310. try {
  26311. var entries = fs.readdirSync(dir);
  26312. } catch (ex) {}
  26313. if (entries) {
  26314. var pattern = "^" + path.basename(glob)
  26315. .replace(/[.+^$[\]\\(){}]/g, "\\$&")
  26316. .replace(/\*/g, "[^/\\\\]*")
  26317. .replace(/\?/g, "[^/\\\\]") + "$";
  26318. var mod = process.platform === "win32" ? "i" : "";
  26319. var rx = new RegExp(pattern, mod);
  26320. var results = entries.filter(function(name) {
  26321. return rx.test(name);
  26322. }).map(function(name) {
  26323. return path.join(dir, name);
  26324. });
  26325. if (results.length) return results;
  26326. }
  26327. }
  26328. return [ glob ];
  26329. }
  26330. function read_file(path, default_value) {
  26331. try {
  26332. return fs.readFileSync(path, "utf8");
  26333. } catch (ex) {
  26334. if ((ex.code == "ENOENT" || ex.code == "ENAMETOOLONG") && default_value != null) return default_value;
  26335. fatal(ex);
  26336. }
  26337. }
  26338. function parse_js(flag) {
  26339. return function(value, options) {
  26340. options = options || {};
  26341. try {
  26342. walk(parse(value, { expression: true }), node => {
  26343. if (node instanceof AST_Assign) {
  26344. var name = node.left.print_to_string();
  26345. var value = node.right;
  26346. if (flag) {
  26347. options[name] = value;
  26348. } else if (value instanceof AST_Array) {
  26349. options[name] = value.elements.map(to_string);
  26350. } else if (value instanceof AST_RegExp) {
  26351. value = value.value;
  26352. options[name] = new RegExp(value.source, value.flags);
  26353. } else {
  26354. options[name] = to_string(value);
  26355. }
  26356. return true;
  26357. }
  26358. if (node instanceof AST_Symbol || node instanceof AST_PropAccess) {
  26359. var name = node.print_to_string();
  26360. options[name] = true;
  26361. return true;
  26362. }
  26363. if (!(node instanceof AST_Sequence)) throw node;
  26364. function to_string(value) {
  26365. return value instanceof AST_Constant ? value.getValue() : value.print_to_string({
  26366. quote_keys: true
  26367. });
  26368. }
  26369. });
  26370. } catch(ex) {
  26371. if (flag) {
  26372. fatal("Error parsing arguments for '" + flag + "': " + value);
  26373. } else {
  26374. options[value] = null;
  26375. }
  26376. }
  26377. return options;
  26378. };
  26379. }
  26380. function symdef(def) {
  26381. var ret = (1e6 + def.id) + " " + def.name;
  26382. if (def.mangled_name) ret += " " + def.mangled_name;
  26383. return ret;
  26384. }
  26385. function collect_from_map(map, callback) {
  26386. var result = [];
  26387. map.forEach(function (def) {
  26388. result.push(callback(def));
  26389. });
  26390. return result;
  26391. }
  26392. function format_object(obj) {
  26393. var lines = [];
  26394. var padding = "";
  26395. Object.keys(obj).map(function(name) {
  26396. if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
  26397. return [ name, JSON.stringify(obj[name]) ];
  26398. }).forEach(function(tokens) {
  26399. lines.push(" " + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
  26400. });
  26401. return lines.join("\n");
  26402. }
  26403. function print_error(msg) {
  26404. process.stderr.write(msg);
  26405. process.stderr.write("\n");
  26406. }
  26407. function describe_ast() {
  26408. var out = OutputStream({ beautify: true });
  26409. function doitem(ctor) {
  26410. out.print("AST_" + ctor.TYPE);
  26411. const props = ctor.SELF_PROPS.filter(prop => !/^\$/.test(prop));
  26412. if (props.length > 0) {
  26413. out.space();
  26414. out.with_parens(function() {
  26415. props.forEach(function(prop, i) {
  26416. if (i) out.space();
  26417. out.print(prop);
  26418. });
  26419. });
  26420. }
  26421. if (ctor.documentation) {
  26422. out.space();
  26423. out.print_string(ctor.documentation);
  26424. }
  26425. if (ctor.SUBCLASSES.length > 0) {
  26426. out.space();
  26427. out.with_block(function() {
  26428. ctor.SUBCLASSES.forEach(function(ctor) {
  26429. out.indent();
  26430. doitem(ctor);
  26431. out.newline();
  26432. });
  26433. });
  26434. }
  26435. }
  26436. doitem(AST_Node);
  26437. return out + "\n";
  26438. }
  26439. }
  26440. async function _default_options() {
  26441. const defs = {};
  26442. Object.keys(infer_options({ 0: 0 })).forEach((component) => {
  26443. const options = infer_options({
  26444. [component]: {0: 0}
  26445. });
  26446. if (options) defs[component] = options;
  26447. });
  26448. return defs;
  26449. }
  26450. async function infer_options(options) {
  26451. try {
  26452. await minify("", options);
  26453. } catch (error) {
  26454. return error.defs;
  26455. }
  26456. }
  26457. exports._default_options = _default_options;
  26458. exports._run_cli = run_cli;
  26459. exports.minify = minify;
  26460. })));